Improve recovery when we fail to parse the operand of a C++ named cast. Fixes PR5210

llvm-svn: 86234
This commit is contained in:
Douglas Gregor 2009-11-06 05:48:00 +00:00
parent 6af6c3ee56
commit f4f2ff773b
2 changed files with 12 additions and 7 deletions

View File

@ -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,

View File

@ -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}}
}
};