OSDN Git Service

* cpplib.c (_cpp_check_directive): Issue -Wtraditional
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Jul 2000 21:02:10 +0000 (21:02 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 Jul 2000 21:02:10 +0000 (21:02 +0000)
warnings for indented directives even if we are skipping.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35256 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cpplib.c

index b1e123a..90527ac 100644 (file)
@@ -1,3 +1,8 @@
+2000-07-25  Zack Weinberg  <zack@wolery.cumb.org>
+
+       * cpplib.c (_cpp_check_directive): Issue -Wtraditional
+       warnings for indented directives even if we are skipping.
+
 2000-07-25  Nathan Sidwell  <nathan@codesourcery.com>
 
        * invoke.texi (strict-prototypes): Remove.
index f39ff0e..7d7bbc2 100644 (file)
@@ -154,28 +154,33 @@ _cpp_check_directive (pfile, token, bol)
   for (i = 0; i < N_DIRECTIVES; i++)
     if (pfile->spec_nodes->dirs[i] == token->val.node)
       {
+       /* In -traditional mode, a directive is ignored unless its #
+          is in column 1.  In code intended to work with K+R compilers,
+          therefore, directives added by C89 must have their # indented,
+          and directives present in traditional C must not.  This is true
+          even of directives in skipped conditional blocks.  */
+       if (CPP_WTRADITIONAL (pfile))
+         {
+           if (!bol && dtable[i].origin == KANDR)
+             cpp_warning (pfile,
+                          "traditional C ignores #%s with the # indented",
+                          dtable[i].name);
+
+           if (bol && dtable[i].origin != KANDR)
+             cpp_warning (pfile,
+                   "suggest hiding #%s from traditional C with an indented #",
+                          dtable[i].name);
+         }
+
        /* If we are skipping a failed conditional group, all non-conditional
           directives are ignored.  */
        if (pfile->skipping && !(dtable[i].flags & COND))
          return 0;
 
-       /* In -traditional mode, a directive is ignored unless its #
-          is in column 1.  */
-       if (!bol && dtable[i].origin == KANDR && CPP_WTRADITIONAL (pfile))
-         cpp_warning (pfile, "traditional C ignores #%s with the # indented",
-                      dtable[i].name);
-
        /* Issue -pedantic warnings for extended directives.   */
        if (CPP_PEDANTIC (pfile) && dtable[i].origin == EXTENSION)
          cpp_pedwarn (pfile, "ISO C does not allow #%s", dtable[i].name);
 
-       /* -Wtraditional gives warnings about directives with inappropriate
-          indentation of #.  */
-       if (bol && dtable[i].origin != KANDR && CPP_WTRADITIONAL (pfile))
-         cpp_warning (pfile,
-                   "suggest hiding #%s from traditional C with an indented #",
-                      dtable[i].name);
-
        return &dtable[i];
       }