aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-04-04 14:32:09 +0000
committerSteve Naroff <snaroff@apple.com>2008-04-04 14:32:09 +0000
commite2ef815de1da36c1ad1494cb58ce37adac1efa26 (patch)
tree4e71084c9277853910ca12a0298d947bedf3d5f4 /lib/Sema/SemaDecl.cpp
parentd389465f426069115a35e857ef11f1fcc5a2f69c (diff)
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
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 6f0f351000..882ec0e1a4 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -290,8 +290,13 @@ FunctionDecl *Sema::MergeFunctionDecl(FunctionDecl *New, Decl *OldD) {
// 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 @@ ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
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;
}