From: Eli Friedman Date: Fri, 6 Sep 2013 21:09:09 +0000 (+0000) Subject: Preserve exception specs in function decl merging. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=130fcc8097ac79c770d480765d4f79b428b285b8;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190206 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 68df00dec4..34f7c46b67 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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(); + AdjustedType = Context.adjustFunctionType(AdjustedType, NewTypeInfo); + New->setType(QualType(AdjustedType, 0)); NewQType = Context.getCanonicalType(New->getType()); + NewType = cast(NewQType); } // If this redeclaration makes the function inline, we may need to add it to diff --git a/test/CXX/except/except.spec/p4.cpp b/test/CXX/except/except.spec/p4.cpp index 1bf7018803..8d1b75fbdd 100644 --- a/test/CXX/except/except.spec/p4.cpp +++ b/test/CXX/except/except.spec/p4.cpp @@ -34,3 +34,8 @@ template struct U { template U::~U() noexcept(true) {} // expected-error {{exception specification in declaration does not match previous declaration}} template void U::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();