This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: cpp -Wtraditional doesn't see left justified #error in unchosen path
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: cpp -Wtraditional doesn't see left justified #error in unchosen path
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Mon, 24 Jul 2000 21:00:21 -0700
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <200007250243.WAA29720@caip.rutgers.edu>
On Mon, Jul 24, 2000 at 10:43:07PM -0400, Kaveh R. Ghazi wrote:
> Zack,
>
> The -Wtraditional warnings cpp is supposed to issue about #error
> needing indentation for traditional C don't occur when the directive
> is wrapped in an #if conditional that evaluates such that the #error
> does not trigger.
Oops. The checks were being done in the wrong order. Here is a
completely untested patch, which I will be testing along with some
unrelated changes later tonight.
If you would write and check in a test case for this behavior, I'd
appreciate it.
zw
===================================================================
Index: cpplib.c
--- cpplib.c 2000/07/19 20:18:06 1.192
+++ cpplib.c 2000/07/25 03:59:23
@@ -154,27 +154,32 @@ _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];
}