diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-22 21:39:03 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-22 21:39:03 +0000 |
commit | d53ffa0a70d807ec77969fa0168ced90ceaddd98 (patch) | |
tree | 6b26b1848a65f8c15b88f069a862cb275c24d8e2 /clang/test | |
parent | f34568b0af4b1479727fd42101fb69b783ce4fe9 (diff) | |
download | bcm5719-llvm-d53ffa0a70d807ec77969fa0168ced90ceaddd98.tar.gz bcm5719-llvm-d53ffa0a70d807ec77969fa0168ced90ceaddd98.zip |
Treat aliases as definitions.
This fixes pr17639.
Before this patch clang would consider
void foo(void) __attribute((alias("__foo")));
a declaration. It now correctly handles it as a definition.
Initial patch by Alp Toker. I added support for variables.
llvm-svn: 193200
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/pragma-weak.c | 16 | ||||
-rw-r--r-- | clang/test/Sema/alias-redefinition.c | 44 | ||||
-rw-r--r-- | clang/test/Sema/pragma-weak.c | 11 |
3 files changed, 55 insertions, 16 deletions
diff --git a/clang/test/CodeGen/pragma-weak.c b/clang/test/CodeGen/pragma-weak.c index 40eb525e18f..559be831a55 100644 --- a/clang/test/CodeGen/pragma-weak.c +++ b/clang/test/CodeGen/pragma-weak.c @@ -7,8 +7,6 @@ // CHECK-DAG: @both = alias void ()* @__both // CHECK-DAG: @both2 = alias void ()* @__both2 -// CHECK-DAG: @both3 = alias weak void ()* @__both3 -// CHECK-DAG: @a3 = alias weak void ()* @__a3 // CHECK-DAG: @weakvar_alias = alias weak i32* @__weakvar_alias // CHECK-DAG: @foo = alias weak void ()* @__foo // CHECK-DAG: @foo2 = alias weak void ()* @__foo2 @@ -125,12 +123,6 @@ void both2(void) __attribute((alias("__both2"))); // first, wins void __both2(void) {} // CHECK-LABEL: define void @__both2() -void __both3(void); -#pragma weak both3 = __both3 // first, wins -void both3(void) __attribute((alias("__both3"))); -void __both3(void) {} -// CHECK-LABEL: define void @__both3() - ///////////// ensure that #pragma weak does not alter existing __attributes() void __a1(void) __attribute((noinline)); @@ -138,14 +130,6 @@ void __a1(void) __attribute((noinline)); void __a1(void) {} // CHECK: define void @__a1() [[NI:#[0-9]+]] -// attributes introduced BEFORE a combination of #pragma weak and alias() -// hold... -void __a3(void) __attribute((noinline)); -#pragma weak a3 = __a3 -void a3(void) __attribute((alias("__a3"))); -void __a3(void) {} -// CHECK: define void @__a3() [[NI]] - #pragma weak xxx = __xxx __attribute((pure,noinline,const)) void __xxx(void) { } // CHECK: void @__xxx() [[RN:#[0-9]+]] diff --git a/clang/test/Sema/alias-redefinition.c b/clang/test/Sema/alias-redefinition.c new file mode 100644 index 00000000000..6c6ebf80250 --- /dev/null +++ b/clang/test/Sema/alias-redefinition.c @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s + +void f0() {} +void fun0(void) __attribute((alias("f0"))); + +void f1() {} +void fun1() {} // expected-note {{previous definition}} +void fun1(void) __attribute((alias("f1"))); // expected-error {{redefinition of 'fun1'}} + +void f2() {} +void fun2(void) __attribute((alias("f2"))); // expected-note {{previous definition}} +void fun2() {} // expected-error {{redefinition of 'fun2'}} + +void f3() {} +void fun3(void) __attribute((alias("f3"))); // expected-note {{previous definition}} +void fun3(void) __attribute((alias("f3"))); // expected-error {{redefinition of 'fun3'}} + +void f4() {} +void fun4(void) __attribute((alias("f4"))); +void fun4(void); + +// FIXME: We should produce a special case error for this. +void f5() {} +void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}} + +int v1; +int var1 __attribute((alias("v1"))); // expected-note {{previous definition}} +int var1 __attribute((alias("v1"))); // expected-error {{redefinition of 'var1'}} + +int v2; +int var2 = 2; // expected-note {{previous definition}} +int var2 __attribute((alias("v2"))); // expected-error {{redefinition of 'var2'}} + +int v3; +int var3 __attribute((alias("v3"))); // expected-note {{previous definition}} +int var3 = 2; // expected-error {{redefinition of 'var3'}} + +int v4; +int var4; // expected-note {{previous definition}} +int var4 __attribute((alias("v4"))); // expected-error {{alias definition of 'var4' after tentative definition}} + +int v5; +int var5 __attribute((alias("v5"))); // expected-note {{previous definition}} +int var5; // expected-error {{tentative definition of 'var5' after alias definition}} diff --git a/clang/test/Sema/pragma-weak.c b/clang/test/Sema/pragma-weak.c new file mode 100644 index 00000000000..c14125eac9f --- /dev/null +++ b/clang/test/Sema/pragma-weak.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s + +void __both3(void); +#pragma weak both3 = __both3 // expected-note {{previous definition}} +void both3(void) __attribute((alias("__both3"))); // expected-error {{redefinition of 'both3'}} +void __both3(void) {} + +void __a3(void) __attribute((noinline)); +#pragma weak a3 = __a3 // expected-note {{previous definition}} +void a3(void) __attribute((alias("__a3"))); // expected-error {{redefinition of 'a3'}} +void __a3(void) {} |