Fix bug: CBackend/2002-10-16-External.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4201 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index feaf135..b7207d5 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -572,17 +572,16 @@
   // Output the global variable definitions and contents...
   if (!M->gempty()) {
     Out << "\n\n/* Global Variable Definitions and Initialization */\n";
-    for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
-      if (I->hasInternalLinkage())
-        Out << "static ";
-      printType(I->getType()->getElementType(), getValueName(I));
+    for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
+      if (!I->isExternal()) {
+        if (I->hasInternalLinkage())
+          Out << "static ";
+        printType(I->getType()->getElementType(), getValueName(I));
       
-      if (I->hasInitializer()) {
         Out << " = " ;
         writeOperand(I->getInitializer());
+        Out << ";\n";
       }
-      Out << ";\n";
-    }
   }
 
   // Output all of the functions...