c/4271: excess warnings

george@palisad.com george@palisad.com
Sat Sep 8 15:06:00 GMT 2001


>Number:         4271
>Category:       c
>Synopsis:       excess warnings
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 08 15:06:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     george@palisad.com
>Release:        3.0.1
>Organization:
>Environment:
solaris 8, x86
>Description:
Warning messages about extra characters after #endif
are annoying and unnecessarily clog up log files.
This happens very frequently as an aid to help identify
closing nested ifdefs.  There is probably a way to
turn these messages off, but what used to be clean under
older versions of gcc is no longer clean, and other
potentially useful messages might be obscured.

>How-To-Repeat:

#ifdef FOO
#ifdef BAR
...
#endif BAR
#endif FOO
>Fix:
/* Ensure there are no stray tokens at the end of a directive.  */
static void
check_eol (pfile)
     cpp_reader *pfile;
{
  if (!pfile->state.next_bol)
    {
      cpp_token token;

      _cpp_lex_token (pfile, &token);
      if (token.type != CPP_EOF) {
/*
 * do not warn on extra stuff after #endif statements,
 *  this occurs too frequently, is of no consequence
 * bogus warnings  like this make it harder to identify real warnings
 */
          if(strcmp(pfile->directive->name, "endif"))
              cpp_pedwarn (pfile, "extra tokens at end of #%s directive",
                           pfile->directive->name);
      }
    }
}
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list