Title
Type-only lookup for using-enum-declarator
Status
tentatively ready
Section
9.7.2 [enum.udecl]
Submitter
Richard Smith

Created on 2024-04-07.00:00:00 last changed 2 weeks ago

Messages

Date: 2024-05-31.21:07:31

Proposed resolution (approved by CWG 2024-05-31):

Change in 9.7.2 [enum.udecl] paragraph 1 as follows:

A using-enum-declarator names the set of declarations found by type-only lookup (6.5.1 [basic.lookup.general] 6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]). The using-enum-declarator shall designate a non-dependent type with a reachable enum-specifier. [ Example:
enum E { x };
void f() {
  int E;
  using enum E;   // OK, names ::E
}
using F = E;
using enum F;     // OK, designates ::E
template<class T> using EE = T;
void g() {
  using enum EE<E>;  // OK, designates ::E
}
-- end example ]
Date: 2024-05-15.00:00:00

Additional notes (May, 2024)

An example is desirable. Also, the treatment of the following example is unclear:

  template<class T> using AA = T;
  enum AA<E> e; // ill-formed elaborated-type-specifier
  using enum AA<E>; // Clang and MSVC reject, GCC and EDG accept
Date: 2024-05-20.09:48:12

Proposed resolution (reviewed by CWG 2024-05-17) [SUPERSEDED]:

Change in 9.7.2 [enum.udecl] paragraph 1 as follows:

A using-enum-declarator names the set of declarations found by type-only lookup (6.5.1 [basic.lookup.general] 6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]). The using-enum-declarator shall designate a non-dependent type with a reachable enum-specifier.
Date: 2024-05-17.22:24:28

Issue 2621 claimed to ask the question whether lookup for using enum declarations was supposed to be type-only, but the example actually highlighted the difference between elaborated-type-specifier lookup (where finding nothing but typedef names is ill-formed) and ordinary lookup.

However, consider:

  enum A {
    x, y
  };
  void f() {
    int A;
    using enum A;      // #1, error: names non-type int A
    using T = enum A;  // #2, OK, names ::A
  }

The two situations should both be type-only lookups for consistency, although #2 would not find typedefs.

History
Date User Action Args
2024-05-31 21:07:31adminsetmessages: + msg7715
2024-05-31 21:07:31adminsetstatus: review -> tentatively ready
2024-05-20 09:48:12adminsetmessages: + msg7705
2024-05-20 09:48:12adminsetstatus: tentatively ready -> review
2024-05-17 22:24:28adminsetmessages: + msg7702
2024-05-17 22:24:28adminsetstatus: open -> tentatively ready
2024-04-07 00:00:00admincreate