Debian Codegraph @

gcc/testsuite/gm2/builtins/run/pass/testalloa.mod

raw
1 MODULE testalloa ;
2
3 FROM libc IMPORT printf, exit ;
4 FROM Builtins IMPORT alloca ;
5 FROM SYSTEM IMPORT ADR, ADDRESS ;
6
7
8 (*
9 assert -
10 *)
11
12 PROCEDURE assert (value: BOOLEAN; message: ARRAY OF CHAR) ;
13 BEGIN
14 IF NOT value
15 THEN
16 printf ("test failed: %s\n", ADR (message)) ;
17 code := 1
18 END
19 END assert ;
20
21
22 (*
23 test -
24 *)
25
26 PROCEDURE test ;
27 VAR
28 ptr: ADDRESS ;
29 BEGIN
30 ptr := alloca (10) ;
31 assert (ptr # NIL, "alloca (10) # NIL")
32 END test ;
33
34
35 VAR
36 code: INTEGER ;
37 BEGIN
38 code := 0 ;
39 test ;
40 IF code = 0
41 THEN
42 printf ("all tests pass\n")
43 ELSE
44 printf ("some tests failed\n")
45 END ;
46 exit (code)
47 END testalloa.