<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/141659>141659</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang][C23] No diagnostic for attribute declaration where statement is required
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          sheumann
      </td>
    </tr>
</table>

<pre>
    In C23, something like `[[/*possible attributes*/]];` is an attribute declaration, not a statement. So it is not allowed by the syntax in places where a statement is required, specifically as the secondary block of a selection or iteration statement.

Therefore, code like the following should give a diagnostic (at least with `-std=c23 -pedantic`), but Clang currently does not produce one:

```
int main(void) {
    if (1)
 [[]];
}
```

If desired, this could still be allowed as an extension when not pedantically following the standard. I do not have a strong opinion on whether it should be. For reference, GCC gives an error for this, even without `-std=c23 -pedantic`.

(This differs from C++, since C++ allows declaration statements.)

Godbolt link: https://godbolt.org/z/sKGe99x9P
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8lNFq6zgTx59GuRkaHNmu4wtfOAkp5YOPhT0vIEtjW1tFk5XGabNPv0hOT8vhsCAIRJ6Z__x_o1Ex2skjdqI-iPq0UQvPFLo443JR3m8GMvfu1cNRlkIeIdIFebZ-AmffEMRzkeMOQp6F7K8Uox0cgmIOdlgYo5B9uqtP6ZQH8VyAjaD81ydgUDsVFFvyqYQnBgWRFeMFPW_hTwLLKSrfOEfvaGC4A88I8e5ZfYD1cHVKY4T3GQN-j0-BAf9ebECTO7iitqPVyrk7qLhmQU3eqHCHwZF-AxpTBnSokyigAJZxVfhNmCh6UfQ_UsGRAqbkmgyuzqS0IyWxyaw40-IMTPaWtBmrJk-RrQYh94rBoYoM75bn5OhTZCPKk5YlPF3RKM9WJ6Nlm0oMC8PRKT-BXkJAz-4OhnB15xrILBqBPIqyXwWm0PUUvfUMF2W9kPsbWSN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