From 4280a4d1d365cf4a1fbe29f20a567cf32275a71f Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 28 Jul 2015 16:16:43 +0000 Subject: [PATCH] Merging r243196: ------------------------------------------------------------------------ r243196 | davide | 2015-07-24 18:19:32 -0700 (Fri, 24 Jul 2015) | 6 lines [SemaTemplate] Detect instantiation of unparsed exceptions. This fixes the clang crash reported in PR24000. Differential Revision: http://reviews.llvm.org/D11341 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_37@243433 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExceptionSpec.cpp | 8 +++++++- test/SemaTemplate/crash-unparsed-exception.cpp | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/SemaTemplate/crash-unparsed-exception.cpp diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp index 094187025d..2cf02b484c 100644 --- a/lib/Sema/SemaExceptionSpec.cpp +++ b/lib/Sema/SemaExceptionSpec.cpp @@ -161,7 +161,13 @@ Sema::ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT) { else InstantiateExceptionSpec(Loc, SourceDecl); - return SourceDecl->getType()->castAs(); + const FunctionProtoType *Proto = + SourceDecl->getType()->castAs(); + if (Proto->getExceptionSpecType() == clang::EST_Unparsed) { + Diag(Loc, diag::err_exception_spec_not_parsed); + Proto = nullptr; + } + return Proto; } void diff --git a/test/SemaTemplate/crash-unparsed-exception.cpp b/test/SemaTemplate/crash-unparsed-exception.cpp new file mode 100644 index 0000000000..1226b35deb --- /dev/null +++ b/test/SemaTemplate/crash-unparsed-exception.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -fcxx-exceptions -fexceptions %s + +struct A { + virtual ~A(); +}; +template +struct B {}; +struct C { + template + struct D { + ~D() throw(); + }; + struct E : A { + D d; //expected-error{{exception specification is not available until end of class definition}} + }; + B b; //expected-note{{in instantiation of template class 'B' requested here}} +}; -- 2.50.1