From 130fcc8097ac79c770d480765d4f79b428b285b8 Mon Sep 17 00:00:00 2001 From: Eli Friedman <eli.friedman@gmail.com> Date: Fri, 6 Sep 2013 21:09:09 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaDecl.cpp | 6 ++++-- test/CXX/except/except.spec/p4.cpp | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 68df00dec44..34f7c46b675 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<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 diff --git a/test/CXX/except/except.spec/p4.cpp b/test/CXX/except/except.spec/p4.cpp index 1bf70188031..8d1b75fbdd6 100644 --- a/test/CXX/except/except.spec/p4.cpp +++ b/test/CXX/except/except.spec/p4.cpp @@ -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(); -- GitLab