================
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify %s
+
+struct A {
+  enum E : unsigned {};
+  [[clang::preferred_type(E)]] unsigned b : 2;
+  [[clang::preferred_type(E)]] int b2 : 2;
+  // expected-warning@-1 {{underlying type 'unsigned int' of enumeration 'E' 
doesn't match bit-field type 'int'}}
+  [[clang::preferred_type(E)]] const unsigned b3 : 2;
+  [[clang::preferred_type(bool)]] unsigned b4 : 1;
+  [[clang::preferred_type(bool)]] unsigned b5 : 2;
+  // expected-warning@-1 {{bit-field that holds a boolean value should have 
width of 1 instead of 2}}
+  [[clang::preferred_type()]] unsigned b6 : 2;
+  // expected-error@-1 {{'preferred_type' attribute takes one argument}}
+  [[clang::preferred_type]] unsigned b7 : 2;
+  // expected-error@-1 {{'preferred_type' attribute takes one argument}}
+  [[clang::preferred_type(E, int)]] unsigned b8 : 2;
----------------
AaronBallman wrote:

Huh, something got confused there.... it's parsing `int` as though it were 
another attribute and not an argument to the `preferred_type` attribute. That 
surprises me!

https://github.com/llvm/llvm-project/pull/69104
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to