| 1 |
// { dg-do run } |
| 2 |
// { dg-require-weak "" } |
| 3 |
// { dg-require-alias "" } |
| 4 |
// { dg-options "-O2 -fno-common" } |
| 5 |
|
| 6 |
// Copyright 2005 Free Software Foundation, Inc. |
| 7 |
// Contributed by Alexandre Oliva <[email protected]> |
| 8 |
|
| 9 |
// PR middle-end/24295 |
| 10 |
|
| 11 |
// The unit-at-a-time call graph code used to fail to emit variables |
| 12 |
// without external linkage that were only used indirectly, through |
| 13 |
// aliases. We might then get linker failures because the static |
| 14 |
// variable was not defined, or run-time errors because the weak alias |
| 15 |
// ended up pointing somewhere random. |
| 16 |
|
| 17 |
#include <stdlib.h> |
| 18 |
|
| 19 |
static unsigned long lv1 = 0xdeadbeefUL; |
| 20 |
#pragma weak Av1a = lv1 |
| 21 |
extern unsigned long Av1a; |
| 22 |
|
| 23 |
static unsigned long lf1(void) { return 0x510bea7UL; } |
| 24 |
#pragma weak Af1a = lf1 |
| 25 |
extern unsigned long Af1a(void); |
| 26 |
|
| 27 |
int main (void) { |
| 28 |
if (! &Av1a |
| 29 |
|| ! &Af1a |
| 30 |
|| Av1a != 0xdeadbeefUL |
| 31 |
|| Af1a() != 0x510bea7UL) |
| 32 |
abort (); |
| 33 |
exit (0); |
| 34 |
} |