From e4658c7dbbe88f742c96e5f58ee4a6d549d642ca Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 16 Apr 2020 07:19:57 +0200 Subject: [PATCH] c++: Fix pasto in structured binding diagnostics [PR94571] This snippet has been copied from the non-structured binding declaration parsing later in the function, and while for non-structured bindings it can be followed by comma or semicolon, structured bindings may be only followed by semicolon. Or, do we want to have a different message for the case when there is a comma (and keep this corrected one only if there is something else) that would explain better what is the bug (or add a fix-it hint)? Marek said in the PR that clang++ reports error: decomposition declaration must be the only declaration in its group There is another thing Marek noted (though, something for different spot), that diagnostic for auto x(1), [e,f] = test2; could also use a clearer wording like the above (or a fix-it hint), but the question is if we should assume [ after , as a structured binding or if we should do some tentative parsing first to figure out if it looks like a structured binding. 2020-04-16 Jakub Jelinek PR c++/94571 * parser.c (cp_parser_simple_declaration): Fix up a pasto in diagnostics. * g++.dg/cpp1z/decomp51.C: New test. --- gcc/cp/ChangeLog | 16 +++++--- gcc/cp/parser.c | 2 +- gcc/testsuite/ChangeLog | 53 +++++++++++++++------------ gcc/testsuite/g++.dg/cpp1z/decomp51.C | 16 ++++++++ 4 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/decomp51.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0f53923e768..3e324056ba7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-16 Jakub Jelinek + + PR c++/94571 + * parser.c (cp_parser_simple_declaration): Fix up a pasto in + diagnostics. + 2020-04-15 Jakub Jelinek PR c/94593 @@ -97,7 +103,7 @@ LOOKUP_AGGREGATE_PAREN_INIT but don't build up a constructor yet. 2020-04-08 Iain Sandoe - Jun Ma + Jun Ma * coroutines.cc (maybe_promote_captured_temps): Add a cleanup expression, if needed, to any call from which we promoted @@ -762,7 +768,7 @@ * coroutines.cc (captures_temporary): Strip component_ref to its base object. -2020-03-03 Jun Ma +2020-03-03 Jun Ma * coroutines.cc (finish_co_await_expr): Build co_await_expr with unknown_type_node. @@ -991,7 +997,7 @@ * tree.c (cp_walk_subtrees): Walk CONSTRUCTOR types here. * pt.c (find_parameter_packs_r): Not here. -2020-02-12 Iain Sandoe +2020-02-12 Iain Sandoe * coroutines.cc (build_actor_fn): Implement deallocation function selection per n4849, dcl.fct.def.coroutine bullet 12. @@ -1146,7 +1152,7 @@ * coroutines.cc (maybe_promote_captured_temps): Increase the index number for temporary variables' name. -2020-02-05 Jun Ma +2020-02-05 Jun Ma * coroutines.cc (build_co_await): Call convert_from_reference to wrap co_await_expr with indirect_ref which avoid @@ -1221,7 +1227,7 @@ * cp-gimplify.c (predeclare_vla): New. (cp_genericize_r) [NOP_EXPR]: Call it. -2020-02-03 Jun Ma +2020-02-03 Jun Ma * coroutines.cc (transform_await_wrapper): Set actor funcion as new context of label_decl. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3855416a854..7be4a8f5cbd 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13675,7 +13675,7 @@ cp_parser_simple_declaration (cp_parser* parser, if ((decl != error_mark_node && DECL_INITIAL (decl) != error_mark_node) || cp_parser_uncommitted_to_tentative_parse_p (parser)) - cp_parser_error (parser, "expected %<,%> or %<;%>"); + cp_parser_error (parser, "expected %<;%>"); /* Skip tokens until we reach the end of the statement. */ cp_parser_skip_to_end_of_statement (parser); /* If the next token is now a `;', consume it. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8181e9df846..545a7f66a3e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,10 +1,15 @@ +2020-04-16 Jakub Jelinek + + PR c++/94571 + * g++.dg/cpp1z/decomp51.C: New test. + 2020-04-15 Uroš Bizjak PR target/94603 * gcc.target/i386/pr94603.c: New test. -2020-04-15 Andre Vieira - Srinath Parvathaneni +2020-04-15 Andre Vieira + Srinath Parvathaneni * gcc.target/arm/mve/intrinsics/mve_vec_duplicate.c: New test. @@ -112,7 +117,7 @@ PR fortran/87644 * gfortran.dg/variable_parameter.f90: New test. -2020-04-13 Linus Koenig +2020-04-13 Linus Koenig PR fortran/94192 * gfortran.dg/bound_resolve_after_error_1.f90: New test. @@ -404,7 +409,7 @@ PR c++/94507 - ICE-on-invalid with lambda template. * g++.dg/cpp2a/lambda-generic7.C: New test. -2020-04-08 Alexandre Oliva +2020-04-08 Alexandre Oliva * gcc.target/arm/fp16-aapcs-3.c: Explicitly use the -mfp16-format=alternative option. @@ -429,7 +434,7 @@ * gfortran.dg/ieee/dec_math_1.f90: ... here; change dg-options to dg-additional-options. -2020-04-08 Alexandre Oliva +2020-04-08 Alexandre Oliva * gcc.dg/tls/pr78796.c: Require tls_runtime. @@ -472,7 +477,7 @@ PR c++/94478 - ICE with defaulted comparison operator * g++.dg/cpp2a/spaceship-err4.C: New test. -2020-04-08 Alexandre Oliva +2020-04-08 Alexandre Oliva * gcc.target/arm/polytypes.c: Add quotes around -flax-vector-conversions. @@ -1037,7 +1042,7 @@ PR c++/94336 - template keyword accepted before destructor names. * g++.dg/template/template-keyword2.C: New test. -2020-03-27 Iain Sandoe +2020-03-27 Iain Sandoe * g++.dg/coroutines/torture/symmetric-transfer-00-basic.C: Add . @@ -7095,11 +7100,11 @@ * gcc.c-torture/compile/pr93927-1.c: New test. * gcc.c-torture/compile/pr93927-2.c: New test. -2020-03-03 Jun Ma +2020-03-03 Jun Ma * g++.dg/coroutines/torture/co-await-15-capture-comp-ref.C: New test. -2020-03-03 Jun Ma +2020-03-03 Jun Ma * g++.dg/coroutines/torture/co-await-14-template-traits.C: New test. @@ -7115,7 +7120,7 @@ * g++.dg/analyzer/cstdlib.C: New test. 2020-03-02 Iain Sandoe - Jun Ma + Jun Ma * g++.dg/coroutines/torture/class-05-lambda-capture-copy-local.C: * g++.dg/coroutines/torture/lambda-09-init-captures.C: New test. @@ -7183,7 +7188,7 @@ * gcc.target/powerpc/pr88233.c: Update expected output and add target selector. -2020-03-01 Iain Sandoe +2020-03-01 Iain Sandoe * g++.dg/coroutines/torture/class-07-data-member.C: New test. @@ -7197,7 +7202,7 @@ PR fortran/92959 * gfortran.dg/associated_8.f90 : New test. -2020-02-29 Iain Sandoe +2020-02-29 Iain Sandoe * g++.dg/coroutines/coro1-ret-int-yield-int.h: Add templated awaitable. @@ -7297,7 +7302,7 @@ * gcc.target/powerpc/ppc64-abi-1.c: Compile with -mno-pcrel. * gcc.target/powerpc/ppc64-abi-2.c: Likewise. -2020-02-27 Alexandre Oliva +2020-02-27 Alexandre Oliva * gcc.target/aarch64/vect-mull.x (SH): Undefine. @@ -7656,11 +7661,11 @@ PR c++/93817 * g++.dg/diagnostic/array-init1.C: Fix for ILP32. -2020-02-18 Jon Beniston +2020-02-18 Jon Beniston * gcc.dg/strcmpopt_6.c: Add space in array for terminator. -2020-02-18 Mark Eggleston +2020-02-18 Mark Eggleston PR fortran/93714 * gfortran.dg/char_pointer_assign_6.f90: Look for no target @@ -7706,7 +7711,7 @@ PR fortran/93603 * gfortran.dg/pr93603.f90 : New test. -2020-02-20 Mark Eggleston +2020-02-20 Mark Eggleston PR fortran/93580 * gfortran.dg/dg/pr93580.f90: New test. @@ -8097,7 +8102,7 @@ PR target/91927 * gcc.target/aarch64/pr91927.c: New testcase. -2020-02-08 Peter Bergner +2020-02-08 Peter Bergner PR target/93136 * gcc.dg/vmx/ops.c: Add -flax-vector-conversions to dg-options. @@ -9199,7 +9204,7 @@ PR ipa/93166 * g++.dg/pr93166.C: New test. -2020-01-25 Andrew Pinski +2020-01-25 Andrew Pinski * gcc.target/aarch64/vec_zeroextend.c: Fix for big-endian. @@ -10191,12 +10196,12 @@ PR c++/92542 * g++.dg/pr92542.C: New. -2020-01-17 Mihail-Calin Ionescu +2020-01-17 Mihail-Calin Ionescu Sudakshina Das * gcc.target/arm/armv8_1m-shift-imm_1.c: New test. -2020-01-17 Mihail-Calin Ionescu +2020-01-17 Mihail-Calin Ionescu Sudakshina Das * gcc.target/arm/armv8_1m-shift-reg_1.c: New test. @@ -10288,8 +10293,8 @@ * testsuite/gcc.target/arm/multilib.exp: Add v8.1-M entries. -2020-01-16 Mihail-Calin Ionescu - Thomas Preud'homme +2020-01-16 Mihail-Calin Ionescu + Thomas Preud'homme * gcc.target/arm/cmse/cmse-1.c: Add check for BLXNS when instructions introduced in Armv8.1-M Mainline Security Extensions are available and @@ -10555,8 +10560,8 @@ * lib/target-supports.exp (check_effective_target_arm_cmse_clear_ok): New procedure. -2020-01-16 Mihail-Calin Ionescu - Thomas Preud'homme +2020-01-16 Mihail-Calin Ionescu + Thomas Preud'homme * lib/target-supports.exp (check_effective_target_arm_arch_v8_1m_main_ok): Define. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp51.C b/gcc/testsuite/g++.dg/cpp1z/decomp51.C new file mode 100644 index 00000000000..fe8b998abc8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp51.C @@ -0,0 +1,16 @@ +// PR c++/94571 +// { dg-do compile { target c++17 } } + +void +foo () +{ + int e[2], f[2]; + auto [a,b] = e, [c,d] = f; // { dg-error "expected ';' before ',' token" } +} + +void +bar () +{ + int e[2]; + auto [a, b] = e ); // { dg-error "expected ';' before '\\\)' token" } +} -- 2.30.2