aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-10-29 15:10:40 +0000
committerDouglas Gregor <dgregor@apple.com>2008-10-29 15:10:40 +0000
commit6fc17ff5bf73c4d190517ebc5773f2ae557598ab (patch)
treecb1e0fe7f4194b4512ed8590167369fd1ef95e36 /lib/Sema/SemaDecl.cpp
parentf70bdb9463a6e3ea2c6307b2c7a5f3e2c6b7e489 (diff)
Simplify and correct the check for function redefinitions. This does two things:
- Allows definitions of overloaded functions :) - Eliminates extraneous error messages when we have a definition of a function that isn't an overload but doesn't have exactly the same type as the original. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58382 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 90fe1ee8a8..2306151279 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1761,20 +1761,6 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
Scope *GlobalScope = FnBodyScope->getParent();
- // See if this is a redefinition.
- Decl *PrevDcl = LookupDecl(D.getIdentifier(), Decl::IDNS_Ordinary,
- GlobalScope);
- if (PrevDcl && isDeclInScope(PrevDcl, CurContext)) {
- if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PrevDcl)) {
- const FunctionDecl *Definition;
- if (FD->getBody(Definition)) {
- Diag(D.getIdentifierLoc(), diag::err_redefinition,
- D.getIdentifier()->getName());
- Diag(Definition->getLocation(), diag::err_previous_definition);
- }
- }
- }
-
return ActOnStartOfFunctionDef(FnBodyScope,
ActOnDeclarator(GlobalScope, D, 0));
}
@@ -1782,6 +1768,15 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D) {
Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
Decl *decl = static_cast<Decl*>(D);
FunctionDecl *FD = cast<FunctionDecl>(decl);
+
+ // See if this is a redefinition.
+ const FunctionDecl *Definition;
+ if (FD->getBody(Definition)) {
+ Diag(FD->getLocation(), diag::err_redefinition,
+ FD->getName());
+ Diag(Definition->getLocation(), diag::err_previous_definition);
+ }
+
PushDeclContext(FD);
// Check the validity of our function parameters