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;
}
"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,
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()
{
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;
}
{
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;
}