Skip to content

Commit 37511f3

Browse files
authored
Merge pull request #8291 from tautschnig/bugfixes/c++-shift-vs-template
C++ front-end: fix parsing of >> as closing template args
2 parents 1657d97 + bc0ce46 commit 37511f3

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

regression/cpp/Templates4/main.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
template <typename _Tp>
2+
struct __remove_cvref_t
3+
{
4+
};
5+
6+
template <typename _Tp, typename _Up = __remove_cvref_t<_Tp>>
7+
struct __inv_unwrap
8+
{
9+
};
10+
11+
template <typename...>
12+
struct __or_;
13+
14+
template <bool _Cond, typename _Iftrue, typename _Iffalse>
15+
struct conditional
16+
{
17+
typedef _Iftrue type;
18+
};
19+
20+
template <typename _B1, typename _B2, typename _B3, typename... _Bn>
21+
struct __or_<_B1, _B2, _B3, _Bn...>
22+
: public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
23+
{
24+
};
25+
26+
int main(int argc, char *argv[])
27+
{
28+
int x = 10 >> 1;
29+
}

regression/cpp/Templates4/test.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.cpp
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

src/cpp/parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4057,8 +4057,8 @@ bool Parser::rTemplateArgs(irept &template_args)
40574057
tk2.text='>';
40584058
lex.Replace(tk2);
40594059
lex.Insert(tk2);
4060+
lex.get_token();
40604061
DATA_INVARIANT(lex.LookAhead(0) == '>', "should be >");
4061-
DATA_INVARIANT(lex.LookAhead(1) == '>', "should be >");
40624062
return true;
40634063

40644064
default:

0 commit comments

Comments
 (0)