diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-15 02:35:39 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-12-15 02:35:39 +0000 |
| commit | dfe85e2d88cdc7684abdeff6c91356d16a394849 (patch) | |
| tree | e5ea9fc48a52df5963fb86670e19f2573a5c9e01 /clang/lib/Sema/SemaDecl.cpp | |
| parent | 81f5ade22790685efa5542bd8b7e7fb2c6b6c56c (diff) | |
| download | bcm5719-llvm-dfe85e2d88cdc7684abdeff6c91356d16a394849.tar.gz bcm5719-llvm-dfe85e2d88cdc7684abdeff6c91356d16a394849.zip | |
[c++1z] Permit constant evaluation of a call through a function pointer whose
type differs from the type of the actual function due to having a different
exception specification.
llvm-svn: 289754
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 89cb4398638..7878355fc19 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9076,27 +9076,16 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, ASTContext::GetBuiltinTypeError Error; LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier()); QualType T = Context.GetBuiltinType(BuiltinID, Error); - if (!T.isNull() && !Context.hasSameType(T, NewFD->getType())) { - auto WithoutExceptionSpec = [&](QualType T) -> QualType { - auto *Proto = T->getAs<FunctionProtoType>(); - if (!Proto) - return T; - return Context.getFunctionType( - Proto->getReturnType(), Proto->getParamTypes(), - Proto->getExtProtoInfo().withExceptionSpec(EST_None)); - }; - - // If the type of the builtin differs only in its exception - // specification, that's OK. - // FIXME: If the types do differ in this way, it would be better to - // retain the 'noexcept' form of the type. - if (!getLangOpts().CPlusPlus1z || - !Context.hasSameType(WithoutExceptionSpec(T), - WithoutExceptionSpec(NewFD->getType()))) - // The type of this function differs from the type of the builtin, - // so forget about the builtin entirely. - Context.BuiltinInfo.forgetBuiltin(BuiltinID, Context.Idents); - } + // If the type of the builtin differs only in its exception + // specification, that's OK. + // FIXME: If the types do differ in this way, it would be better to + // retain the 'noexcept' form of the type. + if (!T.isNull() && + !Context.hasSameFunctionTypeIgnoringExceptionSpec(T, + NewFD->getType())) + // The type of this function differs from the type of the builtin, + // so forget about the builtin entirely. + Context.BuiltinInfo.forgetBuiltin(BuiltinID, Context.Idents); } // If this function is declared as being extern "C", then check to see if |

