]> granicus.if.org Git - clang/commitdiff
Preserve exception specs in function decl merging.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 6 Sep 2013 21:09:09 +0000 (21:09 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 6 Sep 2013 21:09:09 +0000 (21:09 +0000)
Exception specs are not part of the canonical type, but we shouldn't
drop them just because we merged a noreturn attribute.

Fixes PR17110.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190206 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/CXX/except/except.spec/p4.cpp

index 68df00dec44fbc802a728156058a058e2dc320b5..34f7c46b67593c3e68228ae365d95a78316a78cb 100644 (file)
@@ -2382,9 +2382,11 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD, Scope *S,
   }
   
   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
index 1bf70188031fa44192333b6ecb54fabc5245227a..8d1b75fbdd6d677f126ddb8550ad0cd7e75d04c3 100644 (file)
@@ -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();