On Tue, 13 Apr 2021, Jason Merrill wrote:

> On 4/13/21 8:41 AM, Jason Merrill wrote:
> > On 4/12/21 6:24 PM, Patrick Palka wrote:
> > > On Mon, 12 Apr 2021, Jason Merrill wrote:
> > > 
> > > > On 4/10/21 3:57 PM, Patrick Palka wrote:
> > > > > Here, in C++17 mode, we only pedwarn about the use of alias CTAD and
> > > > > then later ICE from alias_ctad_tweaks when attempting to add a
> > > > > constraint to one of the guides.  Since the construction of the guides
> > > > > of an alias template effectively relies on concepts, we shouldn't be
> > > > > permissive about alias CTAD in C++17 mode, so this patch turns the
> > > > > pertinent pedwarn in do_class_deduction into an error.
> > > > 
> > > > Sounds good.
> > > > 
> > > > > In order to get a consistent diagnostic for B() vs the other forms in
> > > > > the added testcase, I had to remove the special handling of CTAD with
> > > > > empty initializer in build_functional_cast_1 so that we always pass
> > > > > 'complain' to do_auto_deduction.
> > > > 
> > > > Did you compare the resulting diagnostics when deduction fails other
> > > > than for
> > > > trying to do alias deduction in C++17 mode?
> > > 
> > > For plain CTAD, e.g. for
> > > 
> > >    template <class T> struct A { };
> > >    auto a = A();
> > > 
> > > we previously emitted
> > > 
> > > test.C:2:10: error: cannot deduce template arguments for ‘A<...auto...>’
> > > from ‘()’
> > >      2 | auto a = A();
> > >        |          ^~~
> > > 
> > > and now we emit
> > > 
> > > test.C:2:12: error: class template argument deduction failed:
> > >      2 | auto a = A();
> > >        |            ^
> > > test.C:2:12: error: no matching function for call to ‘A()’
> > > test.C:1:27: note: candidate: ‘template<class T> A()-> A<T>’
> > >      1 | template <class T> struct A { };
> > >        |                           ^
> > > test.C:1:27: note:   template argument deduction/substitution failed:
> > > test.C:2:12: note:   couldn’t deduce template parameter ‘T’
> > >      2 | auto a = A();
> > >        |            ^
> > > test.C:1:27: note: candidate: ‘template<class T> A(A<T>)-> A<T>’
> > >      1 | template <class T> struct A { };
> > >        |                           ^
> > > test.C:1:27: note:   template argument deduction/substitution failed:
> > > test.C:2:12: note:   candidate expects 1 argument, 0 provided
> > >      2 | auto a = A();
> > >        |            ^
> > > 
> > > which is consistent with what we already emit for failed CTAD of the
> > > form A{}, A(args) and A{args}.
> > 
> > Thanks, that's fine.  The patch is OK.
> 
> Looks like you still need to adjust three testcases in g++.old-deja:
> g++.ns/crash3.C, g++.ns/template7.C, g++.pt/crash8.C.

Drat, sorry about that.  Not sure how I missed these.  Fixed thusly
after testing on x86_64-pc-linux-gnu.

-- >8 --

Subject: [committed] c++: Adjust expected diagnostics for old-deja tests 
[PR99008]

I missed adjusting these tests in the recently committed r11-8155.

gcc/testsuite/ChangeLog:

        PR c++/99008
        * g++.old-deja/g++.ns/crash3.C: Adjust expected diagnostic.
        * g++.old-deja/g++.ns/template7.C: Likewise.
        * g++.old-deja/g++.pt/crash8.C: Likewise.
---
 gcc/testsuite/g++.old-deja/g++.ns/crash3.C    | 2 +-
 gcc/testsuite/g++.old-deja/g++.ns/template7.C | 2 +-
 gcc/testsuite/g++.old-deja/g++.pt/crash8.C    | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/g++.old-deja/g++.ns/crash3.C 
b/gcc/testsuite/g++.old-deja/g++.ns/crash3.C
index 189298de6c5..b5e6323dba9 100644
--- a/gcc/testsuite/g++.old-deja/g++.ns/crash3.C
+++ b/gcc/testsuite/g++.old-deja/g++.ns/crash3.C
@@ -6,6 +6,6 @@ namespace N {
 
 void f()
 {
-  N::S(); // { dg-error "6:cannot deduce template arguments" "" { target c++17 
} } invalid use of template
+  N::S(); // { dg-error "8:class template argument deduction failed|no match" 
"" { target c++17 } } invalid use of template
   // { dg-error "7:missing template arguments" "" { target c++14_down } .-1 }
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.ns/template7.C 
b/gcc/testsuite/g++.old-deja/g++.ns/template7.C
index 71366b79d02..441a41249d1 100644
--- a/gcc/testsuite/g++.old-deja/g++.ns/template7.C
+++ b/gcc/testsuite/g++.old-deja/g++.ns/template7.C
@@ -8,6 +8,6 @@ namespace foo {
 }
 
 void baz() {
-  foo::bar(); // { dg-error "8:cannot deduce template arguments" "" { target 
c++17 } } template used as expression
+  foo::bar(); // { dg-error "12:class template argument deduction failed|no 
match" "" { target c++17 } } template used as expression
   // { dg-error "11:missing template arguments" "" { target c++14_down } .-1 }
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash8.C 
b/gcc/testsuite/g++.old-deja/g++.pt/crash8.C
index 7b4eff595bf..678a728f352 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/crash8.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/crash8.C
@@ -21,11 +21,11 @@ void doit(T x) {
   q2 = TestClass2<T>();
 
   TestClass1<T> p1;
-  p1 = TestClass1(); // { dg-error "8:cannot deduce template arguments" "" { 
target c++17 } } template used as expression
+  p1 = TestClass1(); // { dg-error "19:class template argument deduction 
failed|no match" "" { target c++17 } } template used as expression
   // { dg-error "18:missing template arguments" "" { target c++14_down } .-1 }
 
   TestClass2<T> p2;
-  p2 = TestClass2(); // { dg-error "8:cannot deduce template arguments" "" { 
target c++17 } } template used as expression
+  p2 = TestClass2(); // { dg-error "19:class template argument deduction 
failed|no match" "" { target c++17 } } template used as expression
   // { dg-error "18:missing template arguments" "" { target c++14_down } .-1 }
 }
 
-- 
2.31.1.272.g89b43f80a5

Reply via email to