public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Fix PR 83664, missing check on boundary argument for eoshift
@ 2018-01-03 11:14 Thomas Koenig
  2018-01-03 11:17 ` Janne Blomqvist
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Koenig @ 2018-01-03 11:14 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

Hello world,

the attached patch fixes a missing check for eoshift.

If you're wondering what the "else" belongs to - it is

   if (boundary != NULL)

Regression-tested. OK for trunk?

Regards

	Thomas

2018-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/83664
         * check.c (gfc_check_eoshift): Error for missing boundary if array
         is not one of the standard types.

2018-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/83664
         * gfortran.dg/eoshift_7.f90: New test.

[-- Attachment #2: p-check.diff --]
[-- Type: text/x-patch, Size: 719 bytes --]

Index: check.c
===================================================================
--- check.c	(Revision 255788)
+++ check.c	(Arbeitskopie)
@@ -2270,6 +2270,26 @@ gfc_check_eoshift (gfc_expr *array, gfc_expr *shif
 	  return false;
 	}
     }
+  else
+    {
+      switch (array->ts.type)
+	{
+	case BT_INTEGER:
+	case BT_LOGICAL:
+	case BT_REAL:
+	case BT_COMPLEX:
+	case BT_CHARACTER:
+	  break;
+	  
+	default:
+	  gfc_error ("Missing %qs argument to %qs intrinsic at %L for %qs "
+		     "of type %qs", gfc_current_intrinsic_arg[2]->name,
+		     gfc_current_intrinsic, &array->where,
+		     gfc_current_intrinsic_arg[0]->name,
+		     gfc_typename (&array->ts));
+	  return false;
+	}
+    }
 
   return true;
 }

[-- Attachment #3: eoshift_7.f90 --]
[-- Type: text/x-fortran, Size: 248 bytes --]

! { dg-do compile }
program main
  type t
    integer :: x
  end type t
  type(t), dimension(2) :: a, b
  a(1)%x = 1
  a(2)%x = 2
  b = eoshift(a,1) ! { dg-error "Missing 'boundary' argument to 'eoshift' intrinsic" }
  print *,b%x
end program main

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch, fortran] Fix PR 83664, missing check on boundary argument for eoshift
  2018-01-03 11:14 [patch, fortran] Fix PR 83664, missing check on boundary argument for eoshift Thomas Koenig
@ 2018-01-03 11:17 ` Janne Blomqvist
  0 siblings, 0 replies; 2+ messages in thread
From: Janne Blomqvist @ 2018-01-03 11:17 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Wed, Jan 3, 2018 at 1:13 PM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hello world,
>
> the attached patch fixes a missing check for eoshift.
>
> If you're wondering what the "else" belongs to - it is
>
>   if (boundary != NULL)
>
> Regression-tested. OK for trunk?
>
> Regards
>
>         Thomas
>
> 2018-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>         PR fortran/83664
>         * check.c (gfc_check_eoshift): Error for missing boundary if array
>         is not one of the standard types.
>
> 2018-01-03  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>         PR fortran/83664
>         * gfortran.dg/eoshift_7.f90: New test.

Ok for trunk, thanks!

-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-03 11:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-03 11:14 [patch, fortran] Fix PR 83664, missing check on boundary argument for eoshift Thomas Koenig
2018-01-03 11:17 ` Janne Blomqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).