expr_precedence.c revision 1.2 1 /* $NetBSD: expr_precedence.c,v 1.2 2021/07/15 17:20:58 rillig Exp $ */
2 # 3 "expr_precedence.c"
3
4 /*
5 * Tests for the precedence among operators.
6 */
7
8 int var;
9
10 /*
11 * An initializer needs an assignment-expression; the comma must be
12 * interpreted as a separator, not an operator.
13 */
14 /* expect+1: error: syntax error '4' [249] */
15 int init_error = 3, 4;
16
17 /* expect+1: error: non-constant initializer [177] */
18 int init_syntactically_ok = var = 1 ? 2 : 3;
19
20 /*
21 * The arguments of __attribute__ must be constant-expression, as assignments
22 * don't make sense at that point.
23 */
24 void __attribute__((format(printf,
25 /* expect+2: error: 'var' undefined [99] */ /* XXX: why? */
26 /* expect+1: syntax error '=' [249] */
27 var = 1,
28 /* Syntactically ok, must be a constant expression though. */
29 var > 0 ? 2 : 1)))
30 my_printf(const char *, ...);
31