diff options
author | Richard Smith <richard@metafoo.co.uk> | 2019-11-27 17:54:26 -0800 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2019-11-27 17:54:26 -0800 |
commit | 789a7aa37d0cca70d6e48908ce3e8bb4e761e266 (patch) | |
tree | ce69461aa918ae14ad6e7287e6b797c06b34b860 /clang/lib/Parse/ParseTentative.cpp | |
parent | acc79aa0e747b9777077e0a337e99540a52b94b2 (diff) | |
download | bcm5719-llvm-789a7aa37d0cca70d6e48908ce3e8bb4e761e266.tar.gz bcm5719-llvm-789a7aa37d0cca70d6e48908ce3e8bb4e761e266.zip |
Properly disambiguate between array declarators and array subscript expressions.
Diffstat (limited to 'clang/lib/Parse/ParseTentative.cpp')
-rw-r--r-- | clang/lib/Parse/ParseTentative.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index e2e16ca63d1..9cc41328c46 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -2066,9 +2066,21 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() { /// Parser::TPResult Parser::TryParseBracketDeclarator() { ConsumeBracket(); - if (!SkipUntil(tok::r_square, StopAtSemi)) + + // A constant-expression cannot begin with a '{', but the + // expr-or-braced-init-list of a postfix-expression can. + if (Tok.is(tok::l_brace)) + return TPResult::False; + + if (!SkipUntil(tok::r_square, tok::comma, StopAtSemi | StopBeforeMatch)) return TPResult::Error; + // If we hit a comma before the ']', this is not a constant-expression, + // but might still be the expr-or-braced-init-list of a postfix-expression. + if (Tok.isNot(tok::r_square)) + return TPResult::False; + + ConsumeBracket(); return TPResult::Ambiguous; } |