diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-22 19:26:13 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-22 19:26:13 +0000 |
commit | 208b5c0fa5caa5716a78a04e856bf39ef8f38732 (patch) | |
tree | 0d11ed81ffe224ee4c8a2a5e589092213952e6ca /clang/test/Sema/attr-alias-elf.c | |
parent | be38b9e15fde35e15cf87f28540bd34edfce4db6 (diff) | |
download | bcm5719-llvm-208b5c0fa5caa5716a78a04e856bf39ef8f38732.tar.gz bcm5719-llvm-208b5c0fa5caa5716a78a04e856bf39ef8f38732.zip |
New fix for pr17535.
This is a fixed version of r193161. In order to handle
void foo() __attribute__((alias("bar")));
void bar() {}
void zed() __attribute__((alias("foo")));
it is not enough to delay aliases to the end of the TU, we have to do two
passes over them to find if they are defined or not.
This can be implemented by producing alias as we go and just doing the second
pass at the end. This has the advantage that other parts of clang that were
expecting alias to be processed in order don't have to be changed.
This patch also handles cyclic aliases.
llvm-svn: 193188
Diffstat (limited to 'clang/test/Sema/attr-alias-elf.c')
-rw-r--r-- | clang/test/Sema/attr-alias-elf.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/test/Sema/attr-alias-elf.c b/clang/test/Sema/attr-alias-elf.c new file mode 100644 index 00000000000..88bd7b70958 --- /dev/null +++ b/clang/test/Sema/attr-alias-elf.c @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux -fsyntax-only -verify -emit-llvm-only %s + +void f1(void) __attribute__((alias("g1"))); +void g1(void) { +} + +void f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}} + + +void f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}} +void g3(void); + + +void f4() __attribute__((alias("g4"))); +void g4() {} +void h4() __attribute__((alias("f4"))); + +void f5() __attribute__((alias("g5"))); +void h5() __attribute__((alias("f5"))); +void g5() {} + +void g6() {} +void f6() __attribute__((alias("g6"))); +void h6() __attribute__((alias("f6"))); + +void g7() {} +void h7() __attribute__((alias("f7"))); +void f7() __attribute__((alias("g7"))); + +void h8() __attribute__((alias("f8"))); +void g8() {} +void f8() __attribute__((alias("g8"))); + +void h9() __attribute__((alias("f9"))); +void f9() __attribute__((alias("g9"))); +void g9() {} + +void f10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} +void g10() __attribute__((alias("f10"))); // expected-error {{alias definition is part of a cycle}} + +// FIXME: This could be a bit better, h10 is not part of the cycle, it points +// to it. +void h10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}} + +extern int a1 __attribute__((alias("b1"))); +int b1 = 42; + +extern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}} + +extern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}} +extern int b3; + +extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}} +typedef int b4; |