aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-01-09 22:31:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-01-09 22:31:44 +0000
commit1c94c16317c1a35c1549e022958188eea2567089 (patch)
treedf3c9667a969fdc0872a1ca42c5d2c54dd9fba04 /lib/Parse/ParseDecl.cpp
parentd1d512a9cd1923566a52e57b7e1e8ae65392f66b (diff)
Extend the diagnostic for a ',' at the end of a declaration where a ';' was
intended to cover C++ class definitions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r--lib/Parse/ParseDecl.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 16321491ee..5c4e898bf6 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -994,9 +994,15 @@ bool Parser::MightBeDeclarator(unsigned Context) {
case tok::amp:
case tok::ampamp:
- case tok::colon: // Might be a typo for '::'.
return getLang().CPlusPlus;
+ case tok::l_square: // Might be an attribute on an unnamed bit-field.
+ return Context == Declarator::MemberContext && getLang().CPlusPlus0x &&
+ NextToken().is(tok::l_square);
+
+ case tok::colon: // Might be a typo for '::' or an unnamed bit-field.
+ return Context == Declarator::MemberContext || getLang().CPlusPlus;
+
case tok::identifier:
switch (NextToken().getKind()) {
case tok::code_completion:
@@ -1019,8 +1025,13 @@ bool Parser::MightBeDeclarator(unsigned Context) {
case tok::colon:
// At namespace scope, 'identifier:' is probably a typo for 'identifier::'
- // and in block scope it's probably a label.
- return getLang().CPlusPlus && Context == Declarator::FileContext;
+ // and in block scope it's probably a label. Inside a class definition,
+ // this is a bit-field.
+ return Context == Declarator::MemberContext ||
+ (getLang().CPlusPlus && Context == Declarator::FileContext);
+
+ case tok::identifier: // Possible virt-specifier.
+ return getLang().CPlusPlus0x && isCXX0XVirtSpecifier(NextToken());
default:
return false;