C11 _Atomic 说明符与限定符语法不规则的基本原理?

Rationale for the C11 _Atomic specifier-vs-qualifier syntax irregularity?

这里有一个相关的 "what" 问题:C11 grammar ambiguity between _Atomic type specifier and qualifier

我感兴趣的是 为什么,因为 C11 基本原理还没有公布,这似乎不必要地复杂。

语法包括这两个(并解决了有利于 shifting ( 而不是 reduce 的歧义(否则如果后面跟着 declaratorabstract-declarator)), 可从 declaration-specifiersspecifier-qualifier-list:

到达
atomic-type-specifier: _Atomic ( type-name )
type-qualifier: _Atomic

这导致以下代码:

int i1;
int (i2); // valid, same as i1 - usually seen in the context of pointer-to-function or pointer-to-array
int _Atomic a1;
int _Atomic (a2); // invalid
_Atomic (int) a3; // valid, same as a1

想法:

基本原理在 N1485 中找到:

The _Atomic keyword also can also be used in the form _Atomic(T), where T is a type, as a type specifier equivalent to _Atomic T. Thus, _Atomic(T) x, y; declares x and y with the same type, even if T is a pointer type. This allows for trivial C++0x compatibility with a C++ only _Atomic(T) macro definition as atomic<T>.