mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 19:29:21 +00:00
Make the actual return type of a function be the unqualified version of the type specified.
This is a change that was introduced in C17. However, it actually keeps things closer to ORCA/C's historical behavior, which generally ignored qualifiers in return types.
This commit is contained in:
parent
af455d1900
commit
2614f10ced
@ -1620,7 +1620,7 @@ while typeStack <> nil do begin {reverse the type stack}
|
|||||||
functionType: begin
|
functionType: begin
|
||||||
while tPtr^.kind = definedType do
|
while tPtr^.kind = definedType do
|
||||||
tPtr := tPtr^.dType;
|
tPtr := tPtr^.dType;
|
||||||
tPtr2^.fType := tPtr;
|
tPtr2^.fType := Unqualify(tPtr);
|
||||||
if tPtr^.kind in [functionType,arrayType] then
|
if tPtr^.kind in [functionType,arrayType] then
|
||||||
Error(103);
|
Error(103);
|
||||||
end;
|
end;
|
||||||
@ -3967,7 +3967,7 @@ var
|
|||||||
{tp^.isPascal := false;}
|
{tp^.isPascal := false;}
|
||||||
{tp^.toolNum := 0;}
|
{tp^.toolNum := 0;}
|
||||||
{tp^.dispatcher := 0;}
|
{tp^.dispatcher := 0;}
|
||||||
tp^.fType := tl;
|
tp^.fType := Unqualify(tl);
|
||||||
tl := tp;
|
tl := tp;
|
||||||
NextToken;
|
NextToken;
|
||||||
end {if}
|
end {if}
|
||||||
@ -4055,7 +4055,7 @@ var
|
|||||||
{tp^.isPascal := false;}
|
{tp^.isPascal := false;}
|
||||||
{tp^.toolNum := 0;}
|
{tp^.toolNum := 0;}
|
||||||
{tp^.dispatcher := 0;}
|
{tp^.dispatcher := 0;}
|
||||||
tp^.fType := tl;
|
tp^.fType := Unqualify(tl);
|
||||||
tl := tp;
|
tl := tp;
|
||||||
end; {if}
|
end; {if}
|
||||||
end; {NonEmptyAbstractDeclarator}
|
end; {NonEmptyAbstractDeclarator}
|
||||||
|
36
Symbol.pas
36
Symbol.pas
@ -170,6 +170,16 @@ function MakeQualifiedType (origType: typePtr; qualifiers: typeQualifierSet):
|
|||||||
{ returns: pointer to the qualified type }
|
{ returns: pointer to the qualified type }
|
||||||
|
|
||||||
|
|
||||||
|
function Unqualify (tp: typePtr): typePtr;
|
||||||
|
|
||||||
|
{ returns the unqualified version of a type }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ tp - the original type }
|
||||||
|
{ }
|
||||||
|
{ returns: pointer to the unqualified type }
|
||||||
|
|
||||||
|
|
||||||
function NewSymbol (name: stringPtr; itype: typePtr; class: tokenEnum;
|
function NewSymbol (name: stringPtr; itype: typePtr; class: tokenEnum;
|
||||||
space: spaceType; state: stateKind): identPtr;
|
space: spaceType; state: stateKind): identPtr;
|
||||||
|
|
||||||
@ -1645,6 +1655,32 @@ else
|
|||||||
end; {MakeQualifiedType}
|
end; {MakeQualifiedType}
|
||||||
|
|
||||||
|
|
||||||
|
function Unqualify {tp: typePtr): typePtr};
|
||||||
|
|
||||||
|
{ returns the unqualified version of a type }
|
||||||
|
{ }
|
||||||
|
{ parameters: }
|
||||||
|
{ tp - the original type }
|
||||||
|
{ }
|
||||||
|
{ returns: pointer to the unqualified type }
|
||||||
|
|
||||||
|
var
|
||||||
|
tp2: typePtr; {unqualified type}
|
||||||
|
|
||||||
|
begin {Unqualify}
|
||||||
|
while tp^.kind = definedType do
|
||||||
|
tp := tp^.dType;
|
||||||
|
Unqualify := tp;
|
||||||
|
if tp^.qualifiers <> [] then
|
||||||
|
if not (tp^.kind in [structType,unionType]) then begin
|
||||||
|
tp2 := pointer(Malloc(sizeof(typeRecord)));
|
||||||
|
tp2^ := tp^;
|
||||||
|
tp2^.qualifiers := [];
|
||||||
|
Unqualify := tp2;
|
||||||
|
end;
|
||||||
|
end; {Unqualify}
|
||||||
|
|
||||||
|
|
||||||
function NewSymbol {name: stringPtr; itype: typePtr; class: tokenEnum;
|
function NewSymbol {name: stringPtr; itype: typePtr; class: tokenEnum;
|
||||||
space: spaceType; state: stateKind): identPtr};
|
space: spaceType; state: stateKind): identPtr};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user