tree-optimization/115579 - fix wrong code with store-motion
[official-gcc.git] / gcc / testsuite / g++.dg / other / nested-extern-2.C
blobacd78ff406421bf844de8574806edf1ba02e0063
1 /* { dg-do run } */
2 /* PR 31775 */
3 // { dg-additional-sources "nested-extern-2.cc" }
4 extern int *p_otheri;
5 static int i; // #1
6 int *p_si = &i;
7 int main()
8
9   int i;
10   int *p_ai = &i;
11   {
12     // This is an alias of #1, not a different object
13     extern int i;
14     int *p_ei = &i;
16     *p_si = 1;
17     *p_ai = 2;
18     *p_ei = 3;
19     if (*p_si != 3)
20       return 1;
21     if (*p_ai != 2)
22       return 2;
23     if (*p_otheri != 17)
24       return 3;
25   }
26   return 0;