<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Approved.<div><br></div><div>Thanks, Richard.</div><div><br></div><div>Bill, you'll be handling the merge?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">    </span>- Doug</div><div><br><div><div>On Apr 17, 2012, at 3:35 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Doug,<div><br></div><div>This change fixes a crash when building libc++ (introduced by the fix for libstdc++-4.7), so I'd like to request that it's ported to the 3.1 branch.<div><br><div class="gmail_quote">On Tue, Apr 17, 2012 at 3:30 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>></span> wro!
 te:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Tue Apr 17 17:30:01 2012<br>
New Revision: 154956<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=154956&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=154956&view=rev</a><br>
Log:<br>
PR12569: Instantiate exception specifications of explicit instantiations<br>
and explicit specializations of function templates appropriately.<br>
<br>
Modified:<br>
    cfe/trunk/lib/Sema/SemaDecl.cpp<br>
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp<br>
    cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp<br>
    cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=154956&r1=154955&r2=154956&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=154956&r1=154955&r2=154956&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 17 17:30:01 2012<br>
@@ -7185,8 +7185,7 @@<br>
   }<br>
 }<br>
<br>
-Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope,<br>
-                                         Declarator &D) {<br>
+Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {<br>
   assert(getCurFunctionDecl() == 0 && "Function parsing confused");<br>
   assert(D.isFunctionDeclarator() && "Not a function declarator!");<br>
   Scope *ParentScope = FnBodyScope->getParent();<br>
@@ -7359,6 +7358,10 @@<br>
     }<br>
   }<br>
<br>
+  // Ensure that the function's exception specification is instantiated.<br>
+  if (const FunctionProtoType *FPT = FD->getType()->getAs<FunctionProtoType>())<br>
+    ResolveExceptionSpec(D->getLocation(), FPT);<br>
+<br>
   // Checking attributes of current function definition<br>
   // dllimport attribute.<br>
   DLLImportAttr *DA = FD->getAttr<DLLImportAttr>();<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=154956&r1=154955&r2=154956&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=154956&r1=154955&r2=154956&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Apr 17 17:30:01 2012<br>
