diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2020-09-29 16:27:51 -0400 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2020-09-29 16:32:20 -0400 |
commit | 538762fef0b662048be2a261ebc12da249efa977 (patch) | |
tree | 9fbb656f7a5e635b3999cd84c0f8be9d5b29409e /clang/lib/Parse/ParseDecl.cpp | |
parent | f9e70fa546a461b3c9fa8463efcd9f7fe989bd9f (diff) | |
download | llvm-538762fef0b662048be2a261ebc12da249efa977.zip llvm-538762fef0b662048be2a261ebc12da249efa977.tar.gz llvm-538762fef0b662048be2a261ebc12da249efa977.tar.bz2 |
Better diagnostics for anonymous bit-fields with attributes or an initializer.
The current C++ grammar allows an anonymous bit-field with an attribute,
but this is ambiguous (the attribute in that case could appertain to the
type instead of the bit-field). The current thinking in the Core Working
Group is that it's better to disallow attributes in that position at the
grammar level so that the ambiguity resolves in favor of applying to the
type.
During discussions about the behavior of the attribute, the Core Working
Group also felt it was better to disallow anonymous bit-fields from
specifying a default member initializer.
This implements both sets of related grammar changes.
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index adec7c6..3f314c5 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -4113,8 +4113,13 @@ void Parser::ParseStructDeclaration( DeclaratorInfo.D.setCommaLoc(CommaLoc); // Attributes are only allowed here on successive declarators. - if (!FirstDeclarator) + if (!FirstDeclarator) { + // However, this does not apply for [[]] attributes (which could show up + // before or after the __attribute__ attributes). + DiagnoseAndSkipCXX11Attributes(); MaybeParseGNUAttributes(DeclaratorInfo.D); + DiagnoseAndSkipCXX11Attributes(); + } /// struct-declarator: declarator /// struct-declarator: declarator[opt] ':' constant-expression |