Title
Kind of lookup for using enum declarations
Status
c++23
Section
9.7.2 [enum.udecl]
Submitter
Sean Baxter

Created on 2022-08-17.00:00:00 last changed 9 months ago

Messages

Date: 2022-11-10.21:59:09

Proposed resolution (approved by CWG 2022-11-10):

Change the grammar before 9.2.9.5 [dcl.type.elab] paragraph 1 as follows, merging the grammar productions:

elaborated-type-specifier :
    class-key attribute-specifier-seqopt nested-name-specifieropt identifier
    class-key simple-template-id
    class-key nested-name-specifier templateopt simple-template-id
    elaborated-enum-specifier

elaborated-enum-specifier :
    enum nested-name-specifieropt identifier

Change the grammar before 9.7.2 [enum.udecl] paragraph 1 as follows:

using-enum-declaration:
    using elaborated-enum-specifier enum using-enum-declarator ;

using-enum-declarator:
    nested-name-specifieropt identifier
    nested-name-specifieropt simple-template-id

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

A using-enum-declarator names the set of declarations found by lookup (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]) for the using-enum-declarator. The elaborated-enum-specifier using-enum-declarator shall not name a dependent designate a non-dependent type and the type shall have with a reachable enum-specifier.
Date: 2022-11-08.13:17:36

Proposed resolution (approved by CWG 2022-09-23) [SUPERSEDED]:

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

The terminal name of the elaborated-enum-specifier undergoes ordinary lookup (6.5.3 [basic.lookup.unqual], 6.5.5 [basic.lookup.qual]). The elaborated-enum-specifier shall not name a dependent type and the type shall have a reachable enum-specifier.
Date: 2022-11-08.13:17:36

CWG 2022-11-07:

Use the wording approach presented in CA-054, with necessary adjunct fixes.

Date: 2022-11-08.13:17:36

CWG telecon 2022-09-09:

The example at #1 is intended to be valid; even though the grammar suggests that an elaborated-type-specifier is used here, an ordinary (not a type-only) lookup is performed.

Date: 2022-11-08.13:17:36

Suggested resolution [SUPERSEDED]:

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

Lookup for the elaborated-enum-specifier is as specified in 6.5.6 [basic.lookup.elab]. The elaborated-enum-specifier shall not name a dependent type and the type shall have a reachable enum-specifier.
Date: 2022-11-27.21:00:25
P2720R0 comment CA 054

[Accepted as a DR at the November, 2022 meeting.]

Consider:

enum class E {
  a, b, c
};

using MyE = E;

int main() {
  using enum MyE;   // #1
}

Does the lookup for the elaborated-enum-specifier at #1 use type-only lookup per 6.5.6 [basic.lookup.elab]? There is implementation divergence; EDG, gcc, and MSVC accept, clang rejects.

History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: drwp -> open
2023-02-18 18:43:04adminsetstatus: dr -> drwp
2022-11-25 05:14:04adminsetstatus: nb -> dr
2022-11-10 21:59:09adminsetstatus: review -> nb
2022-11-10 21:59:09adminsetstatus: review -> review
2022-11-10 21:59:09adminsetstatus: review -> review
2022-11-10 21:59:09adminsetstatus: review -> review
2022-11-10 14:29:24adminsetmessages: + msg7013
2022-11-10 14:29:24adminsetmessages: + msg6992
2022-11-08 13:17:36adminsetstatus: nb -> review
2022-11-08 13:17:36adminsetmessages: + msg7010
2022-11-08 13:17:36adminsetstatus: nb -> nb
2022-11-08 13:17:36adminsetstatus: nb -> nb
2022-11-08 13:17:36adminsetstatus: ready -> nb
2022-09-24 20:32:26adminsetmessages: + msg6947
2022-09-24 20:32:26adminsetstatus: drafting -> ready
2022-09-09 21:10:51adminsetstatus: open -> drafting
2022-09-02 07:54:02adminsetmessages: + msg6920
2022-08-17 00:00:00admincreate