Ahem, patch resubmitted with the testsuite correctly adjusted this
time. Tested x86_64 linux, still OK to commit ?

2014-02-23  Fabien Chene  <fab...@gcc.gnu.org>
        PR c++/52369
        * cp/method.c (walk_field_subobs): improve the diagnostic
    locations for both REFERENCE_TYPEs and non-static const members.

2014-02-23  Fabien Chene  <fab...@gcc.gnu.org>

        PR c++/52369
        * g++.dg/init/const10.C: New.
    * g++.dg/init/const11.C: New.
    * g++.dg/init/pr25811.C: Adjust.
    * g++.dg/init/pr29043.C: Adjust.
    * g++.dg/init/pr43719.C: Likewise.
    * g++.dg/init/pr44086.C: Likewise.
    * g++.dg/init/ctor4.C: Likewise.
    * g++.dg/init/ctor8.C: Likewise.
    * g++.dg/init/uninitialized1.C: Likewise.

--
Fabien

2014-02-06 18:04 GMT+01:00 Fabien Chêne <fabien.ch...@gmail.com>:
> Hi,
>
> This bug seems already fixed on mainline. I have added two testcases,
> but as the C++11 one is not obvious to me, I guess this path does not
> qualify as obvious. Incidentally, while writing the C++11 testcase, I
> realized that the diagnostic was not emitted at the proper location
> and fixed it.
Index: gcc/cp/method.c
===================================================================
--- gcc/cp/method.c	(révision 207406)
+++ gcc/cp/method.c	(copie de travail)
@@ -1091,15 +1091,15 @@ walk_field_subobs (tree fields, tree fnn
 	      && default_init_uninitialized_part (mem_type))
 	    {
 	      if (diag)
-		error ("uninitialized non-static const member %q#D",
-		       field);
+		error_at (DECL_SOURCE_LOCATION (field),
+			  "uninitialized non-static const member %q#D", field);
 	      bad = true;
 	    }
 	  else if (TREE_CODE (mem_type) == REFERENCE_TYPE)
 	    {
 	      if (diag)
-		error ("uninitialized non-static reference member %q#D",
-		       field);
+		error_at (DECL_SOURCE_LOCATION (field),
+			  "uninitialized non-static reference member %q#D", field);
 	      bad = true;
 	    }
 
Index: gcc/testsuite/g++.dg/init/pr44086.C
===================================================================
--- gcc/testsuite/g++.dg/init/pr44086.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/pr44086.C	(copie de travail)
@@ -1,9 +1,10 @@
 // PR c++/44086
 // { dg-do compile }
 
-struct A		// { dg-error "uninitialized" "" { target c++11 } }
+struct A
 {
     int const i : 2; // { dg-message "should be initialized" "" { target c++98 } }
+                     // { dg-error "uninitialized" "" { target c++11 } 6 }
 };
 
 void f()
