Skip to content

Commit 8f41d28

Browse files
[c-index-test] Fix warnings
This patch fixes: clang/tools/c-index-test/c-index-test.c:1240:15: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement] clang/tools/c-index-test/c-index-test.c:1367:14: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement] clang/tools/c-index-test/c-index-test.c:1468:14: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
1 parent 6b67aac commit 8f41d28

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clang/tools/c-index-test/c-index-test.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,14 +1231,16 @@ static CXString GetCursorSource(CXCursor Cursor) {
12311231
CXSourceLocation Loc = clang_getCursorLocation(Cursor);
12321232
CXString source;
12331233
CXFile file;
1234+
const char *b;
1235+
CXString result;
12341236
clang_getExpansionLocation(Loc, &file, 0, 0, 0);
12351237
source = clang_getFileName(file);
12361238
if (!clang_getCString(source)) {
12371239
clang_disposeString(source);
12381240
return createCXString("<invalid loc>");
12391241
}
1240-
const char *b = basename(clang_getCString(source));
1241-
CXString result = duplicateCXString(b);
1242+
b = basename(clang_getCString(source));
1243+
result = duplicateCXString(b);
12421244
clang_disposeString(source);
12431245
return result;
12441246
}
@@ -1363,8 +1365,9 @@ enum CXChildVisitResult FilteredPrintingVisitor(CXCursor Cursor,
13631365
if (!Data->Filter || (Cursor.kind == *(enum CXCursorKind *)Data->Filter)) {
13641366
CXSourceLocation Loc = clang_getCursorLocation(Cursor);
13651367
unsigned line, column;
1368+
CXString source;
13661369
clang_getFileLocation(Loc, 0, &line, &column, 0);
1367-
CXString source = GetCursorSource(Cursor);
1370+
source = GetCursorSource(Cursor);
13681371
printf("// %s: %s:%d:%d: ", FileCheckPrefix, clang_getCString(source), line,
13691372
column);
13701373
clang_disposeString(source);
@@ -1461,11 +1464,12 @@ enum CXChildVisitResult USRVisitor(CXCursor C, CXCursor parent,
14611464
if (!Data->Filter || (C.kind == *(enum CXCursorKind *)Data->Filter)) {
14621465
CXString USR = clang_getCursorUSR(C);
14631466
const char *cstr = clang_getCString(USR);
1467+
CXString CursorSource;
14641468
if (!cstr || cstr[0] == '\0') {
14651469
clang_disposeString(USR);
14661470
return CXChildVisit_Recurse;
14671471
}
1468-
CXString CursorSource = GetCursorSource(C);
1472+
CursorSource = GetCursorSource(C);
14691473
printf("// %s: %s %s", FileCheckPrefix, clang_getCString(CursorSource),
14701474
cstr);
14711475
clang_disposeString(CursorSource);

0 commit comments

Comments
 (0)