Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into temp
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSagebaum committed Jun 4, 2024
2 parents 27c2223 + d136153 commit 48f3a1d
Show file tree
Hide file tree
Showing 2,633 changed files with 3,663 additions and 803 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build-cppfront.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-latest]
runs-on: [ubuntu-22.04]
compiler: [g++-10, g++-11, g++-12, clang++-12, clang++-14]
cxx-std: ['c++20', 'c++2b']
exclude:
Expand All @@ -38,6 +38,18 @@ jobs:
- runs-on: macos-latest
compiler: clang++
cxx-std: 'c++20'
- runs-on: ubuntu-24.04
compiler: clang++-16
cxx-std: 'c++20'
- runs-on: ubuntu-24.04
compiler: clang++-17
cxx-std: 'c++20'
- runs-on: ubuntu-24.04
compiler: clang++-18
cxx-std: 'c++20'
- runs-on: ubuntu-24.04
compiler: g++-14
cxx-std: 'c++2b'
runs-on: ${{ matrix.runs-on }}
env:
CXX: ${{ matrix.compiler }}
Expand Down
59 changes: 50 additions & 9 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,70 @@ on:

jobs:
regression-tests:
name: Run on ${{ matrix.os }} using ${{ matrix.compiler }}
name: ${{ matrix.shortosname }} | ${{ matrix.compiler }} | ${{ matrix.cxx_std }} | ${{ matrix.stdlib }} | ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
CXX: ${{ matrix.compiler }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
compiler: [g++-10, clang++-15]
os: [ubuntu-24.04]
shortosname: [ubu-24]
compiler: [g++-14, g++-13]
cxx_std: [c++2b]
stdlib: [libstdc++]
include:
- os: ubuntu-20.04
shortosname: ubu-20
compiler: g++-10
cxx_std: c++20
stdlib: libstdc++
- os: ubuntu-24.04
compiler: g++-13
shortosname: ubu-24
compiler: clang++-18
cxx_std: c++20
stdlib: libstdc++
- os: ubuntu-22.04
shortosname: ubu-22
compiler: clang++-15
cxx_std: c++20
stdlib: libstdc++
- os: ubuntu-22.04
shortosname: ubu-22
compiler: clang++-15
cxx_std: c++20
stdlib: libc++-15-dev
- os: ubuntu-20.04
shortosname: ubu-20
compiler: clang++-12
cxx_std: c++20
stdlib: libstdc++
- os: macos-14
shortosname: mac-14
compiler: clang++
cxx_std: c++2b
stdlib: default
- os: macos-13
shortosname: mac-13
compiler: clang++
cxx_std: c++2b
stdlib: default
- os: macos-13
shortosname: mac-13
compiler: clang++-15
- os: windows-latest
cxx_std: c++2b
stdlib: default
- os: windows-2022
shortosname: win-22
compiler: cl.exe
cxx_std: c++latest
stdlib: default
- os: windows-2022
shortosname: win-22
compiler: cl.exe
cxx_std: c++20
stdlib: default
steps:
- name: Checkout repo
uses: actions/checkout@v4
Expand All @@ -48,21 +89,21 @@ jobs:
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
run: |
cd regression-tests
bash run-tests.sh -c ${{ matrix.compiler }} -l ${{ matrix.os }}
bash run-tests.sh -c ${{ matrix.compiler }} -s ${{ matrix.cxx_std }} -d ${{ matrix.stdlib }} -l ${{ matrix.os }}
- name: Run regression tests - Windows version
if: matrix.os == 'windows-latest'
run: |
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
git config --local core.autocrlf false && ^
cd regression-tests && ^
bash run-tests.sh -c ${{ matrix.compiler }} -l ${{ matrix.os }}
bash run-tests.sh -c ${{ matrix.compiler }} -s ${{ matrix.cxx_std }} -d ${{ matrix.stdlib }} -l ${{ matrix.os }}
shell: cmd

- name: Upload patch
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.compiler }}.patch
path: regression-tests/${{ matrix.os }}-${{ matrix.compiler }}.patch
name: ${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.cxx_std }}-${{ matrix.stdlib }}.patch
path: regression-tests/${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.cxx_std }}-${{ matrix.stdlib }}.patch
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion docs/cpp2/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ All lists use `,` commas between list items, and may be enclosed by

For example:

``` cpp title="Lists, using optional trailing commas just because we can" hl_lines="1 4 6 7"
``` cpp title="Lists" hl_lines="1 4 6 7"
print: <T,U> (t: T, u: U) = std::cout << t << u << "\n";

