1/*	$NetBSD: expr_promote_trad.c,v 1.4 2023/03/28 14:44:34 rillig Exp $	*/
2# 3 "expr_promote_trad.c"
3
4/*
5 * Test arithmetic promotions in traditional C.
6 */
7
8/* lint1-flags: -tw -X 351 */
9
10sink();
11
12struct arithmetic_types {
13	/* _Bool is not available in traditional C */
14	char plain_char;
15	/* signed char is not available in traditional C */
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	/* (unsigned) long long is not available in traditional C */
24	/* __int128_t is not available in traditional C */
25	/* __uint128_t is not available in traditional C */
26	float single_floating;
27	double double_floating;
28	/* long double is not available in traditional C */
29	/* _Complex is not available in traditional C */
30	enum {
31		E
32	} enumerator;
33};
34
35caller(arg)
36	struct arithmetic_types *arg;
37{
38	/* See expr_promote_trad.exp-ln for the resulting types. */
39	sink("",
40	    arg->plain_char,		/* gets promoted to 'int' */
41	    arg->unsigned_char,		/* gets promoted to 'unsigned int' */
42	    arg->signed_short,		/* gets promoted to 'int' */
43	    arg->unsigned_short,	/* gets promoted to 'unsigned int' */
44	    arg->signed_int,
45	    arg->unsigned_int,
46	    arg->signed_long,
47	    arg->unsigned_long,
48	    arg->single_floating,	/* gets promoted to 'double' */
49	    arg->double_floating,
50	    arg->enumerator);
51}
52
53/*
54 * XXX: Enumerations may need be promoted to 'int', at least C99 6.3.1.1p2
55 * suggests that: "If an int can represent ...".
56 */
57