Author: rsmith Date: Tue Nov 1 19:47:52 2016 New Revision: 285779 URL: http://llvm.org/viewvc/llvm-project?rev=285779&view=rev Log: 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.
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=285779&r1=285778&r2=285779&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Nov 1 19:47:52 2016 @@ -2949,6 +2949,15 @@ bool Sema::MergeFunctionDecl(FunctionDec // 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<FunctionProtoType>()) + if (isUnresolvedExceptionSpec(FPT->getExceptionSpecType())) + ResolveExceptionSpec(New->getLocation(), FPT); + } OldQType = Context.getCanonicalType(Old->getType()); NewQType = Context.getCanonicalType(New->getType()); Modified: cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp?rev=285779&r1=285778&r2=285779&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp Tue Nov 1 19:47:52 2016 @@ -89,3 +89,11 @@ namespace CompatWarning { template<typename T> void h(...) = delete; // expected-note {{deleted}} void test_h() { h<void>(nullptr); } // expected-error {{deleted}} } + +namespace ImplicitExceptionSpec { + struct S { + ~S(); + void f(const S &s = S()); + }; + S::~S() {} +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits