Skip to content

Commit b9b5592

Browse files
committed
fix(to_cpp1): consider that postfix tem can be empty
1 parent ebe9405 commit b9b5592

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

regression-tests/pure2-bugfix-for-dependent-types.cpp2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,6 @@ main: () = {
8888
_ = :alias::value_type = 0; // Non-dependent.
8989
}
9090
}(0);
91+
92+
_ = :(r) -> std::type_identity_t<decltype(begin(r)*)> = r[0];(std::vector<int>(1));
9193
}

regression-tests/test-results/gcc-13/gcc-version.output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
1+
c++ (GCC) 13.2.1 20230801
22
Copyright (C) 2023 Free Software Foundation, Inc.
33
This is free software; see the source for copying conditions. There is NO
44
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
pure2-bugfix-for-dependent-types-recursion.cpp: In function ‘int main()’:
2-
pure2-bugfix-for-dependent-types-recursion.cpp:19:13: error: ‘b’ does not name a type
3-
19 | using a = b;
1+
pure2-bugfix-for-dependent-types-recursion.cpp2: In function ‘int main()’:
2+
pure2-bugfix-for-dependent-types-recursion.cpp2:2:13: error: ‘b’ does not name a type
3+
2 | a: type == b;
44
| ^
5-
pure2-bugfix-for-dependent-types-recursion.cpp:20:13: error: ‘a’ does not name a type
6-
20 | using b = a;
5+
pure2-bugfix-for-dependent-types-recursion.cpp2:3:13: error: ‘a’ does not name a type
6+
3 | b: type == a;
77
| ^
8-
pure2-bugfix-for-dependent-types-recursion.cpp:21:21: error: ‘a’ has not been declared
9-
21 | static_cast<void>(a::t);
8+
pure2-bugfix-for-dependent-types-recursion.cpp2:4:21: error: ‘a’ has not been declared
9+
4 | _ = a::t;
1010
| ^
11-
pure2-bugfix-for-dependent-types-recursion.cpp:22:21: error: ‘b’ has not been declared
12-
22 | static_cast<void>(b::t);
11+
pure2-bugfix-for-dependent-types-recursion.cpp2:5:21: error: ‘b’ has not been declared
12+
5 | _ = b::t;
1313
| ^

regression-tests/test-results/pure2-bugfix-for-dependent-types.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,7 @@ auto main() -> int{
120120
static_cast<void>(typename alias::value_type{0});// Non-dependent.
121121
}
122122
}(0));
123+
124+
static_cast<void>([](auto const& r) -> std::type_identity_t<decltype(*cpp2::assert_not_null(begin(r)))> { return CPP2_ASSERT_IN_BOUNDS(r, 0); }(std::vector<int>(1)));
123125
}
124126

source/to_cpp1.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,8 +1947,10 @@ class cppfront
19471947
{
19481948
if (expr.id_expr) {
19491949
return (*this)(*expr.id_expr);
1950+
} else if (expr.expr_list) {
1951+
return (*this)(*expr.expr_list);
19501952
}
1951-
return (*this)(*expr.expr_list);
1953+
return false;
19521954
}
19531955

19541956
auto operator()(primary_expression_node const& expr) const

0 commit comments

Comments
 (0)