* doc/emacs/emacs.texi (Intro): Workaround makeinfo 4 @acronym bug.
[emacs/old-mirror.git] / test / cedet / tests / testsubclass.cpp
blob0565314cd8d547c617eb3d8b71d6b8245fb09e86
1 // testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
3 // Copyright (C) 2007-2014 Free Software Foundation, Inc.
5 // Author: Eric M. Ludlam <eric@siege-engine.com>
7 // This file is part of GNU Emacs.
9 // GNU Emacs is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
14 // GNU Emacs is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 //#include <iostream>
23 #include "testsubclass.hh"
25 void animal::moose::setFeet(int numfeet) //^1^
27 if (numfeet > 4) {
28 std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
29 return;
32 fFeet = numfeet;
35 int animal::moose::getFeet() //^2^
37 return fFeet;
40 void animal::moose::doNothing() //^3^
42 animal::moose foo();
44 fFeet = N// -15-
45 ; // #15# ( "NAME1" "NAME2" "NAME3" )
49 void deer::moose::setAntlers(bool have_antlers) //^4^
51 fAntlers = have_antlers;
54 bool deer::moose::getAntlers() //^5^
55 // %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
57 return fAntlers;
60 bool i_dont_have_symrefs()
61 // %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
65 void deer::moose::doSomething() //^6^
67 // All these functions should be identified by semantic analyzer.
68 getAntlers();
69 setAntlers(true);
71 getFeet();
72 setFeet(true);
74 doNothing();
76 fSomeField = true;
78 fIsValid = true;
81 void deer::alces::setLatin(bool l) {
82 fLatin = l;
85 bool deer::alces::getLatin() {
86 return fLatin;
89 void deer::alces::doLatinStuff(moose moosein) {
90 // All these functions should be identified by semantic analyzer.
91 getFeet();
92 setFeet(true);
94 getLatin();
95 setLatin(true);
97 doNothing();
99 deer::moose foo();
104 moose deer::alces::createMoose()
106 moose MooseVariableName;
107 bool tmp;
108 int itmp;
109 bool fool;
110 int fast;
112 MooseVariableName = createMoose();
114 doLatinStuff(MooseVariableName);
116 tmp = this.f// -1-
117 // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
120 itmp = this.f// -2-
121 // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
124 tmp = f// -3-
125 // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
128 itmp = f// -4-
129 // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
132 MooseVariableName = m// -5-
133 // #5# ( "moose" )
135 return MooseVariableName;
138 /** Test Scope Changes
140 * This function is rigged to make sure the scope changes to account
141 * for different locations in local variable parsing.
143 int someFunction(int mPickle)
145 moose mMoose = deer::alces::createMoose();
147 if (mPickle == 1) {
149 int mOption1 = 2;
151 m// -5-
152 // #5# ( "mMoose" "mOption1" "mPickle" )
155 } else {
157 int mOption2 = 2;
159 m// -6-
160 // #6# ( "mMoose" "mOption2" "mPickle" )
166 // Thanks Ming-Wei Chang for this next example.
168 namespace pub_priv {
170 class A{
171 private:
172 void private_a(){}
173 public:
174 void public_a();
177 void A::public_a() {
178 A other_a;
180 other_a.p// -7-
181 // #7# ( "private_a" "public_a" )
185 int some_regular_function(){
186 A a;
187 a.p// -8-
188 // #8# ( "public_a" )
190 return 0;
196 /** Test Scope w/in a function (non-method) with classes using
197 * different levels of inheritance.
199 int otherFunction()
201 sneaky::antelope Antelope(1);
202 sneaky::jackalope Jackalope(1);
203 sneaky::bugalope Bugalope(1);
205 Antelope.// -9-
206 // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
209 Jackalope.// -10-
210 // #10# ( "fBunnyPublic" "testAccess")
213 Jackalope// @1@ 6
215 Jackalope;
216 Jackalope;
217 Jackalope;
219 Bugalope.// -11-
220 // #11# ( "fBugPublic" "testAccess")
222 Bugalope// @2@ 3
226 /** Test methods within each class for types of access to the baseclass.
229 bool sneaky::antelope::testAccess() //^7^
231 this.// -12-
232 // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
236 bool sneaky::jackalope::testAccess() //^8^
238 this.// -13-
239 // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
243 bool sneaky::bugalope::testAccess() //^9^
245 this.// -14-
246 // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )