public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Committed two additional test cases
@ 2015-05-17 14:43 Thomas Koenig
  0 siblings, 0 replies; only message in thread
From: Thomas Koenig @ 2015-05-17 14:43 UTC (permalink / raw)
  To: fortran, gcc-patches

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

Hello world,

I have committed the two test cases below as obviously
correct after testing.

They stress bounds checking on matmul by having an argument
whose size cannot be predicted at compile-time.

Regards

	Thomas

2015-05-17  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/37131
	* gfortran.dg/matmul_bounds_6.f90:  New test.
	* gfortran.dg/matmul_bounds_7.f90:  New test.

[-- Attachment #2: matmul_bounds_6.f90 --]
[-- Type: text/x-fortran, Size: 642 bytes --]

! { dg-do run }
program main
  real, dimension(3,2) :: a
  real, dimension(6) :: b
  real, dimension(3) :: res1
  real, dimension(:), allocatable :: c1, c2,c3
  real, dimension(2) :: res2

  data a /-2., 3., -5., 7., -11., 13./
  data b /17., -23., 29., -31., 37., -41./
  data res1 /201., -320., 336./
  data res2 /158., -353./

  c1 = matmul(a,[29.,37.])
  if (size(c1,1) /= 3) call abort
  if (any(c1/=res1)) call abort

  c2 = matmul(a,pack(b,[b>20.]))
  if (size(c1,1) /= 3) call abort
  if (any(c1/=res1)) call abort

  c3 = matmul(pack(b,[b<0.]),a)
  if (size(c3,1) /= 2) call abort
  if (any(c3 /= res2)) call abort

end program main

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

! { dg-do run }
! { dg-additional-options "-fcheck=bounds" }
! { dg-shouldfail "Fortran runtime error: dimension of array B incorrect in MATMUL intrinsic" }

program main
  real, dimension(3,2) :: a
  real, dimension(6) :: b
  real, dimension(:), allocatable :: c

  data a /-2., 3., -5., 7., -11., 13./
  data b /17., -23., 29., -31., 37., -41./

  c = matmul(pack(b,[b<20.]),a)
  print *,sum(c)

end program main

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-17 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-17 14:43 [patch, fortran] Committed two additional test cases Thomas Koenig

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).