| 1 |
// PR c++/45331 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options -std=c++98 } |
| 4 |
|
| 5 |
struct OK1 |
| 6 |
{ |
| 7 |
int a; |
| 8 |
} // no complaints |
| 9 |
*s5; |
| 10 |
|
| 11 |
struct OK2 |
| 12 |
{ |
| 13 |
int a; |
| 14 |
} // no complaints |
| 15 |
&s6 = *(new OK2()); |
| 16 |
|
| 17 |
struct OK3 |
| 18 |
{ |
| 19 |
int a; |
| 20 |
} // no complaints |
| 21 |
(s7); |
| 22 |
|
| 23 |
struct OK5 |
| 24 |
{ |
| 25 |
int a; |
| 26 |
} ok5_var; // no complaints |
| 27 |
|
| 28 |
struct OK6 |
| 29 |
{ |
| 30 |
int a; |
| 31 |
} static ok6_var; // no complaints |
| 32 |
|
| 33 |
class OK7 |
| 34 |
{ |
| 35 |
public: |
| 36 |
OK7() { }; |
| 37 |
int a; |
| 38 |
} const ok7_var; // no complaints |
| 39 |
|
| 40 |
class OK8 |
| 41 |
{ |
| 42 |
int a; |
| 43 |
} extern ok8_var; // no complaints |
| 44 |
|
| 45 |
class OK9 |
| 46 |
{ |
| 47 |
class OK9sub { int a; } mutable ok9sub; // no complaints |
| 48 |
int a; |
| 49 |
}; |
| 50 |
|
| 51 |
int |
| 52 |
autotest (void) |
| 53 |
{ |
| 54 |
struct OK10 { int a; } auto ok10 = { 0 }; // no complaints |
| 55 |
|
| 56 |
return ok10.a; |
| 57 |
} |
| 58 |
|
| 59 |
struct OK11 |
| 60 |
{ |
| 61 |
int a; |
| 62 |
} // no complaints |
| 63 |
const *ok11_var; |
| 64 |
|
| 65 |
struct OK12 |
| 66 |
{ |
| 67 |
int a; |
| 68 |
} // no complaints |
| 69 |
const &ok12_var = *(new OK12()); |
| 70 |
|
| 71 |
struct OK13 |
| 72 |
{ |
| 73 |
int a; |
| 74 |
} // no complaints |
| 75 |
static *ok13_var; |
| 76 |
|
| 77 |
class OK14 |
| 78 |
{ |
| 79 |
struct OK14sub |
| 80 |
{ |
| 81 |
int a; |
| 82 |
} // no complaints |
| 83 |
static &ok14_var; |
| 84 |
}; |
| 85 |
|
| 86 |
class OK15 |
| 87 |
{ |
| 88 |
int a; |
| 89 |
} typedef tOK15; |
| 90 |
|
| 91 |
class OK16 |
| 92 |
{ |
| 93 |
int a; |
| 94 |
} typedef *pOK16; |
| 95 |
|
| 96 |
class OK17 |
| 97 |
{ |
| 98 |
int a; |
| 99 |
} typedef &rOK16; |
| 100 |
|
| 101 |
struct E1 |
| 102 |
{ |
| 103 |
int a; |
| 104 |
} // { dg-error "after struct definition" } |
| 105 |
|
| 106 |
typedef float BAR; |
| 107 |
|
| 108 |
struct E2 |
| 109 |
{ |
| 110 |
int a; |
| 111 |
} // { dg-error "after struct definition" } |
| 112 |
|
| 113 |
const int i0 = 1; |
| 114 |
|
| 115 |
struct E3 |
| 116 |
{ |
| 117 |
int a; |
| 118 |
} // { dg-error "after struct definition" } |
| 119 |
|
| 120 |
volatile long l0 = 1; |
| 121 |
|
| 122 |
struct E4 |
| 123 |
{ |
| 124 |
int a; |
| 125 |
} // { dg-error "after struct definition" } |
| 126 |
|
| 127 |
extern char c0; |
| 128 |
|
| 129 |
struct E5 |
| 130 |
{ |
| 131 |
int a; |
| 132 |
} // { dg-error "after struct definition" } |
| 133 |
|
| 134 |
static wchar_t wc0; |
| 135 |
|
| 136 |
struct E6 |
| 137 |
{ |
| 138 |
int a; |
| 139 |
} // { dg-error "after struct definition" } |
| 140 |
|
| 141 |
bool b0; |
| 142 |
|
| 143 |
class E7 |
| 144 |
{ |
| 145 |
int a; |
| 146 |
} // { dg-error "after class definition" } |
| 147 |
|
| 148 |
extern double d0; |
| 149 |
|
| 150 |
class E8 |
| 151 |
{ |
| 152 |
int a; |
| 153 |
} // { dg-error "after class definition" } |
| 154 |
|
| 155 |
inline short f(void) |
| 156 |
{ |
| 157 |
return 2; |
| 158 |
} |
| 159 |
|
| 160 |
class E9 |
| 161 |
{ |
| 162 |
int a; |
| 163 |
} // { dg-error "after class definition" } |
| 164 |
|
| 165 |
class D0 |
| 166 |
{ |
| 167 |
int a; |
| 168 |
}; |
| 169 |
|
| 170 |
class E10 |
| 171 |
{ |
| 172 |
int a; |
| 173 |
} // { dg-error "after class definition" } |
| 174 |
|
| 175 |
extern class D0 &f0 (void); |
| 176 |
|
| 177 |
class E11 |
| 178 |
{ |
| 179 |
int a; |
| 180 |
} // { dg-error "after class definition" } |
| 181 |
|
| 182 |
const struct E6 *f1 (void) { return 0; } |
| 183 |
|
| 184 |
union U0 { |
| 185 |
int i; |
| 186 |
double d; |
| 187 |
}; |
| 188 |
|
| 189 |
class E12 |
| 190 |
{ |
| 191 |
int a; |
| 192 |
} // { dg-error "after class definition" } |
| 193 |
|
| 194 |
const union U0 *f2 (void) { return 0; } |
| 195 |
|
| 196 |
enum e { |
| 197 |
U, V |
| 198 |
}; |
| 199 |
|
| 200 |
class E13 |
| 201 |
{ |
| 202 |
int a; |
| 203 |
} // { dg-error "after class definition" } |
| 204 |
|
| 205 |
static enum e f3 (void) { return U; } |
| 206 |
|
| 207 |
union E14 |
| 208 |
{ |
| 209 |
int i; |
| 210 |
double d; |
| 211 |
} // { dg-error "after union definition" } |
| 212 |
|
| 213 |
unsigned int i1 = 2; |
| 214 |
|
| 215 |
union E15 |
| 216 |
{ |
| 217 |
int i; |
| 218 |
double d; |
| 219 |
} // { dg-error "after union definition" } |
| 220 |
|
| 221 |
signed long l1 = 3; |
| 222 |
|
| 223 |
class E16 |
| 224 |
{ |
| 225 |
class sub0 { int a; } // { dg-error "after class definition" } |
| 226 |
virtual int f2 (void); |
| 227 |
} // { dg-error "after class definition" } |
| 228 |
|
| 229 |
class E17 |
| 230 |
{ |
| 231 |
class sub0 { int a; } // { dg-error "after class definition" } |
| 232 |
mutable int i; |
| 233 |
} // { dg-error "after class definition" } |
| 234 |
|
| 235 |
class E18 |
| 236 |
{ |
| 237 |
int a; |
| 238 |
} // { dg-error "after class definition" } |
| 239 |
|
| 240 |
typedef int E18int; |
| 241 |
|
| 242 |
/* This was the original test from the PR. */ |
| 243 |
|
| 244 |
class C0 |
| 245 |
{ |
| 246 |
public: |
| 247 |
int a; |
| 248 |
} // { dg-error "after class definition" } |
| 249 |
|
| 250 |
const int foo(const C0 &x) |
| 251 |
{ |
| 252 |
return x.a; |
| 253 |
} |