main: () = {
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp2/declarations.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ main: () = {
// Assertion that the size is the square of 4
static_assert( ints.size() == 16 );

// And if can be used at run time, with run time values
// And it can be used at run time, with run time values
std::cout << "the square of 4 is (square(4))$\n";
}
// Prints:
Expand Down
6 changes: 2 additions & 4 deletions docs/cpp2/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,11 @@ Here are some `as` casts with their Cpp1 equivalents. In this table, uppercase n

## <a id="inspect"></a> `inspect` — pattern matching

An `inspect expr -> Type` expression allows pattern matching using `is`.
An `inspect expr -> Type = { /* alternatives */ }` expression allows pattern matching using `is`.

- `expr` is evaluated once.

- Each alternative spelled `is C` is evaluated in order as if called with `expr is C`.

- If an alternative evaluates to `#!cpp true`, then its `#!cpp = alternative;` body is used as the value of the entire `inspect` expression, and the meaning is the same as if the entire `inspect` expression had been written as just `#!cpp :Type = alternative;` — i.e., an unnamed object expression (aka 'temporary object') of type `Type` initialized with `alternative`.
- Each alternative is spelled `is C = statement;` and are evaluated in order. Each `is C` is evaluated if called with `expr is C`, and if it alternative evaluates to `#!cpp true`, then its `#!cpp = alternative;` body is used as the value of the entire `inspect` expression, and the meaning is the same as if the entire `inspect` expression had been written as just `#!cpp :Type = alternative;` — i.e., an unnamed object expression (aka 'temporary object') of type `Type` initialized with `alternative`.

- A catchall `is _` is required.

Expand Down
6 changes: 3 additions & 3 deletions docs/cpp2/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ For example:
abstract_base: type
= {
// A pure virtual function: virtual + no body
print: (virtual this, msg: std::string);
print: (virtual this, msg: std::string) = { /*...*/ }

// ...
}
Expand All @@ -92,7 +92,7 @@ derived: type
this: abstract_base;

// Explicit override
print: (override this, msg: std::string);
print: (override this, msg: std::string) = { /*...*/ }

// ...
}
Expand Down Expand Up @@ -199,7 +199,7 @@ mytype: type
name: std::string;
social_handle: std::string = "(unknown)";

// conversion from string
// conversion from string (construction + assignment)
operator=: (out this, who: std::string) = {
name = who;
// if social_handle is not mentioned, defaults to:
Expand Down
6 changes: 6 additions & 0 deletions include/cpp2util.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ template <typename T>
requires requires { *std::declval<T&>(); }
using deref_t = decltype(*std::declval<T&>());

// Guaranteed to be a total order, unlike built-in operator== for T*
template <typename T>
auto pointer_eq(T const* a, T const* b) {
return std::compare_three_way{}(a, b) == std::strong_ordering::equal;
}


//-----------------------------------------------------------------------
//
Expand Down
64 changes: 50 additions & 14 deletions regression-tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
usage() {
echo "Usage: $0 -c <compiler> [-l <run label>] [-t <tests to run>]"
echo " -c <compiler> The compiler to use for the test"
echo " -s <cxx_std> The C++ standard to compile with (e.g. 'c++20', 'c++2b', 'c++latest' depending on the compiler)"
echo " -d <stdlib> Clang-only: the C++ Standard Library to link with ('libstdc++', 'libc++', or 'default' for platform default)"
echo " -l <run label> The label to use in output patch file name"
echo " -t <tests to run> Runs only the provided, comma-separated tests (filenames including .cpp2)"
echo " If the argument is not used all tests are run"
Expand Down Expand Up @@ -46,7 +48,7 @@ check_file () {
git ls-files --error-unmatch "$file" > /dev/null 2>&1
untracked=$?

patch_file="$label$cxx_compiler.patch"
patch_file="${label}-${cxx_compiler}-${cxx_std}-${cxx_stdlib}.patch"

if [[ $untracked -eq 1 ]]; then
# Add the file to the index to be able to diff it...
Expand All @@ -67,14 +69,20 @@ check_file () {
fi
}

optstring="c:l:t:"
optstring="c:s:d:l:t:"
while getopts ${optstring} arg; do
case "${arg}" in
c)
cxx_compiler="${OPTARG}"
;;
s)
cxx_std="${OPTARG}"
;;
d)
cxx_stdlib="${OPTARG}"
;;
l)
label="${OPTARG}-"
label="${OPTARG}"
;;
t)
# Replace commas with spaces
Expand Down Expand Up @@ -125,8 +133,8 @@ expected_results_dir="test-results"
################
# Get the directory with the exec outputs and compilation command
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
compiler_cmd='cl.exe -nologo -std:c++latest -MD -EHsc -I ..\..\..\include -Fe:'
exec_out_dir="$expected_results_dir/msvc-2022"
compiler_cmd="cl.exe -nologo -std:${cxx_std} -MD -EHsc -I ..\..\..\include -Fe:"
exec_out_dir="$expected_results_dir/msvc-2022-${cxx_std}"
compiler_version=$(cl.exe)
else
# Verify the compiler command
Expand All @@ -136,7 +144,6 @@ else
exit 2
fi

