]> gcc.gnu.org Git - gcc.git/commitdiff
re PR middle-end/48087 (-Wall -Werror adds warnings over and above those generated...
authorJakub Jelinek <jakub@redhat.com>
Thu, 21 Mar 2013 17:36:47 +0000 (18:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 21 Mar 2013 17:36:47 +0000 (18:36 +0100)
PR middle-end/48087
* diagnostic.def (DK_WERROR): New kind.
* diagnostic.h (werrorcount): Define.
* diagnostic.c (diagnostic_report_diagnostic): For DK_WARNING
promoted to DK_ERROR, increment DK_WERROR counter instead of
DK_ERROR counter.
* toplev.c (toplev_main): Call print_ignored_options even if
just werrorcount is non-zero.  Exit with FATAL_EXIT_CODE
even if just werrorcount is non-zero.

* pt.c (convert_nontype_argument): Count werrorcount as warnings.
* call.c (build_temp): Likewise.
* method.c (synthesize_method): Likewise.
* typeck.c (convert_for_initialization): Likewise.

From-SVN: r196887

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/method.c
gcc/cp/pt.c
gcc/cp/typeck.c
gcc/diagnostic.c
gcc/diagnostic.def
gcc/diagnostic.h
gcc/toplev.c

index b8a1b19e699d70083f6ebe55811c5974220bf8cd..8877f658ee7c1ecaae208ae043c186abec0899c7 100644 (file)
@@ -1,5 +1,15 @@
 2013-03-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/48087
+       * diagnostic.def (DK_WERROR): New kind.
+       * diagnostic.h (werrorcount): Define.
+       * diagnostic.c (diagnostic_report_diagnostic): For DK_WARNING
+       promoted to DK_ERROR, increment DK_WERROR counter instead of
+       DK_ERROR counter.
+       * toplev.c (toplev_main): Call print_ignored_options even if
+       just werrorcount is non-zero.  Exit with FATAL_EXIT_CODE
+       even if just werrorcount is non-zero.
+
        PR debug/55608
        * dwarf2out.c (tree_add_const_value_attribute): Call ggc_free (array)
        on failure.
index 7c282e857199069e6be43b161e33c013d773e22f..377528d62a522adc4a2fc1a8f0cb08d49a10aa41 100644 (file)
@@ -1,3 +1,11 @@
+2013-03-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/48087
+       * pt.c (convert_nontype_argument): Count werrorcount as warnings.
+       * call.c (build_temp): Likewise.
+       * method.c (synthesize_method): Likewise.
+       * typeck.c (convert_for_initialization): Likewise.
+
 2013-03-21  Marc Glisse  <marc.glisse@inria.fr>
 
        * call.c (build_conditional_expr_1): Fold VEC_COND_EXPR.
index 5c9c28615df5a7388b6685ed0d9921509b579809..87fbb2ef02028ed37dc06f6ed4c3db065acf4fac 100644 (file)
@@ -5709,12 +5709,12 @@ build_temp (tree expr, tree type, int flags,
   int savew, savee;
   vec<tree, va_gc> *args;
 
-  savew = warningcount, savee = errorcount;
+  savew = warningcount + werrorcount, savee = errorcount;
   args = make_tree_vector_single (expr);
   expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
                                    &args, type, flags, complain);
   release_tree_vector (args);
-  if (warningcount > savew)
+  if (warningcount + werrorcount > savew)
     *diagnostic_kind = DK_WARNING;
   else if (errorcount > savee)
     *diagnostic_kind = DK_ERROR;
index 55c7e50d30894d72c97282cfc91682a8111af6c6..316c5d3b8ebd9efec15df1ee9487c20009e41837 100644 (file)
@@ -755,7 +755,7 @@ synthesize_method (tree fndecl)
   tree stmt;
   location_t save_input_location = input_location;
   int error_count = errorcount;
-  int warning_count = warningcount;
+  int warning_count = warningcount + werrorcount;
 
   /* Reset the source location, we might have been previously
      deferred, and thus have saved where we were first needed.  */
@@ -817,7 +817,7 @@ synthesize_method (tree fndecl)
 
   pop_deferring_access_checks ();
 
-  if (error_count != errorcount || warning_count != warningcount)
+  if (error_count != errorcount || warning_count != warningcount + werrorcount)
     inform (input_location, "synthesized method %qD first required here ",
            fndecl);
 }
index d56ffede6b68ae24012c98e510ae8c6a67924d74..f8153059f7d9f9a59628ece83cf4cf188ec78670 100644 (file)
@@ -5601,12 +5601,12 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
        {
          if (complain & tf_error)
            {
-             int errs = errorcount, warns = warningcount;
+             int errs = errorcount, warns = warningcount + werrorcount;
              if (processing_template_decl
                  && !require_potential_constant_expression (expr))
                return NULL_TREE;
              expr = cxx_constant_value (expr);
-             if (errorcount > errs || warningcount > warns)
+             if (errorcount > errs || warningcount + werrorcount > warns)
                inform (EXPR_LOC_OR_HERE (expr),
                        "in template argument for type %qT ", type);
              if (expr == error_mark_node)
index 3ced85866635a6a58e2c08b3e4f5d467b1280699..c58b7b375f2de211327c3fa20e40eefaf335c299 100644 (file)
@@ -7977,11 +7977,11 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags,
       int savew = 0, savee = 0;
 
       if (fndecl)
-       savew = warningcount, savee = errorcount;
+       savew = warningcount + werrorcount, savee = errorcount;
       rhs = initialize_reference (type, rhs, flags, complain);
       if (fndecl)
        {
-         if (warningcount > savew)
+         if (warningcount + werrorcount > savew)
            warning (0, "in passing argument %P of %q+D", parmnum, fndecl);
          else if (errorcount > savee)
            error ("in passing argument %P of %q+D", parmnum, fndecl);
index a365c608a9151a514b3d829e9dd9d40b400f9773..87eb8dc40abad342f9e18ca9b1413cb2bd2ee5aa 100644 (file)
@@ -729,7 +729,10 @@ diagnostic_report_diagnostic (diagnostic_context *context,
                                    diagnostic->message.format_spec,
                                    diagnostic->message.args_ptr);
     }
-  ++diagnostic_kind_count (context, diagnostic->kind);
+  if (diagnostic->kind == DK_ERROR && orig_diag_kind == DK_WARNING)
+    ++diagnostic_kind_count (context, DK_WERROR);
+  else
+    ++diagnostic_kind_count (context, diagnostic->kind);
 
   saved_format_spec = diagnostic->message.format_spec;
   if (context->show_option_requested)
index 53179e445cdd7d281d62e9f5eb0c0f26c93fe877..9566491ca2a78520a6be2c15751a065da9d4741a 100644 (file)
@@ -42,4 +42,6 @@ DEFINE_DIAGNOSTIC_KIND (DK_DEBUG, "debug: ")
 prefix does not matter.  */
 DEFINE_DIAGNOSTIC_KIND (DK_PEDWARN, "pedwarn: ")
 DEFINE_DIAGNOSTIC_KIND (DK_PERMERROR, "permerror: ")
-
+/* This one is just for counting DK_WARNING promoted to DK_ERROR
+   due to -Werror and -Werror=warning.  */
+DEFINE_DIAGNOSTIC_KIND (DK_WERROR, "error: ")
index f0fae96275b60e16a54575c8145706f144f8f69b..3b500964c7de68101b2fafbc1845ab69837d6ee4 100644 (file)
@@ -240,6 +240,8 @@ extern diagnostic_context *global_dc;
 #define errorcount diagnostic_kind_count (global_dc, DK_ERROR)
 /* Similarly, but for warnings.  */
 #define warningcount diagnostic_kind_count (global_dc, DK_WARNING)
+/* Similarly, but for warnings promoted to errors.  */
+#define werrorcount diagnostic_kind_count (global_dc, DK_WERROR)
 /* Similarly, but for sorrys.  */
 #define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
 
index 071f1bdc3afec5132f8962c62ef00fcb8d43dce3..ad42391764925d350fc86eb5cbecf321bf22d75d 100644 (file)
@@ -1951,7 +1951,7 @@ toplev_main (int argc, char **argv)
   if (!exit_after_options)
     do_compile ();
 
-  if (warningcount || errorcount)
+  if (warningcount || errorcount || werrorcount)
     print_ignored_options ();
   diagnostic_finish (global_dc);
 
@@ -1960,7 +1960,7 @@ toplev_main (int argc, char **argv)
 
   finalize_plugins ();
   location_adhoc_data_fini (line_table);
-  if (seen_error ())
+  if (seen_error () || werrorcount)
     return (FATAL_EXIT_CODE);
 
   return (SUCCESS_EXIT_CODE);
This page took 0.102085 seconds and 5 git commands to generate.