diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 43f62294744..3939e0b58d7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2007-11-22 Tobias Burnus + + * primary.c (gfc_match_structure_constructor): Allow + constructor for types without components. + 2007-11-22 Tobias Burnus PR fortran/34079 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 7e3d539ba16..52977f7e84a 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -1979,7 +1979,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result) if (gfc_match_char (')') != MATCH_YES) goto syntax; - if (comp->next != NULL) + if (comp && comp->next != NULL) { gfc_error ("Too few components in structure constructor at %C"); goto cleanup; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ccd81e904c9..4bde17874eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2007-11-22 Tobias Burnus + + * gfortran.dg/derived_constructor_comps_3.f90: New. + 2007-11-22 Jakub Jelinek PR c++/34094 diff --git a/gcc/testsuite/gfortran.dg/derived_constructor_comps_3.f90 b/gcc/testsuite/gfortran.dg/derived_constructor_comps_3.f90 new file mode 100644 index 00000000000..688c38d9192 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/derived_constructor_comps_3.f90 @@ -0,0 +1,22 @@ +! { dg-compile } +! +! gfortran was ICEing for the constructor of +! componentfree types. +! +! Contributed by James Van Buskirk +! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/c8dd08d6da052499/ +! + module bug4_mod + implicit none + type bug4 ! no components + end type bug4 +end module bug4_mod + +program bug4_structure + use bug4_mod + implicit none + type(bug4) t + t = bug4() + write(*,*) t +end program bug4_structure +! { dg-final { cleanup-modules "bug4_mod" } }