public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/114026] New: incorrect location during for loop type check
@ 2024-02-20 22:09 gaius at gcc dot gnu.org
  2024-02-20 22:09 ` [Bug modula2/114026] " gaius at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-02-20 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114026
           Summary: incorrect location during for loop type check
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

If a for loop has a type expression incompatibility it uses an incorrect
location (0).  For example:

$ cat forloop.mod
MODULE forloop ;


PROCEDURE init ;
VAR
   i: INTEGER ;
   c: CARDINAL ;
BEGIN
   c := 10 ;
   FOR i := 0 TO c DO   (* INTEGER CARDINAL expression incompatible.  *)
   END
END init ;


BEGIN
   init
END forloop.

$ gm2 forloop.mod 
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.1/m2/m2pim/Indexing.mod: In
function ‘init’:
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/14.0.1/m2/m2pim/Indexing.mod:346:1:
error: In procedure ‘init’: type incompatibility between ‘INTEGER’ and
‘CARDINAL’

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
@ 2024-02-20 22:09 ` gaius at gcc dot gnu.org
  2024-02-21  1:46 ` gaius at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-02-20 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2024-02-20

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed.

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
  2024-02-20 22:09 ` [Bug modula2/114026] " gaius at gcc dot gnu.org
@ 2024-02-21  1:46 ` gaius at gcc dot gnu.org
  2024-02-21 16:21 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-02-21  1:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 57474
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57474&action=edit
Proposed fix

Here is the proposed fix.

$ gm2 forloop.mod 
forloop.mod:10:8: error: In procedure ‘init’: type expression incompatibility
between ‘INTEGER’ and ‘CARDINAL’ detected when comparing the designator ‘i’
against the second expression ‘c’ in the FOR loop
   10 |    FOR i := 0 TO c DO   (* INTEGER CARDINAL expression incompatible. 
*)
      |        ^~~~~~~~~~~

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
  2024-02-20 22:09 ` [Bug modula2/114026] " gaius at gcc dot gnu.org
  2024-02-21  1:46 ` gaius at gcc dot gnu.org
@ 2024-02-21 16:21 ` cvs-commit at gcc dot gnu.org
  2024-02-21 16:29 ` gaius at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-21 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:161a67b2bee84d8fd5ab7711e411f76221c1ea52

commit r14-9116-g161a67b2bee84d8fd5ab7711e411f76221c1ea52
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Wed Feb 21 16:21:05 2024 +0000

    PR modula2/114026 Incorrect location during for loop type checking

    If a for loop contains an incompatible type expression between the
    designator and the second expression then the location
    used when generating the error message is set to token 0.
    The bug is fixed by extending the range checking
    InitForLoopBeginRangeCheck.  The range checking is processed after
    all types, constants have been resolved (and converted into gcc
    trees).  The range check will check for assignment compatibility
    between des and expr1, expression compatibility between des and expr2.
    Separate token positions for des, exp1, expr2 and by are stored in the
    Range record and used to create virtual tokens if they are on the same
    source line.

    gcc/m2/ChangeLog:

            PR modula2/114026
            * gm2-compiler/M2GenGCC.mod (Import): Remove DisplayQuadruples.
            Remove DisplayQuadList.
            (MixTypesBinary): Replace check with overflowCheck.
            New variable typeChecking.
            Use GenQuadOTypetok to retrieve typeChecking.
            Use typeChecking to suppress error message.
            * gm2-compiler/M2LexBuf.def (MakeVirtual2Tok): New procedure
            function.
            * gm2-compiler/M2LexBuf.mod (MakeVirtualTok): Improve comment.
            (MakeVirtual2Tok): New procedure function.
            * gm2-compiler/M2Quads.def (GetQuadOTypetok): New procedure.
            * gm2-compiler/M2Quads.mod (QuadFrame): New field CheckType.
            (PutQuadO): Rewrite using PutQuadOType.
            (PutQuadOType): New procedure.
            (GetQuadOTypetok): New procedure.
            (BuildPseudoBy): Rewrite.
            (BuildForToByDo): Remove type checking.
            Add parameters e2, e2tok, BySym, bytok to
            InitForLoopBeginRange.
            Push the RangeId.
            (BuildEndFor): Pop the RangeId.
            Use GenQuadOTypetok to generate AddOp without type checking.
            Call PutRangeForIncrement with the RangeId and IncQuad.
            (GenQuadOtok): Rewrite using GenQuadOTypetok.
            (GenQuadOTypetok): New procedure.
            * gm2-compiler/M2Range.def (InitForLoopBeginRangeCheck):
            Rename d as des, e as expr.
            Add expr1, expr1tok, expr2, expr2tok, byconst, byconsttok
            parameters.
            (PutRangeForIncrement): New procedure.
            * gm2-compiler/M2Range.mod (Import): MakeVirtual2Tok.
            (Range): Add expr2, byconst, destok, exprtok, expr2tok,
            incrementquad.
            (InitRange): Initialize expr2 to NulSym.
            Initialize byconst to NulSym.
            Initialize tokenNo, destok, exprtok, expr2tok, byconst to
            UnknownTokenNo.
            Initialize incrementquad to 0.
            (PutRangeForIncrement): New procedure.
            (PutRangeDesExpr2): New procedure.
            (InitForLoopBeginRangeCheck): Rewrite.
            (ForLoopBeginTypeCompatible): New procedure function.
            (CodeForLoopBegin): Call ForLoopBeginTypeCompatible and
            only code the for loop assignment if all the type checks
            succeed.

    gcc/testsuite/ChangeLog:

            PR modula2/114026
            * gm2/extensions/run/pass/callingc10.mod: New test.
            * gm2/extensions/run/pass/callingc11.mod: New test.
            * gm2/extensions/run/pass/callingc9.mod: New test.
            * gm2/extensions/run/pass/strconst.def: New test.
            * gm2/pim/fail/forloop.mod: New test.
            * gm2/pim/pass/forloop2.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-02-21 16:21 ` cvs-commit at gcc dot gnu.org
