This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to control #pragma once warning with -Wno-deprecated
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Jan 2003 14:16:08 -0500
- Subject: PATCH to control #pragma once warning with -Wno-deprecated
Several people have asked about a flag to disable this warning;
-Wno-deprecated seems like an appropriate one to use.
Incidentally, apparently #pragma once shows up in VC++ headers, which would
explain why people don't want to just fix their code.
Tested i686-pc-linux-gnu, applied to trunk.
2003-01-28 Jason Merrill <jason@redhat.com>
* cpplib.h (struct cpp_options): Add warn_deprecated field.
* cppinit.c (cpp_create_reader): Turn it on by default.
* c-opts.c (c_common_decode_option): Set it.
* cpplib.c (do_pragma_once): Only complain about #pragma once
if warn_deprecated is set.
*** c-opts.c.~1~ Tue Jan 28 13:40:32 2003
--- c-opts.c Mon Jan 27 14:57:57 2003
*************** c_common_decode_option (argc, argv)
*** 767,772 ****
--- 767,773 ----
case OPT_Wdeprecated:
warn_deprecated = on;
+ cpp_opts->warn_deprecated = on;
break;
case OPT_Wdiv_by_zero:
*** cppinit.c.~1~ Tue Jan 28 13:40:32 2003
--- cppinit.c Mon Jan 27 14:57:57 2003
*************** cpp_create_reader (lang)
*** 527,532 ****
--- 527,533 ----
CPP_OPTION (pfile, tabstop) = 8;
CPP_OPTION (pfile, operator_names) = 1;
CPP_OPTION (pfile, warn_endif_labels) = 1;
+ CPP_OPTION (pfile, warn_deprecated) = 1;
CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
CPP_OPTION (pfile, pending) =
*** cpplib.c.~1~ Tue Jan 28 13:40:32 2003
--- cpplib.c Mon Jan 27 14:57:57 2003
*************** static void
*** 1223,1229 ****
do_pragma_once (pfile)
cpp_reader *pfile;
{
! cpp_error (pfile, DL_WARNING, "#pragma once is obsolete");
if (pfile->buffer->prev == NULL)
cpp_error (pfile, DL_WARNING, "#pragma once in main file");
--- 1223,1230 ----
do_pragma_once (pfile)
cpp_reader *pfile;
{
! if (CPP_OPTION (pfile, warn_deprecated))
! cpp_error (pfile, DL_WARNING, "#pragma once is obsolete");
if (pfile->buffer->prev == NULL)
cpp_error (pfile, DL_WARNING, "#pragma once in main file");
*** cpplib.h.~1~ Tue Jan 28 13:40:32 2003
--- cpplib.h Mon Jan 27 14:57:57 2003
*************** struct cpp_options
*** 278,283 ****
--- 278,286 ----
/* Nonzero means don't print warning messages. */
unsigned char inhibit_warnings;
+ /* Nonzero means complain about deprecated features. */
+ unsigned char warn_deprecated;
+
/* Nonzero means don't suppress warnings from system headers. */
unsigned char warn_system_headers;