<?xml version="1.0"?>
<clause number="15.5.1" title="Local variable declarations">
  <paragraph>A <non_terminal where="15.5.1">local-variable-declaration</non_terminal> declares one or more local variables. <grammar_production><name><non_terminal where="15.5.1">local-variable-declaration</non_terminal></name> : <rhs><non_terminal where="11">type</non_terminal><non_terminal where="15.5.1">local-variable-declarators</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.5.1">local-variable-declarator</non_terminal>s</name> : <rhs><non_terminal where="15.5.1">local-variable-declarator</non_terminal></rhs><rhs><non_terminal where="15.5.1">local-variable-declarators</non_terminal><terminal>,</terminal><non_terminal where="15.5.1">local-variable-declarator</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.5.1">local-variable-declarator</non_terminal></name> : <rhs><non_terminal where="9.4.2">identifier</non_terminal></rhs><rhs><non_terminal where="9.4.2">identifier</non_terminal><terminal>=</terminal><non_terminal where="15.5.1">local-variable-initializer</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="15.5.1">local-variable-initializer</non_terminal></name> : <rhs><non_terminal where="14.14">expression</non_terminal></rhs><rhs><non_terminal where="19.6">array-initializer</non_terminal></rhs></grammar_production></paragraph>
  <paragraph>The type of a <non_terminal where="15.5.1">local-variable-declaration</non_terminal> specifies the type of the variables introduced by the declaration. </paragraph>
  <paragraph>The type is followed by a list of <non_terminal where="15.5.1">local-variable-declarator</non_terminal>s, each of which introduces a new variable. A <non_terminal where="15.5.1">local-variable-declarator</non_terminal> consists of an identifier that names the variable, optionally followed by an &quot;=&quot; token and a <non_terminal where="15.5.1">local-variable-initializer</non_terminal> that gives the initial value of the variable. </paragraph>
  <paragraph>The value of a local variable is obtained in an expression using a <non_terminal where="14.5.2">simple-name</non_terminal> (<hyperlink>14.5.2</hyperlink>), and the value of a local variable is modified using an assignment (<hyperlink>14.13</hyperlink>). A local variable must be definitely assigned (<hyperlink>12.3</hyperlink>) at each location where its value is obtained. </paragraph>
  <paragraph>The scope of a local variable declared in a <non_terminal where="15.5.1">local-variable-declaration</non_terminal> is the block in which the declaration occurs. It is an error to refer to a local variable in a textual position that precedes the  <non_terminal where="15.5.1">local-variable-declarator</non_terminal> of the local variable. Within the scope of a local variable, it is a compile-time error to declare another local variable or constant with the same name. </paragraph>
  <paragraph>A local variable declaration that declares multiple variables is equivalent to multiple declarations of single variables with the same type. Furthermore, a variable initializer in a local variable declaration corresponds exactly to an assignment statement that is inserted immediately after the declaration. </paragraph>
  <paragraph>
    <example>[Example: The example <code_example><![CDATA[
void F() {  
   int x = 1, y, z = x * 2;  
}  
]]></code_example>corresponds exactly to <code_example><![CDATA[
void F() {  
   int x; x = 1;  
   int y;  
   int z; z = x * 2;  
}  
]]></code_example>end example]</example>
  </paragraph>
</clause>
