Sync libiberty sources with gcc mainline.
authorNick Clifton <nickc@redhat.com>
Mon, 17 Oct 2016 09:26:56 +0000 (10:26 +0100)
committerNick Clifton <nickc@redhat.com>
Mon, 17 Oct 2016 09:26:56 +0000 (10:26 +0100)
2016-09-19  Andrew Stubbs  <ams@codesourcery.com>

* pex-win32.c (argv_to_cmdline): Quote zero-length parameters.
* testsuite/test-pexecute.c (main): Insert check for zero-length parameters.

2016-09-10  Mark Wielaard  <mjw@redhat.com>

* cp-demangle.c (d_substitution): Change struct demangle_component
variable name from c to dc.

2016-08-12  Marek Polacek  <polacek@redhat.com>

PR c/7652
* cp-demangle.c (d_print_mod): Add FALLTHRU.

2016-08-04  Marcel B?hme  <boehme.marcel@gmail.com>

PR c++/71696
* cplus-dem.c: Prevent infinite recursion when there is a cycle
in the referencing of remembered mangled types.
(work_stuff): New stack to keep track of the remembered mangled
types that are currently being processed.
(push_processed_type): New method to push currently processed
remembered type onto the stack.
(pop_processed_type): New method to pop currently processed
remembered type from the stack.
(work_stuff_copy_to_from): Copy values of new variables.
(delete_non_B_K_work_stuff): Free stack memory.
(demangle_args): Push/Pop currently processed remembered type.
(do_type): Do not demangle a cyclic reference and push/pop
referenced remembered type.

libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/cplus-dem.c
libiberty/pex-win32.c
libiberty/testsuite/test-pexecute.c

index eb966741e967ca27987ad461297336af499acca0..0865428a0855e6d05d6c730fc24fe04947ffa47f 100644 (file)
@@ -1,3 +1,39 @@
+2016-10-17  Nick Clifton  <nickc@redhat.com>
+
+       * Sync with gcc.
+
+2016-09-19  Andrew Stubbs  <ams@codesourcery.com>
+
+       * pex-win32.c (argv_to_cmdline): Quote zero-length parameters.
+       * testsuite/test-pexecute.c (main): Insert check for zero-length parameters.
+
+2016-09-10  Mark Wielaard  <mjw@redhat.com>
+
+       * cp-demangle.c (d_substitution): Change struct demangle_component
+       variable name from c to dc.
+
+2016-08-12  Marek Polacek  <polacek@redhat.com>
+
+       PR c/7652
+       * cp-demangle.c (d_print_mod): Add FALLTHRU.
+
+2016-08-04  Marcel Böhme  <boehme.marcel@gmail.com>
+
+       PR c++/71696
+       * cplus-dem.c: Prevent infinite recursion when there is a cycle
+       in the referencing of remembered mangled types.
+       (work_stuff): New stack to keep track of the remembered mangled
+       types that are currently being processed.
+       (push_processed_type): New method to push currently processed
+       remembered type onto the stack.
+       (pop_processed_type): New method to pop currently processed
+       remembered type from the stack.
+       (work_stuff_copy_to_from): Copy values of new variables.
+       (delete_non_B_K_work_stuff): Free stack memory.
+       (demangle_args): Push/Pop currently processed remembered type.
+       (do_type): Do not demangle a cyclic reference and push/pop
+       referenced remembered type.
+
 2016-07-29  Aldy Hernandez  <aldyh@redhat.com>
 
        * make-relative-prefix.c (make_relative_prefix_1): Fall back to
@@ -16,7 +52,7 @@
        (d_template_args_1): Split out from d_template_args.
        (d_args_length): New.
 
-2016-07-13  Marcel BÃ\83hme  <boehme.marcel@gmail.com>
+2016-07-13  Marcel BÃhme  <boehme.marcel@gmail.com>
 
        PR c++/70926
        * cplus-dem.c: Handle large values and overflow when demangling
 
        PR other/61321
        PR other/61233
-       * demangle.h (enum demangle_component_type)
-       <DEMANGLE_COMPONENT_CONVERSION>: New value.
        * cp-demangle.c (d_demangle_callback, d_make_comp): Handle
        DEMANGLE_COMPONENT_CONVERSION.
        (is_ctor_dtor_or_conversion): Handle DEMANGLE_COMPONENT_CONVERSION
 2013-05-31  Matt Burgess <matthew@linuxfromscratch.org>
 
        PR other/56780
