mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 07:30:54 +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
|
||||
while tPtr^.kind = definedType do
|
||||
tPtr := tPtr^.dType;
|
||||
tPtr2^.fType := tPtr;
|
||||
tPtr2^.fType := Unqualify(tPtr);
|
||||
if tPtr^.kind in [functionType,arrayType] then
|
||||
Error(103);
|
||||
end;
|
||||
@ -3967,7 +3967,7 @@ var
|
||||
{tp^.isPascal := false;}
|
||||
{tp^.toolNum := 0;}
|
||||
{tp^.dispatcher := 0;}
|
||||
tp^.fType := tl;
|
||||
tp^.fType := Unqualify(tl);
|
||||
tl := tp;
|
||||
NextToken;
|
||||
end {if}
|
||||
@ -4055,7 +4055,7 @@ var
|
||||
{tp^.isPascal := false;}
|
||||
{tp^.toolNum := 0;}
|
||||
{tp^.dispatcher := 0;}
|
||||
tp^.fType := tl;
|
||||
tp^.fType := Unqualify(tl);
|
||||
tl := tp;
|
||||
end; {if}
|
||||
end; {NonEmptyAbstractDeclarator}
|
||||
|
36
Symbol.pas
36
Symbol.pas
@ -170,6 +170,16 @@ function MakeQualifiedType (origType: typePtr; qualifiers: typeQualifierSet):
|
||||
{ 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;
|
||||
space: spaceType; state: stateKind): identPtr;
|
||||
|
||||
@ -1645,6 +1655,32 @@ else
|
||||
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;
|
||||
space: spaceType; state: stateKind): identPtr};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user