preamble.c 1.8 KB

1234567891011121314151617181920212223242526272829303132
  1. #include "prefix.h"
  2. #include "preamble.h"
  3. #include "preamble-with-error.h"
  4. #define MACRO_UNUSED 1
  5. #define MACRO_USED 2
  6. int wibble(int);
  7. void f(int x) {
  8. x = MACRO_USED
  9. }
  10. // RUN: c-index-test -write-pch %t.pch -x c-header %S/Inputs/prefix.h
  11. // RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s -Wunused-macros 2> %t.stderr.txt | FileCheck %s
  12. // RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt
  13. // CHECK: preamble.h:1:12: FunctionDecl=bar:1:12 (Definition) Extent=[1:1 - 6:2]
  14. // CHECK: preamble.h:4:3: BinaryOperator= Extent=[4:3 - 4:13]
  15. // CHECK: preamble.h:4:3: DeclRefExpr=ptr:2:8 Extent=[4:3 - 4:6]
  16. // CHECK: preamble.h:4:9: UnexposedExpr=ptr1:3:10 Extent=[4:9 - 4:13]
  17. // CHECK: preamble.h:4:9: DeclRefExpr=ptr1:3:10 Extent=[4:9 - 4:13]
  18. // CHECK: preamble.h:5:10: IntegerLiteral= Extent=[5:10 - 5:11]
  19. // CHECK: preamble.c:8:5: FunctionDecl=wibble:8:5 Extent=[8:1 - 8:16]
  20. // CHECK: preamble.c:8:15: ParmDecl=:8:15 (Definition) Extent=[8:12 - 8:15]
  21. // CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *'
  22. // FIXME: Should see:
  23. // preamble.c:5:9: warning: macro is not used
  24. // CHECK-DIAG-NOT: preamble.c:6:9: warning: macro is not used
  25. // RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:11:1 -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck -check-prefix CHECK-CC %s
  26. // CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50)
  27. // CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (50)
  28. // CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50)
  29. // CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50)