-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang] Add clang::preferred_type attribute for bitfields #69104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
976aa5c
4330b70
faf8238
fc1d920
06bd08b
9bd1652
b9f66ef
f926eea
84a8ea7
85129ee
436b966
300da8b
32975c2
b2bda5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s | ||
|
||
struct A { | ||
enum E : unsigned {}; | ||
[[clang::preferred_type(E)]] unsigned b : 2; | ||
} a; | ||
|
||
// CHECK-DAG: [[ENUM:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E"{{.*}} | ||
// CHECK-DAG: !DIDerivedType(tag: DW_TAG_member, name: "b",{{.*}} baseType: [[ENUM]] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// RUN: %clang_cc1 -verify %s | ||
|
||
struct A { | ||
enum E : unsigned {}; | ||
enum E2 : int {}; | ||
[[clang::preferred_type(E)]] unsigned b : 2; | ||
[[clang::preferred_type(E)]] int b2 : 2; | ||
[[clang::preferred_type(E2)]] const unsigned b3 : 2; | ||
[[clang::preferred_type(bool)]] unsigned b4 : 1; | ||
[[clang::preferred_type(bool)]] unsigned b5 : 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AaronBallman On the topic of automatically-generated diagnostics:
3 diagnostics are issued, 0 says that wrong number of attribute arguments is passed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, something got confused there.... it's parsing |
||
// expected-error@-1 {{expected ')'}} | ||
// expected-error@-2 {{expected ','}} | ||
// expected-warning@-3 {{unknown attribute 'int' ignored}} | ||
}; |
Uh oh!
There was an error while loading. Please reload this page.