]> granicus.if.org Git - clang/commitdiff
[Sema] Emit a better diagnostic when variable redeclarations disagree
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 14 Jul 2015 20:08:49 +0000 (20:08 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 14 Jul 2015 20:08:49 +0000 (20:08 +0000)
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

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

index 14695dd6a88b2a891ff308d610675e260a4a2d88..85866b245753ce4c2f58955cf4dd4e5f89808c30 100644 (file)
@@ -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<
index 28877210c6a47a97c7fd1906e40f74389f226fc5..5646099015bd6235fa04b095249c34163770eef2 100644 (file)
@@ -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();
   }
 
index e040d5b2642ba2412486c16432eb16140c7ac5e6..4686b1c961ec35819dd29fe73dc0421dc7f517db 100644 (file)
@@ -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>();
index 955eb1aa95eac3340e3f385ef6220fd87f9a4721..e7b9e5cec1367810cb430f16da1bf981f59b290d 100644 (file)
@@ -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;
index 77eeea22a23d0ace67d6ab7f6e353ca706594f12..29b66a11e8ce5b2461cabfe64398e23327bbf381 100644 (file)
@@ -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;
   }
index b93fa9a0edf73fc3c36598028dfd3f18486bf1dd..0ff9e949085c68558e946b3e6eb62ce2b9bc9849 100644 (file)
@@ -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'}}
index e066abdb72d3661ca5156c471b749fcbf7b52885..3ca1baa299c10b1df8f45290e2ddf80a01b521c8 100644 (file)
@@ -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}}
index ba1720e8d7dc4a61e2f4d39f2cab05cc584ec23f..7bdeb27293b780dd3ce2b74097dcf51bee457ad5 100644 (file)
@@ -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);
index 65bef9f60555fd0198241c1b0ad668b3bc0fd8c7..68bb2cad45e15fe22bc019eb4d38d97ffad9fc19 100644 (file)
@@ -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) {
index 5614d164a5f4d670fe6334328fdbd1e5cd0e0709..9981be50ad4f362d10456e9eaf544069e3207c78 100644 (file)
@@ -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
index 811e9f10bf20d49bad125e703990cc5efbc6638a..024bfd436a420e9398ba6c987d400ad4c7075eca 100644 (file)
@@ -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]'}}
index c6085fb0a965d074bbd0ba5f85f57b1d78c6aa2e..a360d007c3b7baebb2f1da1770545b56d1a304f0 100644 (file)
@@ -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]'}}
index f1dddc1c3bf744a4788eeb71e60aa7ba9d3025e0..a974d8198561d948d6a34c861f96c64e62f57df5 100644 (file)
@@ -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}}
 }
index 9ff73daa82d43c0399720356db5c240207389f10..123fcfff7f7ac6202af74509d8aedf116bf511c2 100644 (file)
@@ -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);
index 4e62941e681883f25a7c72e0e999b2fcd61d15a8..145bc49fff1fab4baa298b6b0f87b86008c595db 100644 (file)
@@ -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}}
   }
index 0f616d43c89d2a390c0394a82f51f345af6853fc..2fa10756da48fafa4aed7452dc9d5b00288785ed 100644 (file)
@@ -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}}
index dfbf38667c5eddfa67c7a9c583df629ba84ec9f8..295d1f305ee28197a91d95af4cdd7b06d360304b 100644 (file)
@@ -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" {
index 673a7417e384c363efe1f06c9487b4f37b983543..232f8dd794d6ddc6417eb58da5b18a6ed1723771 100644 (file)
@@ -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}}
index 7be5f17daa80345bfc1e9742d0c09253d8c0e03e..9166ba65b9fab3812af9cfb07cb5e2daffc92fef 100644 (file)
@@ -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}}