summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-01-12 03:36:37 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-01-12 03:36:37 +0000
commit234b8188df4aa0c80d1beeb883f74ae9eb24d7ba (patch)
tree55a0778ec44d48b50766383d613bec1e201a86ac
parenta3aef35d54318ba6d13fa1336bd8d0e97c5bc6a3 (diff)
downloadbcm5719-llvm-234b8188df4aa0c80d1beeb883f74ae9eb24d7ba.tar.gz
bcm5719-llvm-234b8188df4aa0c80d1beeb883f74ae9eb24d7ba.zip
Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly
llvm-svn: 225616
-rw-r--r--clang/lib/Parse/ParseCXXInlineMethods.cpp1
-rw-r--r--clang/lib/Parse/ParseExprCXX.cpp13
-rw-r--r--clang/lib/Parse/Parser.cpp6
-rw-r--r--clang/test/Parser/cxx-member-initializers.cpp4
4 files changed, 11 insertions, 13 deletions
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 7c9cceb12bc..ccd051721fa 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -652,6 +652,7 @@ bool Parser::ConsumeAndStoreUntil(tok::TokenKind T1, tok::TokenKind T2,
switch (Tok.getKind()) {
case tok::eof:
+ case tok::cxx_defaultarg_end:
case tok::annot_module_begin:
case tok::annot_module_end:
case tok::annot_module_include:
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index 68bd45e38d1..355503caa9b 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -716,16 +716,9 @@ ExprResult Parser::ParseLambdaExpression() {
Optional<unsigned> DiagID = ParseLambdaIntroducer(Intro);
if (DiagID) {
Diag(Tok, DiagID.getValue());
- auto SkipUntilLambdaToken = [&](tok::TokenKind LambdaToken) {
- // Don't skip past the end of the default argument.
- SkipUntil(LambdaToken, tok::cxx_defaultarg_end,
- StopAtSemi | StopBeforeMatch);
- if (Tok.is(LambdaToken))
- ConsumeAnyToken();
- };
- SkipUntilLambdaToken(tok::r_square);
- SkipUntilLambdaToken(tok::l_brace);
- SkipUntilLambdaToken(tok::r_brace);
+ SkipUntil(tok::r_square, StopAtSemi);
+ SkipUntil(tok::l_brace, StopAtSemi);
+ SkipUntil(tok::r_brace, StopAtSemi);
return ExprError();
}
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index c9243d64880..06a70f7fd33 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -262,6 +262,10 @@ bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) {
// Ran out of tokens.
return false;
+ case tok::cxx_defaultarg_end:
+ // It's never desirable to consume the 'end-of-default-argument' token.
+ return false;
+
case tok::annot_pragma_openmp_end:
// Stop before an OpenMP pragma boundary.
case tok::annot_module_begin:
@@ -1948,7 +1952,7 @@ bool BalancedDelimiterTracker::diagnoseMissingClose() {
// token.
if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) &&
P.Tok.isNot(tok::r_square) &&
- P.SkipUntil(Close, FinalToken, tok::cxx_defaultarg_end,
+ P.SkipUntil(Close, FinalToken,
Parser::StopAtSemi | Parser::StopBeforeMatch) &&
P.Tok.is(Close))
LClose = P.ConsumeAnyToken();
diff --git a/clang/test/Parser/cxx-member-initializers.cpp b/clang/test/Parser/cxx-member-initializers.cpp
index 461810c62fb..ee509b115e9 100644
--- a/clang/test/Parser/cxx-member-initializers.cpp
+++ b/clang/test/Parser/cxx-member-initializers.cpp
@@ -103,5 +103,5 @@ class G {
void l(int x = C<int, C<int, int>::C1>().f()) {}
// This isn't, but it shouldn't crash. The diagnostics don't matter much.
- void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}}
-}; // expected-error {{expected a type}}
+ void m(int x = C<int, union int>().f()) {} // expected-error {{declaration of anonymous union must be a definition}} expected-error {{expected a type}}
+};
OpenPOWER on IntegriCloud