This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ patch] for C++/52369


Hi,

As a followup, the following patch homogeneise some diagnostics that
relate to uninitialized const or reference members.
Tested x86_64 linux in progress, OK to commit for next stage 1 if that
succeeds ? (or trunk otherwise, I dare to mention it).

2014-03-28  Fabien Chêne  <fabien@gcc.gnu.org>

    * cp/init.c (perform_member_init): homogeneize uninitialized
    diagnostics.

2014-03-28  Fabien Chêne  <fabien@gcc.gnu.org>

        * g++.dg/init/ctor4.C: Adjust.
    * g++.dg/init/ctor4-1.C: New.

2014-03-24 18:21 GMT+01:00 Jason Merrill <jason@redhat.com>:
> OK, thanks.
>
> Jason

-- 
Fabien
Index: gcc/testsuite/g++.dg/init/ctor4-1.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor4-1.C	(rÃvision 0)
+++ gcc/testsuite/g++.dg/init/ctor4-1.C	(rÃvision 0)
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+class foo {
+public:
+  foo();
+};
+
+class bar: public foo {	// { dg-error "uninitialized" }
+		   // { dg-message "implicitly deleted" "" { target c++11 } 8 }
+private:
+  int const a; // { dg-message "should be initialized" }
+};
+
+foo::foo() {
+}
+
+int main(int argc, char **argv)
+{
+  bar x; // { dg-error "deleted" "" { target c++11 } }
+	 // { dg-message "synthesized" "" { target { ! c++11 } } 19 }
+}
Index: gcc/testsuite/g++.dg/init/ctor4.C
===================================================================
--- gcc/testsuite/g++.dg/init/ctor4.C	(rÃvision 208853)
+++ gcc/testsuite/g++.dg/init/ctor4.C	(copie de travail)
@@ -6,9 +6,10 @@ public:
   foo();
 };
 
-class bar: public foo {		// { dg-error "reference|bar::bar" }
+class bar: public foo {	// { dg-error "uninitialized" }
+		   // { dg-message "implicitly deleted" "" { target c++11 } 9 }
 private:
-  int &a;
+  int &a; // { dg-message "should be initialized" }
 };
 
 foo::foo() {
@@ -16,5 +17,6 @@ foo::foo() {
 
 int main(int argc, char **argv)
 {
-  bar x; // { dg-message "synthesized|deleted" }
+  bar x; // { dg-error "deleted" "" { target c++11 } }
+         // { dg-message "synthesized" "" { target { ! c++11 } } 20 }
 }
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c	(rÃvision 208854)
+++ gcc/cp/init.c	(copie de travail)
@@ -710,13 +710,19 @@ perform_member_init (tree member, tree i
 	  tree core_type;
 	  /* member traversal: note it leaves init NULL */
 	  if (TREE_CODE (type) == REFERENCE_TYPE)
-	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
-		       "uninitialized reference member %qD",
-		       member);
+	    {
+	      permerror (DECL_SOURCE_LOCATION (current_function_decl),
+			 "uninitialized reference member in %q#T", type);
+	      inform (DECL_SOURCE_LOCATION (member),
+		      "%q#D should be initialized", member);
+	    }
 	  else if (CP_TYPE_CONST_P (type))
-	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
-		       "uninitialized member %qD with %<const%> type %qT",
-		       member, type);
+	    {
+	      permerror (DECL_SOURCE_LOCATION (current_function_decl),
+			 "uninitialized const member in %q#T", type);
+	      inform (DECL_SOURCE_LOCATION (member),
+		      "%q#D should be initialized", member );
+	    }
 
 	  core_type = strip_array_types (type);
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]