This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Disable -Wuninitialized warnings on NSDMI initialized fields (PR c++/53594)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 12 Jun 2012 12:05:54 +0200
- Subject: [C++ PATCH] Disable -Wuninitialized warnings on NSDMI initialized fields (PR c++/53594)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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