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.

llvm-svn: 190206
This commit is contained in:
Eli Friedman 2013-09-06 21:09:09 +00:00
parent deeafd8a58
commit e934af8e58
2 changed files with 9 additions and 2 deletions

View 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

View 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();