r192347 - Parser: Avoid a crash-on-invalid when trying to diagnose function calls with -> in it.

Benjamin Kramer benny.kra at googlemail.com
Thu Oct 10 05:24:40 PDT 2013


Author: d0k
Date: Thu Oct 10 07:24:40 2013
New Revision: 192347

URL: http://llvm.org/viewvc/llvm-project?rev=192347&view=rev
Log:
Parser: Avoid a crash-on-invalid when trying to diagnose function calls with -> in it.

Use the existing convenience function.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=192347&r1=192346&r2=192347&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Oct 10 07:24:40 2013
@@ -1468,8 +1468,7 @@ Parser::ParsePostfixExpressionSuffix(Exp
         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);

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=192347&r1=192346&r2=192347&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Thu Oct 10 07:24:40 2013
@@ -202,6 +202,12 @@ namespace test7 {
   // Comment!
 }
 
+void test8() {
+  struct {} o;
+  // This used to crash.
+  (&o)->(); // expected-error{{expected unqualified-id}}
+}
+
 namespace PR5066 {
   template<typename T> struct X {};
   X<int N> x; // expected-error {{type-id cannot have a name}}





More information about the cfe-commits mailing list