]> gcc.gnu.org Git - gcc.git/commit
c++: Diagnose a deduction guide in a wrong scope [PR91759]
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Mar 2020 07:53:23 +0000 (08:53 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 18 Mar 2020 07:53:23 +0000 (08:53 +0100)
commitaf8656be8df68ac26840f7844430fd595255ebd2
treecad0e122dc2aa53b77ae439efa2921fa06c2a681
parent52b3aa8be18938486065f5f2a23553b134a10a81
c++: Diagnose a deduction guide in a wrong scope [PR91759]

The following testcase is accepts-invalid since r7-6608-ga56c0ac08242269b.
Before that change we had this
"deduction guide %qD must be declared in the same scope as %qT"
diagnostics for it, after the change it is expected to be diagnosed
in set_decl_namespace at the not_found: label in there.  On this testcase
nothing is diagnosed though, because set_decl_namespace isn't called at all,
as in_namespace is NULL.

The following patch restores the old warning but does it only in case we
don't call set_decl_namespace.

2020-03-18  Jakub Jelinek  <jakub@redhat.com>

PR c++/91759
* decl.c (grokfndecl): Restore old diagnostics about deduction
guide declared in different scope if in_namespace is NULL_TREE.

* g++.dg/cpp1z/class-deduction72.C: New test.
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/class-deduction72.C [new file with mode: 0644]
This page took 0.068307 seconds and 5 git commands to generate.