145
|
1 /* { dg-do run } */
|
|
2 /* { dg-require-effective-target noinit } */
|
|
3 /* { dg-options "-O2" } */
|
|
4
|
|
5 /* This test checks that noinit data is handled correctly. */
|
|
6
|
|
7 extern void _start (void) __attribute__ ((noreturn));
|
|
8 extern void abort (void) __attribute__ ((noreturn));
|
|
9 extern void exit (int) __attribute__ ((noreturn));
|
|
10
|
|
11 int var_common;
|
|
12 int var_zero = 0;
|
|
13 int var_one = 1;
|
|
14 int __attribute__((noinit)) var_noinit;
|
|
15 int var_init = 2;
|
|
16
|
|
17 int __attribute__((noinit)) func(); /* { dg-warning "attribute only applies to variables" } */
|
|
18 int __attribute__((section ("mysection"), noinit)) var_section1; /* { dg-warning "because it conflicts with attribute" } */
|
|
19 int __attribute__((noinit, section ("mysection"))) var_section2; /* { dg-warning "because it conflicts with attribute" } */
|
|
20
|
|
21
|
|
22 int
|
|
23 main (void)
|
|
24 {
|
|
25 /* Make sure that the C startup code has correctly initialized the ordinary variables. */
|
|
26 if (var_common != 0)
|
|
27 abort ();
|
|
28
|
|
29 /* Initialized variables are not re-initialized during startup, so
|
|
30 check their original values only during the first run of this
|
|
31 test. */
|
|
32 if (var_init == 2)
|
|
33 if (var_zero != 0 || var_one != 1)
|
|
34 abort ();
|
|
35
|
|
36 switch (var_init)
|
|
37 {
|
|
38 case 2:
|
|
39 /* First time through - change all the values. */
|
|
40 var_common = var_zero = var_one = var_noinit = var_init = 3;
|
|
41 break;
|
|
42
|
|
43 case 3:
|
|
44 /* Second time through - make sure that d has not been reset. */
|
|
45 if (var_noinit != 3)
|
|
46 abort ();
|
|
47 exit (0);
|
|
48
|
|
49 default:
|
|
50 /* Any other value for var_init is an error. */
|
|
51 abort ();
|
|
52 }
|
|
53
|
|
54 /* Simulate a processor reset by calling the C startup code. */
|
|
55 _start ();
|
|
56
|
|
57 /* Should never reach here. */
|
|
58 abort ();
|
|
59 }
|