base_section = darwin_sections[zobj_data_section];
}
else if (ro)
- base_section = darwin_sections[const_data_section];
+ {
+ if (VAR_P (decl) && TREE_TYPE (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
+ && DECL_NAME (decl)
+ && strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)),
+ "__anon_cfstring", 15) == 0)
+ base_section = darwin_sections[cfstring_constant_object_section];
+ else
+ base_section = darwin_sections[const_data_section];
+ }
else
base_section = data_section;
break;
else
return darwin_sections[objc_string_object_section];
}
- else if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_CFString"))
- return darwin_sections[cfstring_constant_object_section];
else
return base_section;
}
}
#endif
+void
+darwin_rename_builtins (void)
+{
+}
+
+/* Implementation for the TARGET_LIBC_HAS_FUNCTION hook. */
+
+bool
+darwin_libc_has_function (enum function_class fn_class,
+ tree type ATTRIBUTE_UNUSED)
+{
+ if (fn_class == function_sincos && darwin_macosx_version_min)
+ return (strverscmp (darwin_macosx_version_min, "10.9") >= 0);
+#if DARWIN_PPC && SUPPORT_DARWIN_LEGACY
+ if (fn_class == function_c99_math_complex
+ || fn_class == function_c99_misc)
+ return (TARGET_64BIT
+ || (darwin_macosx_version_min &&
+ strverscmp (darwin_macosx_version_min, "10.3") >= 0));
+#endif
+ return default_libc_has_function (fn_class, type);
+}
+
/* CFStrings implementation. */
static GTY(()) tree cfstring_class_reference = NULL_TREE;
static GTY(()) tree cfstring_type_node = NULL_TREE;
/* The string literal. */
tree literal;
/* The resulting constant CFString. */
- tree constructor;
+ tree ccf_str;
} cfstring_descriptor;
struct cfstring_hasher : ggc_ptr_hash<cfstring_descriptor>
/* Make a lang-specific section - dup_lang_specific_decl makes a new node
in place of the existing, which may be NULL. */
DECL_LANG_SPECIFIC (cfsfun) = NULL;
- (*lang_hooks.dup_lang_specific_decl) (cfsfun);
+ lang_hooks.dup_lang_specific_decl (cfsfun);
set_decl_built_in_function (cfsfun, BUILT_IN_MD, darwin_builtin_cfstring);
lang_hooks.builtin_function (cfsfun);
TREE_PUBLIC (cfstring_class_reference) = 1;
DECL_ARTIFICIAL (cfstring_class_reference) = 1;
- (*lang_hooks.decls.pushdecl) (cfstring_class_reference);
+ lang_hooks.decls.pushdecl (cfstring_class_reference);
DECL_EXTERNAL (cfstring_class_reference) = 1;
rest_of_decl_compilation (cfstring_class_reference, 0, 0);
return NULL_TREE;
}
-void
-darwin_rename_builtins (void)
-{
-}
-
-/* Implementation for the TARGET_LIBC_HAS_FUNCTION hook. */
-
-bool
-darwin_libc_has_function (enum function_class fn_class,
- tree type ATTRIBUTE_UNUSED)
-{
- if (fn_class == function_sincos && darwin_macosx_version_min)
- return (strverscmp (darwin_macosx_version_min, "10.9") >= 0);
-#if DARWIN_PPC && SUPPORT_DARWIN_LEGACY
- if (fn_class == function_c99_math_complex
- || fn_class == function_c99_misc)
- return (TARGET_64BIT
- || (darwin_macosx_version_min &&
- strverscmp (darwin_macosx_version_min, "10.3") >= 0));
-#endif
- return default_libc_has_function (fn_class, type);
-}
-
hashval_t
cfstring_hasher::hash (cfstring_descriptor *ptr)
{
build_int_cst (TREE_TYPE (field), length));
constructor = build_constructor (ccfstring_type_node, v);
- TREE_READONLY (constructor) = 1;
- TREE_CONSTANT (constructor) = 1;
- TREE_STATIC (constructor) = 1;
-
- /* Fromage: The C++ flavor of 'build_unary_op' expects constructor nodes
- to have the TREE_HAS_CONSTRUCTOR (...) bit set. However, this file is
- being built without any knowledge of C++ tree accessors; hence, we shall
- use the generic accessor that TREE_HAS_CONSTRUCTOR actually maps to! */
+ TREE_READONLY (constructor) = true;
+ TREE_CONSTANT (constructor) = true;
+ TREE_STATIC (constructor) = true;
+
+ /* This file is being built without any knowledge of C++ tree accessors;
+ hence, we shall use the generic accessor to set TREE_HAS_CONSTRUCTOR.
+ ??? Is this actually used any more? */
if (darwin_running_cxx)
TREE_LANG_FLAG_4 (constructor) = 1; /* TREE_HAS_CONSTRUCTOR */
/* Create an anonymous global variable for this CFString. */
- var = build_decl (input_location, CONST_DECL,
+ var = build_decl (input_location, VAR_DECL,
NULL, TREE_TYPE (constructor));
- DECL_ARTIFICIAL (var) = 1;
- TREE_STATIC (var) = 1;
+ char *name = xasprintf ("__anon_cfstring.%u", DECL_UID (var));
+ DECL_NAME (var) = get_identifier (name);
+ free (name);
+ DECL_ARTIFICIAL (var) = true;
+ TREE_STATIC (var) = true;
+ TREE_READONLY (var) = true;
+ TREE_CONSTANT (var) = true;
DECL_INITIAL (var) = constructor;
- /* FIXME: This should use a translation_unit_decl to indicate file scope. */
+ /* global namespace. */
DECL_CONTEXT (var) = NULL_TREE;
- desc->constructor = var;
+ DECL_INITIAL (var) = constructor;
+ lang_hooks.decls.pushdecl (var);
+ rest_of_decl_compilation (var, 1, 0);
+ desc->ccf_str = var;
}
- addr = build1 (ADDR_EXPR, pccfstring_type_node, desc->constructor);
+ addr = build1 (ADDR_EXPR, pccfstring_type_node, desc->ccf_str);
TREE_CONSTANT (addr) = 1;
return addr;