This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] PR c++/26256


On 09/17/2011 09:44 AM, Fabien ChÃne wrote:
I tried various things without success, and I ended up hacking
supplement_binding_1 to handle those ENUMERAL_TYPEs.
I am all ear for another solution ...

Your solution seems reasonable to me, but it needs a comment, along the lines of


/* We allow pushing an enum multiple times in a class template in order to handle late matching of underlying type on an opaque-enum-declaration followed by an enum-specifier. */

And I guess limit it to dependent class scope. Incidentally, repeating opaque-enum-declarations at class scope is invalid under 9.2/1:

--
A member shall not be declared twice in the member-specification, except that a nested class or member class template can be declared and then later defined, and except that an enumeration can be introduced with an opaque-enum-declaration and later redeclared with an enum-specifier.
--


So

struct A
{
  enum E: int;
  enum E: int { e1 };
};

is OK, but

struct B
{
  enum E: int;
  enum E: int;
};

is not.

+static tree
+strip_using_decl (tree decl)

Needs a comment. Also, this function has a loop in it, but various other places in the patch that look through USING_DECLs don't loop.


          if (!DECL_DEPENDENT_P (field))
-           continue;
+           {
+             tree using_decl = USING_DECL_DECLS (field);
+             if ((TREE_CODE (using_decl) == FIELD_DECL
+                  || TREE_CODE (using_decl) == TYPE_DECL)
+                 && DECL_NAME (using_decl) == name)
+               return using_decl;
+             continue;
+           }

This section needs a comment. Why do we look through USING_DECL for these two kinds of member but not others?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]