File: forward-inner.C

package info (click to toggle)
gcc-arm-none-eabi 15%3A8-2019-q3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 571,828 kB
  • sloc: ansic: 2,937,651; cpp: 881,644; ada: 597,189; makefile: 65,528; asm: 56,499; xml: 46,621; exp: 24,747; sh: 19,684; python: 7,256; pascal: 4,370; awk: 3,497; perl: 2,695; yacc: 316; ml: 285; f90: 234; lex: 198; objc: 194; haskell: 119
file content (81 lines) | stat: -rw-r--r-- 2,218 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Check that the compiler warns about inner-style forward declarations in
// contexts where they're not actually illegal, but merely useless.

// Verify warnings for and within classes, and by extension, struct and union.
class C1;
class C1::C2;      // { dg-error "incomplete" }
class C1::C2::C3;  // { dg-error "has not been declared" }

class C1 {
 public:
  class C2;
  class C2::C3;    // { dg-error "incomplete" }
  class C2 {
   public:
    class C3;
    class C3 { };
    class C3;
  };
  class C2;
  class C2::C3;    // { dg-warning "declaration 'class C1::C2::C3' does not declare anything" }
};

class C1;
class C1::C2;      // { dg-warning "declaration 'class C1::C2' does not declare anything" }
class C1::C2::C3;  // { dg-warning "declaration 'class C1::C2::C3' does not declare anything" }


// Verify warnings for namespace scopes.
class N1::C4;      // { dg-error "has not been declared" }
class N1::N2::C5;  // { dg-error "has not been declared" }

namespace N1 {
  class C4;
  class C4 { };
  class C4;

  class N2::C5;    // { dg-error "has not been declared" }
  namespace N2 {
    class C5;
    class C5 { };
    class C5;
  }
  class N2::C5;    // { dg-warning "declaration 'class N1::N2::C5' does not declare anything" }
}

class N1::C4;      // { dg-warning "declaration 'class N1::C4' does not declare anything" }
class N1::N2::C5;  // { dg-warning "declaration 'class N1::N2::C5' does not declare anything" }


// Verify that using declarations related to namespaces don't generate a
// warning.
using namespace N1;
using namespace N1::N2;

namespace N3 {
  using N1::C4;      // Valid using declaration, no warning
  using N1::N2::C5;  // Valid using declaration, no warning
}


// Verify that explicit template instantiations, easy to confuse with
// forward declarations, don't generate a warning.
template<class C>
class TC6 {
 public:
  class TC7 { };
};

template class TC6<int>::TC7;  // Valid explicit instantiation, no warning


// Verify that friend declarations, also easy to confuse with forward
// declrations, are similarly not warned about.
class C8 {
 public:
  class C9 { };
};
class C10 {
 public:
  friend class C8::C9;         // Valid friend declaration, no warning
};