changeset 27764:f64e399b6dda

report missing semicolon location for array expressions (bug #57159) * parse.h, oct-parse.yy (base_parser::finish_matrix, base_parser::finish_cell, base_parser::finish_array): New args, open_delim and close_delim. Change all uses. (base_parser::finish_matrix, base_parser::finish_cell): Use close_delim location info for empty matrix/cell location info. (base_parser::finish_array): Use close_delim location info for array and constant location info.
author John W. Eaton <jwe@octave.org>
date Mon, 02 Dec 2019 10:25:57 -0600
parents 4e6249815ea6
children dd93e1fdc7db
files libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/parse.h
diffstat 2 files changed, 24 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy	Mon Dec 02 08:19:32 2019 -0800
+++ b/libinterp/parse-tree/oct-parse.yy	Mon Dec 02 10:25:57 2019 -0600
@@ -545,12 +545,7 @@
                 ;
 
 matrix          : '[' matrix_rows ']'
-                  {
-                    YYUSE ($1);
-                    YYUSE ($3);
-
-                    $$ = parser.finish_matrix ($2);
-                  }
+                  { $$ = parser.finish_matrix ($2, $1, $3); }
                 ;
 
 matrix_rows     : cell_or_matrix_row
@@ -572,12 +567,7 @@
                 ;
 
 cell            : '{' cell_rows '}'
-                  {
-                    YYUSE ($1);
-                    YYUSE ($3);
-
-                    $$ = parser.finish_cell ($2);
-                  }
+                  { $$ = parser.finish_cell ($2, $1, $3); }
                 ;
 
 cell_rows       : cell_or_matrix_row
@@ -4342,10 +4332,13 @@
   // Finish building an array_list.
 
   tree_expression *
-  base_parser::finish_array_list (tree_array_list *array_list)
+  base_parser::finish_array_list (tree_array_list *array_list,
+                                  token */*open_delim*/, token *close_delim)
   {
     tree_expression *retval = array_list;
 
+    array_list->set_location (close_delim->line (), close_delim->column ());
+
     if (array_list->all_elements_are_constant ())
       {
         interpreter& interp = __get_interpreter__ ("finish_array_list");
@@ -4375,8 +4368,8 @@
             if (msg.empty ())
               {
                 tree_constant *tc_retval
-                  = new tree_constant (tmp, array_list->line (),
-                                       array_list->column ());
+                  = new tree_constant (tmp, close_delim->line (),
+                                       close_delim->column ());
 
                 std::ostringstream buf;
 
@@ -4403,21 +4396,25 @@
   // Finish building a matrix list.
 
   tree_expression *
-  base_parser::finish_matrix (tree_matrix *m)
+  base_parser::finish_matrix (tree_matrix *m, token *open_delim,
+                              token *close_delim)
   {
     return (m
-            ? finish_array_list (m)
-            : new tree_constant (octave_null_matrix::instance));
+            ? finish_array_list (m, open_delim, close_delim)
+            : new tree_constant (octave_null_matrix::instance,
+                                 close_delim->line (), close_delim->column ()));
   }
 
   // Finish building a cell list.
 
   tree_expression *
-  base_parser::finish_cell (tree_cell *c)
+  base_parser::finish_cell (tree_cell *c, token *open_delim,
+                            token *close_delim)
   {
     return (c
-            ? finish_array_list (c)
-            : new tree_constant (octave_value (Cell ())));
+            ? finish_array_list (c, open_delim, close_delim)
+            : new tree_constant (octave_value (Cell ()),
+                                 close_delim->line (), close_delim->column ()));
   }
 
   tree_statement_list *
--- a/libinterp/parse-tree/parse.h	Mon Dec 02 08:19:32 2019 -0800
+++ b/libinterp/parse-tree/parse.h	Mon Dec 02 10:25:57 2019 -0600
@@ -418,13 +418,16 @@
 
     // Finish building an array_list (common action for finish_matrix
     // and finish_cell).
-    tree_expression * finish_array_list (tree_array_list *a);
+    tree_expression * finish_array_list (tree_array_list *a, token *open_delim,
+                                         token *close_delim);
 
     // Finish building a matrix list.
-    tree_expression * finish_matrix (tree_matrix *m);
+    tree_expression * finish_matrix (tree_matrix *m, token *open_delim,
+                                     token *close_delim);
 
     // Finish building a cell list.
-    tree_expression * finish_cell (tree_cell *c);
+    tree_expression * finish_cell (tree_cell *c, token *open_delim,
+                                   token *close_delim);
 
     // Set the print flag for a statement based on the separator type.
     tree_statement_list *