Index: gcc/testsuite/g++.dg/init/const11.C
===================================================================
--- gcc/testsuite/g++.dg/init/const11.C	(révision 0)
+++ gcc/testsuite/g++.dg/init/const11.C	(révision 0)
@@ -0,0 +1,29 @@
+// PR C++/52369
+// { dg-do compile { target c++98 } }
+
+class B
+{
+  int const v_; // { dg-message "should be initialized" }
+};
+
+struct D : B {};
+
+class A
+{
+  int& ref; // { dg-message "should be initialized" }
+};
+
+struct C : A {};
+
+void f()
+{
+  D d; // { dg-error "uninitialized" }
+  new D; // { dg-error "uninitialized" }
+  D();
+  new D();
+
+  C c; // { dg-error "uninitialized" }
+  new C; // { dg-error "uninitialized" }
+  C(); // { dg-error "value-initialization" }
+  new C(); // { dg-error "value-initialization" }
+}
Index: gcc/testsuite/g++.dg/init/ctor4.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor4.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/ctor4.C	(copie de travail)
@@ -8,7 +8,7 @@ public:
 
 class bar: public foo {		// { dg-error "reference|bar::bar" }
 private:
-  int &a;
+  int &a; // { dg-error "uninitialized" "" { target c++11 } }
 };
 
 foo::foo() {
Index: gcc/testsuite/g++.dg/init/uninitialized1.C
===================================================================
--- gcc/testsuite/g++.dg/init/uninitialized1.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/uninitialized1.C	(copie de travail)
@@ -1,8 +1,8 @@
 // PR c++/58126
 
-struct A {		// { dg-error "uninitialized" "" { target c++11 } }
-  const int value1;
-  int& value2;
+struct A {		
+  const int value1; // { dg-error "uninitialized.*const" "" { target c++11 } }
+  int& value2;      // { dg-error "uninitialized.*reference" "" { target c++11 } }
 };
 
 struct B : A { };	// { dg-error "deleted" "" { target c++11 } }
Index: gcc/testsuite/g++.dg/init/pr43719.C
===================================================================
--- gcc/testsuite/g++.dg/init/pr43719.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/pr43719.C	(copie de travail)
@@ -1,51 +1,62 @@
 // PR c++/43719
 // { dg-do compile }
 
-struct A1		  // { dg-error "uninitialized" "" { target c++11 } }
+struct A1
 {
   int const j; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 6 }
 };
 
-struct A2		  // { dg-error "uninitialized" "" { target c++11 } }
+struct A2
 {
   int const volatile i; // { dg-message "should be initialized" "" { target c++98 } }
+  		        // { dg-error "uninitialized" "" { target c++11 } 12 }
 };
 
-struct A3		  // { dg-error "uninitialized" "" { target c++11 } }
+struct A3
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 18 }
 };
 
-struct A4		  // { dg-error "uninitialized" "" { target c++11 } }
+struct A4
 {
   int const& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  		  // { dg-error "uninitialized" "" { target c++11 } 24 }
 };
 
-struct A5		  // { dg-error "uninitialized" "" { target c++11 } }
+struct A5
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 30 }
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 32 }
 };
 
-template <class T> struct S1 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S1
 {
   T const i; // { dg-message "should be initialized" "" { target c++98 } }
+             // { dg-error "uninitialized" "" { target c++11 } 38 }
 };
 
-template <class T> struct S2 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S2
 {
   T const volatile i; // { dg-message "should be initialized" "" { target c++98 } }
+                      // { dg-error "uninitialized" "" { target c++11 } 44 }
 };
 
-template <class T> struct S3 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S3
 {
   T& ref; // { dg-message "should be initialized" "" { target c++98 } }
+          // { dg-error "uninitialized" "" { target c++11 } 50 }
 };
 
-template <class T> struct S4 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S4
 {
   T const i; // { dg-message "should be initialized" "" { target c++98 } }
+             // { dg-error "uninitialized" "" { target c++11 } 56 }
   T& ref; // { dg-message "should be initialized" "" { target c++98 } }
+          // { dg-error "uninitialized" "" { target c++11 } 58 }
 };
 
 struct X
@@ -55,9 +66,10 @@ struct X
   int const& r;
 };
 
-struct Y11		  // { dg-error "uninitialized" "" { target c++11 } }
+struct Y11
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 71 }
 };
 
 struct Y1		  // { dg-error "deleted" "" { target c++11 } }
@@ -65,9 +77,10 @@ struct Y1		  // { dg-error "deleted" ""
   Y11 a[1];
 };
 
-struct Y22	       // { dg-error "uninitialized" "" { target c++11 } }
+struct Y22
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 82 }
 };
 
 struct Y2		      // { dg-error "deleted" "" { target c++11 } }
@@ -75,24 +88,28 @@ struct Y2		      // { dg-error "deleted"
   Y22 a[1];
 };
 
-struct Z1		// { dg-error "uninitialized" "" { target c++11 } }
+struct Z1
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 93 }
 };
 
