diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 794b39f7a649..93233a892b53 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,4 +1,11 @@ -2012-06-16 Ville Voutilainen +2012-06-25 Jakub Jelinek + + PR c++/53594 + * class.c (check_bases_and_members): Avoid -Wuninitialized + diagnostics for non-static const members or references if they + use NSDMI. + +2012-06-16 Ville Voutilainen * parser.c (cp_parser_direct_declarator): Move virt-specifier parsing after late-specified return type parsing. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 021344bad7c4..6307e847a40c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7faf774eb7ff..82bb2d775e21 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-06-25 Jakub Jelinek + + PR c++/53594 + * g++.dg/cpp0x/nsdmi7.C: New test. + 2012-06-24 Kai Tietz * gcc.target/i386/pr23943.c (size_t): Use compatible type-definition diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C new file mode 100644 index 000000000000..ea1957775ad5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C @@ -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; +};