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

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).