d: Use toTypeFunction instead of explicit cast
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 15 Jun 2020 14:56:02 +0000 (16:56 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Tue, 16 Jun 2020 21:33:26 +0000 (23:33 +0200)
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
gcc/d/decl.cc
gcc/d/toir.cc
gcc/d/typeinfo.cc

index 5415d471ef4c4fda0a4e6e2ab3bb26cad68f7eec..7434819d6449d9417d52485c51de250ebe336551 100644 (file)
@@ -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);
 
index 05868631eedd663225023dcc99857848bb213030..a6144f7c269f28ff69549df53cf675716170fed0 100644 (file)
@@ -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;
              }
index 92d0ecdb0a0441c172dce59ce91a5f749d015835..d8a14efd6672fff2e1507a36183c5c8e59e210eb 100644 (file)
@@ -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 ();
 
index 73443eaed505af89db821930864b02d6794b9962..f3051d3e122c5b8fe14a6ccc08db803ce1069e6b 100644 (file)
@@ -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 "