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]

[C++ PATCH] Disable -Wuninitialized warnings on NSDMI initialized fields (PR c++/53594)


Hi!

As stated in the PR, the -Wuninitialized warnings are bogus if
fields have NSDMI, as they are actually initialized then.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
What about 4.7.2?

2012-06-11  Jakub Jelinek  <jakub@redhat.com>

	PR c++/53594
	* class.c (check_bases_and_members): Avoid -Wuninitialized
	diagnostics for non-static const members or references if they
	use NSDMI.

	* g++.dg/cpp0x/nsdmi7.C: New test.

--- gcc/cp/class.c.jj	2012-06-07 08:27:35.000000000 +0200
+++ gcc/cp/class.c	2012-06-11 10:36:39.050739846 +0200
@@ -5122,7 +5122,8 @@ check_bases_and_members (tree t)
 	{
 	  tree type;
 
-	  if (TREE_CODE (field) != FIELD_DECL)
+	  if (TREE_CODE (field) != FIELD_DECL
+	      || DECL_INITIAL (field) != NULL_TREE)
 	    continue;
 
 	  type = TREE_TYPE (field);
--- gcc/testsuite/g++.dg/cpp0x/nsdmi7.C.jj	2012-06-11 10:44:35.723568438 +0200
+++ gcc/testsuite/g++.dg/cpp0x/nsdmi7.C	2012-06-11 10:50:16.000000000 +0200
@@ -0,0 +1,17 @@
+// PR c++/53594
+// { dg-do compile }
+// { dg-options "-std=c++11 -Wuninitialized" }
+
+struct A
+{
+  const int a = 6;	// { dg-bogus "non-static const member" }
+  static int b;
+  int &c = b;		// { dg-bogus "non-static reference" }
+};
+
+struct B
+{
+  const int d;		// { dg-warning "non-static const member" }
+  int &e;		// { dg-warning "non-static reference" }
+  int f = 7;
+};

	Jakub


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