Debian Codegraph @

gcc/testsuite/g++.dg/ext/typedef-init.C

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fpermissive" } // suppress default -pedantic-errors */
3
4 /* This code used to be a legitimate, if dubious, extension. However,
5 it's been broken since GCC 3.0 (caused ICE) and we have now removed
6 the extension. See PR c/7353.
7
8 For cases A and C, C++ issues a warning in addition to the error,
9 since this construct appears to be a case of implicit int
10 (forbidden in std. C++) until we get to the equals sign. */
11
12 /* Case A: just the bare name = initializer. */
13
14 typedef A = 0; /* { dg-error "does not name a type" "A" } */
15 A a; /* { dg-error "does not name a type" "A error cascade" } */
16
17 /* Case B: with a type also. */
18
19 typedef int B = 0; /* { dg-error "initialized" "B" } */
20 B b; /* { dg-error "does not name a type" "B error cascade" } */
21
22 /* C and D are the same as A and B, but wrapped in a structure;
23 field declarations go by a different code path in C++ (ick). */
24
25 struct S {
26 typedef C = 0; /* { dg-error "does not name a type" "C" } */
27 C c; /* { dg-error "" "C error cascade" } */
28
29 typedef int D = 0; /* { dg-error "initialized" "D" } */
30 D d; /* { dg-bogus "" "D error cascade" } */
31 };
32
33 template<int> void foo()
34 {
35 typedef int i = 0; /* { dg-warning "is initialized" } */
36 }