| | @@ -1974,19 +1974,21 @@ |
| 1974 | 1974 | |
| 1975 | 1975 | (* An address given where a var or const parameter of its type wants the |
| 1976 | 1976 | variable itself, as ADR(b) for var b: Buf: an error that says what to |
| 1977 | | - write instead, b for ADR(b) and p^ for a pointer p. Mostly met in |
| 1977 | + write instead, b for SYSTEM.ADR(b) or ADR(b), and p^ for a pointer p. Mostly met in |
| 1978 | 1978 | programs written before the library took var (report 2026-10.33). *) |
| 1979 | 1979 | proc givenAddress(const a: Item; p: ^Sym.Obj): ERROR; |
| 1980 | | -var s, kind: []const U8; |
| 1980 | +var s, kind: []const U8; k: INT; |
| 1981 | 1981 | begin |
| 1982 | 1982 | if (a.typ^.form # Sym.fPtr) or (a.typ^.base = nil) or not Sym.same(a.typ^.base, p^.typ) then |
| 1983 | 1983 | return nil; |
| 1984 | 1984 | end; |
| 1985 | 1985 | if p^.isConst then kind := "const"; else kind := "var"; end; |
| 1986 | 1986 | s := Diag.source(a.pos); |
| 1987 | | - if (LEN(s) > 5) and (s[0..4] = "ADR(") and (s[LEN(s) - 1] = ')') then |
| 1987 | + k := 0; (* past SYSTEM., as ADR is written in a module that imports it *) |
| 1988 | + if (LEN(s) > 7) and (s[0..7] = "SYSTEM.") then k := 7; end; |
| 1989 | + if (LEN(s) > k + 5) and (s[k..k + 4] = "ADR(") and (s[LEN(s) - 1] = ')') then |
| 1988 | 1990 | s := Diag.say("write {} for {}: the parameter is the variable itself, not its address", |
| 1989 | | - [Fmt.str(s[4..LEN(s) - 1]), Fmt.str(s)]); |
| 1991 | + [Fmt.str(s[k + 4..LEN(s) - 1]), Fmt.str(s)]); |
| 1990 | 1992 | else |
| 1991 | 1993 | s := Diag.say("write {}^ for {}: the parameter is the variable itself, not a pointer to it", |
| 1992 | 1994 | [Fmt.str(s), Fmt.str(s)]); |