From 4ed024b604eb6ac2b5f23b3ed0965a31afe9df6b Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 10 May 2013 10:17:45 -0400 Subject: [PATCH] re PR c++/57196 (Bogus "aggregate ... has incomplete type and cannot be defined") PR c++/57196 * pt.c (convert_template_argument): Use dependent_template_arg_p, not uses_template_parms. From-SVN: r198778 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 3 ++- gcc/testsuite/g++.dg/cpp0x/initlist70.C | 27 +++++++++++++++++++++++++ gcc/testsuite/g++.dg/template/crash106.C | 2 ++ gcc/testsuite/g++.dg/template/crash112.C | 4 +++- gcc/testsuite/g++.dg/template/dependent-args1.C | 2 ++ 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist70.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 63cc714..67b4d77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2013-05-10 Jason Merrill + PR c++/57196 + * pt.c (convert_template_argument): Use dependent_template_arg_p, + not uses_template_parms. + PR c++/57047 * semantics.c (cxx_fold_indirect_ref): Fix thinko. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0747de6..8f88b10 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6368,7 +6368,8 @@ convert_template_argument (tree parm, val = error_mark_node; } } - else if (!uses_template_parms (orig_arg) && !uses_template_parms (t)) + else if (!dependent_template_arg_p (orig_arg) + && !uses_template_parms (t)) /* We used to call digest_init here. However, digest_init will report errors, which we don't want when complain is zero. More importantly, digest_init will try too diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist70.C b/gcc/testsuite/g++.dg/cpp0x/initlist70.C new file mode 100644 index 0000000..f215b9d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist70.C @@ -0,0 +1,27 @@ +// PR c++/57196 +// { dg-require-effective-target c++11 } + +#include + +template +struct set { + set() = default; + set(std::initializer_list){} +}; + +struct string { + string(const char*){} + ~string(){} +}; + +typedef decltype(sizeof(0)) size_t; + +template struct EqHelper { }; + +int IsNullLiteralHelper(...); + +void Fn() { + EqHelper{1})> eq1; // ok + EqHelper())> eq2; // ok + EqHelper{"foo"})> eq3; // error +} diff --git a/gcc/testsuite/g++.dg/template/crash106.C b/gcc/testsuite/g++.dg/template/crash106.C index c2d117e..ebd47bc 100644 --- a/gcc/testsuite/g++.dg/template/crash106.C +++ b/gcc/testsuite/g++.dg/template/crash106.C @@ -10,3 +10,5 @@ struct A template > struct B {}; // { dg-error "type|declared" } B<> b; // { dg-error "type|declaration" } + +// { dg-prune-output "could not convert" } diff --git a/gcc/testsuite/g++.dg/template/crash112.C b/gcc/testsuite/g++.dg/template/crash112.C index 919c887..ff35764 100644 --- a/gcc/testsuite/g++.dg/template/crash112.C +++ b/gcc/testsuite/g++.dg/template/crash112.C @@ -5,7 +5,7 @@ struct A template void foo() {} }; -template struct B {}; // { dg-error "declaration" } +template struct B {}; template struct C { @@ -13,3 +13,5 @@ template struct C }; C<0> c; + +// { dg-prune-output "could not convert" } diff --git a/gcc/testsuite/g++.dg/template/dependent-args1.C b/gcc/testsuite/g++.dg/template/dependent-args1.C index 0b197cf..a540e55 100644 --- a/gcc/testsuite/g++.dg/template/dependent-args1.C +++ b/gcc/testsuite/g++.dg/template/dependent-args1.C @@ -9,3 +9,5 @@ struct A template > struct B {}; B b; // { dg-error "type/value mismatch|expected a constant|invalid type" } + +// { dg-prune-output "could not convert" } -- 2.7.4