diff mbox series

Fix clang warnings.

Message ID 189a233e-c594-0775-ad97-969c6885e541@suse.cz
State New
Headers show
Series Fix clang warnings. | expand

Commit Message

Martin Liška April 21, 2021, 8:18 a.m. UTC
Hello.

The patch silents Clang warnings:
1) if (TARGET_MACHO
) ...
 #if TARGET_MACHO

can be replaced with #if TARGET_MACHO

2) add_AT_vms_delta is used only if VMS_DEBUGGING_INFO is defined
3) tree.c:13454:16: warning: result of comparison of constant 42405 with expression of type 'enum tree_code' is always false [-Wtautological-constant-out-of-range-compare]

4) use canonical (more common form) of a condition that's intentionally disabled.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	* config/i386/i386.c: Remove superfluous || TARGET_MACHO
	which remains to be '(... || 0)' and clang complains about it.
	* dwarf2out.c (AT_vms_delta): Declare conditionally.
	(add_AT_vms_delta): Likewise.
	* tree.c (fld_simplified_type): Use rather more common pattern
	for disabling of something (#if 0).
	(get_tree_code_name): Likewise.
	(verify_type_variant): Likewise.
---
 gcc/config/i386/i386.c |  7 +++----
 gcc/dwarf2out.c        |  4 ++++
 gcc/tree.c             | 18 +++++++++++++-----
 3 files changed, 20 insertions(+), 9 deletions(-)

Comments

Jeff Law April 21, 2021, 12:56 p.m. UTC | #1
On 4/21/2021 2:18 AM, Martin Liška wrote:
> Hello.
>
> The patch silents Clang warnings:
> 1) if (TARGET_MACHO
> ) ...
>   #if TARGET_MACHO
>
> can be replaced with #if TARGET_MACHO
>
> 2) add_AT_vms_delta is used only if VMS_DEBUGGING_INFO is defined
> 3) tree.c:13454:16: warning: result of comparison of constant 42405 with expression of type 'enum tree_code' is always false [-Wtautological-constant-out-of-range-compare]
>
> 4) use canonical (more common form) of a condition that's intentionally disabled.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
> 	* config/i386/i386.c: Remove superfluous || TARGET_MACHO
> 	which remains to be '(... || 0)' and clang complains about it.
> 	* dwarf2out.c (AT_vms_delta): Declare conditionally.
> 	(add_AT_vms_delta): Likewise.
> 	* tree.c (fld_simplified_type): Use rather more common pattern
> 	for disabling of something (#if 0).
> 	(get_tree_code_name): Likewise.
> 	(verify_type_variant): Likewise.

OK

jeff
diff mbox series

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 7c41302c75b..09f4e25e3d4 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -10817,12 +10817,11 @@  ix86_legitimate_address_p (machine_mode, rtx addr, bool strict)
 
       else if (SYMBOLIC_CONST (disp)
 	       && (flag_pic
-		   || (TARGET_MACHO
 #if TARGET_MACHO
-		       && MACHOPIC_INDIRECT
-		       && !machopic_operand_p (disp)
+		   || (MACHOPIC_INDIRECT
+		       && !machopic_operand_p (disp))
 #endif
-	       )))
+		  ))
 	{
 
 	is_legitimate_pic:
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7a15debcb48..aba16848295 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3929,8 +3929,10 @@  static void prune_unused_types (void);
 static int maybe_emit_file (struct dwarf_file_data *fd);
 static inline const char *AT_vms_delta1 (dw_attr_node *);
 static inline const char *AT_vms_delta2 (dw_attr_node *);
+#if VMS_DEBUGGING_INFO
 static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute,
 				     const char *, const char *);
+#endif
 static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree);
 static void gen_remaining_tmpl_value_param_die_attribute (void);
 static bool generic_type_p (tree);
@@ -5200,6 +5202,7 @@  AT_file (dw_attr_node *a)
   return a->dw_attr_val.v.val_file;
 }
 
+#if VMS_DEBUGGING_INFO
 /* Add a vms delta attribute value to a DIE.  */
 
 static inline void
@@ -5215,6 +5218,7 @@  add_AT_vms_delta (dw_die_ref die, enum dwarf_attribute attr_kind,
   attr.dw_attr_val.v.val_vms_delta.lbl2 = xstrdup (lbl2);
   add_dwarf_attr (die, &attr);
 }
+#endif
 
 /* Add a symbolic view identifier attribute value to a DIE.  */
 
diff --git a/gcc/tree.c b/gcc/tree.c
index e4e74ac8afc..6129d911ee6 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -5538,9 +5538,11 @@  fld_simplified_type (tree t, class free_lang_data_d *fld)
   if (POINTER_TYPE_P (t))
     return fld_incomplete_type_of (t, fld);
   /* FIXME: This triggers verification error, see PR88140.  */
-  if (TREE_CODE (t) == ARRAY_TYPE && 0)
+#if 0
+  if (TREE_CODE (t) == ARRAY_TYPE)
     return fld_process_array_type (t, fld_simplified_type (TREE_TYPE (t), fld),
 				   fld_simplified_types, fld);
+#endif
   return t;
 }
 
@@ -13451,7 +13453,7 @@  get_tree_code_name (enum tree_code code)
      invalid values, so force an unsigned comparison.  */
   if (unsigned (code) >= MAX_TREE_CODES)
     {
-      if (code == 0xa5a5)
+      if ((unsigned)code == 0xa5a5)
 	return "ggc_freed";
       return invalid;
     }
@@ -14099,8 +14101,10 @@  verify_type_variant (const_tree t, tree tv)
 
   verify_variant_match (TREE_CODE);
   /* FIXME: Ada builds non-artificial variants of artificial types.  */
-  if (TYPE_ARTIFICIAL (tv) && 0)
+#if 0
+  if (TYPE_ARTIFICIAL (tv))
     verify_variant_match (TYPE_ARTIFICIAL);
+#endif
   if (POINTER_TYPE_P (tv))
     verify_variant_match (TYPE_REF_CAN_ALIAS_ALL);
   /* FIXME: TYPE_SIZES_GIMPLIFIED may differs for Ada build.  */
@@ -14113,8 +14117,10 @@  verify_type_variant (const_tree t, tree tv)
   else
     verify_variant_match (TYPE_SATURATING);
   /* FIXME: This check trigger during libstdc++ build.  */
-  if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t) && 0)
+#if 0
+  if (RECORD_OR_UNION_TYPE_P (t) && COMPLETE_TYPE_P (t))
     verify_variant_match (TYPE_FINAL_P);
+#endif
 
   /* tree_type_common checks.  */
 
@@ -14149,8 +14155,10 @@  verify_type_variant (const_tree t, tree tv)
      that may differ BY TYPE_CONTEXT that in turn may point 
      to TRANSLATION_UNIT_DECL.
      Ada also builds variants of types with different TYPE_CONTEXT.   */
-  if ((!in_lto_p || !TYPE_FILE_SCOPE_P (t)) && 0)
+#if 0
+  if (!in_lto_p || !TYPE_FILE_SCOPE_P (t))
     verify_variant_match (TYPE_CONTEXT);
+#endif
   if (TREE_CODE (t) == ARRAY_TYPE || TREE_CODE (t) == INTEGER_TYPE)
     verify_variant_match (TYPE_STRING_FLAG);
   if (TREE_CODE (t) == RECORD_TYPE || TREE_CODE (t) == UNION_TYPE)