[cfe-commits] r43757 - in /cfe/trunk: Sema/SemaDecl.cpp test/Sema/merge-decls.c
Chris Lattner
sabre at nondot.org
Mon Nov 5 22:07:27 PST 2007
Author: lattner
Date: Tue Nov 6 00:07:26 2007
New Revision: 43757
URL: http://llvm.org/viewvc/llvm-project?rev=43757&view=rev
Log:
improve decl merging logic to be more correct with
functions. Patch contributed by Nuno Lopes, thanks!
Added:
cfe/trunk/test/Sema/merge-decls.c
Modified:
cfe/trunk/Sema/SemaDecl.cpp
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=43757&r1=43756&r2=43757&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Nov 6 00:07:26 2007
@@ -245,6 +245,11 @@
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
Added: cfe/trunk/test/Sema/merge-decls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/merge-decls.c?rev=43757&view=auto
==============================================================================
--- cfe/trunk/test/Sema/merge-decls.c (added)
+++ cfe/trunk/test/Sema/merge-decls.c Tue Nov 6 00:07:26 2007
@@ -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'}}
More information about the cfe-commits
mailing list