]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improve error recovery for structured binding in condition.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 May 2018 17:32:54 +0000 (17:32 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 May 2018 17:32:54 +0000 (17:32 +0000)
* parser.c (cp_parser_check_condition_declarator): Handle
cp_error_declarator.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260968 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp1z/decomp16.C

index 37874c02fa4665dc24e98bde7072b15e0a39bab9..07fbafa3500b0e6fd3f5b3655655efeee84b5d7a 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-30  Jason Merrill  <jason@redhat.com>
+
+       * parser.c (cp_parser_check_condition_declarator): Handle
+       cp_error_declarator.
+
 2018-05-30  Jonathan Wakely  <jwakely@redhat.com>
 
        * typeck.c (cxx_sizeof_or_alignof_type): Return size_one_node instead
index d17beb8f93078194596f934b516631911e2cddd3..de090d42d8deddb05cccc2b31c704614dc0d40ce 100644 (file)
@@ -11594,10 +11594,13 @@ cp_parser_check_condition_declarator (cp_parser* parser,
                                      cp_declarator *declarator,
                                      location_t loc)
 {
-  if (function_declarator_p (declarator)
+  if (declarator == cp_error_declarator
+      || function_declarator_p (declarator)
       || declarator->kind == cdk_array)
     {
-      if (declarator->kind == cdk_array)
+      if (declarator == cp_error_declarator)
+       /* Already complained.  */;
+      else if (declarator->kind == cdk_array)
        error_at (loc, "condition declares an array");
       else
        error_at (loc, "condition declares a function");
index dad69b89c08fca0fe8c0ea02fb80e1c5a767df9e..7589c8015a518743288ede0d304f0e9a1b69c63a 100644 (file)
@@ -8,7 +8,7 @@ void
 foo ()
 {
   auto [ a, b ] = A ();
-  for (; auto [ a, b ] = A (); )                       // { dg-error "expected|no match" }
+  for (; auto [ a, b ] = A (); )                       // { dg-error "expected" }
     ;
   for (; false; auto [ a, b ] = A ())                  // { dg-error "expected" }
     ;