c++: Fix pasto in structured binding diagnostics [PR94571]
authorJakub Jelinek <jakub@redhat.com>
Thu, 16 Apr 2020 05:19:57 +0000 (07:19 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 16 Apr 2020 05:19:57 +0000 (07:19 +0200)
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  <jakub@redhat.com>

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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/decomp51.C [new file with mode: 0644]

index 0f53923e76800a6478cedab55eda2df97ef90222..3e324056ba75718f208e88cad5b7778409f60cf5 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94571
+       * parser.c (cp_parser_simple_declaration): Fix up a pasto in
+       diagnostics.
+
 2020-04-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/94593
        LOOKUP_AGGREGATE_PAREN_INIT but don't build up a constructor yet.
 
 2020-04-08  Iain Sandoe  <iain@sandoe.co.uk>
-           Jun Ma <JunMa@linux.alibaba.com>
+           Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (maybe_promote_captured_temps): Add a cleanup
        expression, if needed, to any call from which we promoted
        * coroutines.cc (captures_temporary): Strip component_ref
        to its base object.
 
-2020-03-03  Jun Ma <JunMa@linux.alibaba.com>
+2020-03-03  Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (finish_co_await_expr): Build co_await_expr
        with unknown_type_node.
        * tree.c (cp_walk_subtrees): Walk CONSTRUCTOR types here.
        * pt.c (find_parameter_packs_r): Not here.
 
-2020-02-12 Iain Sandoe <iain@sandoe.co.uk>
+2020-02-12 Iain Sandoe  <iain@sandoe.co.uk>
 
        * coroutines.cc (build_actor_fn): Implement deallocation function
        selection per n4849, dcl.fct.def.coroutine bullet 12.
        * coroutines.cc (maybe_promote_captured_temps): Increase the index
        number for temporary variables' name.
 
-2020-02-05  Jun Ma <JunMa@linux.alibaba.com>
+2020-02-05  Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (build_co_await): Call convert_from_reference
        to wrap co_await_expr with indirect_ref which avoid
        * cp-gimplify.c (predeclare_vla): New.
        (cp_genericize_r) [NOP_EXPR]: Call it.
 
-2020-02-03  Jun Ma <JunMa@linux.alibaba.com>
+2020-02-03  Jun Ma  <JunMa@linux.alibaba.com>
 
        * coroutines.cc (transform_await_wrapper): Set actor funcion as
        new context of label_decl.
index 3855416a85471ff79ec95b5cc4aa90867cd30034..7be4a8f5cbd35e31eb5cf122beb1b8eb064f4aa2 100644 (file)
@@ -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.  */
index 8181e9df8467c4650a21379d9993bc8cbcadbafd..545a7f66a3e091f5a91bc0de2163c5c202dfe900 100644 (file)
@@ -1,10 +1,15 @@
+2020-04-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94571
+       * g++.dg/cpp1z/decomp51.C: New test.
+
 2020-04-15  Uroš Bizjak  <ubizjak@gmail.com>
 
        PR target/94603
        * gcc.target/i386/pr94603.c: New test.
 
-2020-04-15  Andre Vieira <andre.simoesdiasvieira@arm.com>
-            Srinath Parvathaneni <srinath.parvathaneni@arm.com>
+2020-04-15  Andre Vieira  <andre.simoesdiasvieira@arm.com>
+            Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
 
        * gcc.target/arm/mve/intrinsics/mve_vec_duplicate.c: New test.
 
        PR fortran/87644
        * gfortran.dg/variable_parameter.f90: New test.
 
-2020-04-13  Linus Koenig <link@sig-st.de>
+2020-04-13  Linus Koenig  <link@sig-st.de>
 
        PR fortran/94192
        * gfortran.dg/bound_resolve_after_error_1.f90: New test.
        PR c++/94507 - ICE-on-invalid with lambda template.
        * g++.dg/cpp2a/lambda-generic7.C: New test.
 
-2020-04-08  Alexandre Oliva <oliva@adacore.com>
+2020-04-08  Alexandre Oliva  <oliva@adacore.com>
 
        * gcc.target/arm/fp16-aapcs-3.c: Explicitly use the
        -mfp16-format=alternative option.
        * gfortran.dg/ieee/dec_math_1.f90: ... here; change
        dg-options to dg-additional-options.
 
-2020-04-08  Alexandre Oliva <oliva@adacore.com>
+2020-04-08  Alexandre Oliva  <oliva@adacore.com>
 
        * gcc.dg/tls/pr78796.c: Require tls_runtime.
 
        PR c++/94478 - ICE with defaulted comparison operator
        * g++.dg/cpp2a/spaceship-err4.C: New test.
 
-2020-04-08  Alexandre Oliva <oliva@adacore.com>
+2020-04-08  Alexandre Oliva  <oliva@adacore.com>
 
        * gcc.target/arm/polytypes.c: Add quotes around
        -flax-vector-conversions.
        PR c++/94336 - template keyword accepted before destructor names.
        * g++.dg/template/template-keyword2.C: New test.
 
-2020-03-27 Iain Sandoe <iain@sandoe.co.uk>
+2020-03-27 Iain Sandoe  <iain@sandoe.co.uk>
 
        * g++.dg/coroutines/torture/symmetric-transfer-00-basic.C:
        Add <cstdio>.
        * gcc.c-torture/compile/pr93927-1.c: New test.
        * gcc.c-torture/compile/pr93927-2.c: New test.
 
-2020-03-03  Jun Ma <JunMa@linux.alibaba.com>
+2020-03-03  Jun Ma  <JunMa@linux.alibaba.com>
 
        * g++.dg/coroutines/torture/co-await-15-capture-comp-ref.C: New test.
 
-2020-03-03  Jun Ma <JunMa@linux.alibaba.com>
+2020-03-03  Jun Ma  <JunMa@linux.alibaba.com>
 
        * g++.dg/coroutines/torture/co-await-14-template-traits.C: New test.
 
        * g++.dg/analyzer/cstdlib.C: New test.
 
 2020-03-02  Iain Sandoe  <iain@sandoe.co.uk>
-           Jun Ma <JunMa@linux.alibaba.com>
+           Jun Ma  <JunMa@linux.alibaba.com>
 
        * g++.dg/coroutines/torture/class-05-lambda-capture-copy-local.C:
        * g++.dg/coroutines/torture/lambda-09-init-captures.C: New test.
        * gcc.target/powerpc/pr88233.c: Update expected output and
        add target selector.
 
-2020-03-01 Iain Sandoe <iain@sandoe.co.uk>
+2020-03-01  Iain Sandoe  <iain@sandoe.co.uk>
 
        * g++.dg/coroutines/torture/class-07-data-member.C: New test.
 
        PR fortran/92959
        * gfortran.dg/associated_8.f90 : New test.
 
-2020-02-29 Iain Sandoe <iain@sandoe.co.uk>
+2020-02-29  Iain Sandoe  <iain@sandoe.co.uk>
 
        * g++.dg/coroutines/coro1-ret-int-yield-int.h: Add templated
        awaitable.
        * gcc.target/powerpc/ppc64-abi-1.c: Compile with -mno-pcrel.
        * gcc.target/powerpc/ppc64-abi-2.c: Likewise.
 
-2020-02-27  Alexandre Oliva <oliva@adacore.com>
+2020-02-27  Alexandre Oliva  <oliva@adacore.com>
 
        * gcc.target/aarch64/vect-mull.x (SH): Undefine.
 
        PR c++/93817
        * g++.dg/diagnostic/array-init1.C: Fix for ILP32.
 
-2020-02-18  Jon Beniston <jon@beniston.com>
+2020-02-18  Jon Beniston  <jon@beniston.com>
 
        * gcc.dg/strcmpopt_6.c: Add space in array for terminator.
 
-2020-02-18  Mark Eggleston <markeggleston@gcc.gnu.org>
+2020-02-18  Mark Eggleston  <markeggleston@gcc.gnu.org>
 
        PR fortran/93714
        * gfortran.dg/char_pointer_assign_6.f90: Look for no target
        PR fortran/93603
        * gfortran.dg/pr93603.f90 : New test.
 
-2020-02-20  Mark Eggleston <markeggleston@gcc.gnu.org>
+2020-02-20  Mark Eggleston  <markeggleston@gcc.gnu.org>
 
        PR fortran/93580
        * gfortran.dg/dg/pr93580.f90: New test.
        PR target/91927
        * gcc.target/aarch64/pr91927.c: New testcase.
 
-2020-02-08  Peter Bergner <bergner@linux.ibm.com>
+2020-02-08  Peter Bergner  <bergner@linux.ibm.com>
 
        PR target/93136
        * gcc.dg/vmx/ops.c: Add -flax-vector-conversions to dg-options.
        PR ipa/93166
        * g++.dg/pr93166.C: New test.
 
-2020-01-25  Andrew Pinski <apinski@marvell.com>
+2020-01-25  Andrew Pinski  <apinski@marvell.com>
 
        * gcc.target/aarch64/vec_zeroextend.c: Fix for big-endian.
 
        PR c++/92542
        * g++.dg/pr92542.C: New.
 
-2020-01-17  Mihail-Calin Ionescu <mihail.ionescu@arm.com>
+2020-01-17  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
            Sudakshina Das  <sudi.das@arm.com>
 
        * gcc.target/arm/armv8_1m-shift-imm_1.c: New test.
 
-2020-01-17  Mihail-Calin Ionescu <mihail.ionescu@arm.com>
+2020-01-17  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
            Sudakshina Das  <sudi.das@arm.com>
 
        * gcc.target/arm/armv8_1m-shift-reg_1.c: New test.
 
        * testsuite/gcc.target/arm/multilib.exp: Add v8.1-M entries.
 
-2020-01-16  Mihail-Calin Ionescu <mihail.ionescu@arm.com>
-           Thomas Preud'homme <thomas.preudhomme@arm.com>
+2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
+           Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * gcc.target/arm/cmse/cmse-1.c: Add check for BLXNS when instructions
        introduced in Armv8.1-M Mainline Security Extensions are available and
        * lib/target-supports.exp (check_effective_target_arm_cmse_clear_ok):
        New procedure.
 
-2020-01-16  Mihail-Calin Ionescu <mihail.ionescu@arm.com>
-           Thomas Preud'homme <thomas.preudhomme@arm.com>
+2020-01-16  Mihail-Calin Ionescu  <mihail.ionescu@arm.com>
+           Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * 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 (file)
index 0000000..fe8b998
--- /dev/null
@@ -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" }
+}