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

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

The patch needs improving bug it does prevent the ICE and the compiler
generates an error message.

$ gm2 constintarraybyte.mod 
cc1gm2: error: formal parameter ‘w’
constintarraybyte.mod:9:42: error: actual parameter ‘42’
    9 |    s := Sprintf1 (InitString("abc%x\n"), 42)
      |                                          ^~
constintarraybyte.mod:9:42: error: 2nd parameter failure due to assignment
incompatibility between actual parameter ‘42’ and the 2nd formal ‘w’ parameter
in procedure ‘Sprintf1’


The patch needs to be improved to associate the error of cc1gm2 with the
definition module.
Interestingly if the compiler is invoked using:

$ gm2 -c constintarraybyte.mod 
constintarraybyte.mod:9:42: error: 2nd parameter failure due to assignment
incompatibility between actual parameter ‘42’ and the 2nd formal ‘w’ parameter
in procedure ‘Sprintf1’
    9 |    s := Sprintf1 (InitString("abc%x\n"), 42)
      |                                          ^~
constintarraybyte.mod:9:42: error: actual parameter ‘42’
/home/gaius/opt/lib/gcc/x86_64-pc-linux-gnu/16.0.0/m2/m2pim/FormatStrings.def:49:34:
error: In procedure ‘Sprintf1’: formal parameter ‘w’
   49 | PROCEDURE Sprintf1 (fmt: String; w: ARRAY OF BYTE) : String ;
      |                                  ^

it behaves correctly.  Without the -c it builds the scaffold and parses the
implementation modules to detect the import lists, and in the process gets the
wrong param symbol (it should use the definition module symbol).

Reply via email to