shebs       02/08/28 18:34:27

  Modified:    gcc      toplev.c
               gcc/pfe  pfe-mem.c
  Added:       gcc/testsuite/gcc.dg/pfe header.c pfe.exp prog.c
  Log:
  Rearrange toplev.c so PFE works again, catch an edge case in pfe-mem.c,
  and add the first bit of a PFE testsuite.
  
  Revision  Changes    Path
  1.151     +63 -58    gcc3/gcc/toplev.c
  
  Index: toplev.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/toplev.c,v
  retrieving revision 1.150
  retrieving revision 1.151
  diff -u -r1.150 -r1.151
  --- toplev.c  2002/08/26 05:39:48     1.150
  +++ toplev.c  2002/08/29 01:34:25     1.151
  @@ -160,7 +160,8 @@
   
   const char *main_input_filename;
   
  -/* APPLE LOCAL begin fat builds (radar 2865464)  ilr */
  +/* APPLE LOCAL fat builds */
  +/* for radar 2865464  ilr */
   static int arch_specified = 0;
   /* APPLE LOCAL end fat builds */
   
  @@ -4797,10 +4798,12 @@
         }
   #endif
   
  -  /* APPLE LOCAL fat builds (radar 2865464)  ilr */
  -  /* Note, the driver guarantees that -arch will precede the -m options
  -     so that arch_specified will be known by the time we get here.  */
  +  /* APPLE LOCAL begin fat builds */
  +  /* Note, the driver guarantees that -arch will precede the -m
  +     options so that arch_specified will be known by the time we get
  +     here.  For Radar 2865464.  */
     if (!valid_target_option && !arch_specified)
  +    /* APPLE LOCAL end fat builds */
       error ("invalid option `%s'", name);
   }
   
  @@ -5053,7 +5056,7 @@
        can give warnings and errors.  */
     diagnostic_initialize (global_dc);
   
  -  /* APPLE LOCAL setrlimit */
  +  /* APPLE LOCAL begin setrlimit */
   #ifdef RLIMIT_STACK
     /* Get rid of any avoidable limit on stack size.  */
     {
  @@ -5067,12 +5070,13 @@
       setrlimit (RLIMIT_STACK, &rlim);
     }
   #endif /* RLIMIT_STACK defined */
  +  /* APPLE LOCAL end setrlimit */
   
  -  /* Initialize the garbage-collector, string pools and tree type hash
  -     table.  */
  -  init_ggc ();
  -  init_stringpool ();
  -  init_ttree ();
  +  /* APPLE LOCAL begin PFE */
  +  /* Move init_ggc etc down to the beginning of
  +     parse_options_and_default_flags, so we get argc/argv visibility
  +     and can get PFE options that will guide allocation strategy.  */
  +  /* APPLE LOCAL end PFE */
   }
   
   /* Parse command line options and set default flag values, called
  @@ -5090,35 +5094,18 @@
     /* APPLE LOCAL begin PFE */
     int flag_pfe_validate = 0;
     char *arch = (char *) "unkn";
  -  /* APPLE LOCAL end PFE */
     
  -  /* Save in case md file wants to emit args as a comment.  */
  -  save_argc = argc;
  -  save_argv = argv;
  -
  -  /* Initialize register usage now so switches may override.  */
  -  init_reg_sets ();
  -
  -  /* Register the language-independent parameters.  */
  -  add_params (lang_independent_params, LAST_PARAM);
  -
  -  /* APPLE LOCAL begin PFE */
     /* Assume PFE file is not being used and delay language
        initialization until we do know since it may need to
        do PFE memory allocations.  */
     pfe_init (PFE_NOP);
  -  /* APPLE LOCAL end PFE */
   
  -  /* Scan to see what optimization level has been specified.  That will
  -     determine the default value of many flags.  */
  +  /* We need to know whether we're doing -fload or -fdump BEFORE we
  +     allocate any memory.  */
     for (i = 1; i < argc; i++)
       {
  -      /* APPLE LOCAL begin PFE */
  -      /* We also need to know whether we're doing -fload or -fdump BEFORE we
  -      allocate any memory.  This scan for -Oxx serves as a convenient
  -      place to check for that too.  */
         if (errorcount == 0)
  -        {
  +     {
          if (strncmp (argv[i], "-fload=", 7) == 0)
            {
              if (PFE_LOADING)
  @@ -5137,22 +5124,39 @@
              else
                pfe_open_pfe_file (&argv[i][7], arch, 1);
            }
  -       else if (strcmp (argv[i], "-farch=ppc") == 0)
  -         arch = (char *) "ppc";
  -       else if (strcmp (argv[i], "-farch=i386") == 0)
  -         arch = (char *) "i386";
  -       else if (strcmp (argv[i], "-fvalidate") == 0)
  -         flag_pfe_validate = 1;
  -       else if (strcmp (argv[i], "-fno-validate") == 0)
  -         flag_pfe_validate = 0;
        }
  -      
  -      if (strcmp (argv[i], "-ftime-report") == 0)
  -        time_report = 1;
  -      else if (strcmp (argv[i], "-quiet") == 0)
  -        quiet_flag = 1;
  -      else
  -     /* APPLE LOCAL end PFE */
  +     if (strcmp (argv[i], "-farch=ppc") == 0)
  +       arch = (char *) "ppc";
  +     else if (strcmp (argv[i], "-farch=i386") == 0)
  +       arch = (char *) "i386";
  +     else if (strcmp (argv[i], "-fvalidate") == 0)
  +       flag_pfe_validate = 1;
  +     else if (strcmp (argv[i], "-fno-validate") == 0)
  +       flag_pfe_validate = 0;
  +     /* The following two seem to be necessary for obscure reasons.  */
  +     if (strcmp (argv[i], "-ftime-report") == 0)
  +       time_report = 1;
  +     else if (strcmp (argv[i], "-quiet") == 0)
  +       quiet_flag = 1;
  +    }
  +  /* Note that from here down to init_ggc we need to be
  +     careful not to try any GCable allocation.  */
  +  /* APPLE LOCAL end PFE */
  +
  +  /* Save in case md file wants to emit args as a comment.  */
  +  save_argc = argc;
  +  save_argv = argv;
  +
  +  /* Initialize register usage now so switches may override.  */
  +  init_reg_sets ();
  +
  +  /* Register the language-independent parameters.  */
  +  add_params (lang_independent_params, LAST_PARAM);
  +
  +  /* Scan to see what optimization level has been specified.  That will
  +     determine the default value of many flags.  */
  +  for (i = 1; i < argc; i++)
  +    {
         if (!strcmp (argv[i], "-O"))
        {
          optimize = 1;
  @@ -5217,6 +5221,12 @@
         pfe_load_compiler_state (pfe_file);
       }
     
  +  /* Now we can initialize the garbage-collector, string pools and
  +     tree type hash table.  */
  +  init_ggc ();               /* pfe */
  +  init_stringpool ();        /* pfe */
  +  init_ttree ();     /* pfe */
  +
     /* Perform language-specific options initialization.  */
     (*lang_hooks.init_options) ();
     /* APPLE LOCAL end PFE */
  @@ -5420,19 +5430,6 @@
   
     if (flag_really_no_inline == 2)
       flag_really_no_inline = flag_no_inline;
  -
  -  /* APPLE LOCAL begin PFE */
  -  { 
  -    int rslt = (*lang_hooks.post_options) ();
  -    /* All the command line options are processed.  For a pfe load we
  -       already validated the load file with the exception of the
  -       language.  That needs to be delayed until now when we know it
  -       and it's in the reader.  */
  -    if (PFE_LOADING)
  -      pfe_check_compiler ();
  -    return rslt;
  -  }
  -  /* APPLE LOCAL end PFE */
   }
   
   /* Process the options that have been parsed.  */
  @@ -5804,6 +5801,14 @@
     /* All command line options have been parsed; allow the front end to
        perform consistency checks, etc.  */
     bool no_backend = (*lang_hooks.post_options) ();
  +
  +  /* APPLE LOCAL begin PFE */
  +  /* For a pfe load we already validated the load file with the
  +     exception of the language.  That needs to be delayed until now
  +     when we know it and it's in the reader.  */
  +  if (PFE_LOADING)
  +    pfe_check_compiler ();
  +  /* APPLE LOCAL end PFE */
   
     /* The bulk of command line switch processing.  */
     process_options ();
  
  
  
  1.12      +2 -1      gcc3/gcc/pfe/pfe-mem.c
  
  Index: pfe-mem.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/pfe/pfe-mem.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- pfe-mem.c 2002/08/17 06:29:16     1.11
  +++ pfe-mem.c 2002/08/29 01:34:26     1.12
  @@ -1130,7 +1130,8 @@
     
     /* If we get here, the object to be freed should be a fragment in 
        the last block.  */
  -  if (((unsigned long) ptr < (unsigned long) last_block_info->addr)
  +  if (last_block_info == NULL
  +      || ((unsigned long) ptr < (unsigned long) last_block_info->addr)
         || ((unsigned long)ptr >= ((unsigned long) last_block_info->addr
                                 + last_block_info->size)))
       {
  
  
  
  1.1                  gcc3/gcc/testsuite/gcc.dg/pfe/header.c
  
  Index: header.c
  ===================================================================
  /* APPLE LOCAL file PFE */
  /* PFE test, header file.  */
  
  /* This is a .c file because -x c specified here won't show up in the
     right place.  */
  
  /* { dg-do compile } */
  /* { dg-options "--dump-pch pfe-saves" } */
  
  #define macro1(x) ((x)+1)
  
  typedef int bar;
  
  
  
  1.1                  gcc3/gcc/testsuite/gcc.dg/pfe/pfe.exp
  
  Index: pfe.exp
  ===================================================================
  #   Copyright (C) 2002 Free Software Foundation, Inc.
  
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation; either version 2 of the License, or
  # (at your option) any later version.
  # 
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  # 
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
  
  # GCC testsuite that uses the `dg.exp' driver.
  
  # Load support procs.
  load_lib gcc-dg.exp
  
  # If a testcase doesn't have special options, use these.
  global DEFAULT_CFLAGS
  if ![info exists DEFAULT_CFLAGS] then {
      set DEFAULT_CFLAGS " -ansi -pedantic-errors"
  }
  
  # Initialize `dg'.
  dg-init
  
  # Main loop.
  dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[c\]]] \
        "" $DEFAULT_CFLAGS
  
  # All done.
  dg-finish
  
  
  
  1.1                  gcc3/gcc/testsuite/gcc.dg/pfe/prog.c
  
  Index: prog.c
  ===================================================================
  /* APPLE LOCAL file PFE */
  /* PFE test, main program.  */
  
  /* { dg-do run } */
  /* { dg-options "--load-pch pfe-saves" } */
  
  bar x;
  
  main ()
  {
    if (macro1 (1) != 2)
      abort ();
  
    return 0;
  }
  
  
  


Reply via email to