-struct Z2		// { dg-error "uninitialized" "" { target c++11 } }
+struct Z2
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 99 }
 };
 
-struct Z3		// { dg-error "uninitialized" "" { target c++11 } }
+struct Z3
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 105 }
 };
 
-struct Z4		// { dg-error "uninitialized" "" { target c++11 } }
+struct Z4
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 111 }
 };
 
 struct Z5
@@ -109,9 +126,10 @@ struct Z		// { dg-error "deleted" "" { t
   Z5 z5;
 };
 
-union U			// { dg-error "uninitialized" "" { target c++11 } }
+union U
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 131 }
 };
 
 
Index: gcc/testsuite/g++.dg/init/pr25811.C
===================================================================
--- gcc/testsuite/g++.dg/init/pr25811.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/pr25811.C	(copie de travail)
@@ -1,51 +1,62 @@
 // PR c++/25811
 // { dg-do compile }
 
-struct A1		// { dg-error "uninitialized" "" { target c++11 } }
+struct A1 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const j; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 6 }
 };
 
-struct A2		// { dg-error "uninitialized" "" { target c++11 } }
+struct A2 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const volatile i; // { dg-message "should be initialized" "" { target c++98 } }
+  		        // { dg-error "uninitialized" "" { target c++11 } 12 }
 };
 
-struct A3		// { dg-error "uninitialized" "" { target c++11 } }
+struct A3 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 18 }
 };
 
-struct A4		// { dg-error "uninitialized" "" { target c++11 } }
+struct A4 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  		  // { dg-error "uninitialized" "" { target c++11 } 24 }
 };
 
-struct A5		// { dg-error "uninitialized" "" { target c++11 } }
+struct A5 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 30 }
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 32 }
 };
 
-template <class T> struct S1 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S1 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   T const i; // { dg-message "should be initialized" "" { target c++98 } }
+             // { dg-error "uninitialized" "" { target c++11 } 38 }
 };
 
-template <class T> struct S2 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S2 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   T const volatile i; // { dg-message "should be initialized" "" { target c++98 } }
+                      // { dg-error "uninitialized" "" { target c++11 } 44 }
 };
 
-template <class T> struct S3 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S3 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   T& ref; // { dg-message "should be initialized" "" { target c++98 } }
+          // { dg-error "uninitialized" "" { target c++11 } 50 }
 };
 
-template <class T> struct S4 // { dg-error "uninitialized" "" { target c++11 } }
+template <class T> struct S4 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   T const i; // { dg-message "should be initialized" "" { target c++98 } }
+             // { dg-error "uninitialized" "" { target c++11 } 56 }
   T& ref; // { dg-message "should be initialized" "" { target c++98 } }
+          // { dg-error "uninitialized" "" { target c++11 } 58 }
 };
 
 struct X
@@ -55,44 +66,50 @@ struct X
   int const& r;
 };
 
-struct Y11		// { dg-error "uninitialized" "" { target c++11 } }
+struct Y11 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 71 }
 };
 
-struct Y1		// { dg-error "deleted" "" { target c++11 } }
+struct Y1 // { dg-error "deleted" "" { target c++11 } }
 {
   Y11 a[1];
 };
 
-struct Y22		// { dg-error "uninitialized" "" { target c++11 } }
+struct Y22 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+  	    // { dg-error "uninitialized" "" { target c++11 } 82 }
 };
 
-struct Y2		// { dg-error "deleted" "" { target c++11 } }
+struct Y2 // { dg-error "deleted" "" { target c++11 } }
 {
   Y22 a[1];
 };
 
-struct Z1		// { dg-error "uninitialized" "" { target c++11 } }
+struct Z1 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+  	       // { dg-error "uninitialized" "" { target c++11 } 93 }
 };
 
-struct Z2 // { dg-error "uninitialized" "" { target c++11 } }
+struct Z2 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+            // { dg-error "uninitialized" "" { target c++11 } 99 }
 };
 
-struct Z3 // { dg-error "uninitialized" "" { target c++11 } }
+struct Z3 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 105 }
 };
 
