diff mbox series

[committed] d: Use toTypeFunction instead of explicit cast

Message ID 20200616215933.3858164-10-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: Use toTypeFunction instead of explicit cast | expand

Commit Message

Iain Buclaw June 16, 2020, 9:59 p.m. UTC
Hi,

This patch replaces uses of casting to TypeFunction with toTypeFunction,
which takes care of asserting that `ty' is a `Tfunction'.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
master.

Regards
Iain


gcc/d/ChangeLog:

	* d-frontend.cc (eval_builtin): Use toTypeFunction instead of cast.
	* decl.cc (DeclVisitor::visit): Likewise.
	* toir.cc (IRVisitor::visit): Likewise.
	* typeinfo.cc (TypeInfoVisitor::visit): Likewise.
---
 gcc/d/d-frontend.cc |  2 +-
 gcc/d/decl.cc       | 28 ++++++++--------------------
 gcc/d/toir.cc       |  2 +-
 gcc/d/typeinfo.cc   |  3 +--
 4 files changed, 11 insertions(+), 24 deletions(-)
diff mbox series

Patch

diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc
index 5415d471ef4..7434819d644 100644
--- a/gcc/d/d-frontend.cc
+++ b/gcc/d/d-frontend.cc
@@ -177,7 +177,7 @@  eval_builtin (Loc loc, FuncDeclaration *fd, Expressions *arguments)
   gcc_assert (fndecl_built_in_p (decl)
 	      || DECL_INTRINSIC_CODE (decl) != INTRINSIC_NONE);
 
-  TypeFunction *tf = (TypeFunction *) fd->type;
+  TypeFunction *tf = fd->type->toTypeFunction ();
   Expression *e = NULL;
   input_location = make_location_t (loc);
 
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 05868631eed..a6144f7c269 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -449,26 +449,14 @@  public:
 
 	    if (fd->leastAsSpecialized (fd2) || fd2->leastAsSpecialized (fd))
 	      {
-		TypeFunction *tf = (TypeFunction *) fd->type;
-		if (tf->ty == Tfunction)
-		  {
-		    error_at (make_location_t (fd->loc), "use of %qs",
-			      fd->toPrettyChars ());
-		    inform (make_location_t (fd2->loc), "is hidden by %qs",
-			    fd2->toPrettyChars ());
-		    inform (make_location_t (d->loc),
-			    "use %<alias %s = %s.%s;%> to introduce base class "
-			    "overload set", fd->toChars (),
-			    fd->parent->toChars (), fd->toChars ());
-		  }
-		else
-		  {
-		    error_at (make_location_t (fd->loc), "use of %qs",
-			      fd->toPrettyChars ());
-		    inform (make_location_t (fd2->loc), "is hidden by %qs",
-			      fd2->toPrettyChars ());
-		  }
-
+		error_at (make_location_t (fd->loc), "use of %qs",
+			  fd->toPrettyChars ());
+		inform (make_location_t (fd2->loc), "is hidden by %qs",
+			fd2->toPrettyChars ());
+		inform (make_location_t (d->loc),
+			"use %<alias %s = %s.%s;%> to introduce base class "
+			"overload set", fd->toChars (),
+			fd->parent->toChars (), fd->toChars ());
 		has_errors = true;
 		break;
 	      }
diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
index 92d0ecdb0a0..d8a14efd667 100644
--- a/gcc/d/toir.cc
+++ b/gcc/d/toir.cc
@@ -1006,7 +1006,7 @@  public:
 	return;
       }
 
-    TypeFunction *tf = (TypeFunction *)this->func_->type;
+    TypeFunction *tf = this->func_->type->toTypeFunction ();
     Type *type = this->func_->tintro != NULL
       ? this->func_->tintro->nextOf () : tf->nextOf ();
 
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index 73443eaed50..f3051d3e122 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -1045,8 +1045,7 @@  public:
 
     if (sd->xhash)
       {
-	TypeFunction *tf = (TypeFunction *) sd->xhash->type;
-	gcc_assert (tf->ty == Tfunction);
+	TypeFunction *tf = sd->xhash->type->toTypeFunction ();
 	if (!tf->isnothrow || tf->trust == TRUSTsystem)
 	  {
 	    warning (sd->xhash->loc, "toHash() must be declared as "