Code below presents behavior which I think is incorrect: class A { enum class Color { Red, Orange, Yellow, Green, Blue, Violet }; enum class Alert { Green, Yellow, Red }; }; $ g++-4.4.0-alpha20081010 -c -std=c++0x /tmp/enum_class.cc /tmp/enum_class.cc:4: error: declaration of ‘Green’ /tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color A::Green’ /tmp/enum_class.cc:4: error: declaration of ‘Yellow’ /tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color A::Yellow’ /tmp/enum_class.cc:4: error: declaration of ‘Red’ /tmp/enum_class.cc:3: error: conflicts with previous declaration ‘A::Color A::Red’ Moreover, code: class A { enum class Color { Red, Orange, Yellow, Green, Blue, Violet }; static const Color x = Red; }; is incorrectly accepted. This behavior is consistent in both versions i have checked, namely gcc-g++-20080912 and gcc-g++-20081010.
Let's CC Doug...
Subject: Bug 37816 Author: jason Date: Tue Jul 7 17:55:26 2009 New Revision: 149341 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149341 Log: PR c++/37816 * decl.c (build_enumerator): Don't add enumerators for a scoped enum to the enclosing class. PR c++/40639 * decl.c (start_enum): Allow dependent underlying type. PR c++/40633 * decl.c (finish_enum): Finish scope even in a template. Added: trunk/gcc/testsuite/g++.dg/cpp0x/enum4.C trunk/gcc/testsuite/g++.dg/cpp0x/enum5.C trunk/gcc/testsuite/g++.dg/cpp0x/enum6.C trunk/gcc/testsuite/g++.dg/cpp0x/enum7.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 37816 Author: jason Date: Tue Jul 7 22:08:01 2009 New Revision: 149352 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=149352 Log: PR c++/37816 * decl.c (build_enumerator): Don't add enumerators for a scoped enum to the enclosing class. PR c++/40639 * decl.c (start_enum): Allow dependent underlying type. PR c++/40633 * decl.c (finish_enum): Finish scope even in a template. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/enum4.C - copied unchanged from r149341, trunk/gcc/testsuite/g++.dg/cpp0x/enum4.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/enum5.C - copied unchanged from r149341, trunk/gcc/testsuite/g++.dg/cpp0x/enum5.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/enum6.C - copied unchanged from r149341, trunk/gcc/testsuite/g++.dg/cpp0x/enum6.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/enum7.C - copied unchanged from r149341, trunk/gcc/testsuite/g++.dg/cpp0x/enum7.C Modified: branches/gcc-4_4-branch/gcc/ (props changed) branches/gcc-4_4-branch/gcc/ChangeLog-2008 (props changed) branches/gcc-4_4-branch/gcc/cp/ChangeLog branches/gcc-4_4-branch/gcc/cp/ChangeLog-2007 (props changed) branches/gcc-4_4-branch/gcc/cp/ChangeLog-2008 (props changed) branches/gcc-4_4-branch/gcc/cp/decl.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/ChangeLog-2008 (props changed) branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ (props changed) branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C (props changed) branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr36227.c (props changed) branches/gcc-4_4-branch/gcc/testsuite/gcc.target/x86_64/abi/callabi/ (props changed) Propchange: branches/gcc-4_4-branch/gcc/ ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/ChangeLog-2008 ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/cp/ChangeLog-2007 ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/cp/ChangeLog-2008 ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog-2008 ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype-38655.C ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/torture/pr36227.c ('svn:mergeinfo' modified) Propchange: branches/gcc-4_4-branch/gcc/testsuite/gcc.target/x86_64/abi/callabi/ ('svn:mergeinfo' modified)
Fixed for 4.4.1.