summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-12-15 02:35:39 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-12-15 02:35:39 +0000
commitdfe85e2d88cdc7684abdeff6c91356d16a394849 (patch)
treee5ea9fc48a52df5963fb86670e19f2573a5c9e01 /clang/lib/Sema/SemaDecl.cpp
parent81f5ade22790685efa5542bd8b7e7fb2c6b6c56c (diff)
downloadbcm5719-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.cpp31
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
OpenPOWER on IntegriCloud