From: Paolo Carlini Date: Sun, 10 Jun 2018 21:19:07 +0000 (+0000) Subject: decl.c (grokfndecl): Use the location_t argument in two more places. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=874c7b7df2de8cec8dc6732bda78c8639862236e;p=gcc.git decl.c (grokfndecl): Use the location_t argument in two more places. /cp 2018-06-10 Paolo Carlini * decl.c (grokfndecl): Use the location_t argument in two more places. /testsuite 2018-06-10 Paolo Carlini * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 68df0544517..bdf717f82fb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2018-06-10 Paolo Carlini + + * decl.c (grokfndecl): Use the location_t argument in two more places. + 2018-06-06 Marek Polacek PR c++/85977 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5d736e7d1ac..688ba4a1442 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 friend void f()'. */ - 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 34f298fdd6a..040cce2b770 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-06-10 Paolo Carlini + + * 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 * 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 00000000000..77a8c97cf56 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend64.C @@ -0,0 +1,6 @@ +template void foo (int); + +template +class Q { + friend void foo (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 cd9e7fa1074..a5518476907 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 void foo(); template class bar { int i; // { dg-message "" } private - template friend void foo(); // { dg-error "" } bogus declaration + template friend void foo(); // { dg-error "34:invalid use of template-id" } }; template void foo() { bar baz; baz.i = 1; // { dg-error "" } foo cannot access bar::i diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash23.C b/gcc/testsuite/g++.old-deja/g++.pt/crash23.C index 242624eebb8..ef37f95548e 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 void foo(); template class bar { public: int i; - template friend void foo(); // { dg-error "" } template-id + template friend void foo(); // { dg-error "34:invalid use of template-id" } }; template void foo() { bar baz; baz.i = 1;