[cfe-dev] Repeating declaration specifiers
Hans Wennborg
hans at chromium.org
Mon Jun 20 04:15:52 PDT 2011
On Mon, Jun 20, 2011 at 7:53 AM, Marcin Zalewski
<marcin.zalewski at gmail.com> wrote:
> I hope that this has not been asked before, but does Clang allow
> multiple declaration specifiers on purpose? See the following line of
> code:
>
> const const const const volatile const int const const volatile gggg = 8;
>
> Clang produces no diagnostics on this. GCC says:
>
> testt.cpp:8: error: duplicate ‘const’
> testt.cpp:8: error: duplicate ‘volatile’
>
> While I would say that I hope GCC is actually correct, I am not sure.
> Any language lawyers who can help?
Not a language lawyer, but I think GCC is correct.
[dcl.type] says "const or volatile can be combined with any other
type-specifier. However, redundant cv-qualifiers are prohibited except
when introduced through the use of typedefs or template type
arguments, in which case the redundant cv-qualifiers are ignored."
There seems to be a bug filed for this already:
http://llvm.org/bugs/show_bug.cgi?id=8264
Thanks,
Hans
More information about the cfe-dev
mailing list