ENABLE_CHECKING refactoring: C family front ends
authorMikhail Maltsev <maltsevm@gmail.com>
Wed, 4 Nov 2015 14:32:42 +0000 (14:32 +0000)
committerMikhail Maltsev <miyuki@gcc.gnu.org>
Wed, 4 Nov 2015 14:32:42 +0000 (14:32 +0000)
gcc/c-family/

* c-omp.c (c_omp_split_clauses): Remove conditional compilation. Use
flag_checking.

gcc/cp/

* call.c (validate_conversion_obstack): Define unconditionally.
* constexpr.c (maybe_constant_value, fold_non_dependent_expr): Use
gcc_checking_assert.
* cp-tree.h: Use CHECKING_P instead of ENABLE_CHECKING.
* decl2.c (cxx_post_compilation_parsing_cleanups): Use flag_checking.
* mangle.c (add_substitution): Likewise.
* method.c (maybe_explain_implicit_delete): Likewise.
* parser.c (cp_parser_template_argument_list): Remove conditional
compilation.
* pt.c (check_unstripped_args): Rename to...
(verify_unstripped_args): ... this and remove conditional compilation.
(retrieve_specialization): Guard call of verify_unstripped_args with
flag_checking.
(template_parm_to_arg): Remove conditional compilation.
(template_parms_to_args, coerce_template_parameter_pack,
coerce_template_parms): Likewise.
(tsubst_copy): Use flag_checking.
(type_unification_real): Remove conditional compilation.
(build_non_dependent_expr): Use flag_checking.
* tree.c (build_target_expr): Remove conditional compilation, use
gcc_checking_assert.
* typeck.c (comptypes): Likewise.
* typeck2.c (digest_init_r): Likewise.

From-SVN: r229756

14 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-omp.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/constexpr.c
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/cp/mangle.c
gcc/cp/method.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/tree.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index 32a13c0..97a2a84 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-04  Mikhail Maltsev  <maltsevm@gmail.com>
+
+       * c-omp.c (c_omp_split_clauses): Remove conditional compilation. Use
+       flag_checking.
+
 2015-11-03  Bernd Schmidt <bschmidt@redhat.com>
 
        PR c++-common/67882
index 133d079..ca64eda 100644 (file)
@@ -1135,7 +1135,10 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
       OMP_CLAUSE_CHAIN (clauses) = cclauses[s];
       cclauses[s] = clauses;
     }
-#ifdef ENABLE_CHECKING
+
+  if (!flag_checking)
+    return;
+
   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) == 0)
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_TARGET] == NULL_TREE);
   if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NUM_TEAMS)) == 0)
@@ -1150,7 +1153,6 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_FOR] == NULL_TREE);
   if (code != OMP_SIMD)
     gcc_assert (cclauses[C_OMP_CLAUSE_SPLIT_SIMD] == NULL_TREE);
-#endif
 }
 
 
index 86c3653..6243afa 100644 (file)
@@ -1,3 +1,29 @@
+2015-11-04  Mikhail Maltsev  <maltsevm@gmail.com>
+
+       * call.c (validate_conversion_obstack): Define unconditionally.
+       * constexpr.c (maybe_constant_value, fold_non_dependent_expr): Use
+       gcc_checking_assert.
+       * cp-tree.h: Use CHECKING_P instead of ENABLE_CHECKING.
+       * decl2.c (cxx_post_compilation_parsing_cleanups): Use flag_checking.
+       * mangle.c (add_substitution): Likewise.
+       * method.c (maybe_explain_implicit_delete): Likewise.
+       * parser.c (cp_parser_template_argument_list): Remove conditional
+       compilation.
+       * pt.c (check_unstripped_args): Rename to...
+       (verify_unstripped_args): ... this and remove conditional compilation.
+       (retrieve_specialization): Guard call of verify_unstripped_args with
+       flag_checking.
+       (template_parm_to_arg): Remove conditional compilation.
+       (template_parms_to_args, coerce_template_parameter_pack,
+       coerce_template_parms): Likewise.
+       (tsubst_copy): Use flag_checking.
+       (type_unification_real): Remove conditional compilation.
+       (build_non_dependent_expr): Use flag_checking.
+       * tree.c (build_target_expr): Remove conditional compilation, use
+       gcc_checking_assert.
+       * typeck.c (comptypes): Likewise.
+       * typeck2.c (digest_init_r): Likewise.
+
 2015-11-03  Jason Merrill  <jason@redhat.com>
 
        * pt.c (struct find_parameter_pack_data): Add