@ 2024-02-21 16:29 ` gaius at gcc dot gnu.org
  2024-02-22 22:35 ` ro at gcc dot gnu.org
  2024-02-27 15:26 ` gaius at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-02-21 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

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

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now the patch has been applied.  Another PR will be opened citing the
BY incompatible expression type check failure.

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-02-21 16:29 ` gaius at gcc dot gnu.org
@ 2024-02-22 22:35 ` ro at gcc dot gnu.org
  2024-02-27 15:26 ` gaius at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ro at gcc dot gnu.org @ 2024-02-22 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED
                 CC|                            |ro at gcc dot gnu.org

--- Comment #5 from Rainer Orth <ro at gcc dot gnu.org> ---
Two of the new tests FAIL on 32 and 64-bit Solaris/SPARC:

+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -O 
+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -O -g 
+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -O3
-fomit-frame-point
er 
+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -O3
-fomit-frame-point
er -finline-functions 
+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -Os 
+FAIL: gm2/extensions/run/pass/callingc10.mod execution,  -g 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -O 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -O -g 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -O3
-fomit-frame-pointer 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -O3
-fomit-frame-pointer -finline-functions 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -Os 
+FAIL: gm2/extensions/run/pass/callingc11.mod execution,  -g 

The failure mode is the same for both:

parameter is hello and length 0
executed
/var/gcc/regression/master/11.4-gcc/build/gcc/testsuite/gm2/callingc10.x0 with
result fail

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

* [Bug modula2/114026] incorrect location during for loop type check
  2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2024-02-22 22:35 ` ro at gcc dot gnu.org
@ 2024-02-27 15:26 ` gaius at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-02-27 15:26 UTC (permalink / raw)
  To: gcc-bugs

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

Gaius Mulley <gaius at gcc dot gnu.org> changed:

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

--- Comment #6 from Gaius Mulley <gaius at gcc dot gnu.org> ---
ah I'll open up a new PR as this is now a bug relating to passing a pointer
string to a C function.

For clarity and future searching the new PR follow on is:

Bug 114133 - problem passing a string pointer to a C function on solaris 32 bit
and 64 bit

marking the original FOR loop issue as resolved.

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

end of thread, other threads:[~2024-02-27 15:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-20 22:09 [Bug modula2/114026] New: incorrect location during for loop type check gaius at gcc dot gnu.org
2024-02-20 22:09 ` [Bug modula2/114026] " gaius at gcc dot gnu.org
2024-02-21  1:46 ` gaius at gcc dot gnu.org
2024-02-21 16:21 ` cvs-commit at gcc dot gnu.org
2024-02-21 16:29 ` gaius at gcc dot gnu.org
2024-02-22 22:35 ` ro at gcc dot gnu.org
2024-02-27 15:26 ` gaius 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).