File: n_13_8.c

package info (click to toggle)
mcpp 2.7.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,024 kB
  • ctags: 29,151
  • sloc: ansic: 35,191; sh: 9,231; makefile: 176; cpp: 84; exp: 18
file content (46 lines) | stat: -rw-r--r-- 1,257 bytes parent folder | download | duplicates (8)
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
/* n_13_8.c:    Grouping of sub-expressions in #if expression.  */

#include    "defs.h"

main( void)
{
    fputs( "started\n", stderr);

/* 13.8:    Unary operators are grouped from right to left. */
#if (- -1 != 1) || (!!9 != 1) || (-!+!9 != -1) || (~~1 != 1)
    fputs( "Bad grouping of -, +, !, ~ in #if expression.\n", stderr);
    exit( 1);
#endif

/* 13.9:    ?: operators are grouped from right to left.    */
#if (1 ? 2 ? 3 ? 3 : 2 : 1 : 0) != 3
    fputs( "Bad grouping of ? : in #if expression.\n", stderr);
    exit( 1);
#endif

/* 13.10:   Other operators are grouped from left to right. */
#if (15 >> 2 >> 1 != 1) || (3 << 2 << 1 != 24)
    fputs( "Bad grouping of >>, << in #if expression.\n", stderr);
    exit( 1);
#endif

/* 13.11:   Test of precedence. */
#if 3*10/2 >> !0*2 >> !+!-9 != 1
    fputs( "Bad grouping of -, +, !, *, /, >> in #if expression.\n", stderr);
    exit( 1);
#endif

/* 13.12:   Overall test.  Grouped as:
        ((((((+1 - -1 - ~~1 - -!0) & 6) | ((8 % 9) ^ (-2 * -2))) >> 1) == 7)
        ? 7 : 0) != 7
    evaluated to FALSE.
 */
#if (((+1- -1-~~1- -!0&6|8%9^-2*-2)>>1)==7?7:0)!=7
    fputs( "Bad arithmetic of #if expression.\n", stderr);
    exit( 1);
#endif

    fputs( "success\n", stderr);
    return  0;
}