blob: ae8e1aa6a52cf3c4524a1206398f2d26ba0acbed [file] [log] [blame]
Douglas Gregor3e15e0a2010-07-26 23:54:23 +00001#include "prefix.h"
2#include "preamble.h"
Argyrios Kyrtzidis51e75ae2013-08-07 21:17:33 +00003#include "preamble-with-error.h"
4
Stephen Hines651f13c2014-04-23 16:59:28 -07005#define MACRO_UNUSED 1
6#define MACRO_USED 2
7
Douglas Gregor3e15e0a2010-07-26 23:54:23 +00008int wibble(int);
9
Douglas Gregordf95a132010-08-09 20:45:32 +000010void f(int x) {
Stephen Hines651f13c2014-04-23 16:59:28 -070011 x = MACRO_USED
Douglas Gregordf95a132010-08-09 20:45:32 +000012}
Douglas Gregor7ae2faa2010-08-13 05:36:37 +000013// RUN: c-index-test -write-pch %t.pch -x c-header %S/Inputs/prefix.h
Stephen Hines651f13c2014-04-23 16:59:28 -070014// 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
Douglas Gregorc0659ec2010-08-02 20:51:39 +000015// RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt
Abramo Bagnaraff676cb2011-03-08 08:55:46 +000016// CHECK: preamble.h:1:12: FunctionDecl=bar:1:12 (Definition) Extent=[1:1 - 6:2]
Douglas Gregor42b29842011-10-05 19:00:14 +000017// CHECK: preamble.h:4:3: BinaryOperator= Extent=[4:3 - 4:13]
Douglas Gregoreb8837b2010-08-03 19:06:41 +000018// CHECK: preamble.h:4:3: DeclRefExpr=ptr:2:8 Extent=[4:3 - 4:6]
19// CHECK: preamble.h:4:9: UnexposedExpr=ptr1:3:10 Extent=[4:9 - 4:13]
20// CHECK: preamble.h:4:9: DeclRefExpr=ptr1:3:10 Extent=[4:9 - 4:13]
Douglas Gregor42b29842011-10-05 19:00:14 +000021// CHECK: preamble.h:5:10: IntegerLiteral= Extent=[5:10 - 5:11]
Stephen Hines651f13c2014-04-23 16:59:28 -070022// CHECK: preamble.c:8:5: FunctionDecl=wibble:8:5 Extent=[8:1 - 8:16]
23// CHECK: preamble.c:8:15: ParmDecl=:8:15 (Definition) Extent=[8:12 - 8:15]
Douglas Gregorc0659ec2010-08-02 20:51:39 +000024// CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *'
Stephen Hines651f13c2014-04-23 16:59:28 -070025// FIXME: Should see:
26// preamble.c:5:9: warning: macro is not used
27// CHECK-DIAG-NOT: preamble.c:6:9: warning: macro is not used
28// 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
Douglas Gregordf95a132010-08-09 20:45:32 +000029// CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50)
Douglas Gregord475aad2010-09-20 21:25:19 +000030// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (50)
Douglas Gregordf95a132010-08-09 20:45:32 +000031// CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50)
32// CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50)