Yup, it's invalid. Here's the quote.
Section 9 paragraph 11, emphasis mine:
If a class-head-name contains a nested-name-specifier, the class-specifier shall refer to a class that was previously declared directly in the class or namespace to which the nested-name-specifier refers, or in an element of the inline namespace set (7.3.1) of that namespace (i.e., not merely inherited or introduced by a using-declaration), and the class-specifier shall appear in a namespace enclosing the previous declaration. In such cases, the nested-name-specifier of the class-head-name of the definition shall not begin with a decltype-specifier.
In your example, the class-head-name is the tokens B::nested
, which comprises the nested-name-specifier B::
and the class-name nested
. The class-specifier is the entire struct B::nested {
... }
.