diff options
author | Marek Polacek <polacek@redhat.com> | 2022-04-29 17:03:41 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2022-05-04 12:01:31 -0400 |
commit | 79a1a01cbd0e4a491d7078783131e3f88ca7158d (patch) | |
tree | 6d83fea4116ee364d53020afcccf14a24aef68d2 /gcc/cp | |
parent | 22399ad6edcd4a2903b05196b59eec3159ceaa38 (diff) | |
download | gcc-79a1a01cbd0e4a491d7078783131e3f88ca7158d.zip gcc-79a1a01cbd0e4a491d7078783131e3f88ca7158d.tar.gz gcc-79a1a01cbd0e4a491d7078783131e3f88ca7158d.tar.bz2 |
c++: parse error with >= in template argument list [PR105436]
This patch fixes an oversight whereby we treated >= as the end of
a template argument. This causes problems in C++14, because in
cp_parser_template_argument we go different ways for C++14 and C++17:
/* It must be a non-type argument. In C++17 any constant-expression is
allowed. */
if (cxx_dialect > cxx14)
goto general_expr;
so in this testcase in C++14 we get "N" as the template argument but in
C++17 it is the whole "N >= 5" expression. So in C++14 the remaining
">= 5" triggered the newly-added diagnostic.
PR c++/105436
gcc/cp/ChangeLog:
* parser.cc (cp_parser_next_token_ends_template_argument_p): Don't
return true for CPP_GREATER_EQ.
gcc/testsuite/ChangeLog:
* g++.dg/parse/template31.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/parser.cc | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index a5cbb3e..5fa743b 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -33224,7 +33224,6 @@ cp_parser_next_token_ends_template_argument_p (cp_parser *parser) || ((cxx_dialect != cxx98) && token->type == CPP_RSHIFT) /* For better diagnostics, treat >>= like that too, that shouldn't appear non-nested in template arguments. */ - || token->type == CPP_GREATER_EQ || token->type == CPP_RSHIFT_EQ); } |