* Patch to implement -Wunknown-pragmas
@ 1997-10-20 15:06 Nick Clifton
1997-12-21 15:24 ` Jeffrey A Law
0 siblings, 1 reply; 2+ messages in thread
From: Nick Clifton @ 1997-10-20 15:06 UTC (permalink / raw)
To: egcs
After all the discussion, here is the patch to implement the
-Wunknown-pragmas warning:
gcc/ChangeLog:
Mon Oct 20 10:43:15 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.
* invoke.texi (Warning Options): Document -Wunknown-pragmas
command line option.
gcc/cp/ChangeLog:
Mon Oct 20 10:36:44 1997 Nick Clifton <nickc@cygnus.com>
* decl2.c (lang_decode_option): Add support for command line
option: -Wunknown-pragmas.
Index: invoke.texi
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/invoke.texi,v
retrieving revision 1.218
diff -p -r1.218 invoke.texi
*** invoke.texi 1997/10/17 00:13:56 1.218
--- invoke.texi 1997/10/20 21:22:39
*************** in the following sections.
*** 130,135 ****
--- 130,136 ----
-Wsign-compare -Wstrict-prototypes -Wswitch -Wsynth
-Wtemplate-debugging -Wtraditional -Wtrigraphs
-Wundef -Wuninitialized -Wunused -Wwrite-strings
+ -Wunknown-pragmas
@end smallexample
@item Debugging Options
*************** an incorrect result when the signed valu
*** 1440,1445 ****
--- 1441,1455 ----
@cindex template debugging
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
Index: c-decl.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/c-decl.c,v
retrieving revision 1.191
retrieving revision 1.193
diff -p -r1.191 -r1.193
*** c-decl.c 1997/10/14 00:49:15 1.191
--- c-decl.c 1997/10/20 17:42:48 1.193
*************** int warn_main;
*** 557,562 ****
--- 557,566 ----
int warn_sign_compare;
+ /* Warn about #pragma directives that are not recognised. */
+
+ int warn_unknown_pragmas = 0; /* Tri state variable. */
+
/* Nonzero means `$' can be in an identifier. */
#ifndef DOLLARS_IN_IDENTIFIERS
*************** c_decode_option (p)
*** 743,748 ****
--- 747,758 ----
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
*************** c_decode_option (p)
*** 762,767 ****
--- 772,779 ----
/* 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;
Index: decl2.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/decl2.c,v
retrieving revision 1.345
retrieving revision 1.347
diff -p -r1.345 -r1.347
*** decl2.c 1997/10/14 20:34:45 1.345
--- decl2.c 1997/10/20 17:43:59 1.347
*************** int warn_sign_promo;
*** 271,276 ****
--- 271,280 ----
int warn_old_style_cast;
+ /* Warn about #pragma directives that are not recognised. */
+
+ int warn_unknown_pragmas = 0; /* Tri state variable. */
+
/* Nonzero means `$' can be in an identifier. */
#ifndef DOLLARS_IN_IDENTIFIERS
*************** lang_decode_option (p)
*** 670,675 ****
--- 674,683 ----
warn_sign_promo = setting;
else if (!strcmp (p, "old-style-cast"))
warn_old_style_cast = setting;
+ else if (!strcmp (p, "unknown-pragmas"))
+ /* Set to greater than 1, so that even unknown pragmas in
+ system headers will be warned about. */
+ warn_unknown_pragmas = setting * 2;
else if (!strcmp (p, "comment"))
; /* cpp handles this one. */
else if (!strcmp (p, "comments"))
*************** lang_decode_option (p)
*** 699,704 ****
--- 707,715 ----
warn_template_debugging = setting;
warn_reorder = setting;
warn_sign_promo = setting;
+ /* Only warn about unknown pragmas that are not in system
+ headers. */
+ warn_unknown_pragmas = 1;
}
else if (!strcmp (p, "overloaded-virtual"))
Index: c-pragma.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/c-pragma.c,v
retrieving revision 1.23
retrieving revision 1.25
diff -p -r1.23 -r1.25
*** c-pragma.c 1997/10/16 00:44:31 1.23
--- c-pragma.c 1997/10/20 17:42:54 1.25
*************** Boston, MA 02111-1307, USA. */
*** 26,31 ****
--- 26,33 ----
#include "defaults.h"
#include "c-pragma.h"
+ #include "flags.h" /* For the definition of in_system_header. */
+
#ifdef HANDLE_SYSV_PRAGMA
/* When structure field packing is in effect, this variable is the
*************** extern FILE *asm_out_file;
*** 42,47 ****
--- 44,50 ----
extern FILE * attr_info_file;
extern int flag_depragmaize; /* True if we are performing a depragmatization. */
+ extern int warn_unknown_pragmas;
/* Tracks the current data area set by the data area pragma (which
can be nested). Tested by check_default_data_area. */
*************** handle_pragma_token (string, token)
*** 402,407 ****
--- 405,416 ----
else
{
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Patch to implement -Wunknown-pragmas
1997-10-20 15:06 Patch to implement -Wunknown-pragmas Nick Clifton
@ 1997-12-21 15:24 ` Jeffrey A Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey A Law @ 1997-12-21 15:24 UTC (permalink / raw)
To: Nick Clifton; +Cc: egcs
In message <199710202210.PAA00478@elmo.cygnus.com>you write:
> After all the discussion, here is the patch to implement the
> -Wunknown-pragmas warning:
>
> gcc/ChangeLog:
> Mon Oct 20 10:43:15 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.
>
> * invoke.texi (Warning Options): Document -Wunknown-pragmas
> command line option.
>
> gcc/cp/ChangeLog:
> Mon Oct 20 10:36:44 1997 Nick Clifton <nickc@cygnus.com>
>
> * decl2.c (lang_decode_option): Add support for command line
> option: -Wunknown-pragmas.
Just a minor note, I put a decl of warn_unknown_pragmas into flags.h
and installed your patch.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-12-21 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-20 15:06 Patch to implement -Wunknown-pragmas Nick Clifton
1997-12-21 15:24 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).