aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/primary.c1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/structure_constructor_15.f9012
4 files changed, 25 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0f07e0a..fb0f04e 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2018-03-27 Thomas Koenig <tkoenig@gcc.gnu.org>
+ Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/85083
+ * primary.c (gfc_convert_to_structure_constructor): Check
+ conformance of argument types in structure constructor.
+
2018-03-26 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/66709
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index 702010a..094f210 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -2898,6 +2898,7 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
if (this_comp->ts.type == BT_CHARACTER && !this_comp->attr.allocatable
&& this_comp->ts.u.cl && this_comp->ts.u.cl->length
&& this_comp->ts.u.cl->length->expr_type == EXPR_CONSTANT
+ && actual->expr->ts.type == BT_CHARACTER
&& actual->expr->expr_type == EXPR_CONSTANT)
{
ptrdiff_t c, e;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 292cfed..642bf15 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-27 Thomas Koenig <tkoenig@gcc.gnu.org>
+ Harald Anlauf <anlauf@gmx.de>
+
+ * gfortran.dg/structure_constructor_15.f90: New test.
+
2018-03-27 Volker Reichelt <v.reichelt@netcologne.de>
* g++.dg/cpp0x/defaulted2.C: Use dg-message instead of dg-error
diff --git a/gcc/testsuite/gfortran.dg/structure_constructor_15.f90 b/gcc/testsuite/gfortran.dg/structure_constructor_15.f90
new file mode 100644
index 0000000..583e3ab
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/structure_constructor_15.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR 85083
+!
+! Testcase from PR by G. Steinmetz <gscfq@t-online.de>
+!
+program p
+ type t
+ character(3) :: c
+ end type t
+ type(t), allocatable :: z
+ allocate (z, source=t(.true.,'abc')) ! { dg-error "Too many components" }
+end