Skip to content

Commit 7e65a71

Browse files
committed
fix(parse): add missing condition for "inside initializer"
1 parent 11fc88d commit 7e65a71

6 files changed

+43
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pair: <L: _, R: _> type = { }
2+
g: (x: pair<:i32 = (0), :i32 = (0)>) = { }
3+
main: () = { }

regression-tests/test-results/clang-18/pure2-bugfix-for-non-local-initialization.cpp.execution

Whitespace-only changes.

regression-tests/test-results/clang-18/pure2-bugfix-for-non-local-initialization.cpp.output

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
#define CPP2_USE_MODULES Yes
3+
4+
//=== Cpp2 type declarations ====================================================
5+
6+
7+
#include "cpp2util.h"
8+
9+
#line 1 "pure2-bugfix-for-non-local-initialization.cpp2"
10+
template<auto L, auto R> class pair;
11+
12+
13+
//=== Cpp2 type definitions and function declarations ===========================
14+
15+
#line 1 "pure2-bugfix-for-non-local-initialization.cpp2"
16+
template<auto L, auto R> class pair {
17+
public: pair() = default;
18+
public: pair(pair const&) = delete; /* No 'that' constructor, suppress copy */
19+
public: auto operator=(pair const&) -> void = delete;
20+
21+
#line 1 "pure2-bugfix-for-non-local-initialization.cpp2"
22+
};
23+
auto g(cpp2::in<pair<cpp2::i32{0},cpp2::i32{0}>> x) -> void;
24+
auto main() -> int;
25+
26+
27+
//=== Cpp2 function definitions =================================================
28+
29+
30+
#line 2 "pure2-bugfix-for-non-local-initialization.cpp2"
31+
auto g(cpp2::in<pair<cpp2::i32{0},cpp2::i32{0}>> x) -> void{}
32+
auto main() -> int{}
33+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pure2-bugfix-for-non-local-initialization.cpp2... ok (all Cpp2, passes safety checks)
2+

source/parse.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4161,6 +4161,7 @@ class parser
41614161
curr().type() != lexeme::Semicolon
41624162
&& curr().type() != lexeme::RightParen
41634163
&& curr().type() != lexeme::RightBracket
4164+
&& curr().type() != lexeme::Greater
41644165
&& curr().type() != lexeme::Comma
41654166
) {
41664167
expr_list->inside_initializer = false;
@@ -5031,20 +5032,20 @@ class parser
50315032
}
50325033
return expression(false); // false == disallow unparenthesized relational comparisons in template args
50335034
}()
5034-
)
5035+
)
50355036
{
50365037
term.arg = std::move(e);
50375038
}
5038-
5039+
50395040
// Else try parsing it as a type id
50405041
else if (auto i = type_id()) {
50415042
term.arg = std::move(i);
50425043
}
5043-
5044+
50445045
else {
50455046
break;
50465047
}
5047-
5048+
50485049
n->template_args.push_back( std::move(term) );
50495050
}
50505051
// Use the lambda trick to jam in a "next" clause

0 commit comments

Comments
 (0)