From 2be0ef0de563e20472b9cc07967c4fe37363d052 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 31 Mar 2018 21:38:50 -0500 Subject: [PATCH] Allow initialization of static/global variables with the address of members of const structs. Note that this code currently permits discarding the const qualifier via such an initialization. That should give a diagnostic, but currently it doesn't in this or various other cases. The following code (derived from a csmith-generated test case) illustrates the problem: struct S0 { const long f4; }; const struct S0 g_149; const long *g_311 = &g_149.f4; --- Parser.pas | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Parser.pas b/Parser.pas index 06d8321..422ac1e 100644 --- a/Parser.pas +++ b/Parser.pas @@ -1844,6 +1844,8 @@ var end {if} else if tree^.token.kind = dotch then begin tp := Subscript(tree^.left); + while tp^.kind = definedType do + tp := tp^.dType; if tp^.kind in [structType,unionType] then begin DoSelection(tp, tree^.right, select); Subscript := expressionType;