aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-06-10 21:19:07 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-06-10 21:19:07 +0000
commit874c7b7df2de8cec8dc6732bda78c8639862236e (patch)
tree3f5b5c928d3b47a9bfc1c1eed390cfa3a06e26cf
parent980fa45eefc0ec8f71e1947a28938af28f6fdbb2 (diff)
downloadgcc-874c7b7df2de8cec8dc6732bda78c8639862236e.zip
gcc-874c7b7df2de8cec8dc6732bda78c8639862236e.tar.gz
gcc-874c7b7df2de8cec8dc6732bda78c8639862236e.tar.bz2
decl.c (grokfndecl): Use the location_t argument in two more places.
/cp 2018-06-10 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokfndecl): Use the location_t argument in two more places. /testsuite 2018-06-10 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/template/friend64.C: New. * g++.old-deja/g++.other/friend4.C: Test the location too. * g++.old-deja/g++.pt/crash23.C: Likewise. From-SVN: r261389
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c12
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/template/friend64.C6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/friend4.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/crash23.C2
6 files changed, 25 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 68df054..bdf717f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2018-06-10 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (grokfndecl): Use the location_t argument in two more places.
+
2018-06-06 Marek Polacek <polacek@redhat.com>
PR c++/85977
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5d736e7..688ba4a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8674,8 +8674,9 @@ grokfndecl (tree ctype,
if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR)
{
if (funcdef_flag)
- error ("defining explicit specialization %qD in friend declaration",
- orig_declarator);
+ error_at (location,
+ "defining explicit specialization %qD in friend declaration",
+ orig_declarator);
else
{
tree fns = TREE_OPERAND (orig_declarator, 0);
@@ -8684,9 +8685,10 @@ grokfndecl (tree ctype,
if (PROCESSING_REAL_TEMPLATE_DECL_P ())
{
/* Something like `template <class T> friend void f<T>()'. */
- error ("invalid use of template-id %qD in declaration "
- "of primary template",
- orig_declarator);
+ error_at (location,
+ "invalid use of template-id %qD in declaration "
+ "of primary template",
+ orig_declarator);
return NULL_TREE;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 34f298f..040cce2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2018-06-10 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/template/friend64.C: New.
+ * g++.old-deja/g++.other/friend4.C: Test the location too.
+ * g++.old-deja/g++.pt/crash23.C: Likewise.
+
2018-06-10 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/inline_matmul_23.f90: New test.
diff --git a/gcc/testsuite/g++.dg/template/friend64.C b/gcc/testsuite/g++.dg/template/friend64.C
new file mode 100644
index 0000000..77a8c97
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend64.C
@@ -0,0 +1,6 @@
+template <class T> void foo (int);
+
+template <class T>
+class Q {
+ friend void foo<T> (int) { } // { dg-error "15:defining explicit specialization" }
+};
diff --git a/gcc/testsuite/g++.old-deja/g++.other/friend4.C b/gcc/testsuite/g++.old-deja/g++.other/friend4.C
index cd9e7fa..a551847 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/friend4.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/friend4.C
@@ -11,7 +11,7 @@
template <class A, class B> void foo();
template <class C> class bar {
int i; // { dg-message "" } private
- template <class B> friend void foo<C,B>(); // { dg-error "" } bogus declaration
+ template <class B> friend void foo<C,B>(); // { dg-error "34:invalid use of template-id" }
};
template <class A, class B> void foo() {
bar<A> baz; baz.i = 1; // { dg-error "" } foo cannot access bar<int>::i
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash23.C b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C
index 242624e..ef37f95 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash23.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C
@@ -4,7 +4,7 @@ template <class A, class B> void foo();
template <class C> class bar {
public:
int i;
- template <class B> friend void foo<C,B>(); // { dg-error "" } template-id
+ template <class B> friend void foo<C,B>(); // { dg-error "34:invalid use of template-id" }
};
template <class A, class B> void foo() {
bar<A> baz; baz.i = 1;