c-pragma.c (handle_pragma_token): Generate warning messages about unknown pragmas if warn_unknown_pragmas is set.

* c-pragma.c (handle_pragma_token): Generate warning messages
        about unknown pragmas if warn_unknown_pragmas is set.
        * c-decl.c (c_decode_option): Parse -Wunknown-pragmas command
        line option to set variable: warn_unknown_pragmas.

From-SVN: r17168
This commit is contained in:
Nick Clifton 1997-12-21 08:24:48 -07:00 committed by Jeff Law
parent f9fc59e8c7
commit d300e55140
5 changed files with 51 additions and 4 deletions

View File

@ -1,3 +1,11 @@
Sun Dec 21 16:13:55 1997 Nick Clifton <nickc@cygnus.com
* c-pragma.c (handle_pragma_token): Generate warning messages
about unknown pragmas if warn_unknown_pragmas is set.
* c-decl.c (c_decode_option): Parse -Wunknown-pragmas command
line option to set variable: warn_unknown_pragmas.
Sun Dec 21 15:51:10 1997 Manfred Hollstein <manfred@lts.sel.alcatel.de>
* m68k/mot3300.h (ASM_BYTE_OP): Don't include '\t' in the

View File

@ -558,6 +558,10 @@ int warn_missing_braces;
int warn_main;
/* Warn about #pragma directives that are not recognised. */
int warn_unknown_pragmas = 0; /* Tri state variable. */
/* Warn about comparison of signed and unsigned values.
If -1, neither -Wsign-compare nor -Wno-sign-compare has been specified. */
@ -763,6 +767,12 @@ c_decode_option (p)
warn_sign_compare = 1;
else if (!strcmp (p, "-Wno-sign-compare"))
warn_sign_compare = 0;
else if (!strcmp (p, "-Wunknown-pragmas"))
/* Set to greater than 1, so that even unknown pragmas in system
headers will be warned about. */
warn_unknown_pragmas = 2;
else if (!strcmp (p, "-Wno-unknown-pragmas"))
warn_unknown_pragmas = 0;
else if (!strcmp (p, "-Wall"))
{
/* We save the value of warn_uninitialized, since if they put
@ -782,6 +792,8 @@ c_decode_option (p)
/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding can turn
it off only if it's not explicit. */
warn_main = 2;
/* Only warn about unknown pragmas that are not in system headers. */
warn_unknown_pragmas = 1;
}
else
return 0;

View File

@ -1,5 +1,5 @@
/* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack.
Copyright (C) 1992 Free Software Foundation, Inc.
Copyright (C) 1992, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
@ -18,8 +18,8 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include "config.h"
#include <stdio.h>
#include "tree.h"
#include "except.h"
#include "function.h"
@ -65,7 +65,7 @@ handle_pragma_token (string, token)
if (HANDLE_PRAGMA_WEAK)
handle_pragma_weak (state, name, value);
#endif /* HANDLE_PRAMA_WEAK */
#endif /* HANDLE_PRAGMA_WEAK */
}
type = state = ps_start;
@ -82,7 +82,16 @@ handle_pragma_token (string, token)
else if (strcmp (IDENTIFIER_POINTER (token), "weak") == 0)
type = state = ps_weak;
else
type = state = ps_done;
{
type = state = ps_done;
/* Issue a warning message if we have been asked to do so.
Ignoring unknown pragmas in system header file unless
an explcit -Wunknown-pragmas has been given. */
if (warn_unknown_pragmas > 1
|| (warn_unknown_pragmas && ! in_system_header))
warning ("ignoring pragma: %s", string);
}
}
else
type = state = ps_done;

View File

@ -83,6 +83,14 @@ extern int warn_inline;
extern int warn_uninitialized;
/* Zero if unknown pragmas are ignored
One if the compiler should warn about an unknown pragma not in
a system include file.
Greater than one if the compiler should warn for all unknown
pragmas. */
extern int warn_unknown_pragmas;
/* Nonzero means warn about all declarations which shadow others. */
extern int warn_shadow;

View File

@ -126,6 +126,7 @@ in the following sections.
-Wsign-compare -Wstrict-prototypes -Wswitch -Wsynth
-Wtemplate-debugging -Wtraditional -Wtrigraphs
-Wundef -Wuninitialized -Wunused -Wwrite-strings
-Wunknown-pragmas
@end smallexample
@item Debugging Options
@ -1400,6 +1401,15 @@ members.
When using templates in a C++ program, warn if debugging is not yet
fully available (C++ only).
@item -Wunknown-pragmas
@cindex warning for unknown pragmas
@cindex unknown pragmas, warning
@cindex pragmas, warning of unknown
Warn when a #pragma directive is encountered which is not understood by
GCC. If this command line option is used, warnings will even be issued
for unknown pragmas in system header files. This is not the case if
the warnings were only enabled by the @samp{-Wall} command line option.
@item -Wall
All of the above @samp{-W} options combined. This enables all the
warnings about constructions that some users consider questionable, and