xref: /netbsd-src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1 /*	$NetBSD: gcc_stmt_asm.c,v 1.4 2022/06/17 18:54:53 rillig Exp $	*/
2 # 3 "gcc_stmt_asm.c"
3 
4 /*
5  * Tests for the GCC 'asm' statement.
6  */
7 
8 void
9 function(void)
10 {
11 	/*
12 	 * lint is not really interested in assembly language, therefore it
13 	 * just skips everything until and including the closing parenthesis.
14 	 */
15 	asm(any "string" or 12345 || whatever);
16 
17 	/*
18 	 * Parentheses are allowed in 'asm' statements, they have to be
19 	 * properly nested.  Brackets and braces don't have to be nested
20 	 * since they usually not occur in 'asm' statements.
21 	 */
22 	__asm(^(int = typedef[[[{{{));
23 
24 	__asm__();
25 }
26 
27 /*
28  * Even on the top level, 'asm' is allowed.  It is interpreted as a
29  * declaration.
30  */
31 __asm__();
32 
33 void
34 syntax_error(void)
35 {
36 	/* expect+1: error: syntax error '__asm__' [249] */
37 	int i = __asm__();
38 }
39 
40 __asm__(
41 /* cover read_until_rparen at EOF */
42 /* expect+1: error: syntax error '' [249] */
43