From ca2ed24817841eb2727dbc7db6673f18d483b7ea Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 24 Jun 2025 19:50:49 -0500 Subject: [PATCH] Support #pragma STDC FENV_ROUND FE_DYNAMIC (C23). This just specifies dynamic rounding mode that can be configured with calls, like before C23. The other #pragma STDC FENV_ROUND values (specifying static rounding modes) are still not supported. --- Scanner.pas | 18 +++++++++++++++++- Tests/Conformance/c23misc.c | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Scanner.pas b/Scanner.pas index 37a7d85..14041b1 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -832,6 +832,7 @@ if list or (numErr <> 0) then begin 200: msg := @'variable-length array declarator using * is not allowed here'; 201: msg := @'variably modified type is not allowed here'; 202: msg := @'goto or switch enters scope of identifier with variably modified type'; + 203: msg := @'static rounding direction is not supported'; end; {case} if extraStr <> nil then begin extraStr^ := concat(msg^,extraStr^); @@ -3843,7 +3844,22 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin if fenvAccess then if doingFunction then fenvAccessInFunction := true; - end + end {else if} + else if (token.name^ = 'FENV_ROUND') + and ((cStd >= c23) or not strictMode) then begin + NextToken; + if token.kind = typedef then + token.kind := ident; + if token.kind <> ident then + Error(9) + else if token.name^ <> 'FE_DYNAMIC' then + Error(203); + if token.kind <> eolsy then begin + NextToken; + if token.kind <> eolsy then + Error(11); + end; {if} + end {else if} else Error(157); expandMacros := true; diff --git a/Tests/Conformance/c23misc.c b/Tests/Conformance/c23misc.c index 3fc0562..22a7e02 100644 --- a/Tests/Conformance/c23misc.c +++ b/Tests/Conformance/c23misc.c @@ -4,6 +4,8 @@ #include +#pragma STDC FENV_ROUND FE_DYNAMIC + int main(void) { // labels not preceding a statement {