Skip to content

C++ front-end: fix parsing of >> as closing template args #8291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions regression/cpp/Templates4/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
template <typename _Tp>
struct __remove_cvref_t
{
};

template <typename _Tp, typename _Up = __remove_cvref_t<_Tp>>
struct __inv_unwrap
{
};

template <typename...>
struct __or_;

template <bool _Cond, typename _Iftrue, typename _Iffalse>
struct conditional
{
typedef _Iftrue type;
};

template <typename _B1, typename _B2, typename _B3, typename... _Bn>
struct __or_<_B1, _B2, _B3, _Bn...>
: public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type
{
};

int main(int argc, char *argv[])
{
int x = 10 >> 1;
}
8 changes: 8 additions & 0 deletions regression/cpp/Templates4/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
main.cpp

^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
^CONVERSION ERROR$
2 changes: 1 addition & 1 deletion src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4017,8 +4017,8 @@ bool Parser::rTemplateArgs(irept &template_args)
tk2.text='>';
lex.Replace(tk2);
lex.Insert(tk2);
lex.get_token();
DATA_INVARIANT(lex.LookAhead(0) == '>', "should be >");
DATA_INVARIANT(lex.LookAhead(1) == '>', "should be >");
return true;

default:
Expand Down
Loading