index 9178188..0b7d143 100644 (file)
@@ -724,8 +724,6 @@ alloc_conversion (conversion_kind kind)
   return c;
 }
 
-#ifdef ENABLE_CHECKING
-
 /* Make sure that all memory on the conversion obstack has been
    freed.  */
 
@@ -737,8 +735,6 @@ validate_conversion_obstack (void)
                 == obstack_base (&conversion_obstack)));
 }
 
-#endif /* ENABLE_CHECKING */
-
 /* Dynamically allocate an array of N conversions.  */
 
 static conversion **
index 038c6f5..51fae5a 100644 (file)
@@ -3856,13 +3856,11 @@ maybe_constant_value (tree t, tree decl)
     }
 
   r = cxx_eval_outermost_constant_expr (t, true, true, decl);
-#ifdef ENABLE_CHECKING
-  gcc_assert (r == t
-             || CONVERT_EXPR_P (t)
-             || TREE_CODE (t) == VIEW_CONVERT_EXPR
-             || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
-             || !cp_tree_equal (r, t));
-#endif
+  gcc_checking_assert (r == t
+                      || CONVERT_EXPR_P (t)
+                      || TREE_CODE (t) == VIEW_CONVERT_EXPR
+                      || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
+                      || !cp_tree_equal (r, t));
   return r;
 }
 
@@ -3906,14 +3904,12 @@ fold_non_dependent_expr (tree t)
            }
 
          tree r = cxx_eval_outermost_constant_expr (t, true, true, NULL_TREE);
-#ifdef ENABLE_CHECKING
          /* cp_tree_equal looks through NOPs, so allow them.  */
-         gcc_assert (r == t
-                     || CONVERT_EXPR_P (t)
-                     || TREE_CODE (t) == VIEW_CONVERT_EXPR
-                     || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
-                     || !cp_tree_equal (r, t));
-#endif
+         gcc_checking_assert (r == t
+                              || CONVERT_EXPR_P (t)
+                              || TREE_CODE (t) == VIEW_CONVERT_EXPR
+                              || (TREE_CONSTANT (t) && !TREE_CONSTANT (r))
+                              || !cp_tree_equal (r, t));
          return r;
        }
       else if (TREE_OVERFLOW_P (t))
index adb4bae..3c54e76 100644 (file)
@@ -3010,7 +3010,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
    property.  */
 #define SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE, INT_VALUE) \
   NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) = build_int_cst (NULL_TREE, INT_VALUE)
-#ifdef ENABLE_CHECKING
+#if CHECKING_P
 #define GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT(NODE) \
     int_cst_value (NON_DEFAULT_TEMPLATE_ARGS_COUNT (NODE))
 #else
@@ -5517,9 +5517,7 @@ extern tree build_cxx_call                        (tree, int, tree *,
                                                 tsubst_flags_t);
 extern bool is_std_init_list                   (tree);
 extern bool is_list_ctor                       (tree);
-#ifdef ENABLE_CHECKING
 extern void validate_conversion_obstack                (void);
-#endif /* ENABLE_CHECKING */
 extern void mark_versions_used                 (tree);
 extern tree get_function_version_dispatcher    (tree);
 
index 01d4607..23f59eb 100644 (file)
@@ -4923,9 +4923,8 @@ cxx_post_compilation_parsing_cleanups (void)
 
   input_location = locus_at_end_of_parsing;
 
-#ifdef ENABLE_CHECKING
-  validate_conversion_obstack ();
-#endif /* ENABLE_CHECKING */
+  if (flag_checking)
+    validate_conversion_obstack ();
 
   timevar_stop (TV_PHASE_LATE_PARSING_CLEANUPS);
 }
index b6b9f38..182e605 100644 (file)
@@ -396,20 +396,19 @@ add_substitution (tree node)
             get_tree_code_name (TREE_CODE (node)), (void *) node);
   node = c;
 
-#if ENABLE_CHECKING
   /* Make sure NODE isn't already a candidate.  */
-  {
-    int i;
-    tree candidate;
+  if (flag_checking)
+    {
+      int i;
+      tree candidate;
 
-    FOR_EACH_VEC_SAFE_ELT (G.substitutions, i, candidate)
-      {
-       gcc_assert (!(DECL_P (node) && node == candidate));
-       gcc_assert (!(TYPE_P (node) && TYPE_P (candidate)
+      FOR_EACH_VEC_SAFE_ELT (G.substitutions, i, candidate)
+       {
+         gcc_assert (!(DECL_P (node) && node == candidate));
+         gcc_assert (!(TYPE_P (node) && TYPE_P (candidate)
                      && same_type_p (node, candidate)));
-      }
-  }
-#endif /* ENABLE_CHECKING */
+       }
+    }
 
   /* Put the decl onto the varray of substitution candidates.  */
   vec_safe_push (G.substitutions, node);
index 4de6cc2..97643b7 100644 (file)
@@ -1645,10 +1645,8 @@ maybe_explain_implicit_delete (tree decl)
                    "deleted because its exception-specification does not "
                    "match the implicit exception-specification %qX",
                    decl, raises);
-#ifdef ENABLE_CHECKING
-         else
+         else if (flag_checking)
            gcc_unreachable ();
-#endif
 
          pop_scope (scope);
        }
