diff mbox series

[committed] d: Convert convert_for_rvalue switch statement into if condition

Message ID 20210829163353.2036482-1-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: Convert convert_for_rvalue switch statement into if condition | expand

Commit Message

Iain Buclaw Aug. 29, 2021, 4:33 p.m. UTC
Hi,

This patch replaces the switch statement in convert_for_rvalue with an
if condition.  In the D implementation of the D front-end, the condition
value has been changed to an `enum class` type.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32,
committed to mainline.

Regards,
Iain

---
gcc/d/ChangeLog:

	* d-convert.cc (convert_for_rvalue): Convert switch statement into if
	condition.
---
 gcc/d/d-convert.cc | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index d43485dca77..3b4790298a5 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -613,9 +613,8 @@  convert_for_rvalue (tree expr, Type *etype, Type *totype)
   Type *ebtype = etype->toBasetype ();
   Type *tbtype = totype->toBasetype ();
 
-  switch (ebtype->ty)
+  if (ebtype->ty == Tbool)
     {
-    case Tbool:
       /* If casting from bool, the result is either 0 or 1, any other value
 	 violates @safe code, so enforce that it is never invalid.  */
       if (CONSTANT_CLASS_P (expr))
@@ -633,7 +632,6 @@  convert_for_rvalue (tree expr, Type *etype, Type *totype)
 	}
 
       result = convert (build_ctype (tbtype), result);
-      break;
     }
 
   return result ? result : convert_expr (expr, etype, totype);