LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
QualType T = Context.GetBuiltinType(BuiltinID, Error);
if (!T.isNull() && !Context.hasSameType(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);
+ 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);
}
}
};
S::~S() {}
}
+
+namespace Builtins {
+ // Pick two functions that ought to have the same noexceptness.
+ extern "C" int strcmp(const char *, const char *);
+ extern "C" int strncmp(const char *, const char *, decltype(sizeof(0))) noexcept;
+
+ // Check we recognized both as builtins.
+ typedef int arr[strcmp("bar", "foo") + 4 * strncmp("foo", "bar", 4)];
+ typedef int arr[3];
+}