From 7019186f3c05539698b589a59729b0adfb8ea0a1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 22 Feb 2011 23:21:06 +0000 Subject: [PATCH] When checking for abstract types, don't crash when we have a FunctionProtoTypeLoc with NULL function parameter types, which can occur in invalid code. Fixes PR9247 / . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126262 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 3 +++ test/SemaCXX/abstract.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index c12534645f..fbc2a466ee 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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); } diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp index 48805e217b..c262230962 100644 --- a/test/SemaCXX/abstract.cpp +++ b/test/SemaCXX/abstract.cpp @@ -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); + }; + }; +} -- 2.40.0