[pushed] c++: &enum::enumerator [PR101869]
Checks
Commit Message
Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
We don't want to call build_offset_ref with an enum.
PR c++/101869
gcc/cp/ChangeLog:
* semantics.cc (finish_qualified_id_expr): Don't try to build a
pointer-to-member if the scope is an enumeration.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/enum43.C: New test.
---
gcc/cp/semantics.cc | 3 ++-
gcc/testsuite/g++.dg/cpp0x/enum43.C | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/cpp0x/enum43.C
base-commit: e6ccae0ac0d53cfa9099d62fada050ee87d4d0ad
@@ -2386,7 +2386,8 @@ finish_qualified_id_expr (tree qualifying_class,
/* If EXPR occurs as the operand of '&', use special handling that
permits a pointer-to-member. */
- if (address_p && done)
+ if (address_p && done
+ && TREE_CODE (qualifying_class) != ENUMERAL_TYPE)
{
if (TREE_CODE (expr) == SCOPE_REF)
expr = TREE_OPERAND (expr, 1);
new file mode 100644
@@ -0,0 +1,11 @@
+// PR c++/101869
+
+enum E { A };
+E operator & (E e)
+{
+ return e;
+}
+E f(void)
+{
+ return &E::A; // { dg-error "not a class" "" { target c++98_only } }
+}