aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorManuel López-Ibáñez <manu@gcc.gnu.org>2007-11-12 00:28:41 +0000
committerManuel López-Ibáñez <manu@gcc.gnu.org>2007-11-12 00:28:41 +0000
commitb131ad7c3db37bb79f21f5f6532447d0e030acaa (patch)
tree85e9b9c7db2da544bf03730011a29b03a6bada07 /gcc/cp
parentacd7ad0afc0e2be08fe6582e2b46299601d6db7e (diff)
downloadgcc-b131ad7c3db37bb79f21f5f6532447d0e030acaa.zip
gcc-b131ad7c3db37bb79f21f5f6532447d0e030acaa.tar.gz
gcc-b131ad7c3db37bb79f21f5f6532447d0e030acaa.tar.bz2
re PR c++/8570 (line number in error message is badly placed with illegal template friend declaration)
2007-11-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/8570 cp/ * pt.c (redeclare_class_template): Update error message. Use a note to show the previous declaration. (tsubst_friend_class): Use the location of the friend template as the input location before calling redeclare_class_template. testsuite/ * g++.old-deja/g++.ns/template13.C: Update expected output. * g++.old-deja/g++.pt/friend23.C: Likewise. * g++.dg/warn/pr8570.C: New. From-SVN: r130092
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/pt.c16
2 files changed, 19 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e41c990..cfeea80 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2007-11-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
+
+ PR c++/8570
+ * pt.c (redeclare_class_template): Update error message. Use a
+ note to show the previous declaration.
+ (tsubst_friend_class): Use the location of the friend template as
+ the input location before calling redeclare_class_template.
+
2007-11-11 Jakub Jelinek <jakub@redhat.com>
PR c++/34068
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4d9f122..0339a8c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4151,10 +4151,10 @@ redeclare_class_template (tree type, tree parms)
if (TREE_VEC_LENGTH (parms) != TREE_VEC_LENGTH (tmpl_parms))
{
- error ("previous declaration %q+D", tmpl);
- error ("used %d template parameter(s) instead of %d",
- TREE_VEC_LENGTH (tmpl_parms),
- TREE_VEC_LENGTH (parms));
+ error ("redeclared with %d template parameter(s)",
+ TREE_VEC_LENGTH (parms));
+ inform ("previous declaration %q+D used %d template parameter(s)",
+ tmpl, TREE_VEC_LENGTH (tmpl_parms));
return false;
}
@@ -4193,7 +4193,7 @@ redeclare_class_template (tree type, tree parms)
A template-parameter may not be given default arguments
by two different declarations in the same scope. */
error ("redefinition of default argument for %q#D", parm);
- error ("%J original definition appeared here", tmpl_parm);
+ inform ("%Joriginal definition appeared here", tmpl_parm);
return false;
}
@@ -6521,9 +6521,15 @@ tsubst_friend_class (tree friend_tmpl, tree args)
> TMPL_ARGS_DEPTH (args))
{
tree parms;
+ location_t saved_input_location;
parms = tsubst_template_parms (DECL_TEMPLATE_PARMS (friend_tmpl),
args, tf_warning_or_error);
+
+ saved_input_location = input_location;
+ input_location = DECL_SOURCE_LOCATION (friend_tmpl);
redeclare_class_template (TREE_TYPE (tmpl), parms);
+ input_location = saved_input_location;
+
}
friend_type = TREE_TYPE (tmpl);