[cfe-commits] r128326 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/storage-class.cpp
John McCall
rjmccall at apple.com
Fri Mar 25 19:09:52 PDT 2011
Author: rjmccall
Date: Fri Mar 25 21:09:52 2011
New Revision: 128326
URL: http://llvm.org/viewvc/llvm-project?rev=128326&view=rev
Log:
Don't warn about the 'extern' in 'extern "C"' on a tag decl. This is
usually useless, but not always.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/storage-class.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=128326&r1=128325&r2=128326&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Mar 25 21:09:52 2011
@@ -1870,9 +1870,14 @@
if (emittedWarning || (TagD && TagD->isInvalidDecl()))
return TagD;
+ // Note that a linkage-specification sets a storage class, but
+ // 'extern "C" struct foo;' is actually valid and not theoretically
+ // useless.
if (DeclSpec::SCS scs = DS.getStorageClassSpec())
- Diag(DS.getStorageClassSpecLoc(), diag::warn_standalone_specifier)
- << DeclSpec::getSpecifierName(scs);
+ if (!DS.isExternInLinkageSpec())
+ Diag(DS.getStorageClassSpecLoc(), diag::warn_standalone_specifier)
+ << DeclSpec::getSpecifierName(scs);
+
if (DS.isThreadSpecified())
Diag(DS.getThreadSpecLoc(), diag::warn_standalone_specifier) << "__thread";
if (DS.getTypeQualifiers()) {
Modified: cfe/trunk/test/SemaCXX/storage-class.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/storage-class.cpp?rev=128326&r1=128325&r2=128326&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/storage-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/storage-class.cpp Fri Mar 25 21:09:52 2011
@@ -2,3 +2,6 @@
extern const int PR6495a = 42;
extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}
extern const int PR6495c[] = {42,43,44};
+
+extern struct Test1 {}; // expected-warning {{'extern' ignored on this declaration}}
+extern "C" struct Test0 {}; // no warning
More information about the cfe-commits
mailing list