index a90bf3b..12452e6 100644 (file)
@@ -14838,9 +14838,8 @@ cp_parser_template_argument_list (cp_parser* parser)
   parser->non_integral_constant_expression_p = saved_non_ice_p;
   parser->integral_constant_expression_p = saved_ice_p;
   parser->in_template_argument_list_p = saved_in_template_argument_list_p;
-#ifdef ENABLE_CHECKING
-  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
-#endif
+  if (CHECKING_P)
+    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
   return vec;
 }
 
index bc1ba2f..e3f55a7 100644 (file)
@@ -1134,9 +1134,8 @@ optimize_specialization_lookup_p (tree tmpl)
    gone through coerce_template_parms by now.  */
 
 static void
-check_unstripped_args (tree args ATTRIBUTE_UNUSED)
+verify_unstripped_args (tree args)
 {
-#ifdef ENABLE_CHECKING
   ++processing_template_decl;
   if (!any_dependent_template_arguments_p (args))
     {
@@ -1156,7 +1155,6 @@ check_unstripped_args (tree args ATTRIBUTE_UNUSED)
        }
     }
   --processing_template_decl;
-#endif
 }
 
 /* Retrieve the specialization (in the sense of [temp.spec] - a
@@ -1192,7 +1190,8 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
                  ? TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl))
                  : template_class_depth (DECL_CONTEXT (tmpl))));
 
-  check_unstripped_args (args);
+  if (flag_checking)
+    verify_unstripped_args (args);
 
   if (optimize_specialization_lookup_p (tmpl))
     {
@@ -4213,10 +4212,9 @@ template_parm_to_arg (tree t)
          /* Turn this argument into a TYPE_ARGUMENT_PACK
             with a single element, which expands T.  */
          tree vec = make_tree_vec (1);
-#ifdef ENABLE_CHECKING
-         SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
-           (vec, TREE_VEC_LENGTH (vec));
-#endif
+         if (CHECKING_P)
+           SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
+
          TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
 
          t = cxx_make_type (TYPE_ARGUMENT_PACK);
@@ -4233,10 +4231,9 @@ template_parm_to_arg (tree t)
             with a single element, which expands T.  */
          tree vec = make_tree_vec (1);
          tree type = TREE_TYPE (TEMPLATE_PARM_DECL (t));
-#ifdef ENABLE_CHECKING
-         SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
-           (vec, TREE_VEC_LENGTH (vec));
-#endif
+         if (CHECKING_P)
+           SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (vec, TREE_VEC_LENGTH (vec));
+
          t = convert_from_reference (t);
          TREE_VEC_ELT (vec, 0) = make_pack_expansion (t);
 
@@ -4277,9 +4274,8 @@ template_parms_to_args (tree parms)
       for (i = TREE_VEC_LENGTH (a) - 1; i >= 0; --i)
        TREE_VEC_ELT (a, i) = template_parm_to_arg (TREE_VEC_ELT (a, i));
 
-#ifdef ENABLE_CHECKING
-      SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (a, TREE_VEC_LENGTH (a));
-#endif
+      if (CHECKING_P)
+       SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (a, TREE_VEC_LENGTH (a));
 
       if (length > 1)
        TREE_VEC_ELT (args, --l) = a;
@@ -7398,10 +7394,9 @@ coerce_template_parameter_pack (tree parms,
     }
 
   SET_ARGUMENT_PACK_ARGS (argument_pack, packed_args);
-#ifdef ENABLE_CHECKING
-  SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,
-                                      TREE_VEC_LENGTH (packed_args));
-#endif
+  if (CHECKING_P)
+    SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,
+                                        TREE_VEC_LENGTH (packed_args));
   return argument_pack;
 }
 
@@ -7708,11 +7703,9 @@ coerce_template_parms (tree parms,
   if (lost)
     return error_mark_node;
 
-#ifdef ENABLE_CHECKING
-  if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
+  if (CHECKING_P && !NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args))
     SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_inner_args,
                                         TREE_VEC_LENGTH (new_inner_args));
