public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/95446] New: False positive for optional arguments of elemental procedure
@ 2020-05-30 22:45 m.diehl at mpie dot de
2020-05-31 4:02 ` [Bug fortran/95446] " kargl at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: m.diehl at mpie dot de @ 2020-05-30 22:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
Bug ID: 95446
Summary: False positive for optional arguments of elemental
procedure
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: m.diehl at mpie dot de
Target Milestone: ---
to my understanding, the following code is valid
program elemental_optional
implicit none
integer :: m(5), r(5)
m = 1
r = outer()
r = outer(m)
contains
function outer(o) result(l)
integer, intent(in), optional :: o(:)
integer :: u(5), l(5)
l = inner(o,u)
end function outer
elemental function inner(a,b) result(x)
integer, intent(in), optional :: a
integer, intent(in) :: b
integer :: x
if(present(a)) then
x = a*b
else
x = b
endif
end function inner
end program elemental_optional
however, when compiling with "-pedantic-errors", the following error message
shows up:
Error: ‘o’ at (1) is an array and OPTIONAL; IF IT IS MISSING, it cannot be the
actual argument of an ELEMENTAL procedure unless there is a non-optional
argument with the same rank (12.4.1.5) [-Werror=pedantic]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/95446] False positive for optional arguments of elemental procedure
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
@ 2020-05-31 4:02 ` kargl at gcc dot gnu.org
2020-05-31 7:13 ` m.diehl at mpie dot de
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-05-31 4:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
Priority|P3 |P4
--- Comment #1 from kargl at gcc dot gnu.org ---
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 280157)
+++ gcc/fortran/resolve.c (working copy)
@@ -2275,11 +2275,27 @@ resolve_elemental_actual (gfc_expr *expr, gfc_code *c)
&& (set_by_optional || arg->expr->rank != rank)
&& !(isym && isym->id == GFC_ISYM_CONVERSION))
{
- gfc_warning (OPT_Wpedantic,
- "%qs at %L is an array and OPTIONAL; IF IT IS "
- "MISSING, it cannot be the actual argument of an "
- "ELEMENTAL procedure unless there is a non-optional "
- "argument with the same rank (12.4.1.5)",
+ bool t = false;
+ gfc_actual_arglist *a;
+
+ /* Scan the argument list for a non-optional argument with the
+ same rank as arg. */
+ for (a = arg0; a; a = a->next)
+ if (a != arg
+ && a->expr->rank == arg->expr->rank
+ && !a->expr->symtree->n.sym->attr.optional)
+ {
+ t = true;
+ break;
+ }
+
+ if (!t)
+ gfc_warning (OPT_Wpedantic,
+ "%qs at %L is an array with an OPTIONAL attribute; "
+ "If it is not present, than it cannot be the actual "
+ "argument of an ELEMENTAL procedure unless there is "
+ "a non-optional argument with the same rank "
+ "(Fortran 2018, 15.5.2.12)",
arg->expr->symtree->n.sym->name, &arg->expr->where);
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/95446] False positive for optional arguments of elemental procedure
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
2020-05-31 4:02 ` [Bug fortran/95446] " kargl at gcc dot gnu.org
@ 2020-05-31 7:13 ` m.diehl at mpie dot de
2020-06-09 10:48 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: m.diehl at mpie dot de @ 2020-05-31 7:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
--- Comment #2 from Martin Diehl <m.diehl at mpie dot de> ---
many thanks for the quick reply!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/95446] False positive for optional arguments of elemental procedure
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
2020-05-31 4:02 ` [Bug fortran/95446] " kargl at gcc dot gnu.org
2020-05-31 7:13 ` m.diehl at mpie dot de
@ 2020-06-09 10:48 ` dominiq at lps dot ens.fr
2020-07-01 14:40 ` cvs-commit at gcc dot gnu.org
2020-07-02 7:24 ` markeggleston at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-06-09 10:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-06-09
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/95446] False positive for optional arguments of elemental procedure
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
` (2 preceding siblings ...)
2020-06-09 10:48 ` dominiq at lps dot ens.fr
@ 2020-07-01 14:40 ` cvs-commit at gcc dot gnu.org
2020-07-02 7:24 ` markeggleston at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-01 14:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mark Eggleston
<markeggleston@gcc.gnu.org>:
https://gcc.gnu.org/g:685d8dafb4a1cb29ee219ad7857614ff66a78022
commit r11-1761-g685d8dafb4a1cb29ee219ad7857614ff66a78022
Author: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Mon Jun 1 14:56:00 2020 +0100
Fortran : False positive for optional arguments PR95446
Check that there is non-optional argument of the same rank in the
list of actual arguments. If there is the warning is not required.
2020-07-01 Steven G. Kargl <kargl@gcc.gnu.org>
gcc/fortran/
PR fortran/95446
* resolve.c (resolve_elemental_actual): Add code to check for
non-optional argument of the same rank. Revise warning message
to refer to the Fortran 2018 standard.
2020-07-01 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/testsuite/
PR fortran/95446
* gfortran.dg/elemental_optional_args_6.f90: Remove check
for warnings that were erroneously output.
* gfortran.dg/pr95446.f90: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/95446] False positive for optional arguments of elemental procedure
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
` (3 preceding siblings ...)
2020-07-01 14:40 ` cvs-commit at gcc dot gnu.org
@ 2020-07-02 7:24 ` markeggleston at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: markeggleston at gcc dot gnu.org @ 2020-07-02 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
markeggleston at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |markeggleston at gcc dot gnu.org
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #4 from markeggleston at gcc dot gnu.org ---
committed to master.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-02 7:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 22:45 [Bug fortran/95446] New: False positive for optional arguments of elemental procedure m.diehl at mpie dot de
2020-05-31 4:02 ` [Bug fortran/95446] " kargl at gcc dot gnu.org
2020-05-31 7:13 ` m.diehl at mpie dot de
2020-06-09 10:48 ` dominiq at lps dot ens.fr
2020-07-01 14:40 ` cvs-commit at gcc dot gnu.org
2020-07-02 7:24 ` markeggleston at gcc dot gnu.org
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).