[PATCH] D11341: [SemaTemplate] Detect instantiation of unparsed exceptions

Davide Italiano dccitaliano at gmail.com
Sun Jul 19 10:45:25 PDT 2015


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11341.30120.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150719/0545a7d4/attachment.bin>


More information about the cfe-commits mailing list