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
linkage-extern.patch (4.84 KB)
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.
You're right, of course. Sorry for that.