diff options
author | Janus Weil <janus@gcc.gnu.org> | 2011-10-20 00:05:23 +0200 |
---|---|---|
committer | Janus Weil <janus@gcc.gnu.org> | 2011-10-20 00:05:23 +0200 |
commit | 2c23ebfec69d77f9d62e80bfb4157c184f88364f (patch) | |
tree | 7bb1b66ecb7f8dab68864953e87af67e4240c434 | |
parent | e423833d36290e6919a4f286f0ba92e2395267c5 (diff) | |
download | gcc-2c23ebfec69d77f9d62e80bfb4157c184f88364f.zip gcc-2c23ebfec69d77f9d62e80bfb4157c184f88364f.tar.gz gcc-2c23ebfec69d77f9d62e80bfb4157c184f88364f.tar.bz2 |
re PR fortran/47023 (C_Sizeof: Rejects valid code)
2011-10-19 Janus Weil <janus@gcc.gnu.org>
PR fortran/47023
* check.c (gfc_check_sizeof): Reject procedures as argument of SIZEOF.
* intrinsinc.texi (SIZEOF): Document it.
(STORAGE_SIZE): Fix special characters. Fix line breaks.
2011-10-19 Janus Weil <janus@gcc.gnu.org>
PR fortran/47023
* gfortran.dg/sizeof_proc.f90: New.
From-SVN: r180210
-rw-r--r-- | gcc/fortran/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/fortran/check.c | 9 | ||||
-rw-r--r-- | gcc/fortran/intrinsic.texi | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/sizeof_proc.f90 | 28 |
5 files changed, 54 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f7a793f..a350ff2 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2011-10-19 Janus Weil <janus@gcc.gnu.org> + + PR fortran/47023 + * check.c (gfc_check_sizeof): Reject procedures as argument of SIZEOF. + * intrinsinc.texi (SIZEOF): Document it. + (STORAGE_SIZE): Fix special characters. Fix line breaks. + 2011-10-18 Mikael Morin <mikael@gcc.gnu.org> PR fortran/50420 diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index eb8b3e1..bf45592 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -3444,8 +3444,15 @@ gfc_check_size (gfc_expr *array, gfc_expr *dim, gfc_expr *kind) gfc_try -gfc_check_sizeof (gfc_expr *arg ATTRIBUTE_UNUSED) +gfc_check_sizeof (gfc_expr *arg) { + if (arg->ts.type == BT_PROCEDURE) + { + gfc_error ("'%s' argument of '%s' intrinsic at %L may not be a procedure", + gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic, + &arg->where); + return FAILURE; + } return SUCCESS; } diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi index 11f87a5..084cd15 100644 --- a/gcc/fortran/intrinsic.texi +++ b/gcc/fortran/intrinsic.texi @@ -11459,7 +11459,8 @@ number of bytes occupied by the argument. If the argument has the to is returned. If the argument is of a derived type with @code{POINTER} or @code{ALLOCATABLE} components, the return value doesn't account for the sizes of the data pointed to by these components. If the argument is -polymorphic, the size according to the declared type is returned. +polymorphic, the size according to the declared type is returned. The argument +may not be a procedure or procedure pointer. @item @emph{Example}: @smallexample @@ -11816,8 +11817,10 @@ Inquiry function @end multitable @item @emph{Return Value}: -The result is a scalar integer with the kind type parameter speciļ¬ed by KIND (or default integer type if KIND is missing). The result value is the size expressed in bits for an element of an array that -has the dynamic type and type parameters of A. +The result is a scalar integer with the kind type parameter specified by KIND +(or default integer type if KIND is missing). The result value is the size +expressed in bits for an element of an array that has the dynamic type and type +parameters of A. @item @emph{See also}: @ref{C_SIZEOF}, @ref{SIZEOF} diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b0d3bf..23f1e5f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-10-19 Janus Weil <janus@gcc.gnu.org> + + PR fortran/47023 + * gfortran.dg/sizeof_proc.f90: New. + 2011-10-19 Joseph Myers <joseph@codesourcery.com> * g++.dg/compat/struct-layout-1_generate.c: Also pass -mno-mmx diff --git a/gcc/testsuite/gfortran.dg/sizeof_proc.f90 b/gcc/testsuite/gfortran.dg/sizeof_proc.f90 new file mode 100644 index 0000000..b4a2d73 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/sizeof_proc.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! +! PR 47023: C_Sizeof: Rejects valid code +! +! Contributed by Janus Weil <janus@gcc.gnu.org> + +use iso_c_binding +procedure(real) :: proc +procedure(real), pointer :: pp +pp => sin + +print *,sizeof(proc) ! { dg-error "may not be a procedure" } +print *,sizeof(pp) ! { dg-error "may not be a procedure" } +print *,sizeof(pp(0.)) +print *,sizeof(sub) ! { dg-error "may not be a procedure" } +print *,sizeof(func) ! { dg-error "may not be a procedure" } +print *,sizeof(func()) + +contains + + subroutine sub + end subroutine + + real function func() + func = 0. + end function + +end |