-       * libiberty/configure.ac: Move test for --enable-install-libiberty
+       * configure.ac: Move test for --enable-install-libiberty
        outside of the 'with_target_subdir' test so that it actually gets
        run.  Add output messages to show the test result.
-       * libiberty/configure: Regenerate.
-       * libiberty/Makefile.in (install_to_libdir): Place the
+       * configure: Regenerate.
+       * Makefile.in (install_to_libdir): Place the
        installation of the libiberty library in the same guard as that
        used for the headers to prevent it being installed unless
        requested via --enable-install-libiberty.
        Daniel Jacobowitz  <dan@codesourcery.com>
        Pedro Alves  <pedro@codesourcery.com>
 
-       libiberty/
        * argv.c (consume_whitespace): New function.
        (only_whitespace): New function.
        (buildargv): Always use ISSPACE by calling consume_whitespace.
 
 2009-04-07  Arnaud Patard <apatard@mandriva.com>
 
-       * libiberty/configure.ac: Fix Linux/MIPS matching rule.
-       * libiberty/configure: Regenerate.
+       * configure.ac: Fix Linux/MIPS matching rule.
+       * configure: Regenerate.
 
 2009-03-27  Ian Lance Taylor  <iant@google.com>
 
 
 2008-04-21  Aurelien Jarno  <aurelien@aurel32.net>
 
-       * libiberty/configure.ac: use -fPIC on Linux/MIPS hosts.
-       * libiberty/configure: Regenerate.
+       * configure.ac: use -fPIC on Linux/MIPS hosts.
+       * configure: Regenerate.
 
 2008-04-18  Kris Van Hees <kris.van.hees@oracle.com>
 
        that are locale-independent.
        * Makefile.in (filename_cmp.o): Add dependency on safe-ctype.h.
 
-2007-04-11  Thomas Neumann  tneumann@users.sourceforge.net
+2007-04-11  Thomas Neumann  <tneumann@users.sourceforge.net>
 
        * argv.c: Use ANSI C declarations.
        * make-relative-prefix.c: Likewise.
 
 2003-12-15  Brendan Kehoe  <brendan@zen.org>
 
-       * libiberty/Makefile.in (floatformat.o): Add dependency on
+       * Makefile.in (floatformat.o): Add dependency on
        config.h to accompany change of 2003-12-03.
 
 2003-12-15  Ian Lance Taylor  <ian@wasabisystems.com>
 
 2002-10-06  Andreas Jaeger  <aj@suse.de>
 
-       * libiberty/cplus-dem.c (ada_demangle): Get rid of unneeded
+       * cplus-dem.c (ada_demangle): Get rid of unneeded
        variable and of strict-aliasing warning.
        (grow_vect): Use char as first parameter.
 
 
 2002-01-31  Adam Megacz  <adam@xwt.org>
 
-       * gcc/libiberty/configure.in: Treat mingw the same as cywin
+       * configure.in: Treat mingw the same as cywin
        wrt HAVE_SYS_ERRLIST.
 
 2002-01-30  Phil Edwards  <pme@gcc.gnu.org>
@@ -5159,8 +5192,8 @@ Tue Aug 21 12:35:04 2001  Christopher Faylor <cgf@cygnus.com>
 2001-03-10  Neil Booth  <neil@daikokuya.demon.co.uk>
            John David Anglin  <dave@hiauly1.hia.nrc.ca>
 
-       * libiberty/lbasename.c: New file.
-       * libiberty/Makefile.in: Update for lbasename.
+       * lbasename.c: New file.
+       * Makefile.in: Update for lbasename.
 
 2001-03-06  Zack Weinberg  <zackw@stanford.edu>
 
@@ -5533,13 +5566,13 @@ Tue Aug 21 12:35:04 2001  Christopher Faylor <cgf@cygnus.com>
 
 2000-08-24  Greg McGary  <greg@mcgary.org>
 
-       * libiberty/random.c (end_ptr): Revert previous change.
+       * random.c (end_ptr): Revert previous change.
 
 2000-08-24  Greg McGary  <greg@mcgary.org>
 
