summaryrefslogtreecommitdiffstats
path: root/src/interfaces/ecpg/test/preproc/init.pgc
blob: b1f71997a2ae5422a97f4b1bc243e1fc91379480 (plain)
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
exec sql include sqlca;

enum e { ENUM0, ENUM1 };
struct sa { int member; };

static int fa(void)
{
	printf("in fa\n");
	return 2;
}

static int
fb(int x)
{
	printf("in fb (%d)\n", x);
	return x;
}

static int
fc(const char *x)
{
	printf("in fc (%s)\n", x);
	return *x;
}

static int fd(const char *x,int i)
{
	printf("in fd (%s, %d)\n", x, i);
	return (*x)*i;
}

static int fe(enum e x)
{
	printf("in fe (%d)\n", (int) x);
	return (int)x;
}

static void sqlnotice(const char *notice, short trans)
{
	if (!notice)
		notice = "-empty-";
	printf("in sqlnotice (%s, %d)\n", notice, trans);
}

exec sql define NONO 0;

#define YES 1

#ifdef _cplusplus
namespace N
{
	static const int i=2;
};
#endif

int main(void)
{
	struct sa x = { 14 },*y = &x;
	exec sql begin declare section;
		int a=(int)2;
		int b=2+2;
		int b2=(14*7);
		int d=x.member;
		int g=fb(2);
		int i=3^1;
		int j=1?1:2;

		int e=y->member;
		int c=10>>2;
		bool h=2||1;
		long iay /* = 1L */ ;
	exec sql end declare section;

	int f=fa();

#ifdef _cplusplus
	exec sql begin declare section;
	int k=N::i; /* compile error */
	exec sql end declare section;
#endif

	ECPGdebug(1, stderr);

	printf("%d %d %d %d %d %d %d %d %d %d %d\n", a, b, b2, c, d, e, f, g, h, i, j);
	iay = 0;
	printf("%ld\n", iay);
	exec sql whenever sqlerror do fa();
	exec sql select now();
	exec sql whenever sqlerror do fb(20);
	exec sql select now();
	exec sql whenever sqlerror do fc("50");
	exec sql select now();
	exec sql whenever sqlerror do fd("50",1);
	exec sql select now();
	exec sql whenever sqlerror do fe(ENUM0);
	exec sql select now();
	exec sql whenever sqlerror do sqlnotice(NULL, NONO);
	exec sql select now();
	return 0;
}