aboutsummaryrefslogtreecommitdiff
path: root/gcc/langhooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/langhooks.c')
-rw-r--r--gcc/langhooks.c120
1 files changed, 113 insertions, 7 deletions
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 6b0c5bdba08..a1d60f9ff5e 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -32,6 +32,8 @@ Boston, MA 02111-1307, USA. */
#include "flags.h"
#include "langhooks.h"
#include "langhooks-def.h"
+#include "ggc.h"
+#include "diagnostic.h"
/* Do nothing; in many cases the default hook. */
@@ -54,6 +56,16 @@ lhd_do_nothing_i (int i ATTRIBUTE_UNUSED)
{
}
+/* Do nothing (int, int, int). Return NULL_TREE. */
+
+tree
+lhd_do_nothing_iii_return_null_tree (int i ATTRIBUTE_UNUSED,
+ int j ATTRIBUTE_UNUSED,
+ int k ATTRIBUTE_UNUSED)
+{
+ return NULL_TREE;
+}
+
/* Do nothing (function). */
void
@@ -72,6 +84,14 @@ lhd_return_tree (tree t)
/* Do nothing (return NULL_TREE). */
tree
+lhd_return_null_tree_v (void)
+{
+ return NULL_TREE;
+}
+
+/* Do nothing (return NULL_TREE). */
+
+tree
lhd_return_null_tree (tree t ATTRIBUTE_UNUSED)
{
return NULL_TREE;
@@ -136,6 +156,11 @@ lhd_warn_unused_global_decl (tree decl)
return true;
}
+/* Number for making the label on the next
+ static variable internal to a function. */
+
+static GTY(()) int var_labelno;
+
/* Set the DECL_ASSEMBLER_NAME for DECL. */
void
lhd_set_decl_assembler_name (tree decl)
@@ -149,12 +174,28 @@ lhd_set_decl_assembler_name (tree decl)
&& (TREE_STATIC (decl)
|| DECL_EXTERNAL (decl)
|| TREE_PUBLIC (decl))))
- /* By default, assume the name to use in assembly code is the
- same as that used in the source language. (That's correct
- for C, and GCC used to set DECL_ASSEMBLER_NAME to the same
- value as DECL_NAME in build_decl, so this choice provides
- backwards compatibility with existing front-ends. */
- SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
+ {
+ /* By default, assume the name to use in assembly code is the
+ same as that used in the source language. (That's correct
+ for C, and GCC used to set DECL_ASSEMBLER_NAME to the same
+ value as DECL_NAME in build_decl, so this choice provides
+ backwards compatibility with existing front-ends.
+
+ Can't use just the variable's own name for a variable whose
+ scope is less than the whole compilation. Concatenate a
+ distinguishing number. */
+ if (!TREE_PUBLIC (decl) && DECL_CONTEXT (decl))
+ {
+ const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
+ char *label;
+
+ ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
+ var_labelno++;
+ SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
+ }
+ else
+ SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
+ }
else
/* Nobody should ever be asking for the DECL_ASSEMBLER_NAME of
these DECLs -- unless they're in language-dependent code, in
@@ -185,6 +226,13 @@ lhd_type_promotes_to (tree type ATTRIBUTE_UNUSED)
abort ();
}
+/* Registration of machine- or os-specific builtin types. */
+void
+lhd_register_builtin_type (tree type ATTRIBUTE_UNUSED,
+ const char* name ATTRIBUTE_UNUSED)
+{
+}
+
/* Invalid use of an incomplete type. */
void
lhd_incomplete_type_error (tree value ATTRIBUTE_UNUSED, tree type)
@@ -408,6 +456,14 @@ lhd_expr_size (tree exp)
else
return size_in_bytes (TREE_TYPE (exp));
}
+/* lang_hooks.decl_uninit: Find out if a variable is uninitialized based
+ on DECL_INITIAL. */
+
+bool
+lhd_decl_uninit (tree t ATTRIBUTE_UNUSED)
+{
+ return false;
+}
/* lang_hooks.tree_size: Determine the size of a tree with code C,
which is a language-specific tree code in category 'x'. The
@@ -439,7 +495,7 @@ write_global_declarations (void)
tree globals = (*lang_hooks.decls.getdecls) ();
int len = list_length (globals);
- tree *vec = (tree *) xmalloc (sizeof (tree) * len);
+ tree *vec = xmalloc (sizeof (tree) * len);
int i;
tree decl;
@@ -456,3 +512,53 @@ write_global_declarations (void)
/* Clean up. */
free (vec);
}
+
+/* Called to perform language-specific initialization of CTX. */
+void
+lhd_initialize_diagnostics (struct diagnostic_context *ctx ATTRIBUTE_UNUSED)
+{
+}
+
+/* The default function to print out name of current function that caused
+ an error. */
+void
+lhd_print_error_function (diagnostic_context *context, const char *file)
+{
+ if (diagnostic_last_function_changed (context))
+ {
+ const char *old_prefix = context->printer->prefix;
+ char *new_prefix = file ? file_name_as_prefix (file) : NULL;
+
+ pp_set_prefix (context->printer, new_prefix);
+
+ if (current_function_decl == NULL)
+ pp_printf (context->printer, "At top level:");
+ else
+ {
+ if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
+ pp_printf
+ (context->printer, "In member function `%s':",
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
+ else
+ pp_printf
+ (context->printer, "In function `%s':",
+ (*lang_hooks.decl_printable_name) (current_function_decl, 2));
+ }
+ pp_newline (context->printer);
+
+ diagnostic_set_last_function (context);
+ pp_flush (context->printer);
+ context->printer->prefix = old_prefix;
+ free ((char*) new_prefix);
+ }
+}
+
+tree
+lhd_callgraph_analyze_expr (tree *tp ATTRIBUTE_UNUSED,
+ int *walk_subtrees ATTRIBUTE_UNUSED,
+ tree decl ATTRIBUTE_UNUSED)
+{
+ return NULL;
+}
+
+#include "gt-langhooks.h"