Daily bump.
[gcc.git] / libcc1 / libcp1plugin.cc
index bbe32e38bdcc985f454b7694b3985d63da8317b8..00449f43b52d4b81a89c4bb42e596b646180382e 100644 (file)
@@ -1,5 +1,5 @@
 /* Library interface to C++ front end.
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
 
    This file is part of GCC.  As it interacts with GDB through libcc1,
    they all become a single program as regards the GNU GPL's requirements.
@@ -178,15 +178,15 @@ struct plugin_context : public cc1_plugin::connection
     return t;
   }
 
-  source_location get_source_location (const char *filename,
-                                      unsigned int line_number)
+  location_t get_location_t (const char *filename,
+                            unsigned int line_number)
   {
     if (filename == NULL)
       return UNKNOWN_LOCATION;
 
     filename = intern_filename (filename);
     linemap_add (line_table, LC_ENTER, false, filename, line_number);
-    source_location loc = linemap_line_start (line_table, line_number, 0);
+    location_t loc = linemap_line_start (line_table, line_number, 0);
     linemap_add (line_table, LC_LEAVE, false, NULL, 0);
     return loc;
   }
@@ -422,12 +422,6 @@ supplement_binding (cxx_binding *binding, tree decl)
       region to refer only to the namespace to which it already
       refers.  */
     ok = false;
-  else if (maybe_remove_implicit_alias (bval))
-    {
-      /* There was a mangling compatibility alias using this mangled name,
-        but now we have a real decl that wants to use it instead.  */
-      binding->value = decl;
-    }
   else
     {
       // _1: diagnose_name_conflict (decl, bval);
@@ -636,7 +630,8 @@ plugin_pragma_push_user_expression (cpp_reader *)
         usable.  */
       tree this_val = lookup_name (get_identifier ("this"));
       current_class_ref = !this_val ? NULL_TREE
-       : cp_build_indirect_ref (this_val, RO_NULL, tf_warning_or_error);
+       : cp_build_indirect_ref (input_location, this_val, RO_NULL,
+                                tf_warning_or_error);
       current_class_ptr = this_val;
     }
 }
@@ -947,7 +942,7 @@ plugin_add_using_namespace (cc1_plugin::connection *,
 
   gcc_assert (TREE_CODE (used_ns) == NAMESPACE_DECL);
 
-  finish_namespace_using_directive (used_ns, NULL_TREE);
+  finish_using_directive (used_ns, NULL_TREE);
 
   return 1;
 }
@@ -1025,7 +1020,7 @@ plugin_add_using_decl (cc1_plugin::connection *,
     {
       /* We can't be at local scope.  */
       gcc_assert (at_namespace_scope_p ());
-      finish_namespace_using_decl (target, tcontext, identifier);
+      finish_nonmember_using_decl (tcontext, identifier);
     }
 
   return 1;
@@ -1034,7 +1029,7 @@ plugin_add_using_decl (cc1_plugin::connection *,
 static tree
 build_named_class_type (enum tree_code code,
                        tree id,
-                       source_location loc)
+                       location_t loc)
 {
   /* See at_fake_function_scope_p.  */
   gcc_assert (!at_function_scope_p ());
@@ -1120,7 +1115,7 @@ plugin_build_decl (cc1_plugin::connection *self,
       gcc_assert (!substitution_name);
     }
 
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
   bool class_member_p = at_class_scope_p ();
   bool ctor = false, dtor = false, assop = false;
   tree_code opcode = ERROR_MARK;
@@ -1321,7 +1316,7 @@ plugin_build_decl (cc1_plugin::connection *self,
              opcode = ARRAY_REF;
              break;
            case CHARS2 ('c', 'v'): // operator <T> (conversion operator)
-             identifier = mangle_conv_op_name_for_type (TREE_TYPE (sym_type));
+             identifier = make_conv_op_name (TREE_TYPE (sym_type));
              break;
              // C++11-only:
            case CHARS2 ('l', 'i'): // operator "" <id>
@@ -1352,12 +1347,7 @@ plugin_build_decl (cc1_plugin::connection *self,
            }
 
          if (opcode != ERROR_MARK)
-           {
-             if (assop)
-               identifier = cp_assignment_operator_id (opcode);
-             else
-               identifier = cp_operator_id (opcode);
-           }
+           identifier = ovl_op_identifier (assop, opcode);
        }
       decl = build_lang_decl_loc (loc, code, identifier, sym_type);
       /* FIXME: current_lang_name is lang_name_c while compiling an
@@ -1416,19 +1406,14 @@ plugin_build_decl (cc1_plugin::connection *self,
          DECL_DECLARED_INLINE_P (decl) = 1;
          DECL_INITIAL (decl) = error_mark_node;
        }
-      if (ctor || dtor)
-       {
-         if (ctor)
-           DECL_CONSTRUCTOR_P (decl) = 1;
-         if (dtor)
-           DECL_DESTRUCTOR_P (decl) = 1;
-       }
-      else
-       {
-         if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION)
-             && opcode != ERROR_MARK)
-           SET_OVERLOADED_OPERATOR_CODE (decl, opcode);
-       }
+
+      if (ctor)
+       DECL_CXX_CONSTRUCTOR_P (decl) = 1;
+      else if (dtor)
+       DECL_CXX_DESTRUCTOR_P (decl) = 1;
+      else if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION)
+              && opcode != ERROR_MARK)
+       DECL_OVERLOADED_OPERATOR_CODE_RAW (decl) = ovl_op_mapping[opcode];
     }
   else if (RECORD_OR_UNION_CODE_P (code))
     {
@@ -1556,7 +1541,7 @@ plugin_build_decl (cc1_plugin::connection *self,
 
   if ((ctor || dtor)
       /* Don't crash after a duplicate declaration of a cdtor.  */
-      && TYPE_METHODS (current_class_type) == decl)
+      && TYPE_FIELDS (current_class_type) == decl)
     {
       /* ctors and dtors clones are chained after DECL.
         However, we create the clones before TYPE_METHODS is
@@ -1568,9 +1553,9 @@ plugin_build_decl (cc1_plugin::connection *self,
       tree save = DECL_CHAIN (decl);
       DECL_CHAIN (decl) = NULL_TREE;
       clone_function_decl (decl, /*update_methods=*/true);
