Add first pieces of support for parsing and representing
extern "C" in C++ mode. Patch by Mike Stump!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45904 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Parse/Parser.cpp b/Parse/Parser.cpp
index cc2c5d9..eeced57 100644
--- a/Parse/Parser.cpp
+++ b/Parse/Parser.cpp
@@ -386,6 +386,15 @@
return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());
}
+ // If the declspec consisted only of 'extern' and we have a string
+ // literal following it, this must be a C++ linkage specifier like
+ // 'extern "C"'.
+ // FIXME: This should be limited to just C++/ObjectiveC++
+ if (Tok.is(tok::string_literal) &&
+ DS.getStorageClassSpec() == DeclSpec::SCS_extern &&
+ DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier)
+ return ParseLinkage(Declarator::FileContext);
+
// Parse the first declarator.
Declarator DeclaratorInfo(DS, Declarator::FileContext);
ParseDeclarator(DeclaratorInfo);