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
This commit is contained in:
Paolo Carlini 2018-06-10 21:19:07 +00:00 committed by Paolo Carlini
parent 980fa45eef
commit 874c7b7df2
6 changed files with 25 additions and 7 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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.

View File

@ -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" }
};

View File

@ -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

View File

@ -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;