-      gcc_assert (TYPE_METHODS (current_class_type) == decl);
-      TYPE_METHODS (current_class_type)
-       = nreverse (TYPE_METHODS (current_class_type));
+      gcc_assert (TYPE_FIELDS (current_class_type) == decl);
+      TYPE_FIELDS (current_class_type)
+       = nreverse (TYPE_FIELDS (current_class_type));
       DECL_CHAIN (decl) = save;
     }
 
@@ -1758,7 +1743,7 @@ plugin_start_class_type (cc1_plugin::connection *self,
                         unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
   tree typedecl = convert_in (typedecl_in);
   tree type = TREE_TYPE (typedecl);
 
@@ -1818,8 +1803,8 @@ plugin_start_closure_class_type (cc1_plugin::connection *self,
 
   tree lambda_expr = build_lambda_expr ();
 
-  LAMBDA_EXPR_LOCATION (lambda_expr) = ctx->get_source_location (filename,
-                                                                line_number);
+  LAMBDA_EXPR_LOCATION (lambda_expr) = ctx->get_location_t (filename,
+                                                           line_number);
 
   tree type = begin_lambda_type (lambda_expr);
 
@@ -1887,7 +1872,7 @@ plugin_build_field (cc1_plugin::connection *,
        = c_build_bitfield_integer_type (bitsize, TYPE_UNSIGNED (field_type));
     }
 
-  DECL_MODE (decl) = TYPE_MODE (TREE_TYPE (decl));
+  SET_DECL_MODE (decl, TYPE_MODE (TREE_TYPE (decl)));
 
   // There's no way to recover this from DWARF.
   SET_DECL_OFFSET_ALIGN (decl, TYPE_PRECISION (pointer_sized_int_node));
@@ -1952,7 +1937,7 @@ plugin_start_enum_type (cc1_plugin::connection *self,
 
   gcc_assert (is_new_type);
 
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
   tree type_decl = TYPE_NAME (type);
   DECL_SOURCE_LOCATION (type_decl) = loc;
   SET_OPAQUE_ENUM_P (type, false);
@@ -2260,7 +2245,7 @@ plugin_build_type_template_parameter (cc1_plugin::connection *self,
                                      unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
 
   gcc_assert (template_parm_scope_p ());
 
@@ -2290,7 +2275,7 @@ plugin_build_template_template_parameter (cc1_plugin::connection *self,
                                          unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
 
   gcc_assert (template_parm_scope_p ());
 
@@ -2325,7 +2310,7 @@ plugin_build_value_template_parameter (cc1_plugin::connection *self,
                                       unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
 
   gcc_assert (template_parm_scope_p ());
 
@@ -2622,7 +2607,7 @@ plugin_build_dependent_expr (cc1_plugin::connection *self,
          break;
        case CHARS2 ('c', 'v'): // operator <T> (conversion operator)
          convop = true;
-         identifier = mangle_conv_op_name_for_type (conv_type);
+         identifier = make_conv_op_name (conv_type);
          break;
          // C++11-only:
        case CHARS2 ('l', 'i'): // operator "" <id>
@@ -2655,12 +2640,7 @@ plugin_build_dependent_expr (cc1_plugin::connection *self,
       gcc_assert (convop || !conv_type);
 
       if (opcode != ERROR_MARK)
-       {
-         if (assop)
-           identifier = cp_assignment_operator_id (opcode);
-         else
-           identifier = cp_operator_id (opcode);
-       }
+       identifier = ovl_op_identifier (assop, opcode);
 
       gcc_assert (identifier);
     }
@@ -2817,7 +2797,7 @@ plugin_build_unary_expr (cc1_plugin::connection *self,
       break;
 
     case THROW_EXPR:
-      result = build_throw (op0);
+      result = build_throw (input_location, op0);
       break;
 
     case TYPEID_EXPR:
@@ -2826,12 +2806,14 @@ plugin_build_unary_expr (cc1_plugin::connection *self,
 
     case SIZEOF_EXPR:
     case ALIGNOF_EXPR:
-      result = cxx_sizeof_or_alignof_expr (op0, opcode, true);
+      result = cxx_sizeof_or_alignof_expr (input_location,
+                                          op0, opcode, true);
       break;
 
     case DELETE_EXPR:
     case VEC_DELETE_EXPR:
-      result = delete_sanity (op0, NULL_TREE, opcode == VEC_DELETE_EXPR,
+      result = delete_sanity (input_location, op0, NULL_TREE,
+                             opcode == VEC_DELETE_EXPR,
                              global_scope_p, tf_error);
       break;
 
@@ -3067,7 +3049,9 @@ plugin_build_unary_type_expr (cc1_plugin::connection *self,
       break;
 
     default:
-      result = cxx_sizeof_or_alignof_type (type, opcode, true);
+      /* Use the C++11 alignof semantics.  */
+      result = cxx_sizeof_or_alignof_type (input_location, type,
+                                          opcode, true, true);
     }
 
   if (template_dependent_p)
@@ -3083,7 +3067,8 @@ plugin_build_cast_expr (cc1_plugin::connection *self,
                        gcc_expr operand2)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  tree (*build_cast)(tree type, tree expr, tsubst_flags_t complain) = NULL;
+  tree (*build_cast)(location_t loc, tree type, tree expr,
+                    tsubst_flags_t complain) = NULL;
   tree type = convert_in (operand1);
   tree expr = convert_in (operand2);
 
@@ -3120,7 +3105,7 @@ plugin_build_cast_expr (cc1_plugin::connection *self,
   if (!template_dependent_p)
     processing_template_decl--;
 
-  tree val = build_cast (type, expr, tf_error);
+  tree val = build_cast (input_location, type, expr, tf_error);
 
   if (template_dependent_p)
     processing_template_decl--;
@@ -3174,7 +3159,7 @@ plugin_build_expression_list_expr (cc1_plugin::connection *self,
     case CHARS2 ('c', 'v'): // conversion with parenthesized expression list
       gcc_assert (TYPE_P (type));
       args = args_to_tree_list (values_in);
-      result = build_functional_cast (type, args, tf_error);
+      result = build_functional_cast (input_location, type, args, tf_error);
       break;
 
     case CHARS2 ('t', 'l'): // conversion with braced expression list
@@ -3273,8 +3258,8 @@ plugin_build_new_expr (cc1_plugin::connection *self,
   if (!template_dependent_p)
     processing_template_decl--;
 
-  tree result = build_new (&placement, type, nelts, &initializer,
-                          global_scope_p, tf_error);
+  tree result = build_new (input_location, &placement, type, nelts,
+                          &initializer, global_scope_p, tf_error);
 
   if (template_dependent_p)
     processing_template_decl--;
@@ -3358,10 +3343,7 @@ plugin_get_expr_type (cc1_plugin::connection *self,
   if (op0)
     type = TREE_TYPE (op0);
   else
-    {
-      type = make_decltype_auto ();
-      AUTO_IS_DECLTYPE (type) = true;
-    }
+    type = make_decltype_auto ();
   return convert_out (ctx->preserve (type));
 }
 
@@ -3374,7 +3356,7 @@ plugin_build_function_template_specialization (cc1_plugin::connection *self,
                                               unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
   tree name = convert_in (template_decl);
   tree targsl = targlist (targs);
 
@@ -3394,7 +3376,7 @@ plugin_build_class_template_specialization (cc1_plugin::connection *self,
                                            unsigned int line_number)
 {
   plugin_context *ctx = static_cast<plugin_context *> (self);
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
   tree name = convert_in (template_decl);
 
   tree tdecl = finish_template_type (name, targlist (args), false);;
@@ -3621,7 +3603,7 @@ plugin_build_constant (cc1_plugin::connection *self, gcc_type type_in,
   cst = build_int_cst (type, value);
   if (!TYPE_READONLY (type))
     type = build_qualified_type (type, TYPE_QUAL_CONST);
-  decl = build_decl (ctx->get_source_location (filename, line_number),
+  decl = build_decl (ctx->get_location_t (filename, line_number),
                     VAR_DECL, get_identifier (name), type);
   TREE_STATIC (decl) = 1;
   TREE_READONLY (decl) = 1;
@@ -3657,7 +3639,7 @@ plugin_add_static_assert (cc1_plugin::connection *self,
   TREE_TYPE (message) = char_array_type_node;
   fix_string_type (message);
 
-  source_location loc = ctx->get_source_location (filename, line_number);
+  location_t loc = ctx->get_location_t (filename, line_number);
 
   bool member_p = at_class_scope_p ();