public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/102180] New: Improve checking of assume size array spec
@ 2021-09-02 20:04 anlauf at gcc dot gnu.org
  2022-12-11 22:34 ` [Bug fortran/102180] " anlauf at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-02 20:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102180

            Bug ID: 102180
           Summary: Improve checking of assume size array spec
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

F2018 has:

8.5.8.5  Assumed-size array

R821 assumed-implied-spec  is  [ lower-bound : ] *


We currently give a misleading error message for:

subroutine s(x)
  real :: x(0:*) ! legal
end

subroutine t(x)
  real :: x(:*) ! illegal
end


uuu.f90:6:14:

    6 |   real :: x(:*) ! illegal
      |              1
Error: Expected another dimension in array declaration at (1)


A possibly better error message could be:

uuu.f90:6:15:

    6 |   real :: x(:*) ! illegal
      |               1
Error: A lower bound must precede colon in assumed size array specification at
(1)

which is obtained by the patch:

diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index b858bada18a..56d26455972 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -481,6 +481,13 @@ match_array_element_spec (gfc_array_spec *as)
       return AS_ASSUMED_SIZE;
     }

+  if (gfc_match (" : * ") == MATCH_YES)
+    {
+      gfc_error ("A lower bound must precede colon in "
+                "assumed size array specification at %C");
+      return AS_UNKNOWN;
+    }
+
   if (gfc_match_char (':') == MATCH_YES)
     return AS_DEFERRED;


This might be important for some other PRs, as this affects the return value
of match_array_element_spec.  This is also potentially relevant for illegal
coarray specs, such as

  integer :: a[1:,:*]

where match_array_element_spec currently returns AS_DEFERRED for a badly
specified dimension.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/102180] Improve checking of assume size array spec
  2021-09-02 20:04 [Bug fortran/102180] New: Improve checking of assume size array spec anlauf at gcc dot gnu.org
@ 2022-12-11 22:34 ` anlauf at gcc dot gnu.org
  2022-12-12 19:43 ` cvs-commit at gcc dot gnu.org
  2022-12-12 19:50 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-11 22:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102180

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org
   Last reconfirmed|                            |2022-12-11

--- Comment #1 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2022-December/058623.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/102180] Improve checking of assume size array spec
  2021-09-02 20:04 [Bug fortran/102180] New: Improve checking of assume size array spec anlauf at gcc dot gnu.org
  2022-12-11 22:34 ` [Bug fortran/102180] " anlauf at gcc dot gnu.org
@ 2022-12-12 19:43 ` cvs-commit at gcc dot gnu.org
  2022-12-12 19:50 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-12 19:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102180

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:cf5327b89ab610649c5faab78ea7907bb74b103c

commit r13-4623-gcf5327b89ab610649c5faab78ea7907bb74b103c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Dec 11 23:24:03 2022 +0100

    Fortran: improve checking of assumed-size array spec [PR102180]

    gcc/fortran/ChangeLog:

            PR fortran/102180
            * array.cc (match_array_element_spec): Add check for bad
            assumed-implied-spec.
            (gfc_match_array_spec): Reorder logic so that the first bad array
            element spec may trigger an error.

    gcc/testsuite/ChangeLog:

            PR fortran/102180
            * gfortran.dg/pr102180.f90: New test.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/102180] Improve checking of assume size array spec
  2021-09-02 20:04 [Bug fortran/102180] New: Improve checking of assume size array spec anlauf at gcc dot gnu.org
  2022-12-11 22:34 ` [Bug fortran/102180] " anlauf at gcc dot gnu.org
  2022-12-12 19:43 ` cvs-commit at gcc dot gnu.org
@ 2022-12-12 19:50 ` anlauf at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-12-12 19:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102180

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |13.0

--- Comment #3 from anlauf at gcc dot gnu.org ---
Fixed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-12 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-02 20:04 [Bug fortran/102180] New: Improve checking of assume size array spec anlauf at gcc dot gnu.org
2022-12-11 22:34 ` [Bug fortran/102180] " anlauf at gcc dot gnu.org
2022-12-12 19:43 ` cvs-commit at gcc dot gnu.org
2022-12-12 19:50 ` anlauf 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).