Noticed while working on PR c++/51188, I have launched the c++ testsuite with the patch below: Index: class.c =================================================================== --- class.c (revision 181491) +++ class.c (working copy) @@ -6007,7 +6007,7 @@ finish_struct_1 (tree t) hierarchy), and we want this failure to occur quickly. */ n_fields = count_fields (TYPE_FIELDS (t)); - if (n_fields > 7) + if (n_fields > 0) And it has raised two errors related to c++11 enums: forw_enum5.C and forw_enum9.C. Thus, here is a reproducer, comming from forw_enum5.C: // { dg-do compile } // { dg-options "-std=c++0x" } namespace one { struct S { enum { A = 1, B = 2 }; struct T { int i1, i2, i3, i4, i5, i6, i7; enum { B = 102 }; enum class E1; enum E2 : int; }; }; static_assert(int(S::T::A1) == 1, "error"); static_assert(int(S::T::B1) == 102, "error"); static_assert(int(S::T::C1) == 103, "error"); } The following errors are issued: error: 'A1' is not a member of 'one::S::T' error: 'B1' is not a member of 'one::S::T' error: 'C1' is not a member of 'one::S::T' Most likely an issue in the sorted case of lookup_field_1. Mine.
Here is a correct testcase for this bug. // { dg-do compile } // { dg-options "-std=c++0x" } enum { A = 1 }; struct T { int i1, i2, i3, i4, i5, i6, i7; enum E2 : int; }; enum T::E2 : int { A1 = A }; int i = T::A1;
We can manage to mark this bug as a 4.7 Regression, evidence below (to be compiled with -std=c++11 obviously). struct Base { int b1, b2, b3; }; struct T : Base { int t1, t2, t3; using Base::b1; using Base::b2; using Base::b3; enum E2 : int; }; enum T::E2 : int { A1 = 23 }; int i = T::A1; I have a patch for it.
Author: fabien Date: Thu Jun 7 05:36:18 2012 New Revision: 188294 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188294 Log: gcc/testsuite/ChangeLog 2012-06-07 Fabien Chêne <fabien@gcc.gnu.org> PR c++/51214 * g++.dg/cpp0x/forw_enum11.C: New. gcc/cp/ChangeLog 2012-06-07 Fabien Chêne <fabien@gcc.gnu.org> PR c++/51214 * cp-tree.h (insert_late_enum_def_into_classtype_sorted_fields): Declare. * class.c (insert_into_classtype_sorted_fields): New. (add_enum_fields_to_record_type): New. (count_fields): Adjust the comment. (add_fields_to_record_type): Likewise. (finish_struct_1): Move the code that inserts the fields for the sorted case, into insert_into_classtype_sorted_fields, and call it. (insert_late_enum_def_into_classtype_sorted_fields): Define. * decl.c (finish_enum_value_list): Call insert_late_enum_def_into_classtype_sorted_fields if a late enum definition is encountered. Added: trunk/gcc/testsuite/g++.dg/cpp0x/forw_enum11.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk.
GCC 4.7.1 is being released, adjusting target milestone.
Author: fabien Date: Wed Jun 27 17:36:50 2012 New Revision: 189021 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189021 Log: gcc/testsuite/ChangeLog 2012-06-27 Fabien Chêne <fabien@gcc.gnu.org> PR c++/51214 * g++.dg/cpp0x/forw_enum11.C: New. gcc/cp/ChangeLog 2012-06-27 Fabien Chêne <fabien@gcc.gnu.org> PR c++/51214 * cp-tree.h (insert_late_enum_def_into_classtype_sorted_fields): Declare. * class.c (insert_into_classtype_sorted_fields): New. (add_enum_fields_to_record_type): New. (count_fields): Adjust the comment. (add_fields_to_record_type): Likewise. (finish_struct_1): Move the code that inserts the fields for the sorted case, into insert_into_classtype_sorted_fields, and call it. (insert_late_enum_def_into_classtype_sorted_fields): Define. * decl.c (finish_enum_value_list): Call insert_late_enum_def_into_classtype_sorted_fields if a late enum definition is encountered. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/forw_enum11.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/class.c branches/gcc-4_7-branch/gcc/cp/cp-tree.h branches/gcc-4_7-branch/gcc/cp/decl.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Fixed in 4.7.