Skip to main content
summaryrefslogtreecommitdiffstats
blob: c3f7834b32d53858c63a1644376372ec9c0535bb (plain) (blame)
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
#include "occurrences.h"

#define INT      int
#define FUNCTION_MACRO(arg) globalFunc(arg)
#define EMPTY_MACRO(arg) 

enum Enumeration {
	ONE, TWO, THREE
};

const int globalConstant = 0;
int globalVariable = 0;
static int globalStaticVariable = 0;

void globalFunc(int a);
static void globalStaticFunc() {
    EMPTY_MACRO(n);
	globalVariable = 1;
    EMPTY_MACRO(1);
    return 0;
}

class Base1 {
	Base1();
	~Base1();
};

Base1::~Base1() {}
Base1::Base1() {}

Base2::Base2() {}
void Base2::foo() {}

class ClassContainer : Base1, Base2 {
public:
	static int staticPubField;
	const int constPubField;
	const static int constStaticPubField;
	size_t pubField;

	static INT staticPubMethod(int arg) {
		FUNCTION_MACRO(arg);
		globalFunc(arg);
		return globalStaticVariable;
	}
	int pubMethod();

	typedef float pubTypedef;
	pubTypedef tdField;
private:
	static INT staticPrivMethod();
};

template<class T1, class T2> class TemplateClass {
	T1 tArg1;
	T2 tArg2;
	TemplateClass(T1 arg1, T2 arg2) {
		tArg1 = arg1;
		tArg2 = arg2;
	}
	void m(TemplateClass&);
};

template<class T1> class PartialInstantiatedClass : TemplateClass<T1, Base1> {
};

struct CppStruct {
	CppStruct() {}
	int structField;
};

union CppUnion {
	int unionField;
};

typedef CppUnion TUnion;

namespace ns {
int namespaceVar = 0;
int namespaceFunc() {
	globalStaticFunc();
	TUnion tu;
	Enumeration e= TWO;
	switch (e) {
	case ONE: case THREE:
		return 1;
	}
	size_t size;
	return namespaceVar;
}
}

INT ClassContainer::pubMethod() {
	int localVar = 0;
	ns::namespaceVar= 1;
	return pubField + localVar;
}

using namespace ns;
//using ns::namespaceVar;

INT ClassContainer::staticPrivMethod() {
	CppStruct* st= new CppStruct();
	st->structField= namespaceVar;
	CppUnion un;
	un.unionField= 2;
	staticPubMethod(staticPubField);
label:
	FUNCTION_MACRO(0);
	if (un.unionField < st->structField) 
		goto label;
	return globalConstant;
}

template<int X>
class ConstantTemplate {
public:
	size_t getNumber(size_t y) {
		return X;
	}
};

ConstantTemplate<5> c5;
ConstantTemplate<5> c52;
ConstantTemplate<4> c4;

const int c= c5.getNumber(0);

Back to the top