I just wanted to say thanks for implementing this. Being able to forward declare enums will make dependency breaking in legacy code much easier in many real-world cases.
Thanks again! -----Original Message----- From: gcc-ow...@gcc.gnu.org [mailto:gcc-ow...@gcc.gnu.org] On Behalf Of Rodrigo Rivas Sent: Monday, September 20, 2010 6:58 AM To: gcc@gcc.gnu.org Subject: [C++0x] implementing forward declarations for enums Hello all. This patch tries to implement the C++0x featue "Forward declarations for enums" aka "opaque enum declarations": http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf Please note that this is a WIP, and as such lacks formatting, comments, testcases, etc. Except for the things noted below, I think it works pretty well. TODOs 1 A enum declaration should fail if adds a list of constants and it already have one. I check it with "TYPE_VALUES (type)", but this is incorrect because an empty list will not be seen. So, the current patch will accept incorrect code like: enum class Foo { }; enum class Foo { A, B, C}; I think that a new flag is needed for ENUMERAL_TYPE, but I don't know which one. 2 I am calling "finish_enum" several types, for each of the opaque declarations until it gets a list of constants. It doesn't seem to cause problems except with the debug information. With default flags and everything, gdb sees only the first declaration: enum class Foo; enum class Foo {A, B, C} Foo f; (gdb) ptype f; enum Foo {} I don't see an easy way to solve it... 3 I don't like very much the added parameter to the "start_enum" function, but I don't see how to do it without breaking existing code. Comments are most welcomed. Regards. Rodrigo