File: compound

package info (click to toggle)
tcng 10b-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,632 kB
  • ctags: 2,515
  • sloc: ansic: 19,038; pascal: 4,640; yacc: 2,619; sh: 1,908; perl: 1,546; lex: 772; makefile: 755
file content (71 lines) | stat: -rw-r--r-- 2,059 bytes parent folder | download | duplicates (5)
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
# compound construct with single expression -----------------------------------
tcc -c -u stderr -Wnounused 2>&1 >/dev/null
$x = { 5; };
EOF
$x = 5
# compound construct can be anywhere in expression ----------------------------
tcc -c -u stderr -Wnounused 2>&1 >/dev/null
$y = 7*({ 5; }+1);
EOF
$y = 42
# compound construct with assignment ------------------------------------------
tcc -c -u stderr -Wnounused 2>&1 >/dev/null
$z = { $z = 10; $z+5; };
EOF
{
$z = 10
}
$z = 15
# compound construct with multiple assignments --------------------------------
tcc -c -u stderr -Wnounused 2>&1 >/dev/null
$z = { $x = 10; $y = 8; $x << $y; }/60;
EOF
{
$x = 10
$y = 8
}
$z = 42
# compound construct must end with semicolon ----------------------------------
tcc -c -u stderr -Wnounused 2>&1
$z = { 5 };
EOF
ERROR
<stdin>:1: syntax error near "}"
# compound construct may end with multiple semicolons -------------------------
tcc -c -Wnounused 2>&1
$a = { 5;;;; };
EOF
# compound construct requires semicolon after assignment ----------------------
tcc -c -Wnounused 2>&1
$a = { $x=2 $x+5; };
EOF
ERROR
<stdin>:1: syntax error near "$x"
# compound construct allows multiple semicolons after assignment --------------
tcc -c -Wnounused 2>&1
$a = { $x=2;; $x+5; };
EOF
# compound construct warns about unused variables -----------------------------
tcc -c 2>&1
$a = { $x = 13; 7; };
field foo = raw if $a == $a;
EOF
<stdin>:1: warning: unused variable x
# compound expressions may contain fields -------------------------------------
tcc -c -Wnounused 2>&1
$a = { field foo = raw; 5; };
EOF
# compound expressions require semicolon after field --------------------------
tcc -c -Wnounused 2>&1
$a = { field foo = raw 5; };
EOF
ERROR
<stdin>:1: syntax error near "5"
# compound expressions allow multiple semicolons after field ------------------
tcc -c -Wnounused 2>&1
$a = { field foo = raw;;;; 5; };
EOF
# compound expressions can use gcc syntax -------------------------------------
tcc -c -Wnounused 2>&1
$foo = ({ $x = 17; field foo = raw[2] if $x; $x*2; });
EOF