From: Benjamin Kramer Date: Thu, 10 Oct 2013 12:24:40 +0000 (+0000) Subject: Parser: Avoid a crash-on-invalid when trying to diagnose function calls with -> in it. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fbac5c11d4ecd39f083a8d7247ddcb5a0a49c667;p=clang Parser: Avoid a crash-on-invalid when trying to diagnose function calls with -> in it. Use the existing convenience function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192347 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index c9a718b527..a82d5cea63 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -1468,8 +1468,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { const Type* BaseType = Base->getType().getTypePtrOrNull(); if (BaseType && Tok.is(tok::l_paren) && (BaseType->isFunctionType() || - BaseType->getAsPlaceholderType()->getKind() == - BuiltinType::BoundMember)) { + BaseType->isSpecificPlaceholderType(BuiltinType::BoundMember))) { Diag(OpLoc, diag::err_function_is_not_record) << (OpKind == tok::arrow) << Base->getSourceRange() << FixItHint::CreateRemoval(OpLoc); diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index c33a8d561c..ea20354bf9 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -202,6 +202,12 @@ namespace test7 { // Comment! } +void test8() { + struct {} o; + // This used to crash. + (&o)->(); // expected-error{{expected unqualified-id}} +} + namespace PR5066 { template struct X {}; X x; // expected-error {{type-id cannot have a name}}