diff options
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 5ec899f5898..33e3cab8671 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -3390,13 +3390,23 @@ void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs, } void Parser::DiagnoseAndSkipCXX11Attributes() { - if (!isCXX11AttributeSpecifier()) - return; - // Start and end location of an attribute or an attribute list. SourceLocation StartLoc = Tok.getLocation(); + SourceLocation EndLoc = SkipCXX11Attributes(); + + if (EndLoc.isValid()) { + SourceRange Range(StartLoc, EndLoc); + Diag(StartLoc, diag::err_attributes_not_allowed) + << Range; + } +} + +SourceLocation Parser::SkipCXX11Attributes() { SourceLocation EndLoc; + if (!isCXX11AttributeSpecifier()) + return EndLoc; + do { if (Tok.is(tok::l_square)) { BalancedDelimiterTracker T(*this, tok::l_square); @@ -3413,11 +3423,7 @@ void Parser::DiagnoseAndSkipCXX11Attributes() { } } while (isCXX11AttributeSpecifier()); - if (EndLoc.isValid()) { - SourceRange Range(StartLoc, EndLoc); - Diag(StartLoc, diag::err_attributes_not_allowed) - << Range; - } + return EndLoc; } /// ParseMicrosoftAttributes - Parse a Microsoft attribute [Attr] |