asm.c 1.4 KB

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