public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken
@ 2020-08-11 10:55 vries at gcc dot gnu.org
  2020-08-25  9:17 ` [Bug m2/26372] " cvs-commit at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-11 10:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26372

            Bug ID: 26372
           Summary: [Modula-2] Parsing of multi-subscript arrays broken
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: m2
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

When building gdb I see these warnings:
...
src/gdb/m2-exp.y: warning: 34 shift/reduce conflicts [-Wconflicts-sr]
src/gdb/m2-exp.y:301.25-52: warning: rule useless in parser due to conflicts
[-Wother]
...

Looking at line 301, it's related to multi-subscript:
...
   296  /* Modula-2 array subscript notation [a,b,c...] */
   297  exp     :       exp '['
   298                          /* This function just saves the number of
arguments
   299                             that follow in the list.  It is *not*
specific to
   300                             function types */
   301                          { pstate->start_arglist(); }
   302                  non_empty_arglist ']'  %prec DOT
   303                          { write_exp_elt_opcode (pstate,
MULTI_SUBSCRIPT);
   304                            write_exp_elt_longcst (pstate,
   305                                                  
pstate->end_arglist());
   306                            write_exp_elt_opcode (pstate,
MULTI_SUBSCRIPT); }
   307          ;
   308
   309  exp     :       exp '[' exp ']'
   310                          { write_exp_elt_opcode (pstate,
BINOP_SUBSCRIPT); }
   311          ;
...

Using an existing modula-2 test-case, we have with single-subscript:
...
$ gdb -batch \
  outputs/gdb.modula2/max-depth/max-depth \
  -ex start \
  -ex "set language modula-2" \
  -ex "print s3.s2.str[1]"
Temporary breakpoint 1 at 0x4004ab: file max-depth.c, line 40.

Temporary breakpoint 1, main () at max-depth.c:40
40        memcpy (s3.s2.str, "abcde\0fghi", 10);
Warning: the current language does not match this frame.
$1 = 4
...
and with multi-subscript:
...
(gdb) print s3.s2.str[1,2]
A syntax error in expression, near `,2]'.
...

If we strip the conflicting rule m2-exp.y (line 309-311) we have instead:
...
(gdb) print s3.s2.str[1,2]
cannot subscript something of type `char'
...

So, that confirms that we're current not able to parse multi-subscript
expressions in modula-2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug m2/26372] [Modula-2] Parsing of multi-subscript arrays broken
  2020-08-11 10:55 [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken vries at gcc dot gnu.org
@ 2020-08-25  9:17 ` cvs-commit at gcc dot gnu.org
  2020-08-25  9:32 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25  9:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26372

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376

commit 07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Tue Aug 25 11:16:56 2020 +0200

    Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays

    Here is a bugfix for Pr 26372 [Modula-2] Parsing of multi-subscript arrays.
    Also included is a dejagnu testcase.  No extra regressions are caused on
    Debian GNU/Linux Buster amd64.

    gdb/ChangeLog:

    2020-08-25  Gaius Mulley  <gaiusmod2@gmail.com>

            PR m2/26372
            * m2-exp.y: Rewrite array subscript rules to support multidimension
            array access.  (ArgumentList) replaces non_empty_arglist.

    gdb/testsuite/ChangeLog:

    2020-08-25  Gaius Mulley  <gaiusmod2@gmail.com>

            PR m2/26372
            * testsuite/gdb.modula2/multidim.exp: New file.
            * testsuite/gdb.modula2/multidim.c: New file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug m2/26372] [Modula-2] Parsing of multi-subscript arrays broken
  2020-08-11 10:55 [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken vries at gcc dot gnu.org
  2020-08-25  9:17 ` [Bug m2/26372] " cvs-commit at gcc dot gnu.org
@ 2020-08-25  9:32 ` cvs-commit at gcc dot gnu.org
  2020-08-25 10:01 ` vries at gcc dot gnu.org
  2020-08-25 10:02 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25  9:32 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26372

--- Comment #2 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=419cca029e5d4b9b648402f9da3c38f302ca7b0a

commit 419cca029e5d4b9b648402f9da3c38f302ca7b0a
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Tue Aug 25 10:25:32 2020 +0100

    Revert "Fix for Bug 26372 [Modula-2] Parsing of multi-subscript arrays"

    This reverts commit 07758bdfa9e5a762f2ec0deeb51b11d6ad5fe376.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug m2/26372] [Modula-2] Parsing of multi-subscript arrays broken
  2020-08-11 10:55 [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken vries at gcc dot gnu.org
  2020-08-25  9:17 ` [Bug m2/26372] " cvs-commit at gcc dot gnu.org
  2020-08-25  9:32 ` cvs-commit at gcc dot gnu.org
@ 2020-08-25 10:01 ` vries at gcc dot gnu.org
  2020-08-25 10:02 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-25 10:01 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26372

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=3945d2d77e373c828ebbbb05b3ba06adf39019ab

author  Gaius Mulley <gaiusmod2@gmail.com>      
        Tue, 25 Aug 2020 08:39:27 +0000 (09:39 +0100)
committer       Andrew Burgess <andrew.burgess@embecosm.com>    
        Tue, 25 Aug 2020 09:28:06 +0000 (10:28 +0100)
commit  3945d2d77e373c828ebbbb05b3ba06adf39019ab

gdb/modula-2: parsing of multi-subscript arrays

Fix bug PR m2/26372, GDB's inability to parse multi-dimensional
modula-2 arrays.

We previously had two rules for handling the parsing of array
sub-scripts.  I have reproduced them here with the actual handler
blocks removed to make the bug clearer:

  exp     :    exp '[' non_empty_arglist ']'
          ;

  exp     :    exp '[' exp ']'
          ;

  non_empty_arglist
          :       exp
          ;

  non_empty_arglist
          :       non_empty_arglist ',' exp
          ;

This is ambiguous as the pattern "exp '[' exp" could match either of
the 'exp' rules.  Currently it just so happens that the parser picks
the second 'exp' rule which means we can only handle a single array
index.

As the handler code for the first 'exp' pattern will correctly handle
and number of array indexes then lets just remove the second pattern.

gdb/ChangeLog:

PR m2/26372
        * m2-exp.y (exp): Improve comment for non_empty_arglist case, add
an assert.  Remove single element array indexing pattern as the
MULTI_SUBSCRIPT support will handle this case too.

gdb/testsuite/ChangeLog:

PR m2/26372
        * gdb.modula2/multidim.c: New file.
        * gdb.modula2/multidim.exp: New file.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug m2/26372] [Modula-2] Parsing of multi-subscript arrays broken
  2020-08-11 10:55 [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-08-25 10:01 ` vries at gcc dot gnu.org
@ 2020-08-25 10:02 ` vries at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-25 10:02 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=26372

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-08-25 10:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 10:55 [Bug m2/26372] New: [Modula-2] Parsing of multi-subscript arrays broken vries at gcc dot gnu.org
2020-08-25  9:17 ` [Bug m2/26372] " cvs-commit at gcc dot gnu.org
2020-08-25  9:32 ` cvs-commit at gcc dot gnu.org
2020-08-25 10:01 ` vries at gcc dot gnu.org
2020-08-25 10:02 ` vries 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).