d_alignof.c revision 1.5
1/*	$NetBSD: d_alignof.c,v 1.5 2022/05/12 00:28:01 rillig Exp $	*/
2# 3 "d_alignof.c"
3
4/* https://gcc.gnu.org/onlinedocs/gcc/Alignment.html */
5
6unsigned long
7leading_and_trailing_alignof_type(void)
8{
9	return __alignof__(short);
10}
11
12unsigned long
13leading_alignof_type(void)
14{
15	return __alignof(short);
16}
17
18unsigned long
19plain_alignof_type(void)
20{
21	/* The plain word 'alignof' is not recognized by GCC. */
22	/* expect+2: error: function 'alignof' implicitly declared to return int [215] */
23	/* expect+1: error: syntax error 'short' [249] */
24	return alignof(short);
25}
26/* expect-1: warning: function plain_alignof_type falls off bottom without returning value [217] */
27
28unsigned long
29leading_and_trailing_alignof_expr(void)
30{
31	return __alignof__ 3;
32}
33
34unsigned long
35leading_alignof_expr(void)
36{
37	return __alignof 3;
38}
39
40unsigned long
41plain_alignof_expr(void)
42{
43	/* The plain word 'alignof' is not recognized by GCC. */
44	/* expect+2: error: 'alignof' undefined [99] */
45	/* expect+1: error: syntax error '3' [249] */
46	return alignof 3;
47}
48/* expect-1: warning: function plain_alignof_expr falls off bottom without returning value [217] */
49