From c588eda94eaa024c0039a4458aa87c7b4a2de247 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 10 Sep 2017 14:55:08 -0500 Subject: [PATCH] Allow a typedef'd version of "void" to be used in the parameter list of a function taking no arguments. For example, the following is now allowed: typedef void v; void foo(v) {} This appears to be permitted under at least C99 and C11 (the C89 wording is less clear), and is accepted by other modern compilers. --- Parser.pas | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Parser.pas b/Parser.pas index 4edc18a..278e46a 100644 --- a/Parser.pas +++ b/Parser.pas @@ -1169,6 +1169,7 @@ var cp,cpList: pointerListPtr; {pointer list} done,done2: boolean; {for loop termination} isPtr: boolean; {is the parenthesized expr a ptr?} + isVoid: boolean; {is the type specifier void?} wp: parameterPtr; {used to build prototype var list} pvar: identPtr; {work pointer} tPtr2: typePtr; {work pointer} @@ -1309,7 +1310,12 @@ var typeStack := ttPtr; ttPtr^.typeDef := tPtr2; NextToken; {skip the '(' token} - if token.kind = voidsy then begin {check for a void prototype} + isVoid := token.kind = voidsy; + if token.kind = typedef then + if token.symbolPtr^.itype^.kind = scalarType then + if token.symbolPtr^.itype^.baseType = cgVoid then + isVoid := true; + if isVoid then begin {check for a void prototype} lPrintMacroExpansions := printMacroExpansions; printMacroExpansions := false; NextToken;