]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/langhooks.c
c++: Handle multiple aggregate overloads [PR95319].
[thirdparty/gcc.git] / gcc / langhooks.c
index e8295978ca4dd9f348f589d26f36d5fa7be687fc..5e3216da63129b9e2779b43596efdc7d889cd163 100644 (file)
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-diagnostic.h"
 #include "output.h"
 #include "timevar.h"
+#include "stor-layout.h"
 
 /* Do nothing; in many cases the default hook.  */
 
@@ -159,16 +160,17 @@ lhd_set_decl_assembler_name (tree decl)
 
      Can't use just the variable's own name for a variable whose scope
      is less than the whole compilation.  Concatenate a distinguishing
-     number - we use the DECL_UID.  */
+     number.  */
 
   if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
     id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
   else
     {
       const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
+      static unsigned long num;
       char *label;
 
-      ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
+      ASM_FORMAT_PRIVATE_NAME (label, name, num++);
       id = get_identifier (label);
     }
 
@@ -473,6 +475,44 @@ lhd_make_node (enum tree_code code)
   return make_node (code);
 }
 
+/* Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL.  Assume a
+   simple int-based enumerator (which is all the hook can be used for
+   at present) and push each decl individually without any decoration.
+
+   This definition is suitable for LTO and is generic enough that it
+   might be reusable elsewhere.  */
+tree
+lhd_simulate_enum_decl (location_t loc, const char *name,
+                       vec<string_int_pair> values)
+{
+  tree enumtype = lang_hooks.types.make_type (ENUMERAL_TYPE);
+  tree enumdecl = build_decl (loc, TYPE_DECL, get_identifier (name), enumtype);
+  TYPE_STUB_DECL (enumtype) = enumdecl;
+
+  tree value_chain = NULL_TREE;
+  string_int_pair *value;
+  unsigned int i;
+  FOR_EACH_VEC_ELT (values, i, value)
+    {
+      tree value_decl = build_decl (loc, CONST_DECL,
+                                   get_identifier (value->first), enumtype);
+      DECL_INITIAL (value_decl) = build_int_cst (integer_type_node,
+                                                value->second);
+      lang_hooks.decls.pushdecl (value_decl);
+      value_chain = tree_cons (value_decl, DECL_INITIAL (value_decl),
+                              value_chain);
+    }
+
+  TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (integer_type_node);
+  TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (integer_type_node);
+  SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (integer_type_node));
+  TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
+  layout_type (enumtype);
+  lang_hooks.decls.pushdecl (enumdecl);
+
+  return enumtype;
+}
+
 /* Default implementation of LANG_HOOKS_TYPE_FOR_SIZE.
    Return an integer type with PRECISION bits of precision,
    that is unsigned if UNSIGNEDP is nonzero, otherwise signed.  */