]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove unreachable gcc_unreachable () at the end of functions
authorRichard Biener <rguenther@suse.de>
Wed, 24 Nov 2021 14:57:03 +0000 (15:57 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 29 Nov 2021 10:18:35 +0000 (11:18 +0100)
It seems to be a style to place gcc_unreachable () after a
switch that handles all cases with every case returning.
Those are unreachable (well, yes!), so they will be elided
at CFG construction time and the middle-end will place
another __builtin_unreachable "after" them to note the
path doesn't lead to a return when the function is not declared
void.

So IMHO those explicit gcc_unreachable () serve no purpose,
if they could be replaced by a comment.  But since all cases
cover switches not handling a case or not returning will
likely cause some diagnostic to be emitted which is better
than running into an ICE only at runtime.

2021-11-24  Richard Biener  <rguenther@suse.de>

* tree.h (reverse_storage_order_for_component_p): Remove
spurious gcc_unreachable.
* cfganal.c (dfs_find_deadend): Likewise.
* fold-const-call.c (fold_const_logb): Likewise.
(fold_const_significand): Likewise.
* gimple-ssa-store-merging.c (lhs_valid_for_store_merging_p):
Likewise.

gcc/c-family/
* c-format.c (check_format_string): Remove spurious
gcc_unreachable.

gcc/c-family/c-format.c
gcc/cfganal.c
gcc/fold-const-call.c
gcc/gimple-ssa-store-merging.c
gcc/tree.h

index e735e0920434722530ab127be39cd1b4563e823f..617fb5ea6266dd714c04ba24ab79d344bcda50fa 100644 (file)
@@ -296,8 +296,6 @@ check_format_string (const_tree fntype, unsigned HOST_WIDE_INT format_num,
       *no_add_attrs = true;
       return false;
     }
-
-  gcc_unreachable ();
 }
 
 /* Under the control of FLAGS, verify EXPR is a valid constant that
index 0cba612738d3c88e5a53e248fda175b3ee73d3e7..48598e55c01471ece546b522279e9f80f9c3ec0c 100644 (file)
@@ -752,8 +752,6 @@ dfs_find_deadend (basic_block bb)
          next = e ? e->dest : EDGE_SUCC (bb, 0)->dest;
        }
     }
-
-  gcc_unreachable ();
 }
 
 
index d6cb9b11a318fd2ea71868a62fc2004687d6e047..c542e780a18679748b62f00f476b0ea904e376c8 100644 (file)
@@ -429,7 +429,6 @@ fold_const_logb (real_value *result, const real_value *arg,
        }
       return false;
     }
-  gcc_unreachable ();
 }
 
 /* Try to evaluate:
@@ -463,7 +462,6 @@ fold_const_significand (real_value *result, const real_value *arg,
        }
       return false;
     }
-  gcc_unreachable ();
 }
 
 /* Try to evaluate:
index a00370e2a374f845801a76ae4a6ba3099154b4ed..29d5c2449abcb0644ded8f1ea1dbc303af51a01e 100644 (file)
@@ -4867,8 +4867,6 @@ lhs_valid_for_store_merging_p (tree lhs)
     default:
       return false;
     }
-
-  gcc_unreachable ();
 }
 
 /* Return true if the tree RHS is a constant we want to consider
index f0e72b55abeb1814775424197a5809154866ae83..094501bd9b1aaf3c7f2cf3d687785445de96ecb6 100644 (file)
@@ -5110,8 +5110,6 @@ reverse_storage_order_for_component_p (tree t)
     default:
       return false;
     }
-
-  gcc_unreachable ();
 }
 
 /* Return true if T is a storage order barrier, i.e. a VIEW_CONVERT_EXPR