aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2021-05-05 15:25:50 +0200
committerHarald Anlauf <anlauf@gmx.de>2021-05-05 15:25:50 +0200
commita8b79cc939d6786293f654c42a2d1b0ab040de0e (patch)
tree03f0d8b2532c9e139e588d1fdd1ab1c8fe494560 /gcc
parentf3661f2d63fbc5fd30c24d22137691e16b0a0a17 (diff)
downloadgcc-a8b79cc939d6786293f654c42a2d1b0ab040de0e.zip
gcc-a8b79cc939d6786293f654c42a2d1b0ab040de0e.tar.gz
gcc-a8b79cc939d6786293f654c42a2d1b0ab040de0e.tar.bz2
PR fortran/100274 - ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
When the check for the length of formal and actual character arguments found a mismatch and emitted a warning, it would skip further checks like that could lead to errors. Fix that by continuing the checking. Also catch a NULL pointer dereference. gcc/fortran/ChangeLog: PR fortran/100274 * interface.c (gfc_compare_actual_formal): Continue checks after emitting warning for argument length mismatch. * trans-expr.c (gfc_conv_procedure_call): Check for NULL pointer dereference. gcc/testsuite/ChangeLog: PR fortran/100274 * gfortran.dg/argument_checking_25.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/interface.c11
-rw-r--r--gcc/fortran/trans-expr.c1
-rw-r--r--gcc/testsuite/gfortran.dg/argument_checking_25.f9012
3 files changed, 20 insertions, 4 deletions
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 6073612..9e3e8aa 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3255,10 +3255,13 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
&& f->sym->attr.flavor != FL_PROCEDURE)
{
if (a->expr->ts.type == BT_CHARACTER && !f->sym->as && where)
- gfc_warning (0, "Character length of actual argument shorter "
- "than of dummy argument %qs (%lu/%lu) at %L",
- f->sym->name, actual_size, formal_size,
- &a->expr->where);
+ {
+ gfc_warning (0, "Character length of actual argument shorter "
+ "than of dummy argument %qs (%lu/%lu) at %L",
+ f->sym->name, actual_size, formal_size,
+ &a->expr->where);
+ goto skip_size_check;
+ }
else if (where)
{
/* Emit a warning for -std=legacy and an error otherwise. */
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index b83b021..9389a45 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6125,6 +6125,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
bool add_clobber;
add_clobber = fsym && fsym->attr.intent == INTENT_OUT
&& !fsym->attr.allocatable && !fsym->attr.pointer
+ && e->symtree && e->symtree->n.sym
&& !e->symtree->n.sym->attr.dimension
&& !e->symtree->n.sym->attr.pointer
&& !e->symtree->n.sym->attr.allocatable
diff --git a/gcc/testsuite/gfortran.dg/argument_checking_25.f90 b/gcc/testsuite/gfortran.dg/argument_checking_25.f90
new file mode 100644
index 0000000..e699160
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/argument_checking_25.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/100274 - ICE in gfc_conv_procedure_call, at fortran/trans-expr.c:6131
+
+program p
+ call s('y') ! { dg-warning "Character length of actual argument" }
+contains
+ subroutine s(x)
+ character(8), intent(out) :: x
+ end
+end
+
+! { dg-error "in variable definition context" " " { target *-*-* } 5 }