a575963da9
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
10 lines
2.6 KiB
XML
10 lines
2.6 KiB
XML
<?xml version="1.0"?>
|
|
<clause number="15.5.2" title="Local constant declarations">
|
|
<paragraph>A <non_terminal where="15.5.2">local-constant-declaration</non_terminal> declares one or more local constants. <grammar_production><name><non_terminal where="15.5.2">local-constant-declaration</non_terminal></name> : <rhs><keyword>const</keyword><non_terminal where="11">type</non_terminal><non_terminal where="17.3">constant-declarators</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.3">constant-declarator</non_terminal>s</name> : <rhs><non_terminal where="17.3">constant-declarator</non_terminal></rhs><rhs><non_terminal where="17.3">constant-declarators</non_terminal><terminal>,</terminal><non_terminal where="17.3">constant-declarator</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="17.3">constant-declarator</non_terminal></name> : <rhs><non_terminal where="9.4.2">identifier</non_terminal><terminal>=</terminal><non_terminal where="14.15">constant-expression</non_terminal></rhs></grammar_production></paragraph>
|
|
<paragraph>The type of a <non_terminal where="15.5.2">local-constant-declaration</non_terminal> specifies the type of the constants introduced by the declaration. The type is followed by a list of <non_terminal where="17.3">constant-declarator</non_terminal>s, each of which introduces a new constant. A <non_terminal where="17.3">constant-declarator</non_terminal> consists of an identifier that names the constant, followed by an "=" token, followed by a <non_terminal where="14.15">constant-expression</non_terminal> (<hyperlink>14.15</hyperlink>) that gives the value of the constant. </paragraph>
|
|
<paragraph>The type and <non_terminal where="14.15">constant-expression</non_terminal> of a local constant declaration must follow the same rules as those of a constant member declaration (<hyperlink>17.3</hyperlink>). </paragraph>
|
|
<paragraph>The value of a local constant is obtained in an expression using a <non_terminal where="14.5.2">simple-name</non_terminal> (<hyperlink>14.5.2</hyperlink>). </paragraph>
|
|
<paragraph>The scope of a local constant is the block in which the declaration occurs. It is an error to refer to a local constant in a textual position that precedes its <non_terminal where="17.3">constant-declarator</non_terminal>. Within the scope of a local constant, it is a compile-time error to declare another local variable or constant with the same name. </paragraph>
|
|
<paragraph>A local constant declaration that declares multiple constants is equivalent to multiple declarations of single constants with the same type. </paragraph>
|
|
</clause>
|