aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/net/protocol/https
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2026-01-26 14:51:02 -0500
committerMarek Polacek <polacek@redhat.com>2026-02-07 20:58:15 -0500
commit5d9de7136b30b104606e85fc4284a25a8063a0c0 (patch)
treea04587d5c64b462dffdcc8995fea46426975b892 /libjava/gnu/java/net/protocol/https
parentbe597e8c7423998609efd733bf465912ca84d0d3 (diff)
downloadgcc-5d9de7136b30b104606e85fc4284a25a8063a0c0.zip
gcc-5d9de7136b30b104606e85fc4284a25a8063a0c0.tar.gz
gcc-5d9de7136b30b104606e85fc4284a25a8063a0c0.tar.bz2
c++/reflection: splice parsing fixes [PR123823]
This patch fixes the problem that when cp_parser_splice_specifier sees :]<, it always thinks it's a template-id. Consequently, this should compile but does not: int i; constexpr auto r = ^^i; bool b = [:r:] < 42; because we think that a template argument list follows the splice. Fixed by implementing [temp.names]/3 better: only attempt to parse a template argument list if we saw template or typename. As an extension, also parse a template argument list if the splice yielded a TEMPLATE_DECL -- in that case, chances are that the user simply forgot to specify 'template'. In that case we'll suggest adding 'template' in cp_parser_splice_expression. We should accept the following given [temp.names]/3: S<[:r:] < 43> s; and we should also accept: [:r:] < 42 > 0; I also realized that my code to detect unparenthesized splice expressions as template arguments is wrong. [expr.prim.splice] says that constexpr auto i = e<[:^^h:]>; is ill-formed, but "S<[:r:] >= 1>" is fine as per [temp.names]/6. I moved the checking to cp_parser_template_argument while making sure that we only complain when the splice-expression is the whole template-argument. This patch also fixes 123640. PR c++/123823 PR c++/123640 gcc/cp/ChangeLog: * parser.cc (cp_parser_splice_specifier): New typename_p parameter. Use cp_parser_nth_token_starts_template_argument_list_p instead of checking CPP_LESS. Check for typename/template/TEMPLATE_DECL before parsing a template-id. (cp_parser_splice_type_specifier): Adjust the call to cp_parser_splice_specifier. (cp_parser_splice_expression): Don't detect unparenthesized splice expressions here. Adjust the call to cp_parser_splice_specifier. (cp_parser_splice_scope_specifier): Adjust the call to cp_parser_splice_specifier. (cp_parser_skip_entire_splice_expr): New, broken out of... (cp_parser_splice_spec_is_nns_p): ...this. (cp_parser_template_id): Call pop_deferring_access_checks. (cp_parser_template_argument): Detect unparenthesized splice expressions here. gcc/testsuite/ChangeLog: * g++.dg/reflect/crash6.C: Adjust expected diagnostic. * g++.dg/reflect/expr3.C: Likewise. Test more cases. * g++.dg/reflect/splice4.C: Adjust expected diagnostic. * g++.dg/reflect/error12.C: New test. * g++.dg/reflect/parse1.C: New test. * g++.dg/reflect/parse2.C: New test. * g++.dg/reflect/parse3.C: New test. * g++.dg/reflect/parse4.C: New test. * g++.dg/reflect/parse5.C: New test. * g++.dg/reflect/parse6.C: New test. Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'libjava/gnu/java/net/protocol/https')
0 files changed, 0 insertions, 0 deletions