annotate test/cedet/tests/testusing.cpp @ 105328:2f2bc20297c6

Doc/message fixes.
author Glenn Morris <rgm@gnu.org>
date Thu, 01 Oct 2009 03:08:03 +0000
parents e480034314ce
children 7f4c7f5c0eba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104494
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 // Test using statements in C++
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 #include <adstdio.h>
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 #include <testusing.hh>
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 namespace moose {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 class MyClass;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 class Point;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 typedef MyClass snerk;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 namespace moose {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 class Point;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 class MyClass;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 namespace {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 int global_variable = 0;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 };
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 using moose::MyClass;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 void someFcn() {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 MyClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 f.//-1-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ; //#1# ( "getVal" "setVal" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 // Code from Zhiqiu Kong
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 namespace panda {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 using namespace bread_name;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 int func()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 bread test;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 test.//-2-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;// #2# ( "geta" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 return 0;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 // Local using statements and aliased types
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 // Code from David Engster
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 void func2()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 using namespace somestuff;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 OneClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 f.//-3-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ; //#3# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 void func3()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 using somestuff::OneClass;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 OneClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 f.//-4-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ; //#4# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 // Dereferencing alias types created through 'using' statements
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 // Alias with fully qualified name
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 void func4()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 otherstuff::OneClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 f. //-5-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 ; //#5# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 // Alias through namespace directive
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 void func5()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 using namespace otherstuff;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 OneClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 f. //-6-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ; //#6# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 // Check name hiding
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 void func6()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 using namespace morestuff;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 OneClass f; // Alias for somestuff::OneClass
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 f. //-7-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ; //#7# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 aStruct g; // This however is morestuff::aStruct !
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 g. //-8-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ; //#8# ( "anotherBar" "anotherFoo" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 // Alias of an alias
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 // Currently doesn't work interactively for some reason.
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 void func6()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 using namespace evenmorestuff;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 OneClass f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 f. //-7-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 ; //#7# ( "aFunc" "anInt" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 // Alias for struct in nested namespace, fully qualified
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 void func7()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 outer::StructNested f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 f.//-8-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 ; //#8# ( "one" "two" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 }
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 // Alias for nested namespace
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 void func8()
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 {
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 using namespace outerinner;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 StructNested f;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 AnotherStruct g;
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 f.//-9-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ; //#9# ( "one" "two" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 g.//-10-
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ; //#10# ( "four" "three" )
e480034314ce Add Semantic unit tests.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 }