This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Fix PR 50690


On Thu, Dec 08, 2011 at 09:36:13PM +0100, Thomas Koenig wrote:
> >Both of these arrays should be really vec.h vectors, it doesn't
> >make any sense to handcode the same thing everywhere.
> >You can then start with NULL vectors and push something using VEC_safe_push
> >only when needed and let it handle reallocation etc.
>
> I tried that originally, but could not get it to work; getting the
> macros right just didn't happen.

Untested:

#include "vec.h"
...
/* static int omp_level;
   static int omp_size;
   static gfc_code **omp_block; */
typedef gfc_code *gfc_codep;
DEF_VEC_P(gfc_codep);
DEF_VEC_ALLOC_P(gfc_codep,heap);
static VEC(gfc_codep, heap) *omp_block;
...
    /* omp_size = 20;
       omp_block = XCNEWVEC(gfc_code *, omp_size); - Just remove these, VEC_free clears omp_block.  */
...
    /* XDELETEVEC (omp_block); */
    VEC_free (gfc_codep, heap, omp_block);
...
  /* if (omp_level > 0)
       {
	 gfc_exec_op op;
	 op = omp_block[omp_level - 1]->op; */
  if (!VEC_empty (gfc_codep, omp_block))
    {
      gfc_exec_op op;
      op = VEC_last (gfc_codep, omp_block)->op;
...
  /* omp_level = 0; */
  VEC_truncate (gfc_codep, omp_block, 0);
...
   /* if (omp_level >= omp_size)
	{
	  omp_size += omp_size;
	  omp_block = XRESIZEVEC(gfc_code *, omp_block, omp_size);
	}

      omp_block[omp_level] = co;
      omp_level ++; */
    VEC_safe_push (gfc_codep, heap, omp_block, op);
...
  /* if (in_omp)
      omp_level --; */
  if (in_omp)
    VEC_pop (gfc_codep, omp_block);

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]