aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/decl.c11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr93792.f9017
4 files changed, 39 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e3957fb..90e1cab 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-05 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/93792
+ * decl.c (variable_decl): If param and initializer check
+ for BOZ, if found, output an error, set m to MATCH_ERROR
+ and goto cleanup.
+
2020-03-02 Andrew Benson <abensonca@gmail.com>
PR fortran/93486
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 7382fea..2f458c4 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2929,7 +2929,16 @@ variable_decl (int elem)
goto cleanup;
}
else if (param && initializer)
- param->value = gfc_copy_expr (initializer);
+ {
+ if (initializer->ts.type == BT_BOZ)
+ {
+ gfc_error ("BOZ literal constant at %L cannot appear as an "
+ "initializer", &initializer->where);
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
+ param->value = gfc_copy_expr (initializer);
+ }
}
/* Before adding a possible initilizer, do a simple check for compatibility
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7dcc80d..851e0e9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-05 Mark Eggleston <mark.eggleston@codethink.com>
+
+ PR fortran/93792
+ * gfortran.dg/pr93792.f90: New test.
+
2020-03-05 Delia Burduv <delia.burduv@arm.com>
* gcc.target/arm/simd/bf16_ma_1.c: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr93792.f90 b/gcc/testsuite/gfortran.dg/pr93792.f90
new file mode 100644
index 0000000..960d050
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93792.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! Original test case by Gernhard Steinmetz.
+
+module m
+ type t(n)
+ integer, len :: n = z'1'
+ end type
+end
+program p
+ use m
+ type(t(:)), allocatable :: z
+end
+
+! { dg-error "Parameterized type 't' does not have a component" " " { target *-*-* } 5 }
+! { dg-error "BOZ literal constant at .1. cannot appear" " " { target *-*-* } 6 }
+! { dg-error "Cannot open module file" " " { target *-*-* } 10 }
+! { dg-excess-errors "compilation terminated" }