From: Douglas Gregor Date: Fri, 6 Nov 2009 05:48:00 +0000 (+0000) Subject: Improve recovery when we fail to parse the operand of a C++ named cast. Fixes PR5210 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27591ff4fc64600fd67c5d81899e3efe5ef41a80;p=clang 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 --- 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 float* &f0(); // expected-note{{candidate}} + template float* &f0(); // expected-note{{candidate}} + + void f1() { + static_cast(f0<0>()); // expected-error{{ambiguous}} + } +};