Skip to content

Commit 3a5d459

Browse files
authored
Merge branch 'main' into fix-explicit-constructor
2 parents bd3542c + 0fe38ba commit 3a5d459

File tree

346 files changed

+9882
-5100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

346 files changed

+9882
-5100
lines changed

.github/workflows/build-cppfront.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Compiler name & version
1818
run: cl.exe
1919
- name: Build
20-
run: cl.exe source/cppfront.cpp -std:c++latest -MD -EHsc -experimental:module -W4 -WX
20+
run: cl.exe source/cppfront.cpp -std:c++latest -MD -EHsc -W4 -WX
2121
build-unix-like:
2222
strategy:
2323
fail-fast: false

.github/workflows/regression-tests.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,14 @@ jobs:
2525
cxx_std: [c++2b]
2626
stdlib: [libstdc++]
2727
include:
28-
- os: ubuntu-20.04
29-
shortosname: ubu-20
30-
compiler: g++-10
31-
cxx_std: c++20
32-
stdlib: libstdc++
3328
- os: ubuntu-24.04
3429
shortosname: ubu-24
35-
compiler: clang++-18
30+
compiler: clang++-19
3631
cxx_std: c++20
3732
stdlib: libstdc++
3833
- os: ubuntu-24.04
3934
shortosname: ubu-24
40-
compiler: clang++-18
35+
compiler: clang++-19
4136
cxx_std: c++23
4237
stdlib: libc++-18-dev
4338
- os: ubuntu-22.04
@@ -50,11 +45,6 @@ jobs:
5045
compiler: clang++-15
5146
cxx_std: c++20
5247
stdlib: libc++-15-dev
53-
- os: ubuntu-20.04
54-
shortosname: ubu-20
55-
compiler: clang++-12
56-
cxx_std: c++20
57-
stdlib: libstdc++
5848
- os: macos-14
5949
shortosname: mac-14
6050
compiler: clang++
@@ -84,12 +74,17 @@ jobs:
8474
- name: Checkout repo
8575
uses: actions/checkout@v4
8676

87-
- name: Prepare compilers
77+
- name: Prepare compilers - macOS
8878
if: matrix.os == 'macos-13'
8979
run: |
9080
sudo xcode-select --switch /Applications/Xcode_14.3.1.app
9181
sudo ln -s "$(brew --prefix llvm@15)/bin/clang" /usr/local/bin/clang++-15
9282
83+
- name: Prepare compilers - Ubuntu 24.04
84+
if: matrix.os == 'ubuntu-24.04'
85+
run: |
86+
sudo sudo apt-get install clang-19
87+
9388
- name: Run regression tests - Linux and macOS version
9489
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
9590
run: |
81.5 KB
Loading

docs/cpp2/types.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,16 @@ As mentioned above:
148148
149149
This graphic summarizes these generalizations. For convenience I've numbered the (A)ssignment and (M)ove defaults.
150150

151-
![image](https://user-images.githubusercontent.com/1801526/226261443-03125a35-7890-4cc7-bf7d-f23b3a0bb0df.png)
151+
![image](generalized-copy-move-construction-assignment.png)
152152

153153
In Cpp1 terms, they can be described as follows:
154154

155155
- **(M)ove, M1, M2:** If you write a copy constructor or assignment operator, but not a corresponding move constructor or assignment operator, the latter is generated.
156156

157-
- **(A)ssignment, A1, A2, A3:** If you write a copy or move or converting constructor, but not a corresponding copy or move or converting assignment operator, the latter is generated.
157+
- **(A)ssignment, A1, A3:** If you write a generalized constructor, but none of the three more-specific copy/move constructor/assignment functions, the latter three get generated. If you write a converting copy constructor, but no converting assignment operator for the same type and this is not a polymorphic type, the latter is generated.
158158

159159
- **The arrows are transitive.** For example, if you write a copy constructor and nothing else, the move constructor, copy assignment operator, and move assignment operator are generated.
160160

161-
- **M2 is preferred over A2.** Both M2 and A2 can generate a missing `#!cpp (inout this, move that)` function. If both options are available, Cpp2 prefers to use M2 (generate move assignment from copy assignment, which could itself have been generated from copy construction) rather than A2 (generate move assignment from move construction). This is because M2 is a better fit: Move assignment is more like copy assignment than like move construction, because assignments are designed structurally to set the value of an existing `#!cpp this` object.
162-
163161
The most general `#!cpp operator=` with `that` is `#!cpp (out this, that)`. In Cpp1 terms, it generates all four combinations of { copy, move } x { constructor, assignment }. This is often sufficient, so you can write all these value-setting functions just once. If you do want to write a more specific version that does something else, though, you can always write it too.
164162

165163
> Note: Generating `#!cpp inout this` (assignment) from `#!cpp out this` also generates **converting assignment** from converting construction, which is a new thing. Today in Cpp1, if you write a converting constructor from another type `X`, you may or may not write the corresponding assignment from `X`; in Cpp2 you will get that by default, and it sets the object to the same state as the converting constructor from `X` does.
@@ -218,7 +216,7 @@ mytype: type
218216
print();
219217
}
220218

221-
print: (this) = std::cout << "value is [(name)$] [(social_handle)$]\n";
219+
print: (this) = { std::cout << "value is [(name)$] [(social_handle)$]\n"; }
222220
}
223221

224222
// The above definition of mytype allows all of the following...

include/cpp2regex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ template<typename CharT, typename matcher> class regular_expression;
8282

8383
#line 1 "cpp2regex.h2"
8484

85-
// Copyright 2022-2024 Herb Sutter
85+
// Copyright 2022-2025 Herb Sutter
8686
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8787
//
8888
// Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.

include/cpp2regex.h2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Copyright 2022-2024 Herb Sutter
2+
// Copyright 2022-2025 Herb Sutter
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
//
55
// Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.

include/cpp2util.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// Copyright 2022-2024 Herb Sutter
2+
// Copyright 2022-2025 Herb Sutter
33
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
//
55
// Part of the Cppfront Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -301,6 +301,12 @@
301301
#include <vector>
302302
#endif
303303

304+
// Required for pure Cpp2 tests to pass on MSVC
305+
// #include <cstdlib> causes C2995 of math tempaltes
306+
#ifndef EXIT_FAILURE
307+
#define EXIT_FAILURE 1
308+
#endif
309+
304310
// cpp2util.h uses signed integer types for indices and container sizes
305311
// so disable clang signed-to-unsigned conversion warnings in this header.
306312
#ifdef __clang__
@@ -561,7 +567,7 @@ class contract_group {
561567
std::cerr << ": " << msg;
562568
}
563569
std::cerr << "\n";
564-
std::terminate();
570+
std::exit(EXIT_FAILURE);
565571
}
566572

567573
auto inline cpp2_default = contract_group(
@@ -1328,7 +1334,7 @@ constexpr auto type_name() -> std::string_view {
13281334
err += std::string{" and the message \""} + msg + "\"";
13291335
}
13301336
type_safety.report_violation( err.c_str() );
1331-
std::terminate();
1337+
std::exit(EXIT_FAILURE);
13321338
#else
13331339
throw CPP2_FORWARD(x);
13341340
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#else
2+
#else
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
crash_10: (foo: i32) = {
2+
assert( 10LL as i32 == foo$);
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
crash_10: (foo: i32) = {
2+
assert( 10LL as i32 == foo$);
3+
}

0 commit comments

Comments
 (0)