forked from OSchip/llvm-project
Include types when a definition's type differs from a prior declaration.
This is some really old code (took me a while to find the test cases) & the diagnostic text is slightly incorrect (it should really only apply to re/declarations/, redefinitions are an error regardless of whether the types match). Not sure if anyone cares about it, though. For now this just makes the diagnostic more clear in less obvious cases where the type of a declaration might not be explicitly written (eg: because it uses decltype) llvm-svn: 164313
This commit is contained in:
parent
e6af4b9a35
commit
6590220181
|
@ -3185,7 +3185,7 @@ def err_non_thread_thread : Error<
|
|||
def err_thread_non_thread : Error<
|
||||
"thread-local declaration of %0 follows non-thread-local declaration">;
|
||||
def err_redefinition_different_type : Error<
|
||||
"redefinition of %0 with a different type">;
|
||||
"redefinition of %0 with a different type%diff{: $ vs $|}1,2">;
|
||||
def err_redefinition_different_kind : Error<
|
||||
"redefinition of %0 as different kind of symbol">;
|
||||
def warn_forward_class_redefinition : Warning<
|
||||
|
|
|
@ -2442,7 +2442,7 @@ void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old) {
|
|||
}
|
||||
if (MergedT.isNull()) {
|
||||
Diag(New->getLocation(), diag::err_redefinition_different_type)
|
||||
<< New->getDeclName();
|
||||
<< New->getDeclName() << New->getType() << Old->getType();
|
||||
Diag(Old->getLocation(), diag::note_previous_definition);
|
||||
return New->setInvalidDecl();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int i[(short)1];
|
|||
|
||||
enum e { e_1 };
|
||||
extern int j[sizeof(enum e)]; // expected-note {{previous definition}}
|
||||
int j[42]; // expected-error {{redefinition of 'j' with a different type}}
|
||||
int j[42]; // expected-error {{redefinition of 'j' with a different type: 'int [42]' vs 'int [4]'}}
|
||||
|
||||
// rdar://6880104
|
||||
_Decimal32 x; // expected-error {{GNU decimal type extension not supported}}
|
||||
|
|
Loading…
Reference in New Issue