1 /* $NetBSD: expr_promote.c,v 1.1 2021/08/16 20:11:03 rillig Exp $ */ 2 # 3 "expr_promote.c" 3 4 /* 5 * Test arithmetic promotions in C90 and later. 6 */ 7 8 /* lint1-flags: -Sw */ 9 10 void sink(const char *, ...); 11 12 struct arithmetic_types { 13 _Bool boolean; 14 char plain_char; 15 signed char signed_char; 16 unsigned char unsigned_char; 17 short signed_short; 18 unsigned short unsigned_short; 19 int signed_int; 20 unsigned int unsigned_int; 21 long signed_long; 22 unsigned long unsigned_long; 23 long long signed_long_long; 24 unsigned long long unsigned_long_long; 25 float float_floating; 26 double double_floating; 27 long double long_floating; 28 float _Complex float_complex; 29 double _Complex double_complex; 30 long double _Complex long_double_complex; 31 }; 32 33 void 34 caller(struct arithmetic_types *arg) 35 { 36 sink("", 37 arg->boolean, /* gets promoted to 'int' */ 38 arg->plain_char, /* gets promoted to 'int' */ 39 arg->signed_char, /* gets promoted to 'int' */ 40 arg->unsigned_char, /* gets promoted to 'int' */ 41 arg->signed_short, /* gets promoted to 'int' */ 42 arg->unsigned_short, /* gets promoted to 'int' */ 43 arg->signed_int, 44 arg->unsigned_int, 45 arg->signed_long, 46 arg->unsigned_long, 47 arg->signed_long_long, 48 arg->unsigned_long_long, 49 arg->float_floating, /* gets promoted to 'double' */ 50 arg->double_floating, 51 arg->long_floating, 52 arg->float_complex, 53 arg->double_complex, 54 arg->long_double_complex); 55 } 56 57 /* XXX: _Bool is not promoted but should. */ 58