aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2013-04-01 21:19:47 +0000
committerJason Merrill <jason@redhat.com>2013-04-01 21:19:47 +0000
commit38d0eaf56580faa30ac29d663b19cf75e779aeab (patch)
treee9c1233fd43796d6869b937c947c9227ed06f763 /gcc/cp
parent97053904e6cf3b7fde7416b664c3b1230a16d94d (diff)
PR c++/56793
* typeck.c (finish_class_member_access_expr): Handle enum scope. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@197330 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c17
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8981d98c914..aa6f584b093 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2013-04-01 Jason Merrill <jason@redhat.com>
+ PR c++/56793
+ * typeck.c (finish_class_member_access_expr): Handle enum scope.
+
+2013-04-01 Jason Merrill <jason@redhat.com>
+
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.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 830b8af3241..803f5c7e3fa 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2679,6 +2679,23 @@ finish_class_member_access_expr (tree object, tree name, bool template_p,
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 (TREE_CODE (name) == IDENTIFIER_NODE
|| TREE_CODE (name) == BIT_NOT_EXPR);