As a special case,a type name (which is not a declaration of an
identifier) is considered to have a scope that begins just after the
place within the type name where the omitted identifier would appear
were it not omitted.
我正在寻找以下的任何解释:
1)部分名称(6.2.1)是“标识符范围”.这个段落的措词对我来说不清楚:是一个“类型名称范围”,一种范围,类似于块范围,文件范围等?或者它是类型名称本身的范围(在这种情况下,还有一个问题是如何没有名称的对象有范围,什么是这种范围的可能用途).
2)这个定义在哪里呢?更具体地说,如果更改为在对应的类型名称完成后立即启动类型名称的范围,那会影响什么?可以遵循抽象声明符(= type name)中省略的标识符的唯一令牌是一些括号和参数名称或数组维度列表(内含表达式),它们都不能引用所讨论的类型名称,因为存在没有标识符可供参考.为什么不等到宣布者完成?
解决方法
6.7.5.2#4 says that * as an array size “can only be used in declarations with function prototype scope”,and paragraph 5 says “If the size is an expression that is not an integer constant expression: if it occurs in a declaration at function prototype scope,it is treated as if it were replaced by *”.
But is a type name in a function prototype a declaration,and does it have function prototype scope? Scopes are only defined in 6.2.1 for identifiers,and such type names do not declare identifiers. The presence of [*] in the Syntax for abstract declarators suggests that
void f(int (*)[*]);
was intended to be valid and void f(int (*)[a]); was intended to be equivalent to it,but there are no declarations at function prototype scope involved. […]
It appears the issue hinges entirely on the point that a type-name is not a declaration and does not declare an identifier,and because of that it has no scope. Instead of adding complex wording to avoid using the term “scope” as suggested in the DR,it seems clearer to modify the definition of Scope such that it applies to type-name,which is described in 6.7.6 as “syntactically a declaration for a function or an object of that type that omits the identifier”.
这也会影响第6.7.5.2段第4段中的措辞,该修改将:
[…]declarations with function prototype scope[…]
至:
[…]declarations or type-names with function prototype scope[…]