primary.c (gfc_match_structure_constructor): Allow constructor for types without...
authorTobias Burnus <burnus@net-b.de>
Thu, 22 Nov 2007 21:40:22 +0000 (22:40 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 22 Nov 2007 21:40:22 +0000 (22:40 +0100)
2007-11-22  Tobias Burnus  <burnus@net-b.de>

        * primary.c (gfc_match_structure_constructor): Allow
        constructor for types without components.

2007-11-22  Tobias Burnus  <burnus@net-b.de>

        * gfortran.dg/derived_constructor_comps_3.f90: New.

From-SVN: r130358

gcc/fortran/ChangeLog
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/derived_constructor_comps_3.f90 [new file with mode: 0644]

index 43f622947449cc4a86942433a0a74b0e295fb085..3939e0b58d78fba962db14f284eb140f5f4350b4 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-22  Tobias Burnus  <burnus@net-b.de>
+
+       * primary.c (gfc_match_structure_constructor): Allow
+       constructor for types without components.
+
 2007-11-22  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/34079
index 7e3d539ba16555dacf01a1eb1549d3fe4e700fca..52977f7e84ab6cda44f95897f47ae044bdd33ec2 100644 (file)
@@ -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;
index ccd81e904c94b6264fcd59ff29d70573d6be1cfb..4bde17874ebda8b68496cb9ecd6a976af570c822 100644 (file)
@@ -1,3 +1,7 @@
+2007-11-22  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/derived_constructor_comps_3.f90: New.
+
 2007-11-22  Jakub Jelinek  <jakub@redhat.com>
 
        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 (file)
index 0000000..688c38d
--- /dev/null
@@ -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" } }