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/>.
23 #include "testsubclass.hh"
25 void animal::moose::setFeet(int numfeet
) //^1^
28 std::cerr
<< "Why would a moose have more than 4 feet?" << std::endl
;
35 int animal::moose::getFeet() //^2^
40 void animal::moose::doNothing() //^3^
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" ) )
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.
81 void deer::alces::setLatin(bool l
) {
85 bool deer::alces::getLatin() {
89 void deer::alces::doLatinStuff(moose moosein
) {
90 // All these functions should be identified by semantic analyzer.
104 moose
deer::alces::createMoose()
106 moose MooseVariableName
;
112 MooseVariableName
= createMoose();
114 doLatinStuff(MooseVariableName
);
117 // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
121 // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
125 // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
129 // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
132 MooseVariableName
= m
// -5-
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();
152 // #5# ( "mMoose" "mOption1" "mPickle" )
160 // #6# ( "mMoose" "mOption2" "mPickle" )
166 // Thanks Ming-Wei Chang for this next example.
181 // #7# ( "private_a" "public_a" )
185 int some_regular_function(){
188 // #8# ( "public_a" )
196 /** Test Scope w/in a function (non-method) with classes using
197 * different levels of inheritance.
201 sneaky::antelope
Antelope(1);
202 sneaky::jackalope
Jackalope(1);
203 sneaky::bugalope
Bugalope(1);
206 // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
210 // #10# ( "fBunnyPublic" "testAccess")
220 // #11# ( "fBugPublic" "testAccess")
226 /** Test methods within each class for types of access to the baseclass.
229 bool sneaky::antelope::testAccess() //^7^
232 // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
236 bool sneaky::jackalope::testAccess() //^8^
239 // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
243 bool sneaky::bugalope::testAccess() //^9^
246 // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )