summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-07-14 20:08:49 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-07-14 20:08:49 +0000
commit810e25ed9e0ab4c7bd2ba27db51e54527547a166 (patch)
tree55c7a8edf02da3d862d3bd4cad405a9571aa6b74
parentea17ce928b174921a59ad7e03398354ecfdb9c7b (diff)
downloadclang-810e25ed9e0ab4c7bd2ba27db51e54527547a166.tar.gz
[Sema] Emit a better diagnostic when variable redeclarations disagree
We referred to all declaration in definitions in our diagnostic messages which is can be inaccurate. Instead, classify the declaration and emit an appropriate diagnostic for the new declaration and an appropriate note pointing to the old one. This fixes PR24116. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242190 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaDecl.cpp13
-rw-r--r--test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp2
-rw-r--r--test/Modules/linkage-merge.m4
-rw-r--r--test/PCH/cxx1y-variable-templates.cpp4
-rw-r--r--test/Sema/array-declared-as-incorrect-type.c6
-rw-r--r--test/Sema/dllimport.c12
-rw-r--r--test/Sema/mrtd.c8
-rw-r--r--test/Sema/struct-compat.c4
-rw-r--r--test/Sema/types.c2
-rw-r--r--test/Sema/var-redecl.c28
-rw-r--r--test/SemaCXX/array-bound-merge.cpp2
-rw-r--r--test/SemaCXX/cxx11-thread-local.cpp2
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_in_class.cpp4
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_top_level.cpp6
-rw-r--r--test/SemaCXX/dllimport.cpp12
-rw-r--r--test/SemaCXX/extern-c.cpp2
-rw-r--r--test/SemaObjC/objc2-merge-gc-attribue-decl.m16
-rw-r--r--test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm16
19 files changed, 77 insertions, 68 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 14695dd6a8..85866b2457 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -188,6 +188,8 @@ def ext_flexible_array_init : Extension<
"flexible array initialization is a GNU extension">, InGroup<GNUFlexibleArrayInitializer>;
// Declarations.
+def err_redeclaration_different_type : Error<
+ "redeclaration of %0 with a different type%diff{: $ vs $|}1,2">;
def err_bad_variable_name : Error<
"%0 cannot be the name of a variable or data member">;
def err_bad_parameter_name : Error<
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 28877210c6..5646099015 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3270,9 +3270,16 @@ void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
//
// Neither C nor C++ requires a diagnostic for this, but we should still try
// to diagnose it.
- Diag(New->getLocation(), diag::err_redefinition_different_type)
- << New->getDeclName() << New->getType() << Old->getType();
- Diag(Old->getLocation(), diag::note_previous_definition);
+ Diag(New->getLocation(), New->isThisDeclarationADefinition()
+ ? diag::err_redefinition_different_type
+ : diag::err_redeclaration_different_type)
+ << New->getDeclName() << New->getType() << Old->getType();
+
+ diag::kind PrevDiag;
+ SourceLocation OldLocation;
+ std::tie(PrevDiag, OldLocation) =
+ getNoteDiagForInvalidRedeclaration(Old, New);
+ Diag(OldLocation, PrevDiag);
return New->setInvalidDecl();
}
diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
index e040d5b264..4686b1c961 100644
--- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
+++ b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
@@ -158,7 +158,7 @@ namespace dependent {
}
template<typename T> void n() {
- extern T n_var; // expected-error {{redefinition of 'n_var' with a different type: 'double' vs 'int'}} expected-note {{previous}}
+ extern T n_var; // expected-error {{redeclaration of 'n_var' with a different type: 'double' vs 'int'}} expected-note {{previous}}
extern T n_fn(); // expected-error {{functions that differ only in their return type cannot be overloaded}} expected-note {{previous}}
}
template void n<int>();
diff --git a/test/Modules/linkage-merge.m b/test/Modules/linkage-merge.m
index 955eb1aa95..e7b9e5cec1 100644
--- a/test/Modules/linkage-merge.m
+++ b/test/Modules/linkage-merge.m
@@ -16,8 +16,8 @@ static int f2(float); // okay: considered distinct
extern int f3(float); // okay: considered distinct
extern float v0;
-// expected-error@-1{{redefinition of 'v0' with a different type: 'float' vs 'int'}}
-// expected-note@Inputs/linkage-merge-sub.h:6{{previous definition is here}}
+// expected-error@-1{{redeclaration of 'v0' with a different type: 'float' vs 'int'}}
+// expected-note@Inputs/linkage-merge-sub.h:6{{previous declaration is here}}
static float v1;
static float v2;
diff --git a/test/PCH/cxx1y-variable-templates.cpp b/test/PCH/cxx1y-variable-templates.cpp
index 77eeea22a2..29b66a11e8 100644
--- a/test/PCH/cxx1y-variable-templates.cpp
+++ b/test/PCH/cxx1y-variable-templates.cpp
@@ -89,8 +89,8 @@ namespace join {
namespace diff_types {
#ifdef ERROR
- template<typename T> extern T err0; // expected-error {{redefinition of 'err0' with a different type: 'T' vs 'float'}} // expected-note@42 {{previous definition is here}}
- template<typename T> extern float err1; // expected-error {{redefinition of 'err1' with a different type: 'float' vs 'T'}} // expected-note@43 {{previous definition is here}}
+ template<typename T> extern T err0; // expected-error {{redeclaration of 'err0' with a different type: 'T' vs 'float'}} // expected-note@42 {{previous declaration is here}}
+ template<typename T> extern float err1; // expected-error {{redeclaration of 'err1' with a different type: 'float' vs 'T'}} // expected-note@43 {{previous declaration is here}}
#endif
template<typename T> extern T def;
}
diff --git a/test/Sema/array-declared-as-incorrect-type.c b/test/Sema/array-declared-as-incorrect-type.c
index b93fa9a0ed..0ff9e94908 100644
--- a/test/Sema/array-declared-as-incorrect-type.c
+++ b/test/Sema/array-declared-as-incorrect-type.c
@@ -3,14 +3,14 @@
extern int a1[];
int a1[1];
-extern int a2[]; // expected-note {{previous definition is here}}
+extern int a2[]; // expected-note {{previous declaration is here}}
float a2[1]; // expected-error {{redefinition of 'a2'}}
extern int a3[][2];
int a3[1][2];
-extern int a4[][2]; // expected-note {{previous definition is here}}
+extern int a4[][2]; // expected-note {{previous declaration is here}}
int a4[2]; // expected-error {{redefinition of 'a4'}}
-extern int a5[1][2][3]; // expected-note {{previous definition is here}}
+extern int a5[1][2][3]; // expected-note {{previous declaration is here}}
int a5[3][2][1]; // expected-error {{redefinition of 'a5'}}
diff --git a/test/Sema/dllimport.c b/test/Sema/dllimport.c
index e066abdb72..3ca1baa299 100644
--- a/test/Sema/dllimport.c
+++ b/test/Sema/dllimport.c
@@ -81,14 +81,14 @@ __declspec(dllimport) static int StaticGlobal; // expected-error{{'StaticGlobal'
__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
// Import in local scope.
-__declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}}
-__declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}}
-__declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}}
+__declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}}
+__declspec(dllimport) float LocalRedecl2; // expected-note{{previous declaration is here}}
+__declspec(dllimport) float LocalRedecl3; // expected-note{{previous declaration is here}}
__declspec(dllimport) float LocalRedecl4;
void functionScope() {
- __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
- int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
- int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
+ __declspec(dllimport) int LocalRedecl1; // expected-error{{redeclaration of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
+ int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redeclaration of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
+ int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redeclaration of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
__declspec(dllimport) int LocalVarDecl;
__declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}}
diff --git a/test/Sema/mrtd.c b/test/Sema/mrtd.c
index ba1720e8d7..7bdeb27293 100644
--- a/test/Sema/mrtd.c
+++ b/test/Sema/mrtd.c
@@ -17,8 +17,8 @@ void variadic(int a, ...);
void __attribute__((stdcall)) variadic(int a, ...);
#ifdef MRTD
-// expected-note@+3 {{previous definition is here}}
-// expected-error@+3 {{redefinition of 'a' with a different type: 'void ((*))(int, int) __attribute__((cdecl))' vs 'void (*)(int, int) __attribute__((stdcall))'}}
+// expected-note@+3 {{previous declaration is here}}
+// expected-error@+3 {{redeclaration of 'a' with a different type: 'void ((*))(int, int) __attribute__((cdecl))' vs 'void (*)(int, int) __attribute__((stdcall))'}}
#endif
extern void (*a)(int, int);
__attribute__((cdecl)) extern void (*a)(int, int);
@@ -27,8 +27,8 @@ extern void (*b)(int, ...);
__attribute__((cdecl)) extern void (*b)(int, ...);
#ifndef MRTD
-// expected-note@+3 {{previous definition is here}}
-// expected-error@+3 {{redefinition of 'c' with a different type: 'void ((*))(int, int) __attribute__((stdcall))' vs 'void (*)(int, int)'}}
+// expected-note@+3 {{previous declaration is here}}
+// expected-error@+3 {{redeclaration of 'c' with a different type: 'void ((*))(int, int) __attribute__((stdcall))' vs 'void (*)(int, int)'}}
#endif
extern void (*c)(int, int);
__attribute__((stdcall)) extern void (*c)(int, int);
diff --git a/test/Sema/struct-compat.c b/test/Sema/struct-compat.c
index 65bef9f605..68bb2cad45 100644
--- a/test/Sema/struct-compat.c
+++ b/test/Sema/struct-compat.c
@@ -1,8 +1,8 @@
/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
*/
-extern struct {int a;} x; // expected-note {{previous definition is here}}
-extern struct {int a;} x; // expected-error {{redefinition of 'x'}}
+extern struct {int a;} x; // expected-note {{previous declaration is here}}
+extern struct {int a;} x; // expected-error {{redeclaration of 'x'}}
struct x;
int a(struct x* b) {
diff --git a/test/Sema/types.c b/test/Sema/types.c
index 5614d164a5..9981be50ad 100644
--- a/test/Sema/types.c
+++ b/test/Sema/types.c
@@ -45,7 +45,7 @@ extern int i[1LL];
int i[(short)1];
enum e { e_1 };
-extern int j[sizeof(enum e)]; // expected-note {{previous definition}}
+extern int j[sizeof(enum e)]; // expected-note {{previous declaration}}
int j[42]; // expected-error {{redefinition of 'j' with a different type: 'int [42]' vs 'int [4]'}}
// rdar://6880104
diff --git a/test/Sema/var-redecl.c b/test/Sema/var-redecl.c
index 811e9f10bf..024bfd436a 100644
--- a/test/Sema/var-redecl.c
+++ b/test/Sema/var-redecl.c
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
int outer1; // expected-note{{previous definition is here}}
-extern int outer2; // expected-note{{previous definition is here}}
+extern int outer2; // expected-note{{previous declaration is here}}
int outer4;
int outer4; // expected-note{{previous definition is here}}
int outer5;
@@ -9,17 +9,17 @@ int outer6(float); // expected-note{{previous definition is here}}
int outer7(float);
void outer_test() {
- extern float outer1; // expected-error{{redefinition of 'outer1' with a different type}}
- extern float outer2; // expected-error{{redefinition of 'outer2' with a different type}}
- extern float outer3; // expected-note{{previous definition is here}}
+ extern float outer1; // expected-error{{redeclaration of 'outer1' with a different type}}
+ extern float outer2; // expected-error{{redeclaration of 'outer2' with a different type}}
+ extern float outer3; // expected-note{{previous declaration is here}}
double outer4;
- extern int outer5; // expected-note{{previous definition is here}}
+ extern int outer5; // expected-note{{previous declaration is here}}
extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}}
int outer7;
extern int outer8; // expected-note{{previous definition is here}}
extern int outer9;
{
- extern int outer9; // expected-note{{previous definition is here}}
+ extern int outer9; // expected-note{{previous declaration is here}}
}
}
@@ -29,22 +29,22 @@ float outer5; // expected-error{{redefinition of 'outer5' with a different type
int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}}
float outer9; // expected-error{{redefinition of 'outer9' with a different type}}
-extern int outer13; // expected-note{{previous definition is here}}
+extern int outer13; // expected-note{{previous declaration is here}}
void outer_shadowing_test() {
extern int outer10;
- extern int outer11; // expected-note{{previous definition is here}}
- extern int outer12; // expected-note{{previous definition is here}}
+ extern int outer11; // expected-note{{previous declaration is here}}
+ extern int outer12; // expected-note{{previous declaration is here}}
{
float outer10;
float outer11;
float outer12;
{
extern int outer10; // okay
- extern float outer11; // expected-error{{redefinition of 'outer11' with a different type}}
+ extern float outer11; // expected-error{{redeclaration of 'outer11' with a different type}}
static double outer12;
{
- extern float outer12; // expected-error{{redefinition of 'outer12' with a different type}}
- extern float outer13; // expected-error{{redefinition of 'outer13' with a different type}}
+ extern float outer12; // expected-error{{redeclaration of 'outer12' with a different type}}
+ extern float outer13; // expected-error{{redeclaration of 'outer13' with a different type}}
}
}
}
@@ -66,5 +66,5 @@ void f(int x) { // expected-note {{previous definition is here}}
}
extern int b[];
-void g20() { extern int b[3]; } // expected-note{{previous definition is here}}
-void g21() { extern int b[4]; } // expected-error{{redefinition of 'b' with a different type: 'int [4]' vs 'int [3]'}}
+void g20() { extern int b[3]; } // expected-note{{previous declaration is here}}
+void g21() { extern int b[4]; } // expected-error{{redeclaration of 'b' with a different type: 'int [4]' vs 'int [3]'}}
diff --git a/test/SemaCXX/array-bound-merge.cpp b/test/SemaCXX/array-bound-merge.cpp
index c6085fb0a9..a360d007c3 100644
--- a/test/SemaCXX/array-bound-merge.cpp
+++ b/test/SemaCXX/array-bound-merge.cpp
@@ -10,5 +10,5 @@ int c[] = {1,2}; // expected-error {{excess elements in array initializer}}
int d[1][]; // expected-error {{array has incomplete element type 'int []'}}
-extern const int e[2]; // expected-note {{previous definition is here}}
+extern const int e[2]; // expected-note {{previous declaration is here}}
int e[] = { 1 }; // expected-error {{redefinition of 'e' with a different type: 'int []' vs 'const int [2]'}}
diff --git a/test/SemaCXX/cxx11-thread-local.cpp b/test/SemaCXX/cxx11-thread-local.cpp
index f1dddc1c3b..a974d81985 100644
--- a/test/SemaCXX/cxx11-thread-local.cpp
+++ b/test/SemaCXX/cxx11-thread-local.cpp
@@ -19,5 +19,5 @@ thread_local int z[3]; // expected-note {{previous}}
void f() {
thread_local int x;
static thread_local int y;
- extern thread_local int z; // expected-error {{redefinition of 'z' with a different type}}
+ extern thread_local int z; // expected-error {{redeclaration of 'z' with a different type}}
}
diff --git a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 9ff73daa82..123fcfff7f 100644
--- a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -214,7 +214,7 @@ namespace in_class_template {
template<typename T>
class D0a {
template<typename U> static U Data;
- template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous definition is here}}
+ template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous declaration is here}}
};
template<>
template<typename U> U D0a<float>::Data<U*> = U(100); // expected-error {{redefinition of 'Data'}}
@@ -228,7 +228,7 @@ namespace in_class_template {
template<typename T>
class D1 {
template<typename U> static U Data;
- template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous definition is here}}
+ template<typename U> static CONST U Data<U*> = U(10); // expected-note {{previous declaration is here}}
};
template<>
template<typename U> U D1<float>::Data = U(10);
diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index 4e62941e68..145bc49fff 100644
--- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -98,8 +98,8 @@ namespace odr_tmpl {
namespace pvt_extern {
template<typename T> T v = T();
template<typename T> extern T v; // redeclaration is allowed \
- // expected-note {{previous definition is here}}
- template<typename T> extern int v; // expected-error {{redefinition of 'v' with a different type: 'int' vs 'T'}}
+ // expected-note {{previous declaration is here}}
+ template<typename T> extern int v; // expected-error {{redeclaration of 'v' with a different type: 'int' vs 'T'}}
#ifndef PRECXX11
template<typename T> extern auto v; // expected-error {{declaration of variable 'v' with type 'auto' requires an initializer}}
@@ -117,7 +117,7 @@ namespace odr_tmpl {
template<typename T> auto v2 = T(); // expected-note {{previous definition is here}}
template<typename T> T v2; // expected-error {{redefinition of 'v2'}}
template<typename T> auto v3 = T(); // expected-note {{previous definition is here}}
- template<typename T> extern T v3; // expected-error {{redefinition of 'v3' with a different type: 'T' vs 'auto'}}
+ template<typename T> extern T v3; // expected-error {{redeclaration of 'v3' with a different type: 'T' vs 'auto'}}
template<typename T> auto v4 = T();
template<typename T> extern auto v4; // expected-error {{declaration of variable 'v4' with type 'auto' requires an initializer}}
}
diff --git a/test/SemaCXX/dllimport.cpp b/test/SemaCXX/dllimport.cpp
index 0f616d43c8..2fa10756da 100644
--- a/test/SemaCXX/dllimport.cpp
+++ b/test/SemaCXX/dllimport.cpp
@@ -95,13 +95,13 @@ __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-erro
__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
// Import in local scope.
-__declspec(dllimport) float LocalRedecl1; // expected-note{{previous definition is here}}
-__declspec(dllimport) float LocalRedecl2; // expected-note{{previous definition is here}}
-__declspec(dllimport) float LocalRedecl3; // expected-note{{previous definition is here}}
+__declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}}
+__declspec(dllimport) float LocalRedecl2; // expected-note{{previous declaration is here}}
+__declspec(dllimport) float LocalRedecl3; // expected-note{{previous declaration is here}}
void functionScope() {
- __declspec(dllimport) int LocalRedecl1; // expected-error{{redefinition of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
- int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redefinition of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
- int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redefinition of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
+ __declspec(dllimport) int LocalRedecl1; // expected-error{{redeclaration of 'LocalRedecl1' with a different type: 'int' vs 'float'}}
+ int *__attribute__((dllimport)) LocalRedecl2; // expected-error{{redeclaration of 'LocalRedecl2' with a different type: 'int *' vs 'float'}}
+ int LocalRedecl3 __attribute__((dllimport)); // expected-error{{redeclaration of 'LocalRedecl3' with a different type: 'int' vs 'float'}}
__declspec(dllimport) int LocalVarDecl;
__declspec(dllimport) int LocalVarDef = 1; // expected-error{{definition of dllimport data}}
diff --git a/test/SemaCXX/extern-c.cpp b/test/SemaCXX/extern-c.cpp
index dfbf38667c..295d1f305e 100644
--- a/test/SemaCXX/extern-c.cpp
+++ b/test/SemaCXX/extern-c.cpp
@@ -21,7 +21,7 @@ float test2_x; // expected-error {{declaration of 'test2_x' in global scope conf
namespace test3 {
extern "C" {
void test3_f() {
- extern int test3_b; // expected-note {{previous definition is here}}
+ extern int test3_b; // expected-note {{previous declaration is here}}
}
}
extern "C" {
diff --git a/test/SemaObjC/objc2-merge-gc-attribue-decl.m b/test/SemaObjC/objc2-merge-gc-attribue-decl.m
index 673a7417e3..232f8dd794 100644
--- a/test/SemaObjC/objc2-merge-gc-attribue-decl.m
+++ b/test/SemaObjC/objc2-merge-gc-attribue-decl.m
@@ -13,17 +13,17 @@ extern __strong id CFRunLoopGetMain();
extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
extern id WLoopGetMain(); // expected-error {{conflicting types for 'WLoopGetMain'}}
-extern id p3; // expected-note {{previous definition is here}}
-extern __weak id p3; // expected-error {{redefinition of 'p3' with a different type}}
+extern id p3; // expected-note {{previous declaration is here}}
+extern __weak id p3; // expected-error {{redeclaration of 'p3' with a different type}}
-extern void *p4; // expected-note {{previous definition is here}}
-extern void * __strong p4; // expected-error {{redefinition of 'p4' with a different type}}
+extern void *p4; // expected-note {{previous declaration is here}}
+extern void * __strong p4; // expected-error {{redeclaration of 'p4' with a different type}}
extern id p5;
extern __strong id p5;
-extern char* __strong p6; // expected-note {{previous definition is here}}
-extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
+extern char* __strong p6; // expected-note {{previous declaration is here}}
+extern char* p6; // expected-error {{redeclaration of 'p6' with a different type}}
-extern __strong char* p7; // expected-note {{previous definition is here}}
-extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
+extern __strong char* p7; // expected-note {{previous declaration is here}}
+extern char* p7; // expected-error {{redeclaration of 'p7' with a different type}}
diff --git a/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm b/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
index 7be5f17daa..9166ba65b9 100644
--- a/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
+++ b/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
@@ -35,17 +35,17 @@ extern ID CFRunLoopGetMain8();
extern __weak id WLoopGetMain(); // expected-note {{previous declaration is here}}
extern id WLoopGetMain(); // expected-error {{functions that differ only in their return type cannot be overloaded}}
-extern id p3; // expected-note {{previous definition is here}}
-extern __weak id p3; // expected-error {{redefinition of 'p3' with a different type}}
+extern id p3; // expected-note {{previous declaration is here}}
+extern __weak id p3; // expected-error {{redeclaration of 'p3' with a different type}}
-extern void *p4; // expected-note {{previous definition is here}}
-extern void * __strong p4; // expected-error {{redefinition of 'p4' with a different type}}
+extern void *p4; // expected-note {{previous declaration is here}}
+extern void * __strong p4; // expected-error {{redeclaration of 'p4' with a different type}}
extern id p5;
extern __strong id p5;
-extern char* __strong p6; // expected-note {{previous definition is here}}
-extern char* p6; // expected-error {{redefinition of 'p6' with a different type}}
+extern char* __strong p6; // expected-note {{previous declaration is here}}
+extern char* p6; // expected-error {{redeclaration of 'p6' with a different type}}
-extern __strong char* p7; // expected-note {{previous definition is here}}
-extern char* p7; // expected-error {{redefinition of 'p7' with a different type}}
+extern __strong char* p7; // expected-note {{previous declaration is here}}
+extern char* p7; // expected-error {{redeclaration of 'p7' with a different type}}