-struct Z4 // { dg-error "uninitialized" "" { target c++11 } }
+struct Z4 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref; // { dg-message "should be initialized" "" { target c++98 } }
+            // { dg-error "uninitialized" "" { target c++11 } 111 }
 };
 
 struct Z5
@@ -100,7 +117,7 @@ struct Z5
   int i;
 };
 
-struct Z		// { dg-error "deleted" "" { target c++11 } }
+struct Z // { dg-error "deleted" "" { target c++11 } }
 {
   Z1 z1;
   Z2 z2;
@@ -109,9 +126,10 @@ struct Z		// { dg-error "deleted" "" { t
   Z5 z5;
 };
 
-union U // { dg-error "uninitialized" "" { target c++11 } }
+union U // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 131 }
 };
 
 void f1 ()
Index: gcc/testsuite/g++.dg/init/pr29043.C
===================================================================
--- gcc/testsuite/g++.dg/init/pr29043.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/pr29043.C	(copie de travail)
@@ -1,9 +1,10 @@
 // PR c++/29043
 // { dg-do compile }
 
-struct S		// { dg-error "uninitialized" "" { target c++11 } }
+struct S // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 6 }
 };
 
 class C
@@ -13,9 +14,10 @@ public:
   S s;
 };
 
-struct S2		// { dg-error "uninitialized" "" { target c++11 } }
+struct S2 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int& ref;   // { dg-message "should be initialized" "" { target c++98 } }
+              // { dg-error "uninitialized" "" { target c++11 } 19 }
 };
 
 class C2
@@ -33,9 +35,10 @@ class C3
   };
 };
 
-struct S4		// { dg-error "uninitialized" "" { target c++11 } }
+struct S4 // { dg-message "implicitly deleted" "" { target c++11 } }
 {
   int const i; // { dg-message "should be initialized" "" { target c++98 } }
+               // { dg-error "uninitialized" "" { target c++11 } 40 }
 };
 
 struct C4
@@ -46,7 +49,7 @@ struct C4
 
 struct C5
 {
-  C5() {} // { dg-message "uninitialized" }   
+  C5() {} // { dg-error "uninitialized" }
   int const iit[ 1 ];
 };
 
Index: gcc/testsuite/g++.dg/init/ctor8.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor8.C	(révision 207406)
+++ gcc/testsuite/g++.dg/init/ctor8.C	(copie de travail)
@@ -1,7 +1,7 @@
 // PR c++/29039
 
-typedef struct S {	    // { dg-error "reference" "" { target c++11 } }
-  int &r; 
+typedef struct S {	    
+  int &r; // { dg-error "reference" "" { target c++11 } }
 }; // { dg-warning "'typedef' was ignored" }
 
 
Index: gcc/testsuite/g++.dg/init/const10.C
===================================================================
--- gcc/testsuite/g++.dg/init/const10.C	(révision 0)
+++ gcc/testsuite/g++.dg/init/const10.C	(révision 0)
@@ -0,0 +1,31 @@
+// PR C++/52369
+// { dg-do compile { target c++11 } }
+
+class B // { dg-message "implicitly deleted" }
+{
+  int const v_; // { dg-error "uninitialized" }
+};
+
+struct D : B {}; // { dg-error "deleted" }
+
+class A // { dg-message "implicitly deleted" }
+{
+  int& ref; // { dg-error "uninitialized" }
+};
+
+struct C : A {}; // { dg-error "deleted" }
+
+void f()
+{
+  D d; // { dg-error "use of deleted" }
+  new D; // { dg-error "use of deleted" }
+  D(); // { dg-error "use of deleted" }
+  new D(); // { dg-error "use of deleted" }
+
+  C c; // { dg-error "use of deleted" }
+  new C; // { dg-error "use of deleted" }
+  C(); // { dg-error "use of deleted" }
+  new C(); // { dg-error "use of deleted" }
+}
+
+

Reply via email to