summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/alias.c
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2019-08-22 20:47:12 +0000
committerNick Desaulniers <ndesaulniers@google.com>2019-08-22 20:47:12 +0000
commitf21bca02f7a900a9e8253d05682e7316e06afbea (patch)
treefbbd8595ca0e82ab98fdeb3008cb2702cc12dfee /clang/test/CodeGen/alias.c
parent2eaeba6f15d361687795dc429b78090ab38ff1d2 (diff)
downloadbcm5719-llvm-f21bca02f7a900a9e8253d05682e7316e06afbea.tar.gz
bcm5719-llvm-f21bca02f7a900a9e8253d05682e7316e06afbea.zip
[Clang][CodeGen] set alias linkage on QualType
Summary: It seems that CodeGen was always using ExternalLinkage when emitting a GlobalDecl with __attribute__((alias)). This leads to symbol redefinitions (ODR) that cause failures at link time for static aliases. This is readily attempting to link an ARM (32b) allyesconfig Linux kernel built with Clang. Reported-by: nathanchance Suggested-by: ihalip Link: https://bugs.llvm.org/show_bug.cgi?id=42377 Link: https://github.com/ClangBuiltLinux/linux/issues/631 Reviewers: rsmith, aaron.ballman, erichkeane Reviewed By: aaron.ballman Subscribers: javed.absar, kristof.beyls, cfe-commits, srhines, ihalip, nathanchance Tags: #clang Differential Revision: https://reviews.llvm.org/D66492 llvm-svn: 369705
Diffstat (limited to 'clang/test/CodeGen/alias.c')
-rw-r--r--clang/test/CodeGen/alias.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/CodeGen/alias.c b/clang/test/CodeGen/alias.c
index 78b020454a9..296a707c44b 100644
--- a/clang/test/CodeGen/alias.c
+++ b/clang/test/CodeGen/alias.c
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECKBASIC %s
// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -emit-llvm -o - %s | FileCheck -check-prefix=CHECKCC %s
// RUN: %clang_cc1 -triple armv7a-eabi -mfloat-abi hard -S -o - %s | FileCheck -check-prefix=CHECKASM %s
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck -check-prefix=CHECKGLOBALS %s
int g0;
// CHECKBASIC-DAG: @g0 = common global i32 0
@@ -88,3 +89,13 @@ void test8_zed() __attribute__((alias("test8_foo")));
void test9_bar(void) { }
void test9_zed(void) __attribute__((section("test")));
void test9_zed(void) __attribute__((alias("test9_bar")));
+
+// Test that the alias gets its linkage from its declared qual type.
+// CHECKGLOBALS: @test10_foo = internal
+// CHECKGLOBALS-NOT: @test10_foo = dso_local
+int test10;
+static int test10_foo __attribute__((alias("test10")));
+// CHECKGLOBALS: @test11_foo = internal
+// CHECKGLOBALS-NOT: @test11_foo = dso_local
+void test11(void) {}
+static void test11_foo(void) __attribute__((alias("test11")));
OpenPOWER on IntegriCloud