public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6721] c++: &enum::enumerator [PR101869]
@ 2023-03-16 22:10 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-03-16 22:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1cc8814098bb46f9fca58a0b831fbf9a8574bdc9

commit r13-6721-g1cc8814098bb46f9fca58a0b831fbf9a8574bdc9
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 16 13:11:32 2023 -0400

    c++: &enum::enumerator [PR101869]
    
    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.

Diff:
---
 gcc/cp/semantics.cc                 |  3 ++-
 gcc/testsuite/g++.dg/cpp0x/enum43.C | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 57dd7b66da8..87c2e8a7111 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -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);
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum43.C b/gcc/testsuite/g++.dg/cpp0x/enum43.C
new file mode 100644
index 00000000000..b2cd9797a06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/enum43.C
@@ -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 } }
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-16 22:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16 22:10 [gcc r13-6721] c++: &enum::enumerator [PR101869] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).