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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
|
/* Test file for C++ language.
* Attempt to include as many aspects of the C++ language as possible.
* Do not include things tested in test.c since that shares the
* same language.
*
* $Id: test.cpp,v 1.2 2009/09/28 23:23:31 cyd Exp $
*
*/
/* An include test */
#include <stdio.h>
#include <cmath>
#include "c++-test.hh"
#include <c++-test.hh>
double var1 = 1.2;
int simple1(int a) {
}
struct foo1 {
int test;
};
struct foo2 : public foo1 {
const int foo21(int a, int b);
const int foo22(int a, int b) { return 1 }
};
/* Classes */
class class1 {
private:
int var11;
struct foo1 var12;
public:
int p_var11;
struct foo p_var12;
};
class i_class1 : public class1 {
private:
int var11;
struct foo var12;
public:
int p_var11;
struct foo p_var12;
};
class class2 {
private:
int var21;
struct foo var22;
public:
int p_var21;
struct foo p_var22;
};
class i_class2 : public class1, public class2 {
private:
int var21;
struct foo var22;
protected:
int pt_var21;
public:
int p_var21;
struct foo p_var22;
};
class class3 {
/* A class with strange things in it */
public:
class3(); /* A constructor */
enum embedded_foo_enum {
a, b, c
} embed1;
struct embedded_bar_struct {
int a;
int b;
} embed2;
class embedded_baz_class {
embedded_baz_class();
~embedded_baz_class();
} embed3;
~class3(); /* destructor */
/* Methods */
int method_for_class3(int a, char b);
int inline_method(int c) { return c; }
/* Operators */
class3& operator^= (const class3& something);
/* Funny declmods */
const class3 * const method_const_ptr_ptr(const int * const argconst) const = 0;
};
class3::class3()
{
/* Constructor outside the definition. */
}
int class3::method_for_class3(int a, char b)
{
}
int class3::method1_for_class3( int a, int &b)
{
int cvariablename;
class3 fooy[];
class3 moose = new class3;
// Complktion testing line should find external members.
a = fooy[1].me ;
b = cv ;
if (fooy.emb) {
simple1(c);
}
cos(10);
abs(10);
return 1;
}
char class3::method2_for_class3( int a, int b) throw ( exception1 )
{
return 'a';
}
void *class3::method3_for_class3( int a, int b) throw ( exception1, exception2 )
{
int q = a;
return "Moose";
}
void *class3::method31_for_class3( int a, int b) throw ( )
{
int q = a;
return "Moose";
}
void *class3::method4_for_class3( int a, int b) reentrant
{
class3 ct;
ct.method5_for_class3(1,a);
pritf();
}
/*
* A method on class3.
*/
void *class3::method5_for_class3( int a, int b) const
{
}
/*
* Namespace parsing tests
*/
namespace NS {
class class_in_namespace {
int equiv(const NS::class_in_namespace *) const;
};
}
int NS::class_in_namespace::equiv(const NS::class_in_namespace *cin) const
{
return 0;
}
// Stuff Klaus found.
// Inheritance w/out a specifying for public.
class class4 : class1 {
// Pure virtual methods.
void virtual print () const = 0;
public:
// The whacky constructor type
class4()
try : class1(args)
{
// constructor body
}
catch ()
{
}
};
class class5 : public virtual class4 {
// Virtual inheritance
};
class class6 : class1 {
// Mutable
mutable int i;
};
/* Namespaces */
namespace namespace1 {
void ns_method1() { }
class n_class1 {
public:
void method11(int a) { }
};
/* This shouldn't parse due to missing semicolon. */
class _n_class2 : public n_class1 {
void n_c2_method1(int a, int b) { }
};
// Macros in the namespace
#define NSMACRO 1
// Template in the namespace
template<class T> T nsti1(const Foo& foo);
template<> int nsti1<int>(const Foo& foo);
}
namespace namespace2 {
using namespace1::n_class1;
}
/* Initializers */
void tinitializers1(): inita1(False),
inita2(False)
{
inita1= 1;
}
/* How about Extern C type things. */
int funny_prototype(int ,int b,float c)
{
}
extern "C"
int extern_c_1(int a, int b)
{
funny_prototype(1,2,3.4);
printf("Moose", );
return 1;
}
extern "C" {
int extern_c_2(int a, int b)
{
return 1;
}
}
// Some operator stuff
class Action
{
// Problems!! operator() and operator[] can not be parsed with semantic
// 1.4.2 but with latest c.by
virtual void operator()(int i, char *p ) = 0;
virtual String& operator[]() = 0;
virtual void operator!() = 0;
virtual void operator->() = 0;
virtual T& operator+=();
virtual T& operator*();
virtual T& operator*=();
};
// class with namespace qualified parents
class Multiinherit : public virtual POA::Parent,
public virtual POA::Parent1,
Parent
{
private:
int i;
public:
Multiinherit();
~Multiinherit();
// method with a list of qualified exceptions
void* throwtest()
throw(Exception0,
Testnamespace::Exception1,
Testnamespace::Excpetion2,
Testnamespace::testnamespace1::Exception3);
};
void*
Multiinherit::throwtest()
throw (Exception0,
Testnamespace::Exception1,
Testnamespace::Excpetion2,
Testnamespace::testnamespace1::Exception3)
{
return;
}
// Jens Rock <jens.rock@asamnet.de>: Nested classes or structs defined
// outside of the containing class/struct.
class container
{
public:
struct contained;
container();
~container();
};
struct container::contained
{
public:
contained();
~contained();
};
/*
* Ok, how about some template stuff.
*/
template <class CT, class container = vector<CT> >
const CT& max (const CT& a, const CT& b)
{
return a < b ? b : a;
}
// Arne Schmitz found this one
std::vector<int> &a, &b, &c;
class TemplateUsingClass
{
typedef TestClassMap::iterator iterator;
typedef map<long, long> TestClassMap;
// typedefs with const and volatile
typedef const map<long, long> const_TestClassMap;
typedef TestClassMap<string>::iterator volatile volatile_iterator;
map<int, int> mapclassvarthingy;
};
template<class T> T ti1(const Foo& foo);
template<> int ti1<int>(const Foo& foo);
// -----------------------------------
// Now some namespace and related stuff
// -----------------------------------
using CORBA::LEX::get_token;
using Namespace1;
using namespace POA::std;
using namespace Test;
namespace Parser
{
namespace
{
using Lexer::get_test;
string str = "";
}
namespace XXX
{
class Foobar : public virtual POA::Parent,
public virtual POA::Parent1,
private POA::list<fact>,
private map<string>
{
ini i;
list <shared_ptr<item> >::const_iterator l;
public:
Foobar();
~Foobar();
};
}
void test_function(int i);
};
// unnamed namespaces - even nested
namespace
{
namespace
{
using Lexer::get_test;
string str = "";
}
// some builtin types
long long ll = 0;
long double d = 0.0;
unsigned test;
unsigned long int **uli = 0;
signed si = 0;
signed short ss = 0;
short int i = 0;
long int li = 0;
// expressions with namespace/class-qualifyiers
ORB_var cGlobalOrb = ORB::_nil();
ORB_var1 cGlobalOrb1 = ORB::_test;
class Testclass
{
#define TEST 0
ini i;
public:
Testclass();
~Testclass();
};
static void test_function(unsigned int i);
};
// outside method implementations which should be grouped to type Test
XXX&
Test::waiting()
{
return;
}
void
Test::print()
{
return;
}
// outside method implementations with namespaces which should be grouped to
// their complete (incl. namespace) types
void*
Parser::XXX::Foobar::wait(int i, const char const * const * p)
{
return;
}
void*
Namespace1::Test::wait1(int i)
{
return;
}
int
Namespace1::Test::waiting(int i)
{
return;
}
// a class with some outside implementations which should all be grouped to
// this class declaration
class ClassWithExternals
{
private:
int i;
public:
ClassWithExternals();
~ClassWithExternals();
void non_nil();
};
// Foobar is not displayed; seems that semantic tries to add this to the class
// Foobar but can not find/display it, because contained in the namespace above.
void
Foobar::non_nil()
{
return;
}
// are correctly grouped to the ClassWithExternals class
void
ClassWithExternals::non_nil()
{
String s = "lödfjg dlfgkdlfkgjdl";
return;
}
ClassWithExternals::ClassWithExternals()
{
return;
}
void
ClassWithExternals::~ClassWithExternals()
{
return;
}
// -------------------------------
// Now some macro and define stuff
// -------------------------------
#define TEST 0
#define TEST1 "String"
// The first backslash makes this macro unmatched syntax with semantic 1.4.2!
// With flexing \+newline as nothing all is working fine!
#define MZK_ENTER(METHOD) \
{ \
CzkMethodLog lMethodLog(METHOD,"Framework");\
}
#define ZK_ASSERTM(METHOD,ASSERTION,MESSAGE) \
{ if(!(ASSERTION))\
{\
std::ostringstream lMesgStream; \
lMesgStream << "Assertion failed: " \
<< MESSAGE; \
CzkLogManager::doLog(CzkLogManager::FATAL,"",METHOD, \
"Assert",lMesgStream); \
assert(ASSERTION);\
}\
}
// Test if not newline-backslashes are handled correctly
string s = "My \"quoted\" string";
// parsed fine as macro
#define FOO (arg) method(arg, "foo");
// With semantic 1.4.2 this parsed as macro BAR *and* function method.
// With latest c.bnf at least one-liner macros can be parsed correctly.
#define BAR (arg) CzkMessageLog method(arg, "bar");
// some const and volatile stuff
char * p1 = "Hello"; // 1. variable Pointer, variable Data
const char * p2 = "Hello"; // 2. variable pointer, constant data
char * const p3 = "Hello"; // 3. constant pointer, variable data
const char * const p4 = "Hello"; // 4. constant pointer, constant data
// Case 2 and 4 can exchange first "const" and "char"
char const * p21 = "Hello"; // variable pointer, constant data
char const * const p41 = "Hello"; // constant pointer, constant data
char volatile a = 0; // a volatile char
void foo(bar const &arg); // a reference to a const bar
int foobar(bar const * const p); // a const pointer to a const bar
int foobar(bar const volatile * const p); // a const pointer to a const bar
int foobar3(char* p); // a const pointer to a const bar
// Should not be parsed because this is invalid code
int const & const r3 = i;
boolean i = 0;
boolean & r1 = i;
boolean const & r2 = i;
// const * sequences can be very long in C++ ;-)
char const * const * const * const * ppp;
// complex function declarationen with named pointer-arguments
const char** foobar1(volatile char const * const **p);
const char** foobar11(volatile Test::Namespace::Char<char*> const * const **p);
// complex function declarationen with unnamed pointer-arguments
const char* foobar2(const char***);
const char* foobar21(const Test::Namespace::Char<char>***);
// string literal parsing even with wchar_t
char const *p = "string1";
char const *q = "string1" "str\"ing2" "string3";
wchar_t testc = L'a';
wchar_t const *wp = L"string with a \" in it";
wchar_t const *wq = L"string \n\t\"test" L"string2";
wchar_t const *wr = L"string L";
// arch-tag: 59828880-d72f-4059-922f-89579edf9e58
|