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;
This commit is contained in:
Stephen Heumann 2018-03-31 21:38:50 -05:00
parent a9f7f97a2f
commit 2be0ef0de5

View File

@ -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;