r243196 - [SemaTemplate] Detect instantiation of unparsed exceptions.

Davide Italiano davide at freebsd.org
Fri Jul 24 18:19:33 PDT 2015


Author: davide
Date: Fri Jul 24 20:19:32 2015
New Revision: 243196

URL: http://llvm.org/viewvc/llvm-project?rev=243196&view=rev
Log:
[SemaTemplate] Detect instantiation of unparsed exceptions.

This fixes the clang crash reported in PR24000.

Differential Revision:	http://reviews.llvm.org/D11341

Added:
    cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
Modified:
    cfe/trunk/lib/Sema/SemaExceptionSpec.cpp

Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=243196&r1=243195&r2=243196&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Fri Jul 24 20:19:32 2015
@@ -161,7 +161,13 @@ Sema::ResolveExceptionSpec(SourceLocatio
   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

Added: cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp?rev=243196&view=auto
==============================================================================
--- cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp (added)
+++ cfe/trunk/test/SemaTemplate/crash-unparsed-exception.cpp Fri Jul 24 20:19:32 2015
@@ -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}}
+};





More information about the cfe-commits mailing list