cpp_std=c++2b
compiler_version=$("$cxx_compiler" --version)

if [[ "$compiler_version" == *"Apple clang version 14.0"* ||
Expand All @@ -148,30 +155,59 @@ else
exec_out_dir="$expected_results_dir/clang-12"
elif [[ "$compiler_version" == *"clang version 15.0"* ]]; then
exec_out_dir="$expected_results_dir/clang-15"
# c++2b causes starge issues on GitHub ubuntu-latest runner
cpp_std="c++20"
elif [[ "$compiler_version" == *"clang version 18.1"* ]]; then
exec_out_dir="$expected_results_dir/clang-18"
elif [[ "$compiler_version" == *"g++-10"* ]]; then
exec_out_dir="$expected_results_dir/gcc-10"
# GCC 10 does not support c++2b
cpp_std=c++20
elif [[ "$compiler_version" == *"g++-12"* ||
"$compiler_version" == *"g++-13"*
]]; then
exec_out_dir="$expected_results_dir/gcc-13"
elif [[ "$compiler_version" == *"g++-14"* ]]; then
exec_out_dir="$expected_results_dir/gcc-14"
else
printf "Unhandled compiler version:\n$compiler_version\n\n"
exit 2
fi

compiler_cmd="$cxx_compiler -I../../../include -std=$cpp_std -pthread -o "
# Append the C++ standard (e.g. 'c++20') to the expected output dir name
exec_out_dir="${exec_out_dir}-${cxx_std}"

# Clang can link with either libstdc++ or libc++
# By default clang on ubuntu links with libstdc++ and on macOS links with libc++.
if [[ "$compiler_version" == *"clang"* ]]; then
if [[ "$cxx_stdlib" == "default" || "$cxx_stdlib" == "" ]]; then
cxx_stdlib_link_arg="" # Use compiler/platform default
elif [[ "$cxx_stdlib" == "libstdc++" ]]; then
cxx_stdlib_link_arg="-stdlib=libstdc++"
elif [[ "$cxx_stdlib" == *"libc++"* ]]; then

# Need to install the correct libc++ packages, e.g. `libc++-15-dev` and `libc++abi-15-dev` for clang 15.
# Our `cxx_stdlib` variable contains the `libc++-XX-dev` package name so we need to create the abi version.
cxx_stdlib_abi_package="${cxx_stdlib/libc++/libc++abi}"
printf "Installing packages: $cxx_stdlib $cxx_stdlib_abi_package\n\n"
sudo apt-get install -y $cxx_stdlib $cxx_stdlib_abi_package

cxx_stdlib_link_arg="-stdlib=libc++"
exec_out_dir="${exec_out_dir}-libcpp"
else
printf "Unhandled C++ Standard Library option:\n$cxx_stdlib\n\n"
exit 2
fi
else
cxx_stdlib_link_arg="" # Use compiler/platform default
fi

compiler_cmd="$cxx_compiler -I../../../include -std=$cxx_std $cxx_stdlib_link_arg -pthread -o "
printf "\ncompiler_cmd: $compiler_cmd\n\n"
fi

if [[ -d "$exec_out_dir" ]]; then
printf "Full compiler version for '$cxx_compiler':\n$compiler_version\n\n"

printf "Directory with reference compilation/execution files to use:\n$exec_out_dir\n\n"
else
printf "Directory with reference compilation/execution files not found for compiler: '$cxx_compiler'\n\n"
printf "Directory with reference compilation/execution files not found for compiler: '$cxx_compiler' at $exec_out_dir\n\n"
exit 2
fi

Expand All @@ -191,8 +227,8 @@ regression_test_link_obj=""
if [[ "$cxx_compiler" == *"cl.exe"* ]]; then
echo "Building std and std.compat modules"
(cd $exec_out_dir; \
cl.exe -nologo -std:c++latest -MD -EHsc -c "${VCToolsInstallDir}/modules/std.ixx";
cl.exe -nologo -std:c++latest -MD -EHsc -c "${VCToolsInstallDir}/modules/std.compat.ixx")
cl.exe -nologo -std:${cxx_std} -MD -EHsc -c "${VCToolsInstallDir}/modules/std.ixx";
cl.exe -nologo -std:${cxx_std} -MD -EHsc -c "${VCToolsInstallDir}/modules/std.compat.ixx")
regression_test_link_obj="std.obj std.compat.obj"
fi

Expand Down
File renamed without changes.
Loading

0 comments on commit 48f3a1d

Please sign in to comment.