summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-09-20 18:38:57 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-09-20 18:38:57 +0000
commit6590220181b4e77cfd66fa9c8c63cd86088d49ad (patch)
treea8840d7cb29dd339acd1ca43d7855e262dc877f7
parente6af4b9a354677865c71525ecc1be514e275c8d5 (diff)
downloadbcm5719-llvm-6590220181b4e77cfd66fa9c8c63cd86088d49ad.tar.gz
bcm5719-llvm-6590220181b4e77cfd66fa9c8c63cd86088d49ad.zip
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
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/test/Sema/types.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 038ebacbfbd..637c5a509ff 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2dd5df1ea01..cbc3469fc77 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -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();
}
diff --git a/clang/test/Sema/types.c b/clang/test/Sema/types.c
index 3bec83e528b..6ae1a92e054 100644
--- a/clang/test/Sema/types.c
+++ b/clang/test/Sema/types.c
@@ -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}}
OpenPOWER on IntegriCloud