Jens Maurer
N3259=11-0029
2011-03-22

Core Issue 355: Global-scope :: in elaborated-type-specifier

This paper presents the wording changes relative to the Working Paper N3242 to address core issue 355 (see also FCD comments US 2 and CH 1). Due to the volume of the changes, they were not integrated into the core issues list.

In section 3.4.3 basic.lookup.qual paragraph 6, change the grammar snippet as follows:

::opt nested-name-specifieropt class-name :: ~ class-name
In section 3.4.3.2 namespace.qual, replace as indicated:
If the nested-name-specifier of a qualified-id nominates a namespace, the name specified after the nested-name-specifier is looked up in the scope of the namespace, . If a qualified-id starts with ::, the name after the :: is looked up in the global namespace. In either case, except that the names in a template-argument of a template-id are looked up in the context in which the entire postfix-expression occurs.
Strike 5.1.1 expr.prim.general paragraph 3 entirely:
The operator :: followed by an identifier, a qualified-id, an operator-function-id, or a literal-operator-id is a primary-expression. Its type is specified by the declaration of the identifier, qualified-id, operator-function-id, or literal-operator-id. The result is the entity denoted by the identifier, qualified-id, operator-function-id, or literal-operator-id. The result is an lvalue if the entity is a function or variable and a prvalue otherwise. The identifier, qualified-id, operator-function-id, or literal-operator-id shall have global namespace scope or be visible in global scope because of a using-directive (7.3.4 namespace.udir). [ Note: the use of :: allows an entity declared in the global namespace to be referred to even if its name has been hidden (3.4.3 basic.lookup.qual). -- end note ]
Drafting note: It's covered by 5.1.1p7 (type, lvalue-ness, member-ness, reference to 3.4.3.2) and 3.4.3.2 (qualified lookup for namespace members).

In section 5.1.1 expr.prim.general paragraph 6, change the grammar snippet as follows:

qualified-id:
       ::opt nested-name-specifier templateopt unqualified-id
       :: identifier
       :: operator-function-id
       :: literal-operator-id
       :: template-id

nested-name-specifier:
       ::opt type-name ::
       ::opt namespace-name ::
       decltype-specifier ::
       nested-name-specifier identifier ::
       nested-name-specifier templateopt simple-template-id ::
In section 5.1.1 expr.prim.general paragraph 7, replace as indicated:
A ::, or a nested-name-specifier that names a namespace (7.3 basic.namespace), in either case followed by the name of a member of that namespace (or the name of a member of a namespace made visible by a using-directive) is a qualified-id; 3.4.3.2 namespace.qual describes name lookup for namespace members that appear in qualified-ids. ...
In section 5.1.1 expr.prim.general paragraph 9, replace as indicated:
In a qualified-id, if the id-expression unqualified-id is a conversion-function-id, its conversion-type-id shall denote the same type in both the context in which the entire qualified-id occurs and in the context of the class denoted by the nested-name-specifier.
In section 5.2 expr.post paragraph 1, change the grammar as indicated:
...
pseudo-destructor-name:
      ::opt nested-name-specifieropt type-name :: ~ type-name
      ::opt nested-name-specifier template simple-template-id :: ~ type-name
      ::opt nested-name-specifieropt ~ type-name
      ~ decltype-specifier
In section 5.2.4 expr.pseudo paragraph 2, change the grammar snippet as indicated:
::optnested-name-specifieropt type-name :: ~ type-name
In 7.1.6.2 dcl.type.simple paragraph 1, change the grammar snippet as indicated:
simple-type-specifier:
       ::opt nested-name-specifieropt type-name
       ::opt nested-name-specifier template simple-template-id
       char
       ...
In 7.1.6.3 dcl.type.elab before paragraph 1, change the grammar snippet as indicated:
elaborated-type-specifier:
      class-key attribute-specifieropt ::opt nested-name-specifieropt identifier
      class-key ::opt nested-name-specifieropt templateopt simple-template-id
      enum ::opt nested-name-specifieropt identifier
In 7.1.6.3 dcl.type.elab paragraph 1, change the grammar snippet as indicated:
class-key attribute-specifieropt identifier ;
friend class-key ::opt identifier ;
friend class-key ::opt simple-template-id ;
friend class-key ::opt nested-name-specifier identifier ;
friend class-key ::opt nested-name-specifier templateopt simple-template-id ;

In 7.3.2 namespace.alias paragraph 1, change the grammar snippet as indicated:

qualified-namespace-specifier:
       ::opt nested-name-specifieropt namespace-name
In 7.3.3 namespace.udecl paragraph 1, change the grammar snippet as indicated:
using-declaration:
       using typenameopt ::opt nested-name-specifier unqualified-id ;
       using :: unqualified-id ;
In section 7.3.4 namespace.udir before paragraph 1, change the grammar snippet as indicated:
using-directive:
       attribute-specifieropt using namespace ::opt nested-name-specifieropt namespace-name ;
In clause 8 dcl.decl paragraph 4, change the grammar snippet as indicated:
...
ptr-operator:
      * attribute-specifieropt cv-qualifier-seqopt
      & attribute-specifieropt
      && attribute-specifieropt
      ::opt nested-name-specifier * attribute-specifieropt cv-qualifier-seqopt
...
declarator-id:
      ...opt id-expression
      ::opt nested-name-specifieropt class-name
In section 8.3.3 dcl.mptr paragraph 1, change the grammar snippet as indicated:
::opt nested-name-specifier * attribute-specifieropt cv-qualifier-seqopt D1
In section 9.2 class.mem before paragraph 1, change the grammar snippet as indicated:
member-declaration:
     attribute-specifieropt decl-specifier-seqopt member-declarator-listopt ;
     function-definition ;opt
     ::opt nested-name-specifier templateopt unqualified-id ;
     using-declaration
     static_assert-declaration
     template-declaration
     alias-declaration
In clause 10 class.derived paragraph 1, change the grammar snippet as indicated:
...
class-or-decltype:
       ::opt nested-name-specifieropt class-name
       decltype-specifier
...
In section 14.6 temp.res paragraph 3, change the grammar snippet as indicated:
typename-specifier:
      typename ::opt nested-name-specifier identifier
      typename ::opt nested-name-specifier templateopt simple-template-id