forked from OSchip/llvm-project
Parse Microsoft __declspec appearing after class body
MSVC applies these to the following declaration only if present, otherwise silently ignores them whereas we'll issue a warning. Handling differs from ordinary attributes appearing in the same place, so add a Sema test to make sure we get it right. llvm-svn: 195577
This commit is contained in:
parent
1116868a0d
commit
d3f79c5446
|
@ -1021,6 +1021,7 @@ bool Parser::isValidAfterTypeSpecifier(bool CouldBeBitfield) {
|
|||
case tok::l_paren: // struct foo {...} ( x);
|
||||
case tok::comma: // __builtin_offsetof(struct foo{...} ,
|
||||
case tok::kw_operator: // struct foo operator ++() {...}
|
||||
case tok::kw___declspec: // struct foo {...} __declspec(...)
|
||||
return true;
|
||||
case tok::colon:
|
||||
return CouldBeBitfield; // enum E { ... } : 2;
|
||||
|
|
|
@ -410,3 +410,14 @@ struct SealedType sealed : SomeBase {
|
|||
|
||||
// expected-error@+1 {{base 'SealedType' is marked 'sealed'}}
|
||||
struct InheritFromSealed : SealedType {};
|
||||
|
||||
void AfterClassBody() {
|
||||
// expected-warning@+1 {{attribute 'deprecated' is ignored, place it after "struct" to apply attribute to type declaration}}
|
||||
struct D {} __declspec(deprecated);
|
||||
|
||||
struct __declspec(align(4)) S {} __declspec(align(8)) s1;
|
||||
S s2;
|
||||
_Static_assert(__alignof(S) == 4, "");
|
||||
_Static_assert(__alignof(s1) == 8, "");
|
||||
_Static_assert(__alignof(s2) == 4, "");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue