Fix parsing when one extern follows another.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 9 Dec 2016 16:44:05 +0000 (16:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 9 Dec 2016 16:44:05 +0000 (16:44 +0000)
llvm-svn: 289224

lld/ELF/LinkerScript.cpp
lld/test/ELF/dynamic-list-extern.s [new file with mode: 0644]

index d5e9487..bf19914 100644 (file)
@@ -1915,9 +1915,11 @@ void ScriptParser::readVersionDeclaration(StringRef VerStr) {
 std::vector<SymbolVersion> ScriptParser::readSymbols() {
   std::vector<SymbolVersion> Ret;
   for (;;) {
-    if (consume("extern"))
+    if (consume("extern")) {
       for (SymbolVersion V : readVersionExtern())
         Ret.push_back(V);
+      continue;
+    }
 
     if (peek() == "}" || peek() == "local:" || Error)
       break;
diff --git a/lld/test/ELF/dynamic-list-extern.s b/lld/test/ELF/dynamic-list-extern.s
new file mode 100644 (file)
index 0000000..dfeb31d
--- /dev/null
@@ -0,0 +1,15 @@
+# REQUIRES: x86
+
+# Test that we can parse multiple externs.
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+
+# RUN: echo '{ \
+# RUN:         extern "C" { \
+# RUN:           foo; \
+# RUN:         }; \
+# RUN:         extern "C++" { \
+# RUN:           bar; \
+# RUN:         }; \
+# RUN:       };' > %t.list
+# RUN: ld.lld --dynamic-list %t.list %t.o -shared -o %t.so