Don't warn about the 'extern' in 'extern "C"' on a tag decl. This is
usually useless, but not always.
llvm-svn: 128326
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5a4df40..59b4f5f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -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()) {