public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] PR fortran/67805 -- Check for invalid charlength
@ 2015-10-24 19:29 Dominique d'Humières
  2015-10-24 20:44 ` Mikael Morin
  0 siblings, 1 reply; 5+ messages in thread
From: Dominique d'Humières @ 2015-10-24 19:29 UTC (permalink / raw)
  To: Steve Kargl; +Cc: paul Thomas, gfortran, gcc-patches

At revision r229288 compiling the following test

  implicit none

  type :: template_t
     integer :: type
     character(256) :: charset1, charset2
     integer :: len1, len2
  end type template_t

contains

  subroutine match_quoted (tt, s, n, range)
    type(template_t), intent(in) :: tt
    character(*), intent(in) :: s
    integer, intent(out) :: n
    integer, dimension(2), intent(out) :: range
    character(tt%len1) :: ch1
    character(tt%len2) :: ch2
    integer :: i
    ch1 = tt%charset1
    if (s(1:tt%len1) == ch1) then
       ch2 = tt%charset2
       do i = tt%len1 + 1, len (s) - tt%len2 + 1
          if (s(i:i+tt%len2-1) == ch2) then
             n = i + tt%len2 - 1
             range(1) = tt%len1 + 1
             range(2) = i - 1
             return
          end if
       end do
       n = -1
       range = 0
    else
       n = 0
       range = 0
    end if
  end subroutine match_quoted

end

gives the following errors

pr40440_red_1.f90:16:14:

     character(tt%len1) :: ch1
              1
Error: Scalar INTEGER expression expected at (1)
pr40440_red_1.f90:17:14:

     character(tt%len2) :: ch2
              1
Error: Scalar INTEGER expression expected at (1)
pr40440_red_1.f90:19:7:

     ch1 = tt%charset1
       1
Error: Symbol 'ch1' at (1) has no IMPLICIT type
pr40440_red_1.f90:21:10:

        ch2 = tt%charset2
          1
Error: Symbol 'ch2' at (1) has no IMPLICIT type

while it compiles without error at r229261.

TIA

Dominique

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [PATCH] PR fortran/67805 -- Check for invalid charlength
@ 2015-10-23 19:28 Steve Kargl
  2015-10-23 19:29 ` Steve Kargl
  0 siblings, 1 reply; 5+ messages in thread
From: Steve Kargl @ 2015-10-23 19:28 UTC (permalink / raw)
  To: fortran, gcc-patches

All,

The attached patch fixes several ICEs caused by invalid
charlengths.  The new testcase pr67805.f90 shows the 
kinds of issues the patch will detect.  An appropriate
error message is now issued.

Built and regression tested on x86_64-*-freebsd.
OK to commit?

2015-10-23  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67805
	* array.c (gfc_match_array_constructor): Check for error from type
	spec matching.
	* decl.c (char_len_param_value): Check for valid of charlen parameter.
	Reap dead code dating to 2008.
	match.c (gfc_match_type_spec): Special case the keyword use in REAL.

2015-10-23  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67805
	* gfortran.dg/pr67805.f90: New testcase.
	* gfortran.dg/array_constructor_26.f03: Update testcase.
	* gfortran.dg/array_constructor_27.f03: Ditto.
	* gfortran.dg/char_type_len_2.f90: Ditto.
	* gfortran.dg/pr67802.f90: Ditto.
	* gfortran.dg/used_before_typed_3.f90: Ditto.

-- 
Steve

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

end of thread, other threads:[~2015-10-24 20:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-24 19:29 [PATCH] PR fortran/67805 -- Check for invalid charlength Dominique d'Humières
2015-10-24 20:44 ` Mikael Morin
  -- strict thread matches above, loose matches on Subject: below --
2015-10-23 19:28 Steve Kargl
2015-10-23 19:29 ` Steve Kargl
2015-10-24  5:51   ` Paul Richard Thomas

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