1// { dg-do link }
2// { dg-xfail-if "" { "powerpc-ibm-aix*" } { "*" } { "" } }
3// { dg-require-alias "" }
4// { dg-options "-O2 -fno-common" }
5
6// Copyright 2005 Free Software Foundation, Inc.
7// Contributed by Alexandre Oliva <aoliva@redhat.com>
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.  Although the PR above is about #pragma weak-introduced
14// aliases, the underlying machinery is the same.
15
16#ifndef ATTRIBUTE_USED
17# define ATTRIBUTE_USED __attribute__((used))
18#endif
19
20static int lv1;
21extern int Av1a __attribute__((alias ("lv1")));
22int *pv1a = &Av1a;
23
24static int lv2;
25extern int Av2a __attribute__((alias ("lv2")));
26int *pv2a = &lv2;
27
28static int lv3;
29extern int Av3a __attribute__((alias ("lv3")));
30static int *pv3a ATTRIBUTE_USED = &Av3a;
31
32static int lv4;
33extern int Av4a __attribute__((alias ("lv4")));
34static int *pv4a = &Av4a;
35
36typedef void ftype(void);
37
38static void lf1(void) {}
39extern ftype Af1a __attribute__((alias ("lf1")));
40ftype *pf1a = &Af1a;
41
42static void lf2(void) {}
43extern ftype Af2a __attribute__((alias ("lf2")));
44ftype *pf2a = &Af2a;
45
46static void lf3(void) {}
47extern ftype Af3a __attribute__((alias ("lf3")));
48static ftype *pf3a ATTRIBUTE_USED = &Af3a;
49
50static void lf4(void) {}
51extern ftype Af4a __attribute__((alias ("lf4")));
52static ftype *pf4a = &Af4a;
53
54main() {
55#ifdef __mips
56  /* Use real asm for MIPS, to stop the assembler warning about
57     orphaned high-part relocations.  */
58  asm volatile ("lw $2,%0\n\tlw $2,%1" : : "m" (pv4a), "m" (pf4a) : "$2");
59#else
60  asm volatile ("" : : "m" (pv4a), "m" (pf4a));
61#endif
62}
63