r190206 - Preserve exception specs in function decl merging.

Eli Friedman eli.friedman at gmail.com
Fri Sep 6 14:09:09 PDT 2013


Author: efriedma
Date: Fri Sep  6 16:09:09 2013
New Revision: 190206

URL: http://llvm.org/viewvc/llvm-project?rev=190206&view=rev
Log:
Preserve exception specs in function decl merging.

Exception specs are not part of the canonical type, but we shouldn't
drop them just because we merged a noreturn attribute.

Fixes PR17110.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/CXX/except/except.spec/p4.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=190206&r1=190205&r2=190206&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep  6 16:09:09 2013
@@ -2382,9 +2382,11 @@ bool Sema::MergeFunctionDecl(FunctionDec
   }
   
   if (RequiresAdjustment) {
-    NewType = Context.adjustFunctionType(NewType, NewTypeInfo);
-    New->setType(QualType(NewType, 0));
+    const FunctionType *AdjustedType = New->getType()->getAs<FunctionType>();
+    AdjustedType = Context.adjustFunctionType(AdjustedType, NewTypeInfo);
+    New->setType(QualType(AdjustedType, 0));
     NewQType = Context.getCanonicalType(New->getType());
+    NewType = cast<FunctionType>(NewQType);
   }
 
   // If this redeclaration makes the function inline, we may need to add it to

Modified: cfe/trunk/test/CXX/except/except.spec/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/except/except.spec/p4.cpp?rev=190206&r1=190205&r2=190206&view=diff
==============================================================================
--- cfe/trunk/test/CXX/except/except.spec/p4.cpp (original)
+++ cfe/trunk/test/CXX/except/except.spec/p4.cpp Fri Sep  6 16:09:09 2013
@@ -34,3 +34,8 @@ template<typename T> struct U {
 
 template<typename T> U<T>::~U() noexcept(true) {} // expected-error {{exception specification in declaration does not match previous declaration}}
 template<typename T> void U<T>::operator delete(void*) noexcept(false) {} // expected-error {{exception specification in declaration does not match previous declaration}}
+
+
+// Make sure this restriction interacts properly with __attribute__((noreturn))
+void __attribute__ ((__noreturn__)) PR17110(int status) throw();
+void PR17110(int status) throw();





More information about the cfe-commits mailing list