2013-04-01 Jason Merrill <jason@redhat.com>
+ PR c++/56793
+ * typeck.c (finish_class_member_access_expr): Handle enum scope.
+
PR c++/56794
* parser.c (cp_parser_range_for): Don't try to do auto deduction
in a template if the type of the range is incomplete.
return error_mark_node;
}
+ if (TREE_CODE (scope) == ENUMERAL_TYPE)
+ {
+ /* Looking up a member enumerator (c++/56793). */
+ if (!TYPE_CLASS_SCOPE_P (scope)
+ || !DERIVED_FROM_P (TYPE_CONTEXT (scope), object_type))
+ {
+ if (complain & tf_error)
+ error ("%<%D::%D%> is not a member of %qT",
+ scope, name, object_type);
+ return error_mark_node;
+ }
+ tree val = lookup_enumerator (scope, name);
+ if (TREE_SIDE_EFFECTS (object))
+ val = build2 (COMPOUND_EXPR, TREE_TYPE (val), object, val);
+ return val;
+ }
+
gcc_assert (CLASS_TYPE_P (scope));
gcc_assert (identifier_p (name) || TREE_CODE (name) == BIT_NOT_EXPR);
--- /dev/null
+// PR c++/56793
+// { dg-require-effective-target c++11 }
+
+struct A
+{
+ enum struct B {X, Y} b;
+} a;
+
+enum struct D {X,Y};
+struct C { } c;
+
+int main ()
+{
+ if (a.b == a.B::Y)
+ a.b = A::B::X;
+
+ c.D::Y; // { dg-error "not a member" }
+}