r242190 - [Sema] Emit a better diagnostic when variable redeclarations disagree

David Majnemer david.majnemer at gmail.com
Tue Jul 14 13:08:50 PDT 2015


Author: majnemer
Date: Tue Jul 14 15:08:49 2015
New Revision: 242190

URL: http://llvm.org/viewvc/llvm-project?rev=242190&view=rev
Log:
[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.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
    cfe/trunk/test/Modules/linkage-merge.m
    cfe/trunk/test/PCH/cxx1y-variable-templates.cpp
    cfe/trunk/test/Sema/array-declared-as-incorrect-type.c
    cfe/trunk/test/Sema/dllimport.c
    cfe/trunk/test/Sema/mrtd.c
    cfe/trunk/test/Sema/struct-compat.c
    cfe/trunk/test/Sema/types.c
    cfe/trunk/test/Sema/var-redecl.c
    cfe/trunk/test/SemaCXX/array-bound-merge.cpp
    cfe/trunk/test/SemaCXX/cxx11-thread-local.cpp
    cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
    cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
    cfe/trunk/test/SemaCXX/dllimport.cpp
    cfe/trunk/test/SemaCXX/extern-c.cpp
    cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m
    cfe/trunk/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 14 15:08:49 2015
@@ -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<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 14 15:08:49 2015
@@ -3270,9 +3270,16 @@ void Sema::MergeVarDeclTypes(VarDecl *Ne
     //
     // 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();
   }
 

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp Tue Jul 14 15:08:49 2015
@@ -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>();

Modified: cfe/trunk/test/Modules/linkage-merge.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/linkage-merge.m?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Modules/linkage-merge.m (original)
+++ cfe/trunk/test/Modules/linkage-merge.m Tue Jul 14 15:08:49 2015
@@ -16,8 +16,8 @@ static int f2(float); // okay: considere
 extern int f3(float); // okay: considered distinct
 
 extern float v0;
-// expected-error at -1{{redefinition of 'v0' with a different type: 'float' vs 'int'}}
-// expected-note at Inputs/linkage-merge-sub.h:6{{previous definition is here}}
+// expected-error at -1{{redeclaration of 'v0' with a different type: 'float' vs 'int'}}
+// expected-note at Inputs/linkage-merge-sub.h:6{{previous declaration is here}}
 
 static float v1;
 static float v2;

Modified: cfe/trunk/test/PCH/cxx1y-variable-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx1y-variable-templates.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx1y-variable-templates.cpp (original)
+++ cfe/trunk/test/PCH/cxx1y-variable-templates.cpp Tue Jul 14 15:08:49 2015
@@ -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 at 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 at 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 at 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 at 43 {{previous declaration is here}}
 #endif
     template<typename T> extern T def;
   }

Modified: cfe/trunk/test/Sema/array-declared-as-incorrect-type.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/array-declared-as-incorrect-type.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/array-declared-as-incorrect-type.c (original)
+++ cfe/trunk/test/Sema/array-declared-as-incorrect-type.c Tue Jul 14 15:08:49 2015
@@ -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'}}

Modified: cfe/trunk/test/Sema/dllimport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/dllimport.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/dllimport.c (original)
+++ cfe/trunk/test/Sema/dllimport.c Tue Jul 14 15:08:49 2015
@@ -81,14 +81,14 @@ __declspec(dllimport) static int StaticG
 __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}}

Modified: cfe/trunk/test/Sema/mrtd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/mrtd.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/mrtd.c (original)
+++ cfe/trunk/test/Sema/mrtd.c Tue Jul 14 15:08:49 2015
@@ -17,8 +17,8 @@ void variadic(int a, ...);
 void __attribute__((stdcall)) variadic(int a, ...);
 
 #ifdef MRTD
-// expected-note at +3 {{previous definition is here}}
-// expected-error at +3 {{redefinition of 'a' with a different type: 'void ((*))(int, int) __attribute__((cdecl))' vs 'void (*)(int, int) __attribute__((stdcall))'}}
+// expected-note at +3 {{previous declaration is here}}
+// expected-error at +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 at +3 {{previous definition is here}}
-// expected-error at +3 {{redefinition of 'c' with a different type: 'void ((*))(int, int) __attribute__((stdcall))' vs 'void (*)(int, int)'}}
+// expected-note at +3 {{previous declaration is here}}
+// expected-error at +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);

Modified: cfe/trunk/test/Sema/struct-compat.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-compat.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/struct-compat.c (original)
+++ cfe/trunk/test/Sema/struct-compat.c Tue Jul 14 15:08:49 2015
@@ -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) {

Modified: cfe/trunk/test/Sema/types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/types.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/types.c (original)
+++ cfe/trunk/test/Sema/types.c Tue Jul 14 15:08:49 2015
@@ -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

Modified: cfe/trunk/test/Sema/var-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/var-redecl.c?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/Sema/var-redecl.c (original)
+++ cfe/trunk/test/Sema/var-redecl.c Tue Jul 14 15:08:49 2015
@@ -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{{pre
 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{{redefi
 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 {{previ
 }
 
 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]'}}

Modified: cfe/trunk/test/SemaCXX/array-bound-merge.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/array-bound-merge.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/array-bound-merge.cpp (original)
+++ cfe/trunk/test/SemaCXX/array-bound-merge.cpp Tue Jul 14 15:08:49 2015
@@ -10,5 +10,5 @@ int c[] = {1,2}; // expected-error {{exc
 
 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]'}}

Modified: cfe/trunk/test/SemaCXX/cxx11-thread-local.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-thread-local.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-thread-local.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-thread-local.cpp Tue Jul 14 15:08:49 2015
@@ -19,5 +19,5 @@ thread_local int z[3]; // expected-note
 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}}
 }

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp Tue Jul 14 15:08:49 2015
@@ -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);

Modified: cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp Tue Jul 14 15:08:49 2015
@@ -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}}
   }

Modified: cfe/trunk/test/SemaCXX/dllimport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllimport.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/dllimport.cpp (original)
+++ cfe/trunk/test/SemaCXX/dllimport.cpp Tue Jul 14 15:08:49 2015
@@ -95,13 +95,13 @@ __declspec(dllimport) auto InternalAutoT
 __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}}

Modified: cfe/trunk/test/SemaCXX/extern-c.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extern-c.cpp?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/extern-c.cpp (original)
+++ cfe/trunk/test/SemaCXX/extern-c.cpp Tue Jul 14 15:08:49 2015
@@ -21,7 +21,7 @@ float test2_x; // expected-error {{decla
 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" {

Modified: cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m (original)
+++ cfe/trunk/test/SemaObjC/objc2-merge-gc-attribue-decl.m Tue Jul 14 15:08:49 2015
@@ -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}}

Modified: cfe/trunk/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm?rev=242190&r1=242189&r2=242190&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objc2-merge-gc-attribue-decl.mm Tue Jul 14 15:08:49 2015
@@ -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}}





More information about the cfe-commits mailing list