diagnostics: Fix PR 15378

Gabriel Dos Reis gdr@integrable-solutions.net
Mon Aug 30 10:39:00 GMT 2004


This fixes the regression PR 15378.  The cause is of course order of
initialization issue.

I propose it for 3.4.3 too.  There is going to be a corresponding fix
for 3.3.5. 

I did not attach a testcase because our testsuite infrastructure looks
for line numbers, and we don't have one for this kind of thing.

Regtested on an i686-pc-linux-gnu.
Applied to mainline.

-- Gaby

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 2.5134
diff -p -r2.5134 ChangeLog
*** ChangeLog	29 Aug 2004 12:05:22 -0000	2.5134
--- ChangeLog	30 Aug 2004 04:41:02 -0000
***************
*** 1,3 ****
--- 1,14 ----
+ 2004-08-29  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+ 
+ 	PR c++/15378
+ 	* c-opts.c (c_common_handle_option): <case OPT_Werror> set
+ 	global_dc->warning_as_error_requested.
+ 	* diagnostic.c (diagnostic_initialize): Tidy.
+ 	* diagnostic.h (diagnostic_context::x_data): Remove
+ 	(diagnostic_context::issue_warnings_are_errors_message): Rename
+ 	from warnings_are_errors_message.
+ 	(diagnostic_context::warning_as_error_requested): New.
+ 
  2004-08-29  Richard Sandiford  <rsandifo@redhat.com>
  
  	* config/mips/mips.md (*mov[sd]f_on_*): Redefine using :SCALARF.
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.125
diff -p -r1.125 c-opts.c
*** c-opts.c	28 Aug 2004 02:33:48 -0000	1.125
--- c-opts.c	30 Aug 2004 04:41:03 -0000
*************** c_common_handle_option (size_t scode, co
*** 420,425 ****
--- 420,426 ----
  
      case OPT_Werror:
        cpp_opts->warnings_are_errors = value;
+       global_dc->warning_as_error_requested = value;
        break;
  
      case OPT_Werror_implicit_function_declaration:
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.140
diff -p -r1.140 diagnostic.c
*** diagnostic.c	30 Jun 2004 18:17:55 -0000	1.140
--- diagnostic.c	30 Aug 2004 04:41:03 -0000
*************** diagnostic_initialize (diagnostic_contex
*** 107,113 ****
    context->printer->prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;
  
    memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
!   context->warnings_are_errors_message = warnings_are_errors;
    context->abort_on_error = false;
    context->internal_error = NULL;
    diagnostic_starter (context) = default_diagnostic_starter;
--- 107,114 ----
    context->printer->prefixing_rule = DIAGNOSTICS_SHOW_PREFIX_ONCE;
  
    memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
!   context->issue_warnings_are_errors_message = true;
!   context->warning_as_error_requested = false;
    context->abort_on_error = false;
    context->internal_error = NULL;
    diagnostic_starter (context) = default_diagnostic_starter;
*************** diagnostic_initialize (diagnostic_contex
*** 115,121 ****
    context->last_module = 0;
    context->last_function = NULL;
    context->lock = 0;
-   context->x_data = NULL;
  }
  
  /* Returns true if the next format specifier in TEXT is a format specifier
--- 116,121 ----
*************** diagnostic_count_diagnostic (diagnostic_
*** 226,242 ****
        if (!diagnostic_report_warnings_p ())
          return false;
  
!       if (!warnings_are_errors)
          {
            ++diagnostic_kind_count (context, DK_WARNING);
            break;
          }
! 
!       if (context->warnings_are_errors_message)
          {
  	  pp_verbatim (context->printer,
                         "%s: warnings being treated as errors\n", progname);
!           context->warnings_are_errors_message = false;
          }
  
        /* And fall through.  */
--- 226,241 ----
        if (!diagnostic_report_warnings_p ())
          return false;
  
!       if (!context->warning_as_error_requested)
          {
            ++diagnostic_kind_count (context, DK_WARNING);
            break;
          }
!       else if (context->issue_warnings_are_errors_message)
          {
  	  pp_verbatim (context->printer,
                         "%s: warnings being treated as errors\n", progname);
!           context->issue_warnings_are_errors_message = false;
          }
  
        /* And fall through.  */
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.69
diff -p -r1.69 diagnostic.h
*** diagnostic.h	13 May 2004 06:39:37 -0000	1.69
--- diagnostic.h	30 Aug 2004 04:41:03 -0000
*************** struct diagnostic_context
*** 65,71 ****
  
    /* True if we should display the "warnings are being tread as error"
       message, usually displayed once per compiler run.  */
!   bool warnings_are_errors_message;
  
    /* True if we should raise a SIGABRT on errors.  */
    bool abort_on_error;
--- 65,74 ----
  
    /* True if we should display the "warnings are being tread as error"
       message, usually displayed once per compiler run.  */
!   bool issue_warnings_are_errors_message;
!   
!   /* True if it has been requested that warnings be treated as errors.  */
!   bool warning_as_error_requested;
  
    /* True if we should raise a SIGABRT on errors.  */
    bool abort_on_error;
*************** struct diagnostic_context
*** 94,102 ****
    int last_module;
  
    int lock;
-   
-   /* Hook for front-end extensions.  */
-   void *x_data;
  };
  
  /* Client supplied function to announce a diagnostic.  */
--- 97,102 ----



More information about the Gcc-patches mailing list