@@ -2377,7 +2377,16 @@<br>
<br>
 void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation,<br>
                                     FunctionDecl *Decl) {<br>
-  FunctionDecl *Tmpl = Decl->getTemplateInstantiationPattern();<br>
+  // Find the template declaration which contains the exception specification.<br>
+  // Per [except.spec]p4, prefer the exception spec on the primary template<br>
+  // if this is an explicit instantiation.<br>
+  FunctionDecl *Tmpl = 0;<br>
+  if (Decl->getPrimaryTemplate())<br>
+    Tmpl = Decl->getPrimaryTemplate()->getTemplatedDecl();<br>
+  else if (FunctionDecl *MemTmpl = Decl->getInstantiatedFromMemberFunction())<br>
+    Tmpl = MemTmpl;<br>
+  else<br>
+    Tmpl = Decl->getTemplateInstantiationPattern();<br>
   assert(Tmpl && "can't instantiate non-template");<br>
<br>
   if (Decl->getType()->castAs<FunctionProtoType>()->getExceptionSpecType()<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp?rev=154956&r1=154955&r2=154956&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp?rev=154956&r1=154955&r2=154956&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/cxx11-exception-spec.cpp Tue Apr 17 17:30:01 2012<br>
@@ -1,18 +1,66 @@<br>
-// RUN: %clang_cc1 -std=c++11 -verify -emit-llvm %s -o - | FileCheck %s<br>
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s<br>
<br>
-template<typename T> void f() noexcept(sizeof(T) == 4);<br>
+void h();<br>
+<br>
+template<typename T> void f() noexcept(sizeof(T) == 4) { h(); }<br>
+<br>
+template<typename T> struct S {<br>
+  static void f() noexcept(sizeof(T) == 4) { h(); }<br>
+};<br>
+<br>
+// CHECK: define {{.*}} @_Z1fIsEvv() {<br>
+template<> void f<short>() { h(); }<br>
+// CHECK: define {{.*}} @_Z1fIA2_sEvv() nounwind {<br>
+template<> void f<short[2]>() noexcept { h(); }<br>
+<br>
+// CHECK: define {{.*}} @_ZN1SIsE1fEv()<br>
+// CHECK-NOT: nounwind<br>
+template<> void S<short>::f() { h(); }<br>
+// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() nounwind<br>
+template<> void S<short[2]>::f() noexcept { h(); }<br>
+<br>
+// CHECK: define {{.*}} @_Z1fIDsEvv() {<br>
+template void f<char16_t>();<br>
+// CHECK: define {{.*}} @_Z1fIA2_DsEvv() nounwind {<br>
+template void f<char16_t[2]>();<br>
+<br>
+// CHECK: define {{.*}} @_ZN1SIDsE1fEv()<br>
+// CHECK-NOT: nounwind<br>
+template void S<char16_t>::f();<br>
+// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind<br>
+template void S<char16_t[2]>::f();<br>
<br>
 void g() {<br>
-  // CHECK: declare void @_Z1fIiEvv() nounwind<br>
+  // CHECK: define {{.*}} @_Z1fIiEvv() nounwind {<br>
   f<int>();<br>
-  // CHECK: declare void @_Z1fIA2_iEvv()<br>
+  // CHECK: define {{.*}} @_Z1fIA2_iEvv() {<br>
   f<int[2]>();<br>
-  // CHECK: declare void @_Z1fIfEvv() nounwind<br>
+<br>
+  // CHECK: define {{.*}} @_ZN1SIiE1fEv() nounwind<br>
+  S<int>::f();<br>
+  // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv()<br>
+  // CHECK-NOT: nounwind<br>
+  S<int[2]>::f();<br>
+<br>
+  // CHECK: define {{.*}} @_Z1fIfEvv() nounwind {<br>
   void (*f1)() = &f<float>;<br>
-  // CHECK: declare void @_Z1fIdEvv()<br>
+  // CHECK: define {{.*}} @_Z1fIdEvv() {<br>
   void (*f2)() = &f<double>;<br>
-  // CHECK: declare void @_Z1fIA4_cEvv() nounwind<br>
+<br>
+  // CHECK: define {{.*}} @_ZN1SIfE1fEv() nounwind<br>
+  void (*f3)() = &S<float>::f;<br>
+  // CHECK: define {{.*}} @_ZN1SIdE1fEv()<br>
+  // CHECK-NOT: nounwind<br>
+  void (*f4)() = &S<double>::f;<br>
+<br>
+  // CHECK: define {{.*}} @_Z1fIA4_cEvv() nounwind {<br>
   (void)&f<char[4]>;<br>
-  // CHECK: declare void @_Z1fIcEvv()<br>
+  // CHECK: define {{.*}} @_Z1fIcEvv() {<br>
   (void)&f<char>;<br>
+<br>
+  // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() nounwind<br>
+  (void)&S<char[4]>::f;<br>
+  // CHECK: define {{.*}} @_ZN1SIcE1fEv()<br>
+  // CHECK-NOT: nounwind<br>
+  (void)&S<char>::f;<br>
 }<br>
<br>
Modified: cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp?rev=154956&r1=154955&r2=154956&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp?rev=154956&r1=154955&r2=154956&view=diff</a><br>


==============================================================================<br>
--- cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp (original)<br>
+++ cfe/trunk/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp Tue Apr 17 17:30:01 2012<br>
@@ -105,3 +105,16 @@<br>
<br>
   base<types> val = base<types>();<br>
 }<br>
+<br>
+namespace pr9485 {<br>
+  template <typename T> void f1(T) throw(typename T::exception); // expected-note {{candidate}}<br>
+  template <typename T> void f1(T, int = 0) throw(typename T::noitpecxe); // expected-note {{candidate}}<br>
+<br>
+  template <typename T> void f2(T) noexcept(T::throws); // expected-note {{candidate}}<br>
+  template <typename T> void f2(T, int = 0) noexcept(T::sworht); // expected-note {{candidate}}<br>
+<br>
+  void test() {<br>
+    f1(0); // expected-error {{ambiguous}}<br>
+    f2(0); // expected-error {{ambiguous}}<br>
+  }<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div>
</blockquote></div><br></div></body></html>