[cfe-commits] r127603 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateDecl.cpp test/CXX/except/except.spec/template.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Mar 14 11:51:50 PDT 2011


Author: cornedbee
Date: Mon Mar 14 13:51:50 2011
New Revision: 127603

URL: http://llvm.org/viewvc/llvm-project?rev=127603&view=rev
Log:
Implement instantiation of noexcept spec and add a test case.

Added:
    cfe/trunk/test/CXX/except/except.spec/template.cpp
Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=127603&r1=127602&r2=127603&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Mar 14 13:51:50 2011
@@ -2161,14 +2161,20 @@
 
       Exceptions.push_back(T);
     }
+    Expr *NoexceptExpr = 0;
+    if (Expr *OldNoexceptExpr = Proto->getNoexceptExpr()) {
+      ExprResult E = SemaRef.SubstExpr(OldNoexceptExpr, TemplateArgs);
+      if (E.isUsable())
+        NoexceptExpr = E.take();
+    }
 
     // Rebuild the function type 
 
     FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
-    // FIXME: Handle noexcept
     EPI.ExceptionSpecType = Proto->getExceptionSpecType();
     EPI.NumExceptions = Exceptions.size();
     EPI.Exceptions = Exceptions.data();
+    EPI.NoexceptExpr = NoexceptExpr;
     EPI.ExtInfo = Proto->getExtInfo();
 
     const FunctionProtoType *NewProto

Added: cfe/trunk/test/CXX/except/except.spec/template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/except/except.spec/template.cpp?rev=127603&view=auto
==============================================================================
--- cfe/trunk/test/CXX/except/except.spec/template.cpp (added)
+++ cfe/trunk/test/CXX/except/except.spec/template.cpp Mon Mar 14 13:51:50 2011
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++0x -fexceptions -fcxx-exceptions -fsyntax-only -verify %s
+
+// We use pointer assignment compatibility to test instantiation.
+
+template <int N> void f1() throw(int);
+template <int N> void f2() noexcept(N > 1);
+
+void (*t1)() throw(int) = &f1<0>;
+void (*t2)() throw() = &f1<0>; // expected-error {{not superset}}
+
+void (*t3)() noexcept = &f2<2>; // no-error
+void (*t4)() noexcept = &f2<0>; // expected-error {{not superset}}





More information about the cfe-commits mailing list