[dcl.pre] (original) (raw)

9 Declarations [dcl.dcl]

9.1 Preamble [dcl.pre]

[ Note

:

In the declaration for an entity, attributes appertaining to that entity may appear at the start of the declaration and after thedeclarator-id for that declaration.

end note

]

[ Example

:

[[noreturn]] void f [[noreturn]] ();

end example

]

Except where otherwise specified, the meaning of an attribute-declarationis implementation-defined.

A declaration occurs in a scope; the scope rules are summarized in [basic.lookup].

A declaration that declares a function or defines a class, namespace, template, or function also has one or more scopes nested within it.

These nested scopes, in turn, can have declarations nested within them.

Unless otherwise stated, utterances in[dcl.dcl] about components in, of, or contained by a declaration or subcomponent thereof refer only to those components of the declaration that are not nested within scopes nested within the declaration.

In such cases, the decl-specifier-seq shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration.

[ Example

:

enum { };
typedef class { };

end example

]

If the value of the expression when so converted is true, the declaration has no effect.

Otherwise, the program is ill-formed, and the resulting diagnostic message ([intro.compliance]) shall include the text of the string-literal, if one is supplied, except that characters not in the basic source character set are not required to appear in the diagnostic message.

[ Example

:

static_assert(sizeof(int) == sizeof(void*), "wrong pointer size");

end example

]

An empty-declaration has no effect.

If thedecl-specifier-seq contains no typedef specifier, the declaration is called a function declaration if the type associated with the name is a function type ([dcl.fct]) and an object declaration otherwise.

Syntactic components beyond those found in the general form of declaration are added to a function declaration to make afunction-definition.

An object declaration, however, is also a definition unless it contains the extern specifier and has no initializer ([basic.def]).

An object definition causes storage of appropriate size and alignment to be reserved and any appropriate initialization ([dcl.init]) to be done.

A nodeclspec-function-declaration shall declare a constructor, destructor, or conversion function.