]> granicus.if.org Git - clang/commitdiff
weak_import should not make definitions have weak linkage.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 5 Jun 2009 22:58:34 +0000 (22:58 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 5 Jun 2009 22:58:34 +0000 (22:58 +0000)
 - <rdar://problem/6948703> clang treats weak_import like weak

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/attributes.c

index 6e8440a17738e5525bca198cd0b867245325c0d6..5c12c81b36bea7d0e56a3b82c120b6df832b344c 100644 (file)
@@ -298,7 +298,7 @@ void CodeGenModule::SetFunctionDefinitionAttributes(const FunctionDecl *D,
     GV->setLinkage(llvm::Function::InternalLinkage);
   } else if (D->hasAttr<DLLExportAttr>()) {
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  } else if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>()) {
+  } else if (D->hasAttr<WeakAttr>()) {
     GV->setLinkage(llvm::Function::WeakAnyLinkage);
   } else if (Linkage == GVA_C99Inline) {
     // In C99 mode, 'inline' functions are guaranteed to have a strong
@@ -853,7 +853,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
     GV->setLinkage(llvm::Function::DLLImportLinkage);
   else if (D->hasAttr<DLLExportAttr>())
     GV->setLinkage(llvm::Function::DLLExportLinkage);
-  else if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakImportAttr>())
+  else if (D->hasAttr<WeakAttr>())
     GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage);
   else if (!CompileOpts.NoCommon &&
            (!D->hasExternalStorage() && !D->getInit()))
index d45d5124b010e8cc34d62024c6324b4c882f6375..a5de4f4b42a2a1bf7f5225c815b8625fc54e5a8b 100644 (file)
@@ -14,7 +14,7 @@
 // RUN: grep '@t13 =.*section "SECT"' %t &&
 // RUN: grep '@t14.x =.*section "SECT"' %t
 // RUN: grep 'declare extern_weak i32 @t15()' %t &&
-// RUN: grep '@t16 = extern_weak global i32' %t
+// RUN: grep '@t16 = extern_weak global i32' %t &&
 
 void t1() __attribute__((noreturn));
 void t1() {}
@@ -56,4 +56,14 @@ int t17() {
   return t15() + t16;
 }
 
+// RUN: grep '@t18 = global i[0-9]* 1, align .*' %t &&
+extern int t18 __attribute__((weak_import));
+int t18 = 1;
 
+// RUN: grep 'define i[0-9]* @t19() nounwind {' %t &&
+extern int t19(void) __attribute__((weak_import));
+int t19(void) {
+  return 10;
+}
+
+// RUN: true