alias-redefinition.c 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
  2. void f0() {}
  3. void fun0(void) __attribute((alias("f0")));
  4. void f1() {}
  5. void fun1() {} // expected-note {{previous definition}}
  6. void fun1(void) __attribute((alias("f1"))); // expected-error {{redefinition of 'fun1'}}
  7. void f2() {}
  8. void fun2(void) __attribute((alias("f2"))); // expected-note {{previous definition}}
  9. void fun2() {} // expected-error {{redefinition of 'fun2'}}
  10. void f3() {}
  11. void fun3(void) __attribute((alias("f3"))); // expected-note {{previous definition}}
  12. void fun3(void) __attribute((alias("f3"))); // expected-error {{redefinition of 'fun3'}}
  13. void f4() {}
  14. void fun4(void) __attribute((alias("f4")));
  15. void fun4(void);
  16. // FIXME: We should produce a special case error for this.
  17. void f5() {}
  18. void __attribute((alias("f5"))) fun5(void) {} // expected-error {{redefinition of 'fun5'}} // expected-note {{previous definition}}
  19. int var1 __attribute((alias("v1"))); // expected-error {{definition 'var1' cannot also be an alias}}
  20. static int var2 __attribute((alias("v2"))) = 2; // expected-error {{definition 'var2' cannot also be an alias}}
  21. extern int var3 __attribute__((alias("C"))); // expected-note{{previous definition is here}}
  22. int var3 = 3; // expected-error{{redefinition of 'var3'}}
  23. int var4; // expected-note{{previous definition is here}}
  24. extern int var4 __attribute__((alias("v4"))); // expected-error{{alias definition of 'var4' after tentative definition}}