This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++0x] implementing forward declarations for enums
- From: Jason Merrill <jason at redhat dot com>
- To: Rodrigo Rivas <rodrigorivascosta at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Ed Smith-Rowland <3dw4rd at verizon dot net>
- Date: Wed, 29 Sep 2010 18:20:27 -0400
- Subject: Re: [C++0x] implementing forward declarations for enums
- References: <AANLkTim3cfh+gSXSuNLKFKR8jq7W2PBKkwmCTr74qTR5@mail.gmail.com> <4C9ECCE1.7020406@redhat.com> <AANLkTikM8LGvkGL8axC13N551n-rFaZTZEuFSRATJJ4K@mail.gmail.com>
On 09/26/2010 10:23 AM, Rodrigo Rivas wrote:
Most notably, I've moved the begin_scope()/end_scope() of scoped enums
into the parsing code. This way it is much easier to ensure that they
are balanced. I'm not sure if they are needed in the template
instantiation, but added it anyway, just in case.
They are needed.
I'm using the TYPE_LANG_FLAG_2 in order to check for the enumerator
lists, I don't know if this is appropriate.
That's fine.
One more question: scoped enumerations call maybe_warn_cpp0x() so they
are accepted in C++98 mode, but with a warning. Should forward
enumerations be accepted also? Currently, I'm accepting them only in
C++0x mode.
I don't have a strong preference unless libstdc++ really wants to use
them. But rather than checking cxx_dialect with ==, compare it against
cxx0x with < or >=.
+ /* If this enum has value list from a previous declaration, then it has already
+ been finished. Do not do it again. */
+ must_finish = !ENUM_HAS_VALUE_LIST_P (type);
What if you get two opaque declarations in a row?
+ if (CLASS_TYPE_P (nested_name_specifier))
+ {
+ nested_being_defined = TYPE_BEING_DEFINED (nested_name_specifier);
+ TYPE_BEING_DEFINED (nested_name_specifier) = 1;
+ push_scope (nested_name_specifier);
+ }
Hmm, this looks odd, but I guess it's necessary for adding enumerators
to the class scope after the class is already complete.
Comments, testscases and changelog still missing.
Yep. :)
Jason