1 // { dg-options "-fdiagnostics-show-caret" }
2 
3 enum { LASAGNA, SPAGHETTI };
4 namespace outer_ns_a
5 {
6   enum enum_in_outer_ns_a { STRAWBERRY, BANANA };
7   namespace inner_ns
8   {
9     enum enum_in_inner_ns { ELEPHANT, LION };
10   }
11 }
12 namespace outer_ns_b
13 {
14   enum enum_in_outer_ns_b { NIGHT, DAY };
15 }
16 
misspelled_enum_in_global_ns()17 void misspelled_enum_in_global_ns ()
18 {
19   SPOOGHETTI; // { dg-error "'SPOOGHETTI' was not declared in this scope; did you mean 'SPAGHETTI'" }
20   /* { dg-begin-multiline-output "" }
21    SPOOGHETTI;
22    ^~~~~~~~~~
23    SPAGHETTI
24      { dg-end-multiline-output "" } */
25 }
26 
unqualified_enum_in_outer_ns()27 void unqualified_enum_in_outer_ns ()
28 {
29   BANANA; // { dg-error "'BANANA' was not declared in this scope; did you mean 'outer_ns_a::BANANA'" }
30   /* { dg-begin-multiline-output "" }
31    BANANA;
32    ^~~~~~
33    outer_ns_a::BANANA
34      { dg-end-multiline-output "" } */
35   /* { dg-begin-multiline-output "" }
36    enum enum_in_outer_ns_a { STRAWBERRY, BANANA };
37                                          ^~~~~~
38      { dg-end-multiline-output "" } */
39 }
40 
41 namespace outer_ns_a
42 {
misspelled_unqualified_enum_in_outer_ns()43   void misspelled_unqualified_enum_in_outer_ns () {
44     BANANAS; // { dg-error "'BANANAS' was not declared in this scope; did you mean 'BANANA'" }
45   /* { dg-begin-multiline-output "" }
46      BANANAS;
47      ^~~~~~~
48      BANANA
49      { dg-end-multiline-output "" } */
50   }
51 };
52 
unqualified_enum_in_inner_ns()53 void unqualified_enum_in_inner_ns ()
54 {
55   ELEPHANT; // { dg-error "'ELEPHANT' was not declared in this scope; did you mean 'outer_ns_a::inner_ns::ELEPHANT'" }
56   /* { dg-begin-multiline-output "" }
57    ELEPHANT;
58    ^~~~~~~~
59    outer_ns_a::inner_ns::ELEPHANT
60      { dg-end-multiline-output "" } */
61   /* { dg-begin-multiline-output "" }
62      enum enum_in_inner_ns { ELEPHANT, LION };
63                              ^~~~~~~~
64      { dg-end-multiline-output "" } */
65 }
66 
partially_qualified_enum_in_inner_ns()67 void partially_qualified_enum_in_inner_ns ()
68 {
69   outer_ns_a::ELEPHANT; // { dg-error "'ELEPHANT' is not a member of 'outer_ns_a'; did you mean 'outer_ns_a::inner_ns::ELEPHANT'" }
70   /* { dg-begin-multiline-output "" }
71    outer_ns_a::ELEPHANT;
72                ^~~~~~~~
73      { dg-end-multiline-output "" } */
74   /* { dg-begin-multiline-output "" }
75      enum enum_in_inner_ns { ELEPHANT, LION };
76                              ^~~~~~~~
77      { dg-end-multiline-output "" } */
78 }
79 
wrongly_qualified_enum()80 void wrongly_qualified_enum ()
81 {
82   outer_ns_a::NIGHT; // { dg-error "'NIGHT' is not a member of 'outer_ns_a'; did you mean 'outer_ns_b::NIGHT'" }
83   /* { dg-begin-multiline-output "" }
84    outer_ns_a::NIGHT;
85                ^~~~~
86      { dg-end-multiline-output "" } */
87   /* { dg-begin-multiline-output "" }
88    enum enum_in_outer_ns_b { NIGHT, DAY };
89                              ^~~~~
90      { dg-end-multiline-output "" } */
91 }
92