]> granicus.if.org Git - clang/commitdiff
When checking for abstract types, don't crash when we have a
authorDouglas Gregor <dgregor@apple.com>
Tue, 22 Feb 2011 23:21:06 +0000 (23:21 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 22 Feb 2011 23:21:06 +0000 (23:21 +0000)
FunctionProtoTypeLoc with NULL function parameter types, which can
occur in invalid code. Fixes PR9247 / <rdar://problem/9037911>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126262 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/abstract.cpp

index c12534645f675868f744d80cd5a07b90366b28ba..fbc2a466ee70b26d799d69d2aab1ab446170e408 100644 (file)
@@ -2588,6 +2588,9 @@ struct CheckAbstractUsage {
   void Check(FunctionProtoTypeLoc TL, Sema::AbstractDiagSelID Sel) {
     Visit(TL.getResultLoc(), Sema::AbstractReturnType);
     for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) {
+      if (!TL.getArg(I))
+        continue;
+      
       TypeSourceInfo *TSI = TL.getArg(I)->getTypeSourceInfo();
       if (TSI) Visit(TSI->getTypeLoc(), Sema::AbstractParamType);
     }
index 48805e217b6fc82607d1acad81ad7b87553b3799..c262230962f99fa1ea0cecb9d8f19020bf48c9d1 100644 (file)
@@ -249,3 +249,13 @@ namespace test4 {
     static D x; // expected-error {{abstract class}}
   };
 }
+
+// PR9247: Crash on invalid in clang::Sema::ActOnFinishCXXMemberSpecification
+namespace pr9247 {
+  struct A {
+    virtual void g(const A& input) = 0;
+    struct B {
+      C* f(int foo);
+    };
+  };
+}