diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-06 05:48:00 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-06 05:48:00 +0000 |
commit | 27591ff4fc64600fd67c5d81899e3efe5ef41a80 (patch) | |
tree | 857bb16b8d5583614378e21e113b043ea5720b8e | |
parent | 35de813674503b87ec5117b6492cc0a4ef7d8728 (diff) |
Improve recovery when we fail to parse the operand of a C++ named cast. Fixes PR5210
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86234 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/cast-conversion.cpp | 11 |
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index a00dfb0b4c..fa8e64dc12 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -381,13 +381,7 @@ Parser::OwningExprResult Parser::ParseCXXCasts() { OwningExprResult Result = ParseExpression(); // Match the ')'. - if (Result.isInvalid()) - SkipUntil(tok::r_paren); - - if (Tok.is(tok::r_paren)) - RParenLoc = ConsumeParen(); - else - MatchRHSPunctuation(tok::r_paren, LParenLoc); + RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); if (!Result.isInvalid() && !CastTy.isInvalid()) Result = Actions.ActOnCXXNamedCast(OpLoc, Kind, diff --git a/test/SemaCXX/cast-conversion.cpp b/test/SemaCXX/cast-conversion.cpp index 936933d95d..3b6a9d6f8c 100644 --- a/test/SemaCXX/cast-conversion.cpp +++ b/test/SemaCXX/cast-conversion.cpp @@ -33,3 +33,14 @@ void test_X0() { const char array[2]; make_X0(array); } + +// PR5210 recovery +class C { +protected: + template <int> float* &f0(); // expected-note{{candidate}} + template <unsigned> float* &f0(); // expected-note{{candidate}} + + void f1() { + static_cast<float*>(f0<0>()); // expected-error{{ambiguous}} + } +}; |