diff --git a/source/CHANGELOG.md b/source/CHANGELOG.md index 27ad82fbb..37d190ff9 100644 --- a/source/CHANGELOG.md +++ b/source/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased + +* C++: fixing a regression introduced in 2.9.6.2 + - `std::to_string` is not compatible to `--ansi` standard + [[#534](https://github.com/BNFC/bnfc/issues/534)] + # 2.9.6.2 Andreas Abel , January 2026 diff --git a/source/src/BNFC/Backend/C/CFtoBisonC.hs b/source/src/BNFC/Backend/C/CFtoBisonC.hs index 3fd074da7..8c9692f22 100644 --- a/source/src/BNFC/Backend/C/CFtoBisonC.hs +++ b/source/src/BNFC/Backend/C/CFtoBisonC.hs @@ -119,6 +119,10 @@ header mode cf = unlines $ concat , when (stlParser mode) [ "#include /* for std::reverse */" -- mandatory e.g. with GNU C++ 11 , "#include \"" ++ ("ParserError" <.> h) ++ "\"" -- for throwing parser_error in C++ + + -- Commelina, 2026-03-05, issue #534: @std::to_string@ is invalid with @--ansi@ + -- TODO: Choose to use @std::to_string@ or not according to the @--ansi@ flag + , "#include " ] , [ "#include " , "#include " @@ -186,9 +190,15 @@ errorHandler mode = case mode of , "{" , " std::string error_msg = msg;" , " if (loc) {" - , " error_msg += \" at line \" + std::to_string(loc->first_line) +" - , " \", column \" + std::to_string(loc->first_column);" + + -- Commelina, 2026-03-05, issue #534: @std::to_string@ is invalid with @--ansi@ + -- TODO: Choose to use @std::to_string@ or not according to the @--ansi@ flag + , " std::ostringstream oss;" + , " oss << \" at line \" << loc->first_line" + , " << \", column \" << loc->first_column;" + , " error_msg += oss.str();" , " }" + , " if (scanner) {" , " error_msg += \": '\" + std::string(" ++ name ++ "get_text(scanner)) + \"'\";" , " }" diff --git a/testing/src/ParameterizedTests.hs b/testing/src/ParameterizedTests.hs index 3d10f4a56..91b556de6 100644 --- a/testing/src/ParameterizedTests.hs +++ b/testing/src/ParameterizedTests.hs @@ -390,16 +390,11 @@ parameters = concat -- Functor (Haskell & Agda) , [ haskellAgdaFunctorParameters] -- C++ (extras) - - -- Note: Disabled on 2026-03-04. Re-enable it after - -- https://github.com/BNFC/bnfc/issues/534 is resolved. - -- - -- , [ cBase { tpName = "C++ (with line numbers)" - -- , tpBnfcOptions = ["--cpp", "-l"] } - -- , cBase { tpName = "C++ (with namespace)" - -- , tpBnfcOptions = ["--cpp", "-p foobar"] } - -- ] - + , [ cBase { tpName = "C++ (with line numbers)" + , tpBnfcOptions = ["--cpp", "-l"] } + , cBase { tpName = "C++ (with namespace)" + , tpBnfcOptions = ["--cpp", "-p foobar"] } + ] -- C , [ TP { tpName = "C" , tpBnfcOptions = ["--c"] @@ -433,12 +428,8 @@ parameters = concat -- C++ (basic) , [ cBase { tpName = "C++ (no STL)" , tpBnfcOptions = ["--cpp-nostl"] } - - -- Note: Disabled on 2026-03-04. Re-enable it after - -- https://github.com/BNFC/bnfc/issues/534 is resolved. - -- - -- , cBase { tpName = "C++" - -- , tpBnfcOptions = ["--cpp"] } + , cBase { tpName = "C++" + , tpBnfcOptions = ["--cpp"] } ] -- Agda , [ haskellAgdaParameters ]