OSDN Git Service

* toplev.c (finalize): Add no_backend parameter. Don't finish
[pf3gnuchains/gcc-fork.git] / gcc / cp / lex.c
index 890640e..c583d7d 100644 (file)
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cp-tree.h"
 #include "cpplib.h"
 #include "flags.h"
-#include "c-pragma.h"
+#include "c-family/c-pragma.h"
 #include "toplev.h"
 #include "output.h"
 #include "tm_p.h"
@@ -81,6 +81,8 @@ struct impl_files
 
 static struct impl_files *impl_file_chain;
 
+/* True if we saw "#pragma GCC java_exceptions".  */
+bool pragma_java_exceptions;
 \f
 void
 cxx_finish (void)
@@ -172,19 +174,21 @@ init_reswords (void)
   tree id;
   int mask = 0;
 
-  mask |= D_CONLY;
   if (cxx_dialect != cxx0x)
     mask |= D_CXX0X;
   if (flag_no_asm)
     mask |= D_ASM | D_EXT;
   if (flag_no_gnu_keywords)
     mask |= D_EXT;
-  if (!c_dialect_objc())
-    mask |= D_OBJC;
 
-  ridpointers = GGC_CNEWVEC (tree, (int) RID_MAX);
+  /* The Objective-C keywords are all context-dependent.  */
+  mask |= D_OBJC;
+
+  ridpointers = ggc_alloc_cleared_vec_tree ((int) RID_MAX);
   for (i = 0; i < num_c_common_reswords; i++)
     {
+      if (c_common_reswords[i].disable & D_CONLY)
+       continue;
       id = get_identifier (c_common_reswords[i].word);
       C_SET_RID_CODE (id, c_common_reswords[i].rid);
       ridpointers [(int) c_common_reswords[i].rid] = id;
@@ -222,8 +226,9 @@ cxx_init (void)
    CTOR_INITIALIZER,   TRY_BLOCK,      HANDLER,
    EH_SPEC_BLOCK,      USING_STMT,     TAG_DEFN,
    IF_STMT,            CLEANUP_STMT,   FOR_STMT,
-   WHILE_STMT,         DO_STMT,        BREAK_STMT,
-   CONTINUE_STMT,      SWITCH_STMT,    EXPR_STMT
+   RANGE_FOR_STMT,     WHILE_STMT,     DO_STMT,
+   BREAK_STMT,         CONTINUE_STMT,  SWITCH_STMT,
+   EXPR_STMT
   };
 
   memset (&statement_code_p, 0, sizeof (statement_code_p));
@@ -246,17 +251,6 @@ cxx_init (void)
 
   cxx_init_decl_processing ();
 
