C99 DR #316 implies that the function parameter types that are known
only from a function definition (that does not have a prototype) are
only used to determine the compatible with other declarations of that
same function. In particular, when referencing the function we pretend
as if it does not have a prototype. Implement this behavior, which
fixes PR3626.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65460 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index abb5e40..c312195 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -334,7 +334,8 @@
FunctionDecl *New = FunctionDecl::Create(Context,
Context.getTranslationUnitDecl(),
Loc, II, R,
- FunctionDecl::Extern, false);
+ FunctionDecl::Extern, false,
+ /*hasPrototype=*/true);
New->setImplicit();
// Create Decl objects for each parameter, adding them to the
@@ -1736,6 +1737,7 @@
// code path.
NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(),
Name, R, SC, isInline,
+ /*hasPrototype=*/true,
// FIXME: Move to DeclGroup...
D.getDeclSpec().getSourceRange().getBegin());
InvalidDecl = true;
@@ -1765,6 +1767,10 @@
NewFD = FunctionDecl::Create(Context, DC,
D.getIdentifierLoc(),
Name, R, SC, isInline,
+ /*hasPrototype=*/
+ (getLangOptions().CPlusPlus ||
+ (D.getNumTypeObjects() &&
+ D.getTypeObject(0).Fun.hasPrototype)),
// FIXME: Move to DeclGroup...
D.getDeclSpec().getSourceRange().getBegin());
}