Section 3.3.4 / 2 indicates how specifiers of specified types are developed in any situation, and what effect they may have:
If the specified type specifier is entered by the class key and this search does not find the previously declared type name [..] The developed type specifier is a declaration that introduces class-name, as described in section 3.3.2 .
Then in ยง3.3.2 / 7 (.2) it reads
The declaration point of the class first declared in the specified type specifier is as follows: [..] for the specified form specifier type
key class Identifier
if the specified type specifier is used in the qualifier-description-seq or parameter-declaration-sentence of the function defined in the namespace area, the identifier is declared as the class name in the namespace, contains a declaration; otherwise, with the exception of the friend declaration, the identifier is declared in the smallest namespace or block area containing the declaration.
source share