Annex A (informative) Grammar summary [gram]

A.6 Declarations [gram.dcl]

declaration-seq:
    declaration
    declaration-seq declaration
declaration:
    block-declaration
    nodeclspec-function-declaration
    function-definition
    template-declaration
    deduction-guide
    explicit-instantiation
    explicit-specialization
    linkage-specification
    namespace-definition
    empty-declaration
    attribute-declaration
block-declaration:
    simple-declaration
    asm-definition
    namespace-alias-definition
    using-declaration
    using-directive
    static_assert-declaration
    alias-declaration
    opaque-enum-declaration
nodeclspec-function-declaration:
    attribute-specifier-seqopt declarator ;
alias-declaration:
    using identifier attribute-specifier-seqopt = defining-type-id ;
simple-declaration:
    decl-specifier-seq init-declarator-listopt ;
    attribute-specifier-seq decl-specifier-seq init-declarator-list ;
    attribute-specifier-seqopt decl-specifier-seq ref-qualifieropt [ identifier-list ] initializer ;
static_assert-declaration:
  static_assert ( constant-expression ) ;
  static_assert ( constant-expression , string-literal ) ;
empty-declaration:
    ;
attribute-declaration:
    attribute-specifier-seq ;
decl-specifier:
    storage-class-specifier
    defining-type-specifier
    function-specifier
    friend
    typedef
    constexpr
    inline
decl-specifier-seq:
    decl-specifier attribute-specifier-seqopt
    decl-specifier decl-specifier-seq
storage-class-specifier:
    static
    thread_local
    extern
    mutable
function-specifier:
    virtual
    explicit
typedef-name:
    identifier
type-specifier:
  simple-type-specifier
  elaborated-type-specifier
  typename-specifier
  cv-qualifier
type-specifier-seq:
    type-specifier attribute-specifier-seqopt
    type-specifier type-specifier-seq
defining-type-specifier:
    type-specifier
    class-specifier
    enum-specifier
defining-type-specifier-seq:
  defining-type-specifier attribute-specifier-seqopt
  defining-type-specifier defining-type-specifier-seq
simple-type-specifier:
    nested-name-specifieropt type-name
    nested-name-specifier template simple-template-id
    nested-name-specifieropt template-name
    char
    char16_t
    char32_t
    wchar_t
    bool
    short
    int
    long
    signed
    unsigned
    float
    double
    void
    auto
    decltype-specifier
type-name:
    class-name
    enum-name
    typedef-name
    simple-template-id
decltype-specifier:
  decltype ( expression )
  decltype ( auto )
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
    enum nested-name-specifieropt identifier
enum-name:
    identifier
enum-specifier:
    enum-head { enumerator-listopt }
    enum-head { enumerator-list , }
enum-head:
    enum-key attribute-specifier-seqopt enum-head-nameopt enum-baseopt
enum-head-name:
    nested-name-specifieropt identifier
opaque-enum-declaration:
    enum-key attribute-specifier-seqopt nested-name-specifieropt identifier enum-baseopt ;
enum-key:
    enum
    enum class
    enum struct
enum-base:
    : type-specifier-seq
enumerator-list:
    enumerator-definition
    enumerator-list , enumerator-definition
enumerator-definition:
    enumerator
    enumerator = constant-expression
enumerator:
    identifier attribute-specifier-seqopt
namespace-name:
        identifier
        namespace-alias
namespace-definition:
        named-namespace-definition
        unnamed-namespace-definition
        nested-namespace-definition
named-namespace-definition:
        inlineopt namespace attribute-specifier-seqopt identifier { namespace-body }
unnamed-namespace-definition:
        inlineopt namespace attribute-specifier-seqopt { namespace-body }
nested-namespace-definition:
        namespace enclosing-namespace-specifier :: identifier { namespace-body }
enclosing-namespace-specifier:
        identifier
        enclosing-namespace-specifier :: identifier
namespace-body:
        declaration-seqopt
namespace-alias:
        identifier
namespace-alias-definition:
        namespace identifier = qualified-namespace-specifier ;
qualified-namespace-specifier:
    nested-name-specifieropt namespace-name
using-declaration:
    using using-declarator-list ;
using-declarator-list:
    using-declarator ...opt
    using-declarator-list , using-declarator ...opt
using-declarator:
    typenameopt nested-name-specifier unqualified-id
using-directive:
    attribute-specifier-seqopt using  namespace nested-name-specifieropt namespace-name ;
asm-definition:
    asm ( string-literal ) ;
linkage-specification:
    extern string-literal { declaration-seqopt }
    extern string-literal declaration
attribute-specifier-seq:
  attribute-specifier-seqopt attribute-specifier
attribute-specifier:
  [ [ attribute-using-prefixopt attribute-list ] ]
  alignment-specifier
alignment-specifier:
  alignas ( type-id ...opt )
  alignas ( constant-expression ...opt )
attribute-using-prefix:
  using attribute-namespace :
attribute-list:
  attributeopt
  attribute-list , attributeopt
  attribute ...
  attribute-list , attribute ...
attribute:
    attribute-token attribute-argument-clauseopt
attribute-token:
    identifier
    attribute-scoped-token
attribute-scoped-token:
    attribute-namespace :: identifier
attribute-namespace:
    identifier
attribute-argument-clause:
    ( balanced-token-seqopt )
balanced-token-seq:
    balanced-token
    balanced-token-seq balanced-token
balanced-token:
    ( balanced-token-seqopt )
    [ balanced-token-seqopt ]
    { balanced-token-seqopt }
    any token other than a parenthesis, a bracket, or a brace