You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change cpp2::in closer to its original condition, closes#317
Restore a `pass_by_value` computation, but exclude class/union/array/function types. See comment thread in #317 for details.
Also don't allow the Cpp1 casts, and emit migration usability diagnostics for attempts to use them.
pure2-bounds-safety-pointer-arithmetic-error.cpp2(15,13): error: 'delete' and owning raw pointers are not supported in Cpp2 - use unique.new<T>, shared.new<T>, or gc.new<T> instead (in that order)
2
+
pure2-bounds-safety-pointer-arithmetic-error.cpp2(15,13): error: 'delete' and owning raw pointers are not supported in Cpp2 - use unique.new<T> or shared.new<T> instead in that order (or, in the future, gc.new<T>, but that is not yet implemented)
Copy file name to clipboardExpand all lines: source/lex.h
+27-2Lines changed: 27 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1649,6 +1649,31 @@ auto lex_line(
1649
1649
//
1650
1650
elseif (auto j = peek_is_keyword()) {
1651
1651
store(j, lexeme::Keyword);
1652
+
1653
+
if (tokens.back() == "const_cast") {
1654
+
errors.emplace_back(
1655
+
source_position(lineno, i),
1656
+
"'const_cast' is not supported in Cpp2 - the current C++ best practice is to never cast away const, and that is const_cast's only effective use"
1657
+
);
1658
+
}
1659
+
if (tokens.back() == "reinterpret_cast") {
1660
+
errors.emplace_back(
1661
+
source_position(lineno, i),
1662
+
"'reinterpret_cast' is not supported in Cpp2 - use std::bit_cast instead"
1663
+
);
1664
+
}
1665
+
if (tokens.back() == "static_cast") {
1666
+
errors.emplace_back(
1667
+
source_position(lineno, i),
1668
+
"'static_cast<T>(val)' is not supported in Cpp2 - use 'val as T' for safe conversions instead, or if necessary unsafe_narrow<T>(val) for a possibly-lossy narrowing conversion"
1669
+
);
1670
+
}
1671
+
if (tokens.back() == "dynamic_cast") {
1672
+
errors.emplace_back(
1673
+
source_position(lineno, i),
1674
+
"'dynamic_cast<Derived*>(pBase)' is not supported in Cpp2 - use 'pBase as *Derived' for safe dynamic conversions instead"
1675
+
);
1676
+
}
1652
1677
}
1653
1678
1654
1679
// Identifier
@@ -1675,13 +1700,13 @@ auto lex_line(
1675
1700
if (tokens.back() == "union") {
1676
1701
errors.emplace_back(
1677
1702
source_position(lineno, i),
1678
-
"unsafe 'union's are not supported in Cpp2 - use std::variant instead (or, in the future, the Cpp2 'union' metaclass function, but that is not yet implemented)"
1703
+
"unsafe 'union' is not supported in Cpp2 - use std::variant instead (or, in the future, the Cpp2 'union' metaclass function, but that is not yet implemented)"
1679
1704
);
1680
1705
}
1681
1706
if (tokens.back() == "delete") {
1682
1707
errors.emplace_back(
1683
1708
source_position(lineno, i),
1684
-
"'delete' and owning raw pointers are not supported in Cpp2 - use unique.new<T>, shared.new<T>, or gc.new<T> instead (in that order)"
1709
+
"'delete' and owning raw pointers are not supported in Cpp2 - use unique.new<T> or shared.new<T> instead in that order (or, in the future, gc.new<T>, but that is not yet implemented)"
0 commit comments