assembler-with-cpp.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // RUN: %clang_cc1 -x assembler-with-cpp -E %s -o - | FileCheck -strict-whitespace -check-prefix=CHECK-Identifiers-False %s
  2. #ifndef __ASSEMBLER__
  3. #error "__ASSEMBLER__ not defined"
  4. #endif
  5. // Invalid token pasting is ok.
  6. #define A X ## .
  7. 1: A
  8. // CHECK-Identifiers-False: 1: X .
  9. // Line markers are not linemarkers in .S files, they are passed through.
  10. # 321
  11. // CHECK-Identifiers-False: # 321
  12. // Unknown directives are passed through.
  13. # B C
  14. // CHECK-Identifiers-False: # B C
  15. // Unknown directives are expanded.
  16. #define D(x) BAR ## x
  17. # D(42)
  18. // CHECK-Identifiers-False: # BAR42
  19. // Unmatched quotes are permitted.
  20. 2: '
  21. 3: "
  22. // CHECK-Identifiers-False: 2: '
  23. // CHECK-Identifiers-False: 3: "
  24. // (balance quotes to keep editors happy): "'
  25. // Empty char literals are ok.
  26. 4: ''
  27. // CHECK-Identifiers-False: 4: ''
  28. // Portions of invalid pasting should still expand as macros.
  29. // rdar://6709206
  30. #define M4 expanded
  31. #define M5() M4 ## (
  32. 5: M5()
  33. // CHECK-Identifiers-False: 5: expanded (
  34. // rdar://6804322
  35. #define FOO(name) name ## $foo
  36. 6: FOO(blarg)
  37. // CHECK-Identifiers-False: 6: blarg $foo
  38. // RUN: %clang_cc1 -x assembler-with-cpp -fdollars-in-identifiers -E %s -o - | FileCheck -check-prefix=CHECK-Identifiers-True -strict-whitespace %s
  39. #define FOO(name) name ## $foo
  40. 7: FOO(blarg)
  41. // CHECK-Identifiers-True: 7: blarg$foo
  42. //
  43. #define T6() T6 #nostring
  44. #define T7(x) T7 #x
  45. 8: T6()
  46. 9: T7(foo)
  47. // CHECK-Identifiers-True: 8: T6 #nostring
  48. // CHECK-Identifiers-True: 9: T7 "foo"
  49. // Concatenation with period doesn't leave a space
  50. #define T8(A,B) A ## B
  51. 10: T8(.,T8)
  52. // CHECK-Identifiers-True: 10: .T8
  53. // This should not crash.
  54. #define T11(a) #0
  55. 11: T11(b)
  56. // CHECK-Identifiers-True: 11: #0
  57. // Universal character names can specify basic ascii and control characters
  58. 12: \u0020\u0030\u0080\u0000
  59. // CHECK-Identifiers-False: 12: \u0020\u0030\u0080\u0000
  60. // This should not crash
  61. // rdar://8823139
  62. # ##
  63. // CHECK-Identifiers-False: # ##
  64. #define X(a) # # # 1
  65. X(1)
  66. // CHECK-Identifiers-False: # # # 1