[cfe-commits] r160582 - /cfe/trunk/tools/c-index-test/c-index-test.c

Dmitri Gribenko gribozavr at gmail.com
Fri Jul 20 15:00:35 PDT 2012


Author: gribozavr
Date: Fri Jul 20 17:00:35 2012
New Revision: 160582

URL: http://llvm.org/viewvc/llvm-project?rev=160582&view=rev
Log:
Fix c-index-test to compile as C89.

Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=160582&r1=160581&r2=160582&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Jul 20 17:00:35 2012
@@ -256,12 +256,15 @@
 
 static void DumpCXCommentInternal(struct CommentASTDumpingContext *Ctx,
                                   CXComment Comment) {
+  unsigned i;
+  unsigned e;
+  enum CXCommentKind Kind = clang_Comment_getKind(Comment);
+
   Ctx->IndentLevel++;
-  for (unsigned i = 0, e = Ctx->IndentLevel; i != e; ++i)
+  for (i = 0, e = Ctx->IndentLevel; i != e; ++i)
     printf("  ");
 
   printf("(");
-  enum CXCommentKind Kind = clang_Comment_getKind(Comment);
   switch (Kind) {
   case CXComment_Null:
     printf("CXComment_Null");
@@ -280,7 +283,7 @@
     PrintCXStringWithPrefixAndDispose(
         "CommandName",
         clang_InlineCommandComment_getCommandName(Comment));
-    for (unsigned i = 0, e = clang_InlineCommandComment_getNumArgs(Comment);
+    for (i = 0, e = clang_InlineCommandComment_getNumArgs(Comment);
          i != e; ++i) {
       printf(" Arg[%u]=", i);
       PrintCXStringAndDispose(
@@ -289,15 +292,16 @@
     if (clang_InlineContentComment_hasTrailingNewline(Comment))
       printf(" HasTrailingNewline");
     break;
-  case CXComment_HTMLStartTag:
+  case CXComment_HTMLStartTag: {
+    unsigned NumAttrs;
     printf("CXComment_HTMLStartTag");
     PrintCXStringWithPrefixAndDispose(
         "Name",
         clang_HTMLTagComment_getTagName(Comment));
-    const unsigned NumAttrs = clang_HTMLStartTag_getNumAttrs(Comment);
+    NumAttrs = clang_HTMLStartTag_getNumAttrs(Comment);
     if (NumAttrs != 0) {
       printf(" Attrs:");
-      for (unsigned i = 0; i != NumAttrs; ++i) {
+      for (i = 0; i != NumAttrs; ++i) {
         printf(" ");
         PrintCXStringAndDispose(clang_HTMLStartTag_getAttrName(Comment, i));
         printf("=");
@@ -309,6 +313,7 @@
     if (clang_InlineContentComment_hasTrailingNewline(Comment))
       printf(" HasTrailingNewline");
     break;
+  }
   case CXComment_HTMLEndTag:
     printf("CXComment_HTMLEndTag");
     PrintCXStringWithPrefixAndDispose(
@@ -327,7 +332,7 @@
     PrintCXStringWithPrefixAndDispose(
         "CommandName",
         clang_BlockCommandComment_getCommandName(Comment));
-    for (unsigned i = 0, e = clang_BlockCommandComment_getNumArgs(Comment);
+    for (i = 0, e = clang_BlockCommandComment_getNumArgs(Comment);
          i != e; ++i) {
       printf(" Arg[%u]=", i);
       PrintCXStringAndDispose(
@@ -383,7 +388,8 @@
   }
   if (Kind != CXComment_Null) {
     const unsigned NumChildren = clang_Comment_getNumChildren(Comment);
-    for (unsigned i = 0; i != NumChildren; ++i) {
+    unsigned i;
+    for (i = 0; i != NumChildren; ++i) {
       printf("\n// %s: ", FileCheckPrefix);
       DumpCXCommentInternal(Ctx, clang_Comment_getChild(Comment, i));
     }





More information about the cfe-commits mailing list