Add explicit support for diagnosing implicit function decls.
Without this, the diagnostic is very confusing. The diag is now consistent with gcc as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49214 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 6f0f351..882ec0e 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -290,8 +290,13 @@
// A function that has already been declared has been redeclared or defined
// with a different type- show appropriate diagnostic
- diag::kind PrevDiag = Old->getBody() ? diag::err_previous_definition :
- diag::err_previous_declaration;
+ diag::kind PrevDiag;
+ if (Old->getBody())
+ PrevDiag = diag::err_previous_definition;
+ else if (Old->isImplicit())
+ PrevDiag = diag::err_previous_implicit_declaration;
+ else
+ PrevDiag = diag::err_previous_declaration;
// TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
// TODO: This is totally simplistic. It should handle merging functions
@@ -1181,7 +1186,10 @@
while (S->getParent())
S = S->getParent();
- return dyn_cast<ScopedDecl>(static_cast<Decl*>(ActOnDeclarator(S, D, 0)));
+ FunctionDecl *FD =
+ dyn_cast<FunctionDecl>(static_cast<Decl*>(ActOnDeclarator(S, D, 0)));
+ FD->setImplicit();
+ return FD;
}