-  /* The fact that G++ uses COMDAT for many entities (inline
-     functions, template instantiations, virtual tables, etc.) mean
-     that it is fundamentally unreliable to try to make decisions
-     about whether or not to output a particular entity until the end
-     of the compilation.  However, the inliner requires that functions
-     be provided to the back end if they are to be inlined.
-     Therefore, we always use unit-at-a-time mode; in that mode, we
-     can provide entities to the back end and it will decide what to
-     emit based on what is actually needed.  */
-  flag_unit_at_a_time = 1;
-
   if (c_common_init () == false)
     {
       input_location = saved_loc;
@@ -439,6 +433,7 @@ handle_pragma_java_exceptions (cpp_reader* dfile ATTRIBUTE_UNUSED)
     warning (0, "junk at end of #pragma GCC java_exceptions");
 
   choose_personality_routine (lang_java);
+  pragma_java_exceptions = true;
 }
 
 /* Issue an error message indicating that the lookup of NAME (an
@@ -454,13 +449,15 @@ unqualified_name_lookup_error (tree name)
     }
   else
     {
-      error ("%qD was not declared in this scope", name);
+      if (!objc_diagnose_private_ivar (name))
+        error ("%qD was not declared in this scope", name);
       /* Prevent repeated error messages by creating a VAR_DECL with
         this NAME in the innermost block scope.  */
       if (current_function_decl)
        {
          tree decl;
-         decl = build_decl (VAR_DECL, name, error_mark_node);
+         decl = build_decl (input_location,
+                            VAR_DECL, name, error_mark_node);
          DECL_CONTEXT (decl) = current_function_decl;
          push_local_binding (name, decl, 0);
          /* Mark the variable as used so that we do not get warnings
@@ -491,7 +488,7 @@ unqualified_fn_lookup_error (tree name)
         Note that we have the exact wording of the following message in
         the manual (trouble.texi, node "Name lookup"), so they need to
         be kept in synch.  */
-      permerror ("there are no arguments to %qD that depend on a template "
+      permerror (input_location, "there are no arguments to %qD that depend on a template "
                 "parameter, so a declaration of %qD must be available",
                 name, name);
 
@@ -500,7 +497,7 @@ unqualified_fn_lookup_error (tree name)
          static bool hint;
          if (!hint)
            {
-             inform ("(if you use %<-fpermissive%>, G++ will accept your "
+             inform (input_location, "(if you use %<-fpermissive%>, G++ will accept your "
                     "code, but allowing the use of an undeclared name is "
                     "deprecated)");
              hint = true;
@@ -512,19 +509,27 @@ unqualified_fn_lookup_error (tree name)
   return unqualified_name_lookup_error (name);
 }
 
+/* Wrapper around build_lang_decl_loc(). Should gradually move to
+   build_lang_decl_loc() and then rename build_lang_decl_loc() back to
+   build_lang_decl().  */
+
 tree
 build_lang_decl (enum tree_code code, tree name, tree type)
 {
+  return build_lang_decl_loc (input_location, code, name, type);
+}
+
+/* Build a decl from CODE, NAME, TYPE declared at LOC, and then add
+   DECL_LANG_SPECIFIC info to the result.  */
+
+tree
+build_lang_decl_loc (location_t loc, enum tree_code code, tree name, tree type)
+{
   tree t;
 
-  t = build_decl (code, name, type);
+  t = build_decl (loc, code, name, type);
   retrofit_lang_decl (t);
 
-  /* All nesting of C++ functions is lexical; there is never a "static
-     chain" in the sense of GNU C nested functions.  */
-  if (code == FUNCTION_DECL)
-    DECL_NO_STATIC_CHAIN (t) = 1;
-
   return t;
 }
 
@@ -536,19 +541,22 @@ retrofit_lang_decl (tree t)
 {
   struct lang_decl *ld;
   size_t size;
-
-  if (CAN_HAVE_FULL_LANG_DECL_P (t))
-    size = sizeof (struct lang_decl);
+  int sel;
+
+  if (TREE_CODE (t) == FUNCTION_DECL)
+    sel = 1, size = sizeof (struct lang_decl_fn);
+  else if (TREE_CODE (t) == NAMESPACE_DECL)
+    sel = 2, size = sizeof (struct lang_decl_ns);
+  else if (TREE_CODE (t) == PARM_DECL)
+    sel = 3, size = sizeof (struct lang_decl_parm);
+  else if (LANG_DECL_HAS_MIN (t))
+    sel = 0, size = sizeof (struct lang_decl_min);
   else
-    size = sizeof (struct lang_decl_flags);
+    gcc_unreachable ();
 
-  ld = GGC_CNEWVAR (struct lang_decl, size);
+  ld = ggc_alloc_cleared_lang_decl (size);
 
-  ld->decl_flags.can_be_full = CAN_HAVE_FULL_LANG_DECL_P (t) ? 1 : 0;
-  ld->decl_flags.u1sel = TREE_CODE (t) == NAMESPACE_DECL ? 1 : 0;
-  ld->decl_flags.u2sel = 0;
-  if (ld->decl_flags.can_be_full)
-    ld->u.f.u3sel = TREE_CODE (t) == FUNCTION_DECL ? 1 : 0;
+  ld->u.base.selector = sel;
 
   DECL_LANG_SPECIFIC (t) = ld;
   if (current_lang_name == lang_name_cplusplus
@@ -576,11 +584,18 @@ cxx_dup_lang_specific_decl (tree node)
   if (! DECL_LANG_SPECIFIC (node))
     return;
 
-  if (!CAN_HAVE_FULL_LANG_DECL_P (node))
-    size = sizeof (struct lang_decl_flags);
+  if (TREE_CODE (node) == FUNCTION_DECL)
+    size = sizeof (struct lang_decl_fn);
+  else if (TREE_CODE (node) == NAMESPACE_DECL)
+    size = sizeof (struct lang_decl_ns);
+  else if (TREE_CODE (node) == PARM_DECL)
+    size = sizeof (struct lang_decl_parm);
+  else if (LANG_DECL_HAS_MIN (node))
+    size = sizeof (struct lang_decl_min);
   else
-    size = sizeof (struct lang_decl);
-  ld = GGC_NEWVAR (struct lang_decl, size);
+    gcc_unreachable ();
+
+  ld = ggc_alloc_lang_decl (size);
   memcpy (ld, DECL_LANG_SPECIFIC (node), size);
   DECL_LANG_SPECIFIC (node) = ld;
 
@@ -617,7 +632,7 @@ copy_lang_type (tree node)
     size = sizeof (struct lang_type);
   else
     size = sizeof (struct lang_type_ptrmem);
-  lt = GGC_NEWVAR (struct lang_type, size);
+  lt = ggc_alloc_lang_type (size);
   memcpy (lt, TYPE_LANG_SPECIFIC (node), size);
   TYPE_LANG_SPECIFIC (node) = lt;
 
@@ -648,7 +663,8 @@ cxx_make_type (enum tree_code code)
   if (RECORD_OR_UNION_CODE_P (code)
       || code == BOUND_TEMPLATE_TEMPLATE_PARM)
     {
-      struct lang_type *pi = GGC_CNEW (struct lang_type);
+      struct lang_type *pi
+          = ggc_alloc_cleared_lang_type (sizeof (struct lang_type));
 
       TYPE_LANG_SPECIFIC (t) = pi;
       pi->u.c.h.is_lang_type_class = 1;