diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2006-01-26 20:19:09 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2006-01-26 20:19:09 +0000 |
commit | 20236f90d949c062847aa4b7512db999c4d82f12 (patch) | |
tree | ebf78f5f326fc3e241a4ed6fc7cd2feb71ba9ae0 /gcc/testsuite/gfortran.dg | |
parent | e8b053801c57d8d7daf305d6b7ce01cbd4958e73 (diff) | |
download | gcc-20236f90d949c062847aa4b7512db999c4d82f12.zip gcc-20236f90d949c062847aa4b7512db999c4d82f12.tar.gz gcc-20236f90d949c062847aa4b7512db999c4d82f12.tar.bz2 |
re PR fortran/25964 (NIST regression on fm311.f)
2005-01-26 Paul Thomas <pault@gcc.gnu.org>
PR fortran/25964
* resolve.c (resolve_function): Exclude statement functions from
global reference checking.
PR fortran/25084
PR fortran/20852
PR fortran/25085
PR fortran/25086
* resolve.c (resolve_function): Declare a gfc_symbol to replace the
references through the symtree to the symbol associated with the
function expresion. Give error on reference to an assumed character
length function is defined in an interface or an external function
that is not a dummy argument.
(resolve_symbol): Give error if an assumed character length function
is array-valued, pointer-valued, pure or recursive. Emit warning
that character(*) value functions are obsolescent in F95.
PR fortran/25416
* trans-expr.c (gfc_conv_function_call): The above patch to resolve.c
prevents any assumed character length function call from getting here
except intrinsics such as SPREAD. In this case, ensure that no
segfault occurs from referencing non-existent charlen->length->
expr_type and provide a backend_decl for the charlen from the charlen
of the first actual argument.
Cure temp name confusion.
* trans-expr.c (gfc_get_interface_mapping_array): Change name of
temporary from "parm" to "ifm" to avoid clash with temp coming from
trans-array.c.
2005-01-26 Paul Thomas <pault@gcc.gnu.org>
PR fortran/25964
* gfortran.dg/global_references_2.f90: New test.
PR fortran/25084
PR fortran/20852
PR fortran/25085
PR fortran/25086
* gfortran.dg/assumed_charlen_function_1.f90: New test.
* gfortran.dg/assumed_charlen_function_3.f90: New test.
PR fortran/25416
* gfortran.dg/assumed_charlen_function_2.f90: New test.
From-SVN: r110269
Diffstat (limited to 'gcc/testsuite/gfortran.dg')
4 files changed, 145 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_function_1.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_function_1.f90 new file mode 100644 index 0000000..c90617d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_charlen_function_1.f90 @@ -0,0 +1,83 @@ +! { dg-do compile }
+! { dg-options "-std=legacy" }
+! Tests the patch for PRs 25084, 20852, 25085 and 25086, all of
+! which involve assumed character length functions.
+! Compiled from original PR testcases, which were all contributed
+! by Joost VandeVondele <jv244@cam.ac.uk>
+!
+! PR25084 - the error is not here but in any use of .IN.
+! It is OK to define an assumed character length function
+! in an interface but it cannot be invoked (5.1.1.5).
+
+MODULE M1
+ TYPE SET
+ INTEGER CARD
+ END TYPE SET
+END MODULE M1
+
+MODULE INTEGER_SETS
+ INTERFACE OPERATOR (.IN.)
+ FUNCTION ELEMENT(X,A)
+ USE M1
+ CHARACTER(LEN=*) :: ELEMENT
+ INTEGER, INTENT(IN) :: X
+ TYPE(SET), INTENT(IN) :: A
+ END FUNCTION ELEMENT
+ END INTERFACE
+END MODULE
+
+! 5.1.1.5 of the Standard: A function name declared with an asterisk
+! char-len-param shall not be array-valued, pointer-valued, recursive
+! or pure
+!
+! PR20852
+RECURSIVE FUNCTION TEST() ! { dg-error "cannot be recursive" }
+ CHARACTER(LEN=*) :: TEST
+ TEST = ""
+END FUNCTION
+
+!PR25085
+FUNCTION F1() ! { dg-error "cannot be array-valued" }
+ CHARACTER(LEN=*), DIMENSION(10) :: F1
+ F1 = ""
+END FUNCTION F1
+
+!PR25086
+FUNCTION F2() result(f4) ! { dg-error "cannot be pointer-valued" }
+ CHARACTER(LEN=*), POINTER :: f4
+ f4 = ""
+END FUNCTION F2
+
+!PR?????
+pure FUNCTION F3() ! { dg-error "cannot be pure" }
+ CHARACTER(LEN=*) :: F3
+ F3 = ""
+END FUNCTION F3
+
+function not_OK (ch)
+ character(*) not_OK, ch ! OK in an external function
+ not_OK = ch
+end function not_OK
+
+ use INTEGER_SETS
+ use m1
+
+ character(4) :: answer
+ character(*), external :: not_OK
+ integer :: i
+ type (set) :: z
+
+ interface
+ function ext (i)
+ character(*) :: ext
+ integer :: i
+ end function ext
+ end interface
+
+ answer = i.IN.z ! { dg-error "cannot be used|Operands of user operator" }
+ answer = ext (2) ! { dg-error "but cannot be used" }
+
+ answer = not_OK ("unOK") ! { dg-error "since it is not a dummy" }
+
+END
+
diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_function_2.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_function_2.f90 new file mode 100644 index 0000000..bd7d713 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_charlen_function_2.f90 @@ -0,0 +1,13 @@ +! { dg-do compile }
+! Tests the fix for PR25416, which ICED in gfc_conv_function_call, when
+! treating SPREAD in the statement below.
+!
+! Contributed by Ulrich Weigand <uweigand@gcc.gnu.org>
+function bug(self,strvec) result(res)
+ character(*) :: self
+ character(*), dimension(:), intent(in) :: strvec
+ logical(kind=kind(.true.)) :: res
+
+ res = any(index(strvec,spread(self,1,size(strvec))) /= 0)
+end function
+
diff --git a/gcc/testsuite/gfortran.dg/assumed_charlen_function_3.f90 b/gcc/testsuite/gfortran.dg/assumed_charlen_function_3.f90 new file mode 100644 index 0000000..09c9be9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/assumed_charlen_function_3.f90 @@ -0,0 +1,39 @@ +! { dg-do compile }
+! Tests the patch for PRs 25084, 20852, 25085 and 25086, all of
+! which involve assumed character length functions.
+! This test checks the things that should not emit errors.
+!
+! Contributed by Paul Thomas <pault@gcc.gnu.org>
+!
+function is_OK (ch) ! { dg-warning "is obsolescent in fortran 95" }
+ character(*) is_OK, ch ! OK in an external function
+ is_OK = ch
+end function is_OK
+
+! The warning occurs twice for the next line; for 'more_OK' and for 'fcn';
+function more_OK (ch, fcn) ! { dg-warning "is obsolescent in fortran 95" }
+ character(*) more_OK, ch
+ character (*), external :: fcn ! OK as a dummy argument
+ more_OK = fcn (ch)
+end function more_OK
+
+ character(4) :: answer
+ character(4), external :: is_OK, more_OK
+
+ answer = is_OK ("isOK") ! LEN defined in calling scope
+ print *, answer
+
+ answer = more_OK ("okay", is_OK) ! Actual arg has defined LEN
+ print *, answer
+
+ answer = also_OK ("OKOK")
+ print *, answer
+
+contains
+ function also_OK (ch)
+ character(4) also_OK
+ character(*) ch
+ also_OK = is_OK (ch) ! LEN obtained by host association
+ end function also_OK
+END
+
diff --git a/gcc/testsuite/gfortran.dg/global_references_2.f90 b/gcc/testsuite/gfortran.dg/global_references_2.f90 new file mode 100644 index 0000000..9566698 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/global_references_2.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! This program tests the patch for PR25964. This is a +! regression that would not allow a common block and a statement +! to share the same name. +! +! Contributed by Paul Thomas <pault@gcc.gnu.org> + common /foo/ a, b, c + foo (x) = x + 1.0 + print *, foo (0.0) + end
\ No newline at end of file |