As specified into the standard int a
belongs to the simple declaration
. Actually
simple-declaration:
decl-specifier-seq_opt init-declarator-list_opt ; //
attribute-specifier-seq decl-specifier-seq_opt init-declarator-list ;
type-specifier:
trailing-type-specifier //
class-specifier
enum-specifier
trailing-type-specifier:
simple-type-specifier //
elaborated-type-specifier
typename-specifier
cv-qualifier
simple-type-specifier:
nested-name-specifieropt type-name
nested-name-specifier template simple-template-id
char
char16_t
char32_t
wchar_t
bool
short
int //
long
signed
unsigned
float
double
void
auto
decltype-specifier
Hence int a
is a simple declaration. But if we redeclare a
into the same scope as the following:
int a;
int a;
We have
test.cpp:4:5: error: redefinition of ‘int a’
test.cpp:3:5: error: ‘int a’ previously declared here
So what exactly int a
is?