This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Wno-warning-directives [WasRe: cpplib: Start moving ...]
- From: Devang Patel <dpatel at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 12 Aug 2002 15:58:06 -0700
- Subject: PATCH: Wno-warning-directives [WasRe: cpplib: Start moving ...]
On Thursday, August 8, 2002, at 02:00 PM, Richard Henderson wrote:
On Thu, Aug 08, 2002 at 10:59:02AM -0700, Stan Shebs wrote:
If everybody thinks, it is not OK then I will change it to
-Wno-pound-warnings.
"pound" is somewhat cultural - I think of the char as "sharp"
(musical),
and H-P called it "hash". If we do this, we should use terminology
from
the language definition and call it -Wno-warning-directives.
I much prefer -Wno-warning-directives.
Here is the patch.
OK to commit ?
2002-12-08 Devang Patel <dpatel@apple.com>
* c-opts.c (preprocess_file): Add new OPT_Wwarning-directives.
(c_common_decode_option): Handle OPT_Wwarning_directives
* cppinit.c (cpp_create_reader): Init warn_warning_directives
* cpplib.c (do_warning): Add warn_warning_directives check.
* cpplib.h (struct cpp_options): Add new item,
warn_warning_directives.
* doc/invoke.texi: Add information for -Wno-warning-directives.
testsuite:
* gcc.dg/Wno-warning-directives.c: New test.
Index: gcc/c-opts.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 c-opts.c
*** gcc/c-opts.c 12 Aug 2002 06:02:53 -0000 1.8
--- gcc/c-opts.c 12 Aug 2002 22:49:28 -0000
*************** static void preprocess_file PARAMS ((voi
*** 157,162 ****
--- 157,163 ----
OPT("Wstrict-prototypes", CL_ALL, OPT_Wstrict_prototypes)
\
OPT("Wsynth", CL_CXX, OPT_Wsynth)
\
OPT("Wsystem-headers", CL_ALL, OPT_Wsystem_headers)
\
+ OPT("Wwarning-directives", CL_ALL, OPT_Wwarning_directives)
\
OPT("Wtraditional", CL_C, OPT_Wtraditional)
\
OPT("Wtrigraphs", CL_ALL, OPT_Wtrigraphs)
\
OPT("Wundef", CL_ALL, OPT_Wundef)
\
*************** c_common_decode_option (argc, argv)
*** 820,825 ****
--- 821,830 ----
case OPT_Wsystem_headers:
cpp_opts->warn_system_headers = on;
+ break;
+
+ case OPT_Wwarning_directives:
+ cpp_opts->warn_warning_directives = on;
break;
case OPT_Wtraditional:
Index: gcc/cppinit.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.256
diff -c -3 -p -r1.256 cppinit.c
*** gcc/cppinit.c 12 Aug 2002 06:02:53 -0000 1.256
--- gcc/cppinit.c 12 Aug 2002 22:49:28 -0000
*************** cpp_create_reader (lang)
*** 471,476 ****
--- 471,477 ----
cpp_set_lang (pfile, lang);
CPP_OPTION (pfile, warn_import) = 1;
CPP_OPTION (pfile, warn_multichar) = 1;
+ CPP_OPTION (pfile, warn_warning_directives) = 1;
CPP_OPTION (pfile, discard_comments) = 1;
CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
CPP_OPTION (pfile, show_column) = 1;
Index: gcc/cpplib.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.320
diff -c -3 -p -r1.320 cpplib.c
*** gcc/cpplib.c 23 Jul 2002 22:57:44 -0000 1.320
--- gcc/cpplib.c 12 Aug 2002 22:49:28 -0000
*************** do_warning (pfile)
*** 953,959 ****
cpp_reader *pfile;
{
/* We want #warning diagnostics to be emitted in system headers
too. */
! do_diagnostic (pfile, DL_WARNING_SYSHDR, 1);
}
/* Report program identification. */
--- 953,960 ----
cpp_reader *pfile;
{
/* We want #warning diagnostics to be emitted in system headers
too. */
! if (CPP_OPTION (pfile, warn_warning_directives))
! do_diagnostic (pfile, DL_WARNING_SYSHDR, 1);
}
/* Report program identification. */
Index: gcc/cpplib.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.232
diff -c -3 -p -r1.232 cpplib.h
*** gcc/cpplib.h 12 Aug 2002 06:02:53 -0000 1.232
--- gcc/cpplib.h 12 Aug 2002 22:49:28 -0000
*************** struct cpp_options
*** 405,410 ****
--- 405,413 ----
/* Nonzero means __STDC__ should have the value 0 in system
headers. */
unsigned char stdc_0_in_system_headers;
+
+ /* Zero means, do not emit #warning warnings. */
+ unsigned char warn_warning_directives;
};
/* Call backs. */
Index: gcc/doc/invoke.texi
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.170
diff -c -3 -p -r1.170 invoke.texi
*** gcc/doc/invoke.texi 11 Aug 2002 09:47:47 -0000 1.170
--- gcc/doc/invoke.texi 12 Aug 2002 22:49:32 -0000
*************** in the following sections.
*** 227,233 ****
-Wno-multichar -Wno-format-extra-args -Wno-format-y2k @gol
-Wno-import -Wnonnull -Wpacked -Wpadded @gol
-Wparentheses -Wpointer-arith -Wredundant-decls @gol
! -Wreturn-type -Wsequence-point -Wshadow @gol
-Wsign-compare -Wswitch -Wswitch-default -Wswitch-enum @gol
-Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
-Wunknown-pragmas -Wunreachable-code @gol
--- 227,233 ----
-Wno-multichar -Wno-format-extra-args -Wno-format-y2k @gol
-Wno-import -Wnonnull -Wpacked -Wpadded @gol
-Wparentheses -Wpointer-arith -Wredundant-decls @gol
! -Wreturn-type -Wsequence-point -Wshadow -Wno-warning-directives @gol
-Wsign-compare -Wswitch -Wswitch-default -Wswitch-enum @gol
-Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
-Wunknown-pragmas -Wunreachable-code @gol
*************** Warn whenever an @samp{#else} or an @sam
*** 2436,2441 ****
--- 2436,2445 ----
@opindex Wshadow
Warn whenever a local variable shadows another local variable,
parameter or
global variable or whenever a built-in function is shadowed.
+
+ @item -Wno-warning-directives
+ @opindex Wno-warning-directives
+ Disable #warning messages.
@item -Wlarger-than-@var{len}
@opindex Wlarger-than
Index: Wno-warning-directives.c
===================================================================
RCS file: Wno-warning-directives.c
diff -N Wno-warning-directives.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- Wno-warning-directives.c 12 Aug 2002 22:56:28 -0000
***************
*** 0 ****
--- 1,16 ----
+ /* Test for -Wno-warning-directives compiler option.
+ Copyright (C) 2002 Free Software Foundation Inc
+ Contributed by Devang Patel <dpatel@apple.com>
+ */
+
+ /* { dg-do compile } */
+ /* { dg-options -Wno-warning-directives } */
+
+
+ #warning Do not use this APIs /* { dg-bogus "Do not use this APIs" }
*/
+
+ int main ()
+ {
+ return 0;
+ }
+