r...@zedat.fu-berlin.de (Stefan Ram) writes:
> A compiler compiled this:
>
> #include <new>
>
> int main()
> { { class ::std::bad_alloc b; }
> { struct ::std::bad_alloc b; }
> { typename ::std::bad_alloc b; }}
>
> I was trying to explain, why »class«, »struct«, and
> »typename« is allowed here. I found this grammatical
> derivation for »class« and »struct«:
>
> compound-statement: "{" [statement-seq] "}"
> statement-seq: statement | statement-seq statement
> statement: declaration-statement
> declaration-statement: block-declaration
> block-declaration: simple-declaration
> simple-declaration: [decl-specifier-seq] [init-declarator-list] ";"
> decl-specifier: type-specifier
> type-specifier: trailing-type-specifier
> trailing-type-specifier: elaborated-type-specifier
Another production is /typename-specifier/ which has almost the same
syntax as /elaborated-type-specifier/:
typename ["::"] nested-name-specifier identifier
> elaborated-type-specifier: class-key nested-name-specifier identifier
> class-key: "class" | "struct"
>
> . But this does not apply to »typename«. Should the
> compiler issue a diagnostics?
--
Ben.