Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.brendan/nest18.C

raw
1 // { dg-do assemble }
2 // GROUPS passed nested-classes
3 // This is the first line of file ||t2.C||.
4
5 // This code demonstrates what appears to be a bug with nested types.
6 // In C++, nested typedefs are not supposed to be visible outside
7 // their class scopes but they apparently are in gcc 2.4.5. This code
8 // compiles fine in AT&T cfront 3.0.1, but will not compile with gcc.
9
10 // If this class does not precede String, then the code will compile.
11
12 class Another {
13 public:
14 typedef int Length;
15 };
16
17 // If String does not define typedef int Length, then the code will
18 // compile.
19
20 class String {
21 public:
22 typedef int Length; // remove this and it will compile fine
23
24 int foo(Length length) const;
25 };
26
27 int String::foo(Length length) const {
28 return length;
29 }
30
31 // File ||t2.C|| ends here.