diff options
author | Nick Clifton <nickc@cygnus.com> | 1997-12-21 08:24:48 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 1997-12-21 08:24:48 -0700 |
commit | d300e55140f3d2b7c72b6e2c54aa8117508a278e (patch) | |
tree | 0b8fadd5175f1003cd62fe44249ac0f84a09d3d4 /gcc | |
parent | f9fc59e8c7d867eed481ec74433c8e582f95ce39 (diff) | |
download | gcc-d300e55140f3d2b7c72b6e2c54aa8117508a278e.zip gcc-d300e55140f3d2b7c72b6e2c54aa8117508a278e.tar.gz gcc-d300e55140f3d2b7c72b6e2c54aa8117508a278e.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-decl.c | 12 | ||||
-rw-r--r-- | gcc/c-pragma.c | 17 | ||||
-rw-r--r-- | gcc/flags.h | 8 | ||||
-rw-r--r-- | gcc/invoke.texi | 10 |
5 files changed, 51 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 517b380..6655c7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 895ce36..0bc292a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -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; diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 886c67b..87e060e 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -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; diff --git a/gcc/flags.h b/gcc/flags.h index ba05720..43c88c9 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -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; diff --git a/gcc/invoke.texi b/gcc/invoke.texi index f8c9f9a..d1f8756 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -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 |