* [PATCH] PR fortran/89646 -- suppress spurious warnings
@ 2019-06-13 22:15 Steve Kargl
2019-06-14 16:09 ` Janne Blomqvist
0 siblings, 1 reply; 2+ messages in thread
From: Steve Kargl @ 2019-06-13 22:15 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 457 bytes --]
The attached patch suppresses the spurious warnings that
would otherwise occur for the testcase. Regression
tested cleanly on x86_64-*-freebsd. OK to commit?
2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89646
* dependency.c (gfc_check_argument_var_dependency): Suppress spurious
warnings by comparing variable names.
2019-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/89646
* gfortran.dg/pr89646.f90: New test.
--
Steve
[-- Attachment #2: pr89646.diff --]
[-- Type: text/x-diff, Size: 1982 bytes --]
Index: gcc/fortran/dependency.c
===================================================================
--- gcc/fortran/dependency.c (revision 272257)
+++ gcc/fortran/dependency.c (working copy)
@@ -979,10 +979,14 @@ gfc_check_argument_var_dependency (gfc_expr *var, sym_
If a dependency is found in the case
elemental == ELEM_CHECK_VARIABLE, we will generate
a temporary, so we don't need to bother the user. */
- gfc_warning (0, "INTENT(%s) actual argument at %L might "
- "interfere with actual argument at %L.",
- intent == INTENT_OUT ? "OUT" : "INOUT",
- &var->where, &expr->where);
+
+ if (var->expr_type == EXPR_VARIABLE
+ && expr->expr_type == EXPR_VARIABLE
+ && strcmp(var->symtree->name, expr->symtree->name) == 0)
+ gfc_warning (0, "INTENT(%s) actual argument at %L might "
+ "interfere with actual argument at %L.",
+ intent == INTENT_OUT ? "OUT" : "INOUT",
+ &var->where, &expr->where);
}
return 0;
}
Index: gcc/testsuite/gfortran.dg/pr89646.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr89646.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr89646.f90 (working copy)
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! PR fortran/89646
+! Original testcase contributed by Ian Harvey <ian_harvey at bigpond dot com>
+!
+! This code use to give spurious warnings about aliasing.
+!
+module m
+ implicit none
+ type :: t
+ end type t
+ contains
+ ! To reproduce, both actual arguments must be TARGET,
+ ! both arguments must be of derived type.
+ subroutine s
+ type(t), target :: a(5)
+ type(t), target :: b(5)
+ call move(a, b)
+ end subroutine s
+ ! To reproduce, called procedure must be elemental.
+ elemental subroutine move(x, y)
+ type(t), intent(inout) :: x
+ type(t), intent(out) :: y
+ end subroutine move
+end module m
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] PR fortran/89646 -- suppress spurious warnings
2019-06-13 22:15 [PATCH] PR fortran/89646 -- suppress spurious warnings Steve Kargl
@ 2019-06-14 16:09 ` Janne Blomqvist
0 siblings, 0 replies; 2+ messages in thread
From: Janne Blomqvist @ 2019-06-14 16:09 UTC (permalink / raw)
To: Steve Kargl; +Cc: Fortran List, GCC Patches
On Fri, Jun 14, 2019 at 1:16 AM Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:
>
> The attached patch suppresses the spurious warnings that
> would otherwise occur for the testcase. Regression
> tested cleanly on x86_64-*-freebsd. OK to commit?
Ok, thanks for the patch.
--
Janne Blomqvist
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-14 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 22:15 [PATCH] PR fortran/89646 -- suppress spurious warnings Steve Kargl
2019-06-14 16:09 ` Janne Blomqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).