Author: rsmith Date: Wed Mar 8 17:00:26 2017 New Revision: 297316 URL: http://llvm.org/viewvc/llvm-project?rev=297316&view=rev Log: Take into account C++17's noexcept function types during merging -- it should be possible to merge a declaration with an unresolved function type against one with a resolved function type.
Added: cfe/trunk/test/Modules/Inputs/cxx17/ cfe/trunk/test/Modules/Inputs/cxx17/decls.h cfe/trunk/test/Modules/Inputs/cxx17/module.modulemap cfe/trunk/test/Modules/cxx17.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=297316&r1=297315&r2=297316&view=diff ============================================================================== --- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Mar 8 17:00:26 2017 @@ -2758,9 +2758,23 @@ static bool isSameEntity(NamedDecl *X, N CtorY->getInheritedConstructor().getConstructor())) return false; } + ASTContext &C = FuncX->getASTContext(); + if (!C.hasSameType(FuncX->getType(), FuncY->getType())) { + // We can get functions with different types on the redecl chain in C++17 + // if they have differing exception specifications and at least one of + // the excpetion specs is unresolved. + // FIXME: Do we need to check for C++14 deduced return types here too? + auto *XFPT = FuncX->getType()->getAs<FunctionProtoType>(); + auto *YFPT = FuncY->getType()->getAs<FunctionProtoType>(); + if (C.getLangOpts().CPlusPlus1z && XFPT && YFPT && + (isUnresolvedExceptionSpec(XFPT->getExceptionSpecType()) || + isUnresolvedExceptionSpec(YFPT->getExceptionSpecType())) && + C.hasSameFunctionTypeIgnoringExceptionSpec(FuncX->getType(), + FuncY->getType())) + return true; + return false; + } return FuncX->getLinkageInternal() == FuncY->getLinkageInternal() && - FuncX->getASTContext().hasSameType(FuncX->getType(), - FuncY->getType()) && hasSameOverloadableAttrs(FuncX, FuncY); } Added: cfe/trunk/test/Modules/Inputs/cxx17/decls.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx17/decls.h?rev=297316&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/cxx17/decls.h (added) +++ cfe/trunk/test/Modules/Inputs/cxx17/decls.h Wed Mar 8 17:00:26 2017 @@ -0,0 +1,3 @@ +struct MergeExceptionSpec { + ~MergeExceptionSpec(); // unevaluated exception spec +}; Added: cfe/trunk/test/Modules/Inputs/cxx17/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx17/module.modulemap?rev=297316&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/cxx17/module.modulemap (added) +++ cfe/trunk/test/Modules/Inputs/cxx17/module.modulemap Wed Mar 8 17:00:26 2017 @@ -0,0 +1 @@ +module Decls { header "decls.h" } Added: cfe/trunk/test/Modules/cxx17.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx17.cpp?rev=297316&view=auto ============================================================================== --- cfe/trunk/test/Modules/cxx17.cpp (added) +++ cfe/trunk/test/Modules/cxx17.cpp Wed Mar 8 17:00:26 2017 @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -x c++ -std=c++1z -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/cxx17 %s -verify -fno-modules-error-recovery + +// expected-no-diagnostics +struct MergeExceptionSpec { + ~MergeExceptionSpec(); +} mergeExceptionSpec; // trigger evaluation of exception spec + +#include "decls.h" + +MergeExceptionSpec mergeExceptionSpec2; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits