aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-05-23 02:18:33 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-05-22 22:18:33 -0400
commit1139b3d8708d1c4efc526564f20cbdb35eb45029 (patch)
treede8ec1626af94687adb1a9f6d5f0bd2f954042f9
parent62c154ed39c6410c39944a8b7f6feccddc2a2946 (diff)
downloadgcc-1139b3d8708d1c4efc526564f20cbdb35eb45029.zip
gcc-1139b3d8708d1c4efc526564f20cbdb35eb45029.tar.gz
gcc-1139b3d8708d1c4efc526564f20cbdb35eb45029.tar.bz2
cp-tree.def: Add SRCLOC.
* cp-tree.def: Add SRCLOC. * cp-tree.h: Add struct tree_srcloc and accessor macros. * tree.c (build_srcloc, build_srcloc_here): New fns. * pt.c (add_pending_template): Use build_srcloc_here. (push_tinst_level): Update last_template_error_tick before erroring. (instantiate_decl): Restore lineno and input_filename before calling add_pending_template. * decl2.c (finish_file): Set up lineno and input_filename for pending templates. From-SVN: r19967
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/cp-tree.def3
-rw-r--r--gcc/cp/cp-tree.h11
-rw-r--r--gcc/cp/decl2.c5
-rw-r--r--gcc/cp/pt.c10
-rw-r--r--gcc/cp/tree.c17
6 files changed, 55 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 023f457..341db45 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+1998-05-23 Jason Merrill <jason@yorick.cygnus.com>
+
+ * cp-tree.def: Add SRCLOC.
+ * cp-tree.h: Add struct tree_srcloc and accessor macros.
+ * tree.c (build_srcloc, build_srcloc_here): New fns.
+ * pt.c (add_pending_template): Use build_srcloc_here.
+ (push_tinst_level): Update last_template_error_tick before erroring.
+ (instantiate_decl): Restore lineno and input_filename before
+ calling add_pending_template.
+ * decl2.c (finish_file): Set up lineno and input_filename for
+ pending templates.
+
1998-05-22 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (lang_print_error_function): New fn.
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 2124a04..cad0a59 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -179,6 +179,9 @@ DEFTREECODE (OVERLOAD, "overload", 'x', 1)
tree structure. */
DEFTREECODE (WRAPPER, "wrapper", 'x', 1)
+/* A node to remember a source position. */
+DEFTREECODE (SRCLOC, "srcloc", 'x', 2)
+
/* A whole bunch of tree codes for the initial, superficial parsing of
templates. */
DEFTREECODE (LOOKUP_EXPR, "lookup_expr", 'e', 2)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3cde102..f12a82e 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -166,6 +166,15 @@ struct tree_wrapper
} u;
};
+#define SRCLOC_FILE(NODE) (((struct tree_srcloc*)NODE)->filename)
+#define SRCLOC_LINE(NODE) (((struct tree_srcloc*)NODE)->linenum)
+struct tree_srcloc
+{
+ char common[sizeof (struct tree_common)];
+ char *filename;
+ int linenum;
+};
+
/* To identify to the debug emitters if it should pay attention to the
flag `-Wtemplate-debugging'. */
#define HAVE_TEMPLATES 1
@@ -2823,6 +2832,8 @@ extern tree make_temp_vec PROTO((int));
extern tree build_ptr_wrapper PROTO((void *));
extern tree build_expr_ptr_wrapper PROTO((void *));
extern tree build_int_wrapper PROTO((int));
+extern tree build_srcloc PROTO((char *, int));
+extern tree build_srcloc_here PROTO((void));
extern int varargs_function_p PROTO((tree));
extern int really_overloaded_fn PROTO((tree));
extern int cp_tree_equal PROTO((tree, tree));
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 3190341..2ad9bbe 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3086,7 +3086,12 @@ finish_file ()
for (fnname = pending_templates; fnname; fnname = TREE_CHAIN (fnname))
{
+ tree srcloc = TREE_PURPOSE (fnname);
tree decl = TREE_VALUE (fnname);
+
+ input_filename = SRCLOC_FILE (srcloc);
+ lineno = SRCLOC_LINE (srcloc);
+
if (TREE_CODE_CLASS (TREE_CODE (decl)) == 't')
{
instantiate_class_template (decl);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 920e062..d148e0d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2775,7 +2775,7 @@ add_pending_template (d)
return;
*template_tail = perm_tree_cons
- (current_function_decl, d, NULL_TREE);
+ (build_srcloc_here (), d, NULL_TREE);
template_tail = &TREE_CHAIN (*template_tail);
TI_PENDING_TEMPLATE_FLAG (ti) = 1;
}
@@ -3346,8 +3346,8 @@ print_template_context (err)
if (current_function_decl == p->decl)
/* Avoid redundancy with the the "In function" line. */;
else if (current_function_decl == NULL_TREE)
- fprintf (stderr, "In instantiation of `%s':\n",
- decl_as_string (p->decl, 0));
+ fprintf (stderr, "%s: In instantiation of `%s':\n",
+ file, decl_as_string (p->decl, 0));
else
my_friendly_abort (980521);
@@ -3397,6 +3397,7 @@ push_tinst_level (d)
if (uses_template_parms (d))
return 0;
+ last_template_error_tick = tinst_level_tick;
error ("template instantiation depth exceeds maximum of %d",
max_tinst_depth);
error (" (use -ftemplate-depth-NN to increase the maximum)");
@@ -7127,6 +7128,9 @@ instantiate_decl (d)
|| (! (TREE_CODE (d) == FUNCTION_DECL && DECL_INLINE (d) && nested)
&& ! at_eof))
{
+ lineno = line;
+ input_filename = file;
+
add_pending_template (d);
goto out;
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 60d20b3..ce60118 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2267,6 +2267,23 @@ build_int_wrapper (i)
return t;
}
+tree
+build_srcloc (file, line)
+ char *file;
+ int line;
+{
+ tree t = make_node (SRCLOC);
+ SRCLOC_FILE (t) = file;
+ SRCLOC_LINE (t) = line;
+ return t;
+}
+
+tree
+build_srcloc_here ()
+{
+ return build_srcloc (input_filename, lineno);
+}
+
void
push_expression_obstack ()
{