Assume there is a declaration:
struct A { static int i; };
A a;
As I know, the input string int decltype(a)::i = 0; has no strictly described behaviour.
It can be parsed as int decltype(a)::i = 0;, where:
int is a decl-specifier and decltype(a)::i the declarator.
However,it can be parsed as int decltype(a) ::i = 0;,where
int and decltype(a) are parsed asdecl-specifers, and ::i is the (re)declaration of a global variable i - the compiler should give a error msg which goes like "a decl-specifier-seq should not contain two type-specifiers".
I clearly know the first way to parse should be the right one but I can't find any proof.
Anyway, in int A::a = 0;, A is sure to be parsed as part of declarator because A is a type-name and as described in standard
If a type-name is encountered while parsing a decl-specifier-seq, it is interpreted as part of the decl-specifier-seq if and only if there is no previous type-specifier other than a cv-qualifier in the decl-specifier-seq.
In constrant, decltype(a) is not a type-name, it's a type-specifier.
I am not 'finding a quarrel in a straw', I have this question because I'm writing my parser for C++.
So, I wonder if the description should be:
If a type-specifier is encountered while parsing a decl-specifier-seq, it is interpreted as part of the decl-specifier-seq if and only if there is no previous type-specifier other than a cv-qualifier in the decl-specifier-seq.