-#endif
 
   return new_inner_args;
 }
@@ -14292,8 +14285,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       return tsubst_binary_right_fold (t, args, complain, in_decl);
 
     default:
-      /* We shouldn't get here, but keep going if !ENABLE_CHECKING.  */
-      gcc_checking_assert (false);
+      /* We shouldn't get here, but keep going if !flag_checking.  */
+      if (flag_checking)
+       gcc_unreachable ();
       return t;
     }
 }
@@ -18201,10 +18195,9 @@ type_unification_real (tree tparms,
       if (saw_undeduced++ == 1)
        goto again;
     }
-#ifdef ENABLE_CHECKING
-  if (!NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
+
+  if (CHECKING_P && !NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs))
     SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (targs, TREE_VEC_LENGTH (targs));
-#endif
 
   return unify_success (explain_p);
 }
@@ -23252,12 +23245,10 @@ build_non_dependent_expr (tree expr)
 {
   tree inner_expr;
 
-#ifdef ENABLE_CHECKING
   /* Try to get a constant value for all non-dependent expressions in
       order to expose bugs in *_dependent_expression_p and constexpr.  */
-  if (cxx_dialect >= cxx11)
+  if (flag_checking && cxx_dialect >= cxx11)
     fold_non_dependent_expr (expr);
-#endif
 
   /* Preserve OVERLOADs; the functions must be available to resolve
      types.  */
index 11bd129..4311212 100644 (file)
@@ -321,15 +321,13 @@ build_target_expr (tree decl, tree value, tsubst_flags_t complain)
   tree t;
   tree type = TREE_TYPE (decl);
 
-#ifdef ENABLE_CHECKING
-  gcc_assert (VOID_TYPE_P (TREE_TYPE (value))
-             || TREE_TYPE (decl) == TREE_TYPE (value)
-             /* On ARM ctors return 'this'.  */
-             || (TYPE_PTR_P (TREE_TYPE (value))
-                 && TREE_CODE (value) == CALL_EXPR)
-             || useless_type_conversion_p (TREE_TYPE (decl),
-                                           TREE_TYPE (value)));
-#endif
+  gcc_checking_assert (VOID_TYPE_P (TREE_TYPE (value))
+                      || TREE_TYPE (decl) == TREE_TYPE (value)
+                      /* On ARM ctors return 'this'.  */
+                      || (TYPE_PTR_P (TREE_TYPE (value))
+                          && TREE_CODE (value) == CALL_EXPR)
+                      || useless_type_conversion_p (TREE_TYPE (decl),
+                                                    TREE_TYPE (value)));
 
   t = cxx_maybe_build_cleanup (decl, complain);
   if (t == error_mark_node)
index e68e9df..0501e4d 100644 (file)
@@ -1418,8 +1418,7 @@ comptypes (tree t1, tree t2, int strict)
           perform a deep check. */
        return structural_comptypes (t1, t2, strict);
 
-#ifdef ENABLE_CHECKING
-      if (USE_CANONICAL_TYPES)
+      if (flag_checking && USE_CANONICAL_TYPES)
        {
          bool result = structural_comptypes (t1, t2, strict);
          
@@ -1440,10 +1439,8 @@ comptypes (tree t1, tree t2, int strict)
          
          return result;
        }
-#else
-      if (USE_CANONICAL_TYPES)
+      if (!flag_checking && USE_CANONICAL_TYPES)
        return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
-#endif
       else
        return structural_comptypes (t1, t2, strict);
     }
index b717ea9..000f5e3 100644 (file)
@@ -1075,11 +1075,11 @@ digest_init_r (tree type, tree init, bool nested, int flags,
              || TREE_CODE (type) == UNION_TYPE
              || TREE_CODE (type) == COMPLEX_TYPE);
 
-#ifdef ENABLE_CHECKING
   /* "If T is a class type and the initializer list has a single
      element of type cv U, where U is T or a class derived from T,
      the object is initialized from that element."  */
-  if (cxx_dialect >= cxx11
+  if (flag_checking
+      && cxx_dialect >= cxx11
       && BRACE_ENCLOSED_INITIALIZER_P (init)
       && CONSTRUCTOR_NELTS (init) == 1
       && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
@@ -1090,7 +1090,6 @@ digest_init_r (tree type, tree init, bool nested, int flags,
        /* We should have fixed this in reshape_init.  */
        gcc_unreachable ();
     }
-#endif
 
   if (BRACE_ENCLOSED_INITIALIZER_P (init)
       && !TYPE_NON_AGGREGATE_CLASS (type))