From 2de8ac993ea138d0634120a83f19e858f8de783b Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 7 Mar 2021 23:35:12 -0600 Subject: [PATCH] Fix to make _Generic handle struct types properly. Also, use an existing error message instead of creating a new equivalent one. --- Expression.pas | 9 ++++++++- Scanner.pas | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Expression.pas b/Expression.pas index 85bf542..98c76f1 100644 --- a/Expression.pas +++ b/Expression.pas @@ -1892,6 +1892,13 @@ var controllingType.kind := pointerType; controllingType.pType := expressionType; end {if} + else if expressionType^.kind in [structType,unionType] then begin + controllingType.size := expressionType^.size; + controllingType.saveDisp := 0; + controllingType.isConstant := false; + controllingType.kind := definedType; + controllingType.dType := expressionType; + end {else if} else controllingType := expressionType^; if controllingType.kind = arrayType then @@ -1910,7 +1917,7 @@ var TypeName; {get the type name} currentType := typeSpec; if (currentType^.size = 0) or (currentType^.kind = functionType) then - Error(161); + Error(133); tl := typesSeen; {check if it is a duplicate} while tl <> nil do begin if CompTypes(currentType, tl^.theType) then begin diff --git a/Scanner.pas b/Scanner.pas index 434cd5d..aed7d15 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -699,7 +699,6 @@ if list or (numErr <> 0) then begin 158: msg := @'_Generic expression includes two compatible types'; 159: msg := @'_Generic expression includes multiple default cases'; 160: msg := @'no matching association in _Generic expression'; - 161: msg := @'complete object type expected'; otherwise: Error(57); end; {case} writeln(msg^);