This revision was automatically updated to reflect the committed changes.
Closed by commit rL243196: [SemaTemplate] Detect instantiation of unparsed
exceptions. (authored by davide).
Changed prior to commit:
http://reviews.llvm.org/D11341?vs=30120&id=30627#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11341
Files:
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
Index: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
+++ cfe/trunk/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: cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
===================================================================
--- cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
+++ cfe/trunk/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: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
+++ cfe/trunk/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: cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
===================================================================
--- cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
+++ cfe/trunk/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}}
+};
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits