Bug 114380 - Incorrect type specified in an error message
Summary: Incorrect type specified in an error message
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: modula2 (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Gaius Mulley
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-18 15:46 UTC by Gaius Mulley
Modified: 2024-03-18 16:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-03-18 00:00:00


Attachments
Proposed fix (453 bytes, patch)
2024-03-18 16:02 UTC, Gaius Mulley
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gaius Mulley 2024-03-18 15:46:58 UTC
The source code:

MODULE tiny4 ;

FROM SYSTEM IMPORT WORD ;

PROCEDURE func () : WORD ;
BEGIN
   RETURN WORD (0)
END func ;

VAR
   b: BITSET ;
BEGIN
   b := func () - {6..31}
END tiny4.

when compiled should complain about BITSET rather than CARDINAL.

$ gm2 tiny4.mod 
tiny4.mod:13:17: error: In program module 'tiny4': type incompatibility between 'CARDINAL' and 'WORD'
   13 |    b := func () - {6..31}
      |         ~~~~~~~~^~~~~~~~~
Comment 1 Gaius Mulley 2024-03-18 15:47:13 UTC
Confirmed.
Comment 2 Gaius Mulley 2024-03-18 16:02:48 UTC
Created attachment 57725 [details]
Proposed fix



PR modula2/114380 Incorrect type specified in an error message

This patch corrects an error message relating to a variable of
a SET type. The bugfix is not to skip over set types (in
GetLowestType).

gcc/m2/ChangeLog:

	* gm2-compiler/SymbolTable.mod (GetLowestType): Do not
	skip over a set type, but return sym.

gcc/testsuite/ChangeLog:

	* gm2/pim/fail/badset7.mod: New test.
Comment 3 Gaius Mulley 2024-03-18 16:04:05 UTC
$ gm2 tiny4.mod 
tiny4.mod:13:17: error: In program module ‘tiny4’: type incompatibility between ‘BITSET’ and ‘WORD’
   13 |    b := func () - {6..31}
      |         ~~~~~~~~^~~~~~~~~
Comment 4 GCC Commits 2024-03-18 16:41:13 UTC
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

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

commit r14-9520-gd2029bbc69df7341775faf6cf1aa13d978c223a1
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Mon Mar 18 16:40:35 2024 +0000

    PR modula2/114380 Incorrect type specified in an error message
    
    This patch corrects an error message relating to a variable of
    a SET type. The bugfix is not to skip over set types (in
    GetLowestType).
    
    gcc/m2/ChangeLog:
    
            PR modula2/114380
            * gm2-compiler/SymbolTable.mod (GetLowestType): Do not
            skip over a set type, but return sym.
    
    gcc/testsuite/ChangeLog:
    
            PR modula2/114380
            * gm2/pim/fail/badset7.mod: New test.
    
    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Comment 5 Gaius Mulley 2024-03-18 16:41:39 UTC
Closing now that the patch has been applied.