-       * libiberty/cplus-dem.c (cplus_demangle_opname, cplus_mangle_opname,
+       * cplus-dem.c (cplus_demangle_opname, cplus_mangle_opname,
        demangle_expression, demangle_function_name): Use ARRAY_SIZE.
-       * libiberty/random.c (end_ptr): Likewise.
+       * random.c (end_ptr): Likewise.
 
 2000-08-23  Alex Samuel  <samuel@codesourcery.com>
 
index 0c6d71436e3f16b252278230f8732f05b139f2d2..a843dc38f98c42ea0e6fd7a27d307d37dad27035 100644 (file)
@@ -3769,7 +3769,7 @@ d_substitution (struct d_info *di, int prefix)
            {
              const char *s;
              int len;
-             struct demangle_component *c;
+             struct demangle_component *dc;
 
              if (p->set_last_name != NULL)
                di->last_name = d_make_sub (di, p->set_last_name,
@@ -3785,15 +3785,15 @@ d_substitution (struct d_info *di, int prefix)
                  len = p->simple_len;
                }
              di->expansion += len;
-             c = d_make_sub (di, s, len);
+             dc = d_make_sub (di, s, len);
              if (d_peek_char (di) == 'B')
                {
                  /* If there are ABI tags on the abbreviation, it becomes
                     a substitution candidate.  */
-                 c = d_abi_tags (di, c);
-                 d_add_substitution (di, c);
+                 dc = d_abi_tags (di, dc);
+                 d_add_substitution (di, dc);
                }
-             return c;
+             return dc;
            }
        }
 
@@ -5777,11 +5777,13 @@ d_print_mod (struct d_print_info *dpi, int options,
     case DEMANGLE_COMPONENT_REFERENCE_THIS:
       /* For the ref-qualifier, put a space before the &.  */
       d_append_char (dpi, ' ');
+      /* FALLTHRU */
     case DEMANGLE_COMPONENT_REFERENCE:
       d_append_char (dpi, '&');
       return;
     case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS:
       d_append_char (dpi, ' ');
+      /* FALLTHRU */
     case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
       d_append_string (dpi, "&&");
       return;
index 3ee2df1c56ad4413fde2c68c68700da5b7dd2329..f95405062c9eec334f30df3efb1faaba0be90e5c 100644 (file)
@@ -144,6 +144,9 @@ struct work_stuff
   string* previous_argument; /* The last function argument demangled.  */
   int nrepeats;         /* The number of times to repeat the previous
                           argument.  */
+  int *proctypevec;     /* Indices of currently processed remembered typevecs.  */
+  int proctypevec_size;
+  int nproctypes;
 };
 
 #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
@@ -436,6 +439,10 @@ iterate_demangle_function (struct work_stuff *,
 
 static void remember_type (struct work_stuff *, const char *, int);
 
+static void push_processed_type (struct work_stuff *, int);
+
+static void pop_processed_type (struct work_stuff *);
+
 static void remember_Btype (struct work_stuff *, const char *, int, int);
 
 static int register_Btype (struct work_stuff *);
@@ -1302,6 +1309,10 @@ work_stuff_copy_to_from (struct work_stuff *to, struct work_stuff *from)
       memcpy (to->btypevec[i], from->btypevec[i], len);
     }
 
+  if (from->proctypevec)
+    to->proctypevec =
+      XDUPVEC (int, from->proctypevec, from->proctypevec_size);
+
   if (from->ntmpl_args)
     to->tmpl_argvec = XNEWVEC (char *, from->ntmpl_args);
 
@@ -1330,11 +1341,17 @@ delete_non_B_K_work_stuff (struct work_stuff *work)
   /* Discard the remembered types, if any.  */
 
   forget_types (work);
