davide created this revision. davide added a reviewer: rsmith. davide added subscribers: dim, cfe-commits.
Full story here: https://llvm.org/bugs/show_bug.cgi?id=24000 Implementing what Richard suggested in the PR. Cc:ing Dimitry as this caused regression while building some FreeBSD ports. http://reviews.llvm.org/D11341 Files: lib/Sema/SemaExceptionSpec.cpp test/SemaTemplate/crash-unparsed-exception.cpp Index: test/SemaTemplate/crash-unparsed-exception.cpp =================================================================== --- test/SemaTemplate/crash-unparsed-exception.cpp +++ 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 <class> +struct B {}; +struct C { + template <typename> + struct D { + ~D() throw(); + }; + struct E : A { + D<int> d; //expected-error{{exception specification is not available until end of class definition}} + }; + B<int> b; //expected-note{{in instantiation of template class 'B<int>' requested here}} +}; Index: lib/Sema/SemaExceptionSpec.cpp =================================================================== --- lib/Sema/SemaExceptionSpec.cpp +++ lib/Sema/SemaExceptionSpec.cpp @@ -161,7 +161,13 @@ else InstantiateExceptionSpec(Loc, SourceDecl); - return SourceDecl->getType()->castAs<FunctionProtoType>(); + const FunctionProtoType *Proto = + SourceDecl->getType()->castAs<FunctionProtoType>(); + if (Proto->getExceptionSpecType() == clang::EST_Unparsed) { + Diag(Loc, diag::err_exception_spec_not_parsed); + Proto = nullptr; + } + return Proto; } void
Index: test/SemaTemplate/crash-unparsed-exception.cpp =================================================================== --- test/SemaTemplate/crash-unparsed-exception.cpp +++ 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 <class> +struct B {}; +struct C { + template <typename> + struct D { + ~D() throw(); + }; + struct E : A { + D<int> d; //expected-error{{exception specification is not available until end of class definition}} + }; + B<int> b; //expected-note{{in instantiation of template class 'B<int>' requested here}} +}; Index: lib/Sema/SemaExceptionSpec.cpp =================================================================== --- lib/Sema/SemaExceptionSpec.cpp +++ lib/Sema/SemaExceptionSpec.cpp @@ -161,7 +161,13 @@ else InstantiateExceptionSpec(Loc, SourceDecl); - return SourceDecl->getType()->castAs<FunctionProtoType>(); + const FunctionProtoType *Proto = + SourceDecl->getType()->castAs<FunctionProtoType>(); + if (Proto->getExceptionSpecType() == clang::EST_Unparsed) { + Diag(Loc, diag::err_exception_spec_not_parsed); + Proto = nullptr; + } + return Proto; } void
_______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits