Movatterモバイル変換


[0]ホーム

URL:


Issue 1318 - WG21 CWG Issues
Title
Syntactic ambiguities with final
Status
cd3
Section
Clause [11] [class]
Submitter
Johannes Schaub

Created on2011-05-14.00:00:00 last changed145 months ago

Messages

msg3891 (view)
Date: 2013-04-15.00:00:00

[Moved to DR at the April, 2013 meeting.]

msg3890 (view)
Date: 2012-10-15.00:00:00

Proposed resolution (October, 2012):

  1. Change 5.11 [lex.name] paragraph 2 as follows:

  2. The identifiers in Table 3 have a special meaning when appearing in acertain context. When referred to in the grammar, these identifiersare used explicitly rather than using theidentifier grammarproduction.Unless otherwise specified, any ambiguity as towhether a given identifier has a special meaning is resolved tointerpret the token as a regularidentifier.
  3. Change Clause 11 [class] paragraph 3 as follows:

  4. If a class is marked with theclass-virt-specifierfinal and it appears as abase-type-specifier in abase-clause (11.7 [class.derived]), the program isill-formed.Whenever aclass-key is followed by aclass-head-name, theidentifierfinal, and acolon or left brace,final is interpreted as aclass-virt-specifier. [Example:

      struct A;  struct A final {};      // OK: definition ofstruct A,                          // not value-initialization of variablefinal  struct X {   struct C { constexpr operator int() { return 5; } };   struct B final : C{};  // OK: definition of nested classB,                          // not declaration of a bit-field memberfinal  };

    end example]

msg3504 (view)
Date: 2012-09-24.00:00:00

The ambiguity in an example like

  struct A final { };

is resolved by 5.11 [lex.name] paragraph 2 to be thedeclaration of a variable namedfinal:

any ambiguity as to whether a givenidentifier has a specialmeaning is resolved to interpret the token as a regularidentifier.

Similarly, in an example like

  struct C { constexpr operator int() { return 5; } };  struct A {   struct B final : C{};  };

final is taken as the name of a bit-field member rather thanas the name of a nested class.

History
DateUserActionArgs
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetstatus: ready -> dr
2012-11-03 00:00:00adminsetstatus: review -> ready
2012-09-24 00:00:00adminsetmessages: +msg3891
2012-09-24 00:00:00adminsetmessages: +msg3890
2012-09-24 00:00:00adminsetstatus: ready -> review
2012-02-27 00:00:00adminsetstatus: tentatively ready -> ready
2012-01-17 00:00:00adminsetstatus: review -> tentatively ready
2011-05-14 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp