As per Neil's comment:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080114/003778.html

This patch ensures that function declarations are no longer called
definitions in the diagnostic output, which should be less confusing
for everybody :-).

Carl.
Index: Sema/SemaDecl.cpp
===================================================================
--- Sema/SemaDecl.cpp	(revision 46067)
+++ Sema/SemaDecl.cpp	(working copy)
@@ -251,11 +251,16 @@
   if (Context.functionTypesAreCompatible(OldQType, NewQType))
     return New;
 
+  // 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; 
+
   // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
   // TODO: This is totally simplistic.  It should handle merging functions
   // together etc, merging extern int X; int X; ...
-  Diag(New->getLocation(), diag::err_redefinition, New->getName());
-  Diag(Old->getLocation(), diag::err_previous_definition);
+  Diag(New->getLocation(), diag::err_conflicting_types, New->getName());
+  Diag(Old->getLocation(), PrevDiag);
   return New;
 }
 
Index: include/clang/Basic/DiagnosticKinds.def
===================================================================
--- include/clang/Basic/DiagnosticKinds.def	(revision 46067)
+++ include/clang/Basic/DiagnosticKinds.def	(working copy)
@@ -598,6 +598,8 @@
      "redefinition of '%0'")
 DIAG(err_redefinition_different_kind, ERROR,
      "redefinition of '%0' as different kind of symbol")
+DIAG(err_conflicting_types, ERROR,
+     "conflicting types for '%0'")
 DIAG(err_nested_redefinition, ERROR,
      "nested redefinition of '%0'")
 DIAG(err_use_with_wrong_tag, ERROR,
Index: test/Sema/merge-decls.c
===================================================================
--- test/Sema/merge-decls.c	(revision 46067)
+++ test/Sema/merge-decls.c	(working copy)
@@ -3,9 +3,9 @@
 void foo(void);
 void foo(void) {} 
 void foo(void);
-void foo(void); // expected-error{{previous definition is here}}
+void foo(void); // expected-error{{previous declaration is here}}
 
-void foo(int); // expected-error {{redefinition of 'foo'}}
+void foo(int); // expected-error {{conflicting types for 'foo'}}
 
 int funcdef()
 {
Index: test/Sema/predefined-function.c
===================================================================
--- test/Sema/predefined-function.c	(revision 46067)
+++ test/Sema/predefined-function.c	(working copy)
@@ -4,13 +4,13 @@
 enum Test {A=-1};
 char *funk(enum Test x);
 
-int eli(float b); // expected-error {{previous definition is here}}
+int eli(float b); // expected-error {{previous declaration is here}}
 int b(int c) {return 1;}
 
 int foo();
 int foo()
 {
-    int eli(int (int)); // expected-error {{redefinition of 'eli'}}
+    int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
     eli(b);
 	return 0;	
 }
@@ -20,19 +20,19 @@
 {
 	return 0;
 }
-int bar() // expected-error {{redefinition of 'bar'}}
+int bar() // expected-error {{redefinition of 'bar'}} expected-error {{conflicting types for 'bar'}}
 {
 	return 0;
 }
 
-int foobar(int); // expected-error {{previous definition is here}}
-int foobar() // expected-error {{redefinition of 'foobar'}}
+int foobar(int); // expected-error {{previous declaration is here}}
+int foobar() // expected-error {{conflicting types for 'foobar'}}
 {
 	return 0;
 }
 
-int wibble(); // expected-error {{previous definition is here}}
-float wibble() // expected-error {{redefinition of 'wibble'}}
+int wibble(); // expected-error {{previous declaration is here}}
+float wibble() // expected-error {{conflicting types for 'wibble'}}
 {
 	return 0.0f;
 }
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to