Fortran: Fix PR 47485.
[gcc.git] / gcc / testsuite / g++.dg / diagnostic / redeclaration-5.C
blob8c60d539c62fb332fd02f312aaf5c5d12ea7946e
1 // PR c++/52953
2 // { dg-do compile }
3 // { dg-options "-pedantic-errors -Wno-switch-unreachable" }
5 void
6 foo (int x)                             // { dg-message "'int x' previously declared here" }
8   extern int x (int);                   // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
11 void
12 bar (int x)                             // { dg-message "'int x' previously declared here" }
13 try
15   extern int x (int);                   // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
17 catch (...)
21 volatile int v;
23 void
24 baz ()
26 #if __cplusplus >= 201103L
27   auto f = [] (int x) { extern int x (int); };// { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" "" { target c++11 } }
28                                         // { dg-message "'int x' previously declared here" "" { target c++11 } .-1 }
29 #endif
30   if (int x = 1)                        // { dg-message "'int x' previously declared here" }
31     {
32       extern int x (int);               // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
33     }
34   if (int x = 0)                        // { dg-message "'int x' previously declared here" }
35     ;
36   else
37     {
38       extern int x (int);               // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
39     }
40   if (int x = 1)                        // { dg-message "'int x' previously declared here" }
41     extern int x (int);                 // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
42   if (int x = 0)                        // { dg-message "'int x' previously declared here" }
43     ;
44   else
45     extern int x (int);                 // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
46   switch (int x = 1)                    // { dg-message "'int x' previously declared here" }
47     {
48       extern int x (int);               // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
49     default:;
50     }
51   switch (int x = 1)                    // { dg-message "'int x' previously declared here" }
52     extern int x (int);                 // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
53   while (int x = v)
54     {
55       extern int x (int);               // { dg-error "'int x\\\(int\\\)' redeclared as different kind of entity" }
56     }
57   while (int x = v)
58     extern int x (int);                 // { dg-error "'int x\\\(int\\\)' redeclared as different kind of entity" }
59   for (int x = v; x; ++x)               // { dg-message "'int x' previously declared here" }
60     {
61       extern int x (int);               // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
62     }
63   for (int x = v; x; ++x)               // { dg-message "'int x' previously declared here" }
64     extern int x (int);                 // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
65   for (; int x = v; )
66     {
67       extern int x (int);               // { dg-error "'int x\\\(int\\\)' redeclared as different kind of entity" }
68     }
69   for (; int x = v; )
70     extern int x (int);                 // { dg-error "'int x\\\(int\\\)' redeclared as different kind of entity" }
71   try
72     {
73     }
74   catch (int x)                         // { dg-message "'int x' previously declared here" }
75     {
76       extern int x (int);               // { dg-error "redeclaration of 'int x\\\(int\\\)'" }
77     }
80 void
81 corge (int x)                           // { dg-message "'int x' previously declared here" }
82 try
85 catch (...)
87   extern int x (int);                   // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
90 void
91 fred (int x)                            // { dg-message "'int x' previously declared here" }
92 try
95 catch (int)
98 catch (long)
100   extern int x (int);                   // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
103 void
104 garply (int x)
106   try
107     {
108       extern int x (int);
109     }
110   catch (...)
111     {
112       extern int x (int);
113     }
116 struct S
118   S (int x)                             // { dg-message "'int x' previously declared here" }
119   try : s (x)
120   {
121     extern int x (int);                 // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
122   }
123   catch (...)
124   {
125   }
126   int s;
129 struct T
131   T (int x)                             // { dg-message "'int x' previously declared here" }
132   try : t (x)
133   {
134   }
135   catch (...)
136   {
137     extern int x (int);                 // { dg-error "declaration of 'int x\\\(int\\\)' shadows a parameter" }
138   }
139   int t;
142 struct U
144   U (int x) : u (x)
145   {
146     try
147     {
148       extern int x (int);
149     }
150     catch (...)
151     {
152       extern int x (int);
153     }
154   }
155   int u;
158 struct V
160   V (int x) : v (x)
161   {
162     {
163       extern int x (int);
164     }
165   }
166   int v;