mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-09 01:29:33 +00:00
Prevent spurious errors about structs containing function pointers.
If a struct contained a function pointer with a prototyped parameter list, processing the parameters could reset the declaredTagOrEnumConst flag, potentially leading to a spurious error, as in this example: struct S { int (*f)(int); }; This also gives a better error for structs declared as containing functions.
This commit is contained in:
parent
a864954353
commit
afe40c0f67
|
@ -1330,6 +1330,7 @@ var
|
||||||
lLastParameter: identPtr; {next parameter to process}
|
lLastParameter: identPtr; {next parameter to process}
|
||||||
luseGlobalPool: boolean; {local copy of useGlobalPool}
|
luseGlobalPool: boolean; {local copy of useGlobalPool}
|
||||||
lSuppressMacroExpansions: boolean;{local copy of suppressMacroExpansions}
|
lSuppressMacroExpansions: boolean;{local copy of suppressMacroExpansions}
|
||||||
|
ldeclaredTagOrEnumConst: boolean; {local copy of declaredTagOrEnumConst}
|
||||||
|
|
||||||
begin {StackDeclarations}
|
begin {StackDeclarations}
|
||||||
lastWasIdentifier := false; {used to see if the declaration is a fn}
|
lastWasIdentifier := false; {used to see if the declaration is a fn}
|
||||||
|
@ -1484,9 +1485,12 @@ var
|
||||||
prototyped := true; {it is prototyped}
|
prototyped := true; {it is prototyped}
|
||||||
repeat {collect the declarations}
|
repeat {collect the declarations}
|
||||||
if token.kind in declarationSpecifiersElement then begin
|
if token.kind in declarationSpecifiersElement then begin
|
||||||
|
ldeclaredTagOrEnumConst := declaredTagOrEnumConst;
|
||||||
lLastParameter := lastParameter;
|
lLastParameter := lastParameter;
|
||||||
DoDeclaration(true);
|
DoDeclaration(true);
|
||||||
lastParameter := lLastParameter;
|
lastParameter := lLastParameter;
|
||||||
|
declaredTagOrEnumConst :=
|
||||||
|
ldeclaredTagOrEnumConst or declaredTagOrEnumConst;
|
||||||
if protoType <> nil then begin
|
if protoType <> nil then begin
|
||||||
wp := pointer(Malloc(sizeof(parameterRecord)));
|
wp := pointer(Malloc(sizeof(parameterRecord)));
|
||||||
wp^.next := parameterList;
|
wp^.next := parameterList;
|
||||||
|
|
|
@ -693,7 +693,7 @@ if list or (numErr <> 0) then begin
|
||||||
114: msg := @'a function call was made to a non-function';
|
114: msg := @'a function call was made to a non-function';
|
||||||
115: msg := @'illegal bit field declaration';
|
115: msg := @'illegal bit field declaration';
|
||||||
116: msg := @'missing field name';
|
116: msg := @'missing field name';
|
||||||
117: msg := @'field cannot have incomplete type';
|
117: msg := @'field cannot have incomplete or function type';
|
||||||
118: msg := @'flexible array must be last member of structure';
|
118: msg := @'flexible array must be last member of structure';
|
||||||
119: msg := @'inline specifier is only allowed on functions';
|
119: msg := @'inline specifier is only allowed on functions';
|
||||||
120: msg := @'non-static inline functions are not supported';
|
120: msg := @'non-static inline functions are not supported';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user