[cfe-dev] Wrong extern inside no braces linkage specification declaration
abramo.bagnara at gmail.com
Mon Apr 26 01:59:33 PDT 2010
Il 26/04/2010 10:39, Sebastian Redl ha scritto:
> On Sun, 25 Apr 2010 22:57:58 +0200, Abramo Bagnara
> <abramo.bagnara at gmail.com> wrote:
>> Currently clang marks these two declarations
>> extern "C" int a;
>> extern "C" void foo();
>> as extern in StorageClassAsWritten, but the inner declarations does not
>> have any storage class specified (and C++ standard does not allow any).
>> The attached patch wrt r102259 fixes the problem (and do not introduce
>> any regressions).
> As I explained in Bug 6276, Clang's behavior is correct. 7.5p7 states that
> a linkage specifier without braces acts like an extern storage class
This patch is not about whether or not the inner Decl should be
interpreted as declaration or a definition, neither it has to do with
whether or not the linkage of the declaration should be interpreted as
extern (in both cases clang's behavior is correct).
Rather, the patch is only addressing whether or not the "extern" keyword
was syntactically written in the source code as a storage specifier.
This is not the case in the given examples, as the keyword is
syntactically written as a linkage specification.
Note that if you query those Decl by method getStorageClass() you will
still obtain Extern. On the other hand, if you call
getStorageClassAsWritten(), you will obtain None.
More information about the cfe-dev