diff options
| author | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-06-15 20:57:04 +0000 |
|---|---|---|
| committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-06-15 20:57:04 +0000 |
| commit | 425efcf6ea8c34b5711f910d20ba3f145b2c720f (patch) | |
| tree | 2ebc83c69cf60424c6a736447c43f656f9c516ec | |
| parent | 717820faa0903266083e773bcbea87ec6ca0d1f5 (diff) | |
| download | bcm5719-llvm-425efcf6ea8c34b5711f910d20ba3f145b2c720f.tar.gz bcm5719-llvm-425efcf6ea8c34b5711f910d20ba3f145b2c720f.zip | |
parser: improve diagnostics for MS attributes
Switch to using BalancedDelimiterTracker to get better diagnostics for
unbalanced delimiters. This still does not handle any of the attributes, simply
improves the parsing.
llvm-svn: 239758
| -rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 14 | ||||
| -rw-r--r-- | clang/test/Parser/MicrosoftExtensions.c | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 55909de0928..9ed797f881d 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -3780,7 +3780,7 @@ SourceLocation Parser::SkipCXX11Attributes() { return EndLoc; } -/// ParseMicrosoftAttributes - Parse a Microsoft attribute [Attr] +/// ParseMicrosoftAttributes - Parse Microsoft attributes [Attr] /// /// [MS] ms-attribute: /// '[' token-seq ']' @@ -3792,13 +3792,15 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes &attrs, SourceLocation *endLoc) { assert(Tok.is(tok::l_square) && "Not a Microsoft attribute list"); - while (Tok.is(tok::l_square)) { + do { // FIXME: If this is actually a C++11 attribute, parse it as one. - ConsumeBracket(); + BalancedDelimiterTracker T(*this, tok::l_square); + T.consumeOpen(); SkipUntil(tok::r_square, StopAtSemi | StopBeforeMatch); - if (endLoc) *endLoc = Tok.getLocation(); - ExpectAndConsume(tok::r_square); - } + T.consumeClose(); + if (endLoc) + *endLoc = T.getCloseLocation(); + } while (Tok.is(tok::l_square)); } void Parser::ParseMicrosoftIfExistsClassDeclaration(DeclSpec::TST TagType, diff --git a/clang/test/Parser/MicrosoftExtensions.c b/clang/test/Parser/MicrosoftExtensions.c index 40a9510d6e2..a29f6c0b549 100644 --- a/clang/test/Parser/MicrosoftExtensions.c +++ b/clang/test/Parser/MicrosoftExtensions.c @@ -52,6 +52,9 @@ void deprecated_enum_test(void) { [returnvalue:SA_Post( attr=1)] int foo1([SA_Post(attr=1)] void *param); +[unbalanced(attribute) /* expected-note {{to match this '['}} */ +void f(void); /* expected-error {{expected ']'}} */ + void ms_intrinsics(int a) { __noop(); __assume(a); |