-  if (work -> typevec != NULL)
+  if (work->typevec != NULL)
     {
-      free ((char *) work -> typevec);
-      work -> typevec = NULL;
-      work -> typevec_size = 0;
+      free ((char *) work->typevec);
+      work->typevec = NULL;
+      work->typevec_size = 0;
+    }
+  if (work->proctypevec != NULL)
+    {
+      free (work->proctypevec);
+      work->proctypevec = NULL;
+      work->proctypevec_size = 0;
     }
   if (work->tmpl_argvec)
     {
@@ -3555,6 +3572,8 @@ static int
 do_type (struct work_stuff *work, const char **mangled, string *result)
 {
   int n;
+  int i;
+  int is_proctypevec;
   int done;
   int success;
   string decl;
@@ -3567,6 +3586,7 @@ do_type (struct work_stuff *work, const char **mangled, string *result)
 
   done = 0;
   success = 1;
+  is_proctypevec = 0;
   while (success && !done)
     {
       int member;
@@ -3627,8 +3647,15 @@ do_type (struct work_stuff *work, const char **mangled, string *result)
              success = 0;
            }
          else
-           {
-             remembered_type = work -> typevec[n];
+           for (i = 0; i < work->nproctypes; i++)
+             if (work -> proctypevec [i] == n)
+               success = 0;
+
+         if (success)
+           {    
+             is_proctypevec = 1;
+             push_processed_type (work, n);
+             remembered_type = work->typevec[n];
              mangled = &remembered_type;
            }
          break;
@@ -3850,6 +3877,9 @@ do_type (struct work_stuff *work, const char **mangled, string *result)
     string_delete (result);
   string_delete (&decl);
 
+  if (is_proctypevec)
+    pop_processed_type (work); 
+
   if (success)
     /* Assume an integral type, if we're not sure.  */
     return (int) ((tk == tk_none) ? tk_integral : tk);
@@ -4262,6 +4292,41 @@ do_arg (struct work_stuff *work, const char **mangled, string *result)
   return 1;
 }
 
+static void
+push_processed_type (struct work_stuff *work, int typevec_index)
+{
+  if (work->nproctypes >= work->proctypevec_size)
+    {
+      if (!work->proctypevec_size)
+       {
+         work->proctypevec_size = 4;
+         work->proctypevec = XNEWVEC (int, work->proctypevec_size);
+       }
+      else 
+       {
+         if (work->proctypevec_size < 16)
+           /* Double when small.  */
+           work->proctypevec_size *= 2;
+         else
+           {
+             /* Grow slower when large.  */
+             if (work->proctypevec_size > (INT_MAX / 3) * 2)
+                xmalloc_failed (INT_MAX);
+              work->proctypevec_size = (work->proctypevec_size * 3 / 2);
+           }   
+          work->proctypevec
+            = XRESIZEVEC (int, work->proctypevec, work->proctypevec_size);
+       }
+    }
+    work->proctypevec [work->nproctypes++] = typevec_index;
+}
+
+static void
+pop_processed_type (struct work_stuff *work)
+{
+  work->nproctypes--;
+}
+
 static void
 remember_type (struct work_stuff *work, const char *start, int len)
 {
@@ -4526,10 +4591,13 @@ demangle_args (struct work_stuff *work, const char **mangled,
                {
                  string_append (declp, ", ");
                }
+             push_processed_type (work, t);  
              if (!do_arg (work, &tem, &arg))
                {
+                 pop_processed_type (work);
                  return (0);
                }
+             pop_processed_type (work);
              if (PRINT_ARG_TYPES)
                {
                  string_appends (declp, &arg);
index 66d2f1157c730ae99e62a2e2b4be20437c43af52..4c15b0d11a0e0b89ec3e188b57020b55aebed8dc 100644 (file)
@@ -370,6 +370,8 @@ argv_to_cmdline (char *const *argv)
              cmdline_len++;
            }
        }
+      if (j == 0)
+       needs_quotes = 1;
       /* Trailing backslashes also need to be escaped because they will be
          followed by the terminating quote.  */
       if (needs_quotes)
@@ -394,6 +396,8 @@ argv_to_cmdline (char *const *argv)
               break;
             }
         }
+      if (j == 0)
+       needs_quotes = 1;
 
       if (needs_quotes)
         {
index 8e01fda479a8936eea9cb756a1a3d637ded836ed..f62239d49b8d40dfcadb37400da929afa3c96cad 100644 (file)
@@ -285,6 +285,20 @@ main (int argc, char **argv)
     ERROR ("echo exit status failed");
   pex_free (pex1);
 
+  /* Check empty parameters don't get lost.  */
+  pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp");
+  subargv[1] = "echo";
+  subargv[2] = "foo";
+  subargv[3] = "";
+  subargv[4] = "bar";
+  subargv[5] = NULL;
+  TEST_PEX_RUN (pex1, 0, "./test-pexecute", subargv, NULL, NULL);
+  e = TEST_PEX_READ_OUTPUT (pex1);
+  CHECK_LINE (e, "foo  bar");  /* Two spaces!  */
+  if (TEST_PEX_GET_STATUS_1 (pex1) != 0)
+    ERROR ("echo exit status failed");
+  pex_free (pex1);
+
   pex1 = TEST_PEX_INIT (PEX_USE_PIPES, "temp");
   subargv[1] = "echo";
   subargv[2] = "bar";
This page took 0.036922 seconds and 4 git commands to generate.