From: Richard Smith Date: Wed, 2 Nov 2016 00:47:52 +0000 (+0000) Subject: More forcibly resolve exception specifications when checking a function X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c30dc1c5c00534c506f864b55fc2ad1f2628ce3f;p=clang More forcibly resolve exception specifications when checking a function redeclaration in C++1z mode. We need the exception specification in order for the function's type to be complete. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285779 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 319e63dbb1..1813aa0b64 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2949,6 +2949,15 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, // but do not necessarily update the type of New. if (CheckEquivalentExceptionSpec(Old, New)) return true; + // If exceptions are disabled, we might not have resolved the exception spec + // of one or both declarations. Do so now in C++1z, so that we can properly + // compare the types. + if (getLangOpts().CPlusPlus1z) { + for (QualType T : {Old->getType(), New->getType()}) + if (auto *FPT = T->getAs()) + if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) + ResolveExceptionSpec(New->getLocation(), FPT); + } OldQType = Context.getCanonicalType(Old->getType()); NewQType = Context.getCanonicalType(New->getType()); diff --git a/test/SemaCXX/cxx1z-noexcept-function-type.cpp b/test/SemaCXX/cxx1z-noexcept-function-type.cpp index 72b28432ef..ae686d396b 100644 --- a/test/SemaCXX/cxx1z-noexcept-function-type.cpp +++ b/test/SemaCXX/cxx1z-noexcept-function-type.cpp @@ -89,3 +89,11 @@ namespace CompatWarning { template void h(...) = delete; // expected-note {{deleted}} void test_h() { h(nullptr); } // expected-error {{deleted}} } + +namespace ImplicitExceptionSpec { + struct S { + ~S(); + void f(const S &s = S()); + }; + S::~S() {} +}