From 524c500146189ddfbf718d217762bfd016843895 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 25 Feb 2023 16:50:48 +0200 Subject: [PATCH] cgen: add `requires` to `c_reserved`, so that V generated code, can be compiled with `-cc g++-11 -no-std -cflags -std=c++20` as well (#17404) --- .github/workflows/other_ci.yml | 14 ++++++++------ vlib/v/gen/c/cgen.v | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/other_ci.yml b/.github/workflows/other_ci.yml index d5e847ba78..134e9f6cca 100644 --- a/.github/workflows/other_ci.yml +++ b/.github/workflows/other_ci.yml @@ -81,17 +81,20 @@ jobs: sudo apt-get update sudo apt-get install --quiet -y libsodium-dev libssl-dev sqlite3 libsqlite3-dev postgresql libpq-dev valgrind sudo apt-get install --quiet -y libfreetype6-dev libxi-dev libxcursor-dev libgl-dev xfonts-75dpi xfonts-base - sudo apt-get install --quiet -y g++-9 + sudo apt-get install --quiet -y g++-9 g++-11 - name: Build v run: make - - name: g++ version + - name: g++-9 version run: g++-9 --version - - name: V self compilation with g++ + - name: V self compilation with g++ and -std=c++11 run: ./v -cc g++-9 -no-std -cflags -std=c++11 -o v2 cmd/v && ./v2 -cc g++-9 -no-std -cflags -std=c++11 -o v3 cmd/v - ## - name: Running tests with g++ - ## run: ./v -cc g++-9 test-self + + - name: g++-11 version + run: g++-11 --version + - name: V self compilation with g++ and -std=c++20 + run: ./v -cc g++-11 -no-std -cflags -std=c++20 -o v2 cmd/v && ./v2 -cc g++-11 -no-std -cflags -std=c++20 -o v3 cmd/v - name: Ensure V can be compiled with -autofree run: ./v -autofree -o v2 cmd/v ## NB: this does not mean it runs, but at least keeps it from regressing @@ -150,4 +153,3 @@ jobs: ./v test-parser -S examples/cli_fuzz.v ./v test-parser -S examples/regex_example_fuzz.v ./v test-parser -S examples/2048/2048_fuzz.v - diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index cec006540d..b981055844 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -25,7 +25,7 @@ const ( 'long', 'malloc', 'namespace', 'new', 'nil', 'panic', 'register', 'restrict', 'return', 'short', 'signed', 'sizeof', 'static', 'string', 'struct', 'switch', 'typedef', 'typename', 'union', 'unix', 'unsigned', 'void', 'volatile', 'while', 'template', 'true', 'small', - 'stdout', 'stdin', 'stderr', 'far', 'near', 'huge'] + 'stdout', 'stdin', 'stderr', 'far', 'near', 'huge', 'requires'] c_reserved_chk = token.new_keywords_matcher_from_array_trie(c_reserved) // same order as in token.Kind cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le']