[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Error with Opaque types in GNU Modula-2?
From: |
Gaius Mulley |
Subject: |
Error with Opaque types in GNU Modula-2? |
Date: |
Sat, 25 Jan 2025 00:18:44 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi Kurt,
many thanks for the bug report. Now fixed in the development trunk of
GCC.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118589
At some point after a suitable amount of testing it could be backported
onto gcc-14,
regards,
Gaius
$ cat opaquedefs.def
DEFINITION MODULE opaquedefs ;
TYPE
OpaqueA ;
OpaqueB ;
END opaquedefs.
$ cat opaquedefs.mod
(* { dg-do compile } *)
(* { dg-options "-g -c" } *)
IMPLEMENTATION MODULE opaquedefs ;
TYPE
OpaqueA = POINTER TO CARDINAL ;
OpaqueB = POINTER TO RECORD
width : CARDINAL ;
height: CARDINAL ;
END ;
END opaquedefs.
$ cat badopaque.mod
(* { dg-do compile } *)
(* { dg-options "-g" } *)
MODULE badopaque ;
FROM opaquedefs IMPORT OpaqueA ;
VAR
a: OpaqueA ;
c: CARDINAL ;
BEGIN
c := 123 ;
a^ := c (* { dg-error "with an opaque type" } *)
END badopaque.
$ gm2 -c badopaque.mod
badopaque.mod:14:5: error: In program module ‘badopaque’: ‘a’ is declared with
an opaque type from a different module and cannot be dereferenced
14 | a^ := c (* { dg-error "with an opaque type" } *)
| ^
$ cat badopaque2.mod
(* { dg-do compile } *)
(* { dg-options "-g" } *)
MODULE badopaque2 ;
FROM opaquedefs IMPORT OpaqueB ;
VAR
b: OpaqueB ;
c: CARDINAL ;
BEGIN
c := 123 ;
b^.width := c (* { dg-bogus "unnamed" } *)
(* { dg-error "cannot be dereferenced" "b^.width" { target *-*-* } 14 } *)
(* { dg-error "has no field" "no field" { target *-*-* } 14 } *)
END badopaque2.
$ gm2 -c badopaque2.mod
badopaque2.mod:14:5: error: In program module ‘badopaque2’: ‘b’ is declared
with an opaque type from a different module and cannot be dereferenced
14 | b^.width := c (* { dg-bogus "unnamed" } *)
| ^
badopaque2.mod:14:4: error: the type of ‘bad opaque pointer dereference’ is not
a record (but ‘ADDRESS’) and therefore it has no field
14 | b^.width := c (* { dg-bogus "unnamed" } *)
| ^~