From 9a30c9946e898e595eb71f23dc9a60303428998b Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 5 Jul 2011 16:13:20 +0000 Subject: [PATCH] ActOnCXXConditionDeclaration should take into account that ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134416 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 5 ++++- test/SemaCXX/crashes.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index ac51138b91..368fd9259e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -8914,10 +8914,13 @@ DeclResult Sema::ActOnCXXConditionDeclaration(Scope *S, Declarator &D) { "Parser allowed 'typedef' as storage class of condition decl."); Decl *Dcl = ActOnDeclarator(S, D); + if (!Dcl) + return true; + if (isa(Dcl)) { // The declarator shall not specify a function. Diag(Dcl->getLocation(), diag::err_invalid_use_of_function_type) << D.getSourceRange(); - return DeclResult(); + return true; } return Dcl; diff --git a/test/SemaCXX/crashes.cpp b/test/SemaCXX/crashes.cpp index c75b0401fe..b77248ef41 100644 --- a/test/SemaCXX/crashes.cpp +++ b/test/SemaCXX/crashes.cpp @@ -95,3 +95,12 @@ namespace PR9026 { Write(x); } } + +namespace PR10270 { + template class C; + template void f() { + if (C == 1) // expected-error{{expected unqualified-id}} \ + // expected-error{{invalid '==' at end of declaration}} + return; + } +} -- 2.40.0