diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-06-13 18:07:53 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2019-06-13 18:07:53 +0000 |
commit | b9fb83059d73733742f5511f9261111db8eddbfd (patch) | |
tree | 64d2a813f0ab7c748fdff8d459e839be182f6eff /gcc | |
parent | 7b6879b2db04384b7228f2aca4533be817b9efbd (diff) | |
download | gcc-b9fb83059d73733742f5511f9261111db8eddbfd.zip gcc-b9fb83059d73733742f5511f9261111db8eddbfd.tar.gz gcc-b9fb83059d73733742f5511f9261111db8eddbfd.tar.bz2 |
re PR fortran/89344 (uncaught programmer error: polymorphic variable is INTENT(IN) but assigned to without error)
2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89344
* expr.c (gfc_check_vardef_context): Check for INTENT(IN) variable
in SELECT TYPE construct.
2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89344
* gfortran.dg/pr89344.f90: New test.
From-SVN: r272255
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/expr.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr89344.f90 | 15 |
4 files changed, 35 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ebff427..2b2395c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/89344 + * expr.c (gfc_check_vardef_context): Check for INTENT(IN) variable + in SELECT TYPE construct. + +2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org> + PR fortran/88810 * dependency.c (gfc_dep_resolver): Re-arrange code to make the logic a bit more transparent. Fix 2 nearby formatting issues. diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 949eff1..ec9e328 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -6089,7 +6089,12 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, check_intentin = false; } } - if (check_intentin && sym->attr.intent == INTENT_IN) + + if (check_intentin + && (sym->attr.intent == INTENT_IN + || (sym->attr.select_type_temporary && sym->assoc + && sym->assoc->target && sym->assoc->target->symtree + && sym->assoc->target->symtree->n.sym->attr.intent == INTENT_IN))) { if (pointer && is_pointer) { @@ -6101,10 +6106,12 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool alloc_obj, } if (!pointer && !is_pointer && !sym->attr.pointer) { + const char *name = sym->attr.select_type_temporary + ? sym->assoc->target->symtree->name : sym->name; if (context) gfc_error ("Dummy argument %qs with INTENT(IN) in variable" " definition context (%s) at %L", - sym->name, context, &e->where); + name, context, &e->where); return false; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7ec2594..1761ae7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org> + + PR fortran/89344 + * gfortran.dg/pr89344.f90: New test. + 2019-06-13 Iain Sandoe <iain@sandoe.co.uk> * gcc.dg/darwin-minversion-1.c: Use compile rather than link/run. diff --git a/gcc/testsuite/gfortran.dg/pr89344.f90 b/gcc/testsuite/gfortran.dg/pr89344.f90 new file mode 100644 index 0000000..8749071 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89344.f90 @@ -0,0 +1,15 @@ +! { dg-do compile } +program demo_setval + call setval(value) + write(*,*)'VALUE=',value + contains + subroutine setval(value) + class(*),intent(in) :: value + select type(value) + type is (integer) + value = 10 ! { dg-error "in variable definition context" } + type is (real) + value = 10.20 ! { dg-error "in variable definition context" } + end select + end subroutine setval +end program demo_setval |