xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/asm.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc 
f1()3f4a2713aSLionel Sambuc void f1() {
4f4a2713aSLionel Sambuc   // PR7673: Some versions of GCC support an empty clobbers section.
5f4a2713aSLionel Sambuc   asm ("ret" : : :);
6f4a2713aSLionel Sambuc }
7f4a2713aSLionel Sambuc 
f2()8f4a2713aSLionel Sambuc void f2() {
9f4a2713aSLionel Sambuc   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
10f4a2713aSLionel Sambuc   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}}
11f4a2713aSLionel Sambuc 
12f4a2713aSLionel Sambuc   asm const (""); // expected-warning {{ignored const qualifier on asm}}
13f4a2713aSLionel Sambuc   asm volatile ("");
14f4a2713aSLionel Sambuc   asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
15f4a2713aSLionel Sambuc   // FIXME: Once GCC supports _Atomic, check whether it allows this.
16f4a2713aSLionel Sambuc   asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
17f4a2713aSLionel Sambuc }
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc 
20f4a2713aSLionel Sambuc // rdar://5952468
21f4a2713aSLionel Sambuc __asm ; // expected-error {{expected '(' after 'asm'}}
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc // <rdar://problem/10465079> - Don't crash on wide string literals in 'asm'.
24f4a2713aSLionel Sambuc int foo asm (L"bar"); // expected-error {{cannot use wide string literal in 'asm'}}
25f4a2713aSLionel Sambuc 
26*0a6a1f1dSLionel Sambuc asm() // expected-error {{expected string literal in 'asm'}}
27*0a6a1f1dSLionel Sambuc // expected-error@-1 {{expected ';' after top-level asm block}}
28*0a6a1f1dSLionel Sambuc 
29*0a6a1f1dSLionel Sambuc asm(; // expected-error {{expected string literal in 'asm'}}
30*0a6a1f1dSLionel Sambuc 
31*0a6a1f1dSLionel Sambuc asm("") // expected-error {{expected ';' after top-level asm block}}
32*0a6a1f1dSLionel Sambuc 
33*0a6a1f1dSLionel Sambuc // Unterminated asm strings at the end of the file were causing us to crash, so
34*0a6a1f1dSLionel Sambuc // this needs to be last. rdar://15624081
35*0a6a1f1dSLionel Sambuc // expected-warning@+3 {{missing terminating '"' character}}
36*0a6a1f1dSLionel Sambuc // expected-error@+2 {{expected string literal in 'asm'}}
37*0a6a1f1dSLionel Sambuc // expected-error@+1 {{expected ';' after top-level asm block}}
38*0a6a1f1dSLionel Sambuc asm("
39