When we attempt to create a built-in that involves a library type we
don't have access to (e.g., fprintf, which needs the library type
FILE), fail with a warning and forget about the builtin
entirely. Previously, we would actually provide an error, which breaks
autoconf's super-lame checks for fprintf, longjmp, etc. Fixes PR8316.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122744 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index abd6319..32791f9 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -793,13 +793,13 @@
case ASTContext::GE_Missing_stdio:
if (ForRedeclaration)
- Diag(Loc, diag::err_implicit_decl_requires_stdio)
+ Diag(Loc, diag::warn_implicit_decl_requires_stdio)
<< Context.BuiltinInfo.GetName(BID);
return 0;
case ASTContext::GE_Missing_setjmp:
if (ForRedeclaration)
- Diag(Loc, diag::err_implicit_decl_requires_setjmp)
+ Diag(Loc, diag::warn_implicit_decl_requires_setjmp)
<< Context.BuiltinInfo.GetName(BID);
return 0;
}
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 6972536..5ed973b 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -483,12 +483,21 @@
S.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
return false;
- NamedDecl *D = S.LazilyCreateBuiltin((IdentifierInfo *)II, BuiltinID,
- S.TUScope, R.isForRedeclaration(),
- R.getNameLoc());
- if (D)
+ if (NamedDecl *D = S.LazilyCreateBuiltin((IdentifierInfo *)II,
+ BuiltinID, S.TUScope,
+ R.isForRedeclaration(),
+ R.getNameLoc())) {
R.addDecl(D);
- return (D != NULL);
+ return true;
+ }
+
+ if (R.isForRedeclaration()) {
+ // If we're redeclaring this function anyway, forget that
+ // this was a builtin at all.
+ S.Context.BuiltinInfo.ForgetBuiltin(BuiltinID, S.Context.Idents);
+ }
+
+ return false;
}
}
}