On Fri, 12 Nov 2021 18:39:48 +0100
Harald Anlauf via Fortran <fort...@gcc.gnu.org> wrote:

Sounds plausible.
Nits:

> diff --git a/gcc/testsuite/gfortran.dg/c_sizeof_7.f90 
> b/gcc/testsuite/gfortran.dg/c_sizeof_7.f90
> new file mode 100644
> index 00000000000..3cfa3371f72
> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/c_sizeof_7.f90

[I'd name this .f08, no?]

> @@ -0,0 +1,13 @@
> +! { dg-do compile }
> +! { dg-options "-std=f2008 -fdump-tree-original" }

[and drop the -std]

> +! { dg-final { scan-tree-dump-times "_gfortran_stop_numeric" 0 "original" } }

[ ...-times 0 == scan-tree-dump-not ]

> +! PR fortran/102368
> +
> +program main
> +  use, intrinsic :: iso_c_binding
> +  implicit none
> +  character(kind=c_char, len=*), parameter :: a = 'abc'
> +  character(kind=c_char, len=8)            :: b

character(kind=c_char, len=-42) :: c ! { dg-error "positive integer greater 
than 0" }
character(kind=c_char, len=-0) :: d ! { dg-error "positive integer greater than 
0" }
character(kind=c_char, len=0) :: e ! { dg-error "positive integer greater than 
0" }
character(kind=c_char, len=+0) :: f ! { dg-error "positive integer greater than 
0" }
character(kind=c_char, len=0.0d) :: g ! { dg-error "positive integer greater 
than 0" }
character(kind=c_char, len=3.) :: h ! { dg-error "positive integer greater than 
0" }
character(kind=c_char, len=.031415e2) :: i ! { dg-error "positive integer 
greater than 0" }
...
are caught elsewhere if one assumes that len should be a positive int > 0 
(didn't look)
Also did not look if
character(kind=c_char, len=SELECTED_REAL_KIND(10)) :: j ! is that constant? 
Should it be?

> +  if (c_sizeof (a) /= 3) stop 1
> +  if (c_sizeof (b) /= 8) stop 2

indeed.
cheers,

> +end program main
> --
> 2.26.2
> 

Reply via email to