complete-macro-args.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. struct Point {
  2. float x;
  3. float y;
  4. float z;
  5. };
  6. #define MACRO2(x) x
  7. #define MACRO(x) MACRO2(x)
  8. void test(struct Point *p) {
  9. p->x;
  10. MACRO(p->x);
  11. }
  12. #define MACRO3(x,y,z) x;y;z
  13. void test2(struct Point *p) {
  14. MACRO3(p->x);
  15. MACRO3(p->x
  16. }
  17. #define FM(x) x
  18. void test3(struct Point *p) {
  19. FM(p->x, a);
  20. }
  21. #define VGM(...) 0
  22. #define VGM2(...) __VA_ARGS__
  23. // These need to be last, to test proper handling of EOF.
  24. #ifdef EOF_TEST1
  25. void test3(struct Point *p) {
  26. VGM(1,2, p->x
  27. #elif EOF_TEST2
  28. void test3(struct Point *p) {
  29. VGM2(VGM(1,2, p->x
  30. #endif
  31. // RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck %s
  32. // RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s
  33. // RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck %s
  34. // RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck %s
  35. // RUN: c-index-test -code-completion-at=%s:24:9 %s | FileCheck %s
  36. // CHECK: FieldDecl:{ResultType float}{TypedText x} (35)
  37. // CHECK-NEXT: FieldDecl:{ResultType float}{TypedText y} (35)
  38. // CHECK-NEXT: FieldDecl:{ResultType float}{TypedText z} (35)
  39. // CHECK-NEXT: Completion contexts:
  40. // CHECK-NEXT: Arrow member access
  41. // CHECK-NEXT: Container Kind: StructDecl
  42. // With these, code-completion is unknown because the macro argument (and the
  43. // completion point) is not expanded by the macro definition.
  44. // RUN: c-index-test -code-completion-at=%s:33:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF
  45. // RUN: c-index-test -code-completion-at=%s:37:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF
  46. // CHECK-EOF: Completion contexts:
  47. // CHECK-EOF: Unknown