Commit 874c7b7d by Paolo Carlini Committed by Paolo Carlini

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
parent 980fa45e
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> 2018-06-06 Marek Polacek <polacek@redhat.com>
PR c++/85977 PR c++/85977
......
...@@ -8674,7 +8674,8 @@ grokfndecl (tree ctype, ...@@ -8674,7 +8674,8 @@ grokfndecl (tree ctype,
if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR) if (friendp && TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR)
{ {
if (funcdef_flag) if (funcdef_flag)
error ("defining explicit specialization %qD in friend declaration", error_at (location,
"defining explicit specialization %qD in friend declaration",
orig_declarator); orig_declarator);
else else
{ {
...@@ -8684,7 +8685,8 @@ grokfndecl (tree ctype, ...@@ -8684,7 +8685,8 @@ grokfndecl (tree ctype,
if (PROCESSING_REAL_TEMPLATE_DECL_P ()) if (PROCESSING_REAL_TEMPLATE_DECL_P ())
{ {
/* Something like `template <class T> friend void f<T>()'. */ /* Something like `template <class T> friend void f<T>()'. */
error ("invalid use of template-id %qD in declaration " error_at (location,
"invalid use of template-id %qD in declaration "
"of primary template", "of primary template",
orig_declarator); orig_declarator);
return NULL_TREE; return NULL_TREE;
......
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> 2018-06-10 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.dg/inline_matmul_23.f90: New test. * gfortran.dg/inline_matmul_23.f90: New test.
......
template <class T> void foo (int);
template <class T>
class Q {
friend void foo<T> (int) { } // { dg-error "15:defining explicit specialization" }
};
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
template <class A, class B> void foo(); template <class A, class B> void foo();
template <class C> class bar { template <class C> class bar {
int i; // { dg-message "" } private 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() { template <class A, class B> void foo() {
bar<A> baz; baz.i = 1; // { dg-error "" } foo cannot access bar<int>::i bar<A> baz; baz.i = 1; // { dg-error "" } foo cannot access bar<int>::i
......
...@@ -4,7 +4,7 @@ template <class A, class B> void foo(); ...@@ -4,7 +4,7 @@ template <class A, class B> void foo();
template <class C> class bar { template <class C> class bar {
public: public:
int i; 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() { template <class A, class B> void foo() {
bar<A> baz; baz.i = 1; bar<A> baz; baz.i = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment