improve decl merging logic to be more correct with

functions.  Patch contributed by Nuno Lopes, thanks!

llvm-svn: 43757
This commit is contained in:
Chris Lattner 2007-11-06 06:07:26 +00:00
parent 0fc613b85d
commit 45d561ad99
2 changed files with 13 additions and 0 deletions

View File

@ -245,6 +245,11 @@ FunctionDecl *Sema::MergeFunctionDecl(FunctionDecl *New, ScopedDecl *OldD) {
Old->getCanonicalType() == New->getCanonicalType()) {
return New;
}
if (New->getBody() == 0 &&
Old->getCanonicalType() == New->getCanonicalType()) {
return 0;
}
// TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
// TODO: This is totally simplistic. It should handle merging functions

View File

@ -0,0 +1,8 @@
// RUN: clang %s -verify -fsyntax-only
void foo(void);
void foo(void) {} // expected-error{{previous definition is here}}
void foo(void);
void foo(void);
void foo(int); // expected-error {{redefinition of 'foo'}}