OSDN Git Service

PR c++/10968
[pf3gnuchains/gcc-fork.git] / gcc / toplev.c
index 6a6e076..85157e7 100644 (file)
@@ -76,6 +76,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cfgloop.h"
 #include "hosthooks.h"
 #include "cgraph.h"
+#include "opts.h"
 
 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
 #include "dwarf2out.h"
@@ -759,6 +760,17 @@ int flag_delayed_branch;
 
 int flag_pic;
 
+/* Nonzero if we are compiling position independent code for executable.
+   The value is 1 if we are doing "small" pic; value is 2 if we're doing
+   "large" pic.  */
+
+int flag_pie;
+
+/* Nonzero if we are compiling code for a shared library, zero for
+   executable.  */
+
+int flag_shlib;
+
 /* Set to the default thread-local storage (tls) model to use.  */
 
 enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
@@ -1156,6 +1168,9 @@ static const lang_independent_options f_options[] =
   {"pic", &flag_pic, 1,
    N_("Generate position independent code, if possible") },
   {"PIC", &flag_pic, 2, ""},
+  {"pie", &flag_pie, 1,
+   N_("Generate position independent code for executables, if possible") },
+  {"PIE", &flag_pie, 2, ""},
   {"exceptions", &flag_exceptions, 1,
    N_("Enable exception handling") },
   {"unwind-tables", &flag_unwind_tables, 1,
@@ -1443,7 +1458,7 @@ documented_lang_options[] =
 
 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
 
-#include "options.h"
+#include "options_.h"
 
 };
 
@@ -2156,14 +2171,11 @@ push_srcloc (const char *file, int line)
 {
   struct file_stack *fs;
 
-  if (input_file_stack)
-    input_file_stack->location = input_location;
-
   fs = (struct file_stack *) xmalloc (sizeof (struct file_stack));
-  input_filename = file;
-  input_line = line;
   fs->location = input_location;
   fs->next = input_file_stack;
+  input_filename = file;
+  input_line = line;
   input_file_stack = fs;
   input_file_stack_tick++;
 }
@@ -2178,17 +2190,10 @@ pop_srcloc (void)
   struct file_stack *fs;
 
   fs = input_file_stack;
+  input_location = fs->location;
   input_file_stack = fs->next;
   free (fs);
   input_file_stack_tick++;
-
-  if (input_file_stack)
-    input_location = input_file_stack->location;
-  else
-    {
-      input_filename = NULL;
-      input_line = 0;
-    }
 }
 
 /* Compile an entire translation unit.  Write a file of assembly
@@ -2256,9 +2261,7 @@ compile_file (void)
       timevar_pop (TV_DUMP);
     }
 
-#ifdef ASM_FILE_END
-  ASM_FILE_END (asm_out_file);
-#endif
+  targetm.asm_out.file_end ();
 
   /* Attach a special .ident directive to the end of the file to identify
      the version of GCC which compiled this code.  The format of the .ident
@@ -2391,7 +2394,7 @@ rest_of_type_compilation (
                          int toplev
 #else
                          tree type ATTRIBUTE_UNUSED,
-                         int toplev ATTRIBUTE_UNUSED,
+                         int toplev ATTRIBUTE_UNUSED
 #endif
                          )
 {
@@ -3468,6 +3471,9 @@ rest_of_compilation (tree decl)
 
   timevar_push (TV_REST_OF_COMPILATION);
 
+  /* Register rtl specific functions for cfg.  */
+  rtl_register_cfg_hooks ();
+  
   /* Now that we're out of the frontend, we shouldn't have any more
      CONCATs anywhere.  */
   generating_concat_p = 0;
@@ -3564,7 +3570,7 @@ rest_of_compilation (tree decl)
 
   timevar_pop (TV_JUMP);
 
-  scope_to_insns_initialize ();
+  insn_locators_initialize ();
   /* Complete generation of exception handling code.  */
   if (doing_eh (0))
     {
@@ -5127,7 +5133,7 @@ general_init (char *argv0)
 static void
 parse_options_and_default_flags (int argc, char **argv)
 {
-  int i;
+  int i, lang_mask;
 
   /* Save in case md file wants to emit args as a comment.  */
   save_argc = argc;
@@ -5143,7 +5149,7 @@ parse_options_and_default_flags (int argc, char **argv)
   init_ggc_heuristics();
 
   /* Perform language-specific options initialization.  */
-  (*lang_hooks.init_options) ();
+  lang_mask = (*lang_hooks.init_options) ();
 
   /* Scan to see what optimization level has been specified.  That will
      determine the default value of many flags.  */
@@ -5280,7 +5286,7 @@ parse_options_and_default_flags (int argc, char **argv)
       int indep_processed;
 
       /* Give the language a chance to decode the option for itself.  */
-      lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
+      lang_processed = handle_option (argc - i, argv + i, lang_mask);
 
       if (lang_processed >= 0)
        /* Now see if the option also has a language independent meaning.
@@ -5338,6 +5344,11 @@ parse_options_and_default_flags (int argc, char **argv)
        }
     }
 
+  if (flag_pie)
+    flag_pic = flag_pie;
+  if (flag_pic && !flag_pie)
+    flag_shlib = 1;
+
   if (flag_no_inline == 2)
     flag_no_inline = 0;
   else
@@ -5632,9 +5643,6 @@ lang_dependent_init (const char *name)
   init_expr_once ();
   expand_dummy_function_end ();
 
-  /* Put an entry on the input file stack for the main input file.  */
-  push_srcloc (input_filename, 0);
-
   /* If dbx symbol table desired, initialize writing it and output the
      predefined types.  */
   timevar_push (TV_SYMOUT);