Fix PR c++/69283 (auto deduction fails when ADL is required)

gcc/cp/ChangeLog:

	PR c++/69283
	PR c++/67835
	* decl2.c (mark_used): When given a TEMPLATE_DECL, return after
	setting its TREE_USED flag.

gcc/testsuite/ChangeLog:

	PR c++/69283
	PR c++/67835
	* g++.dg/cpp1y/auto-fn29.C: New test.
	* g++.dg/cpp1y/auto-fn30.C: New test.

From-SVN: r233230
This commit is contained in:
Patrick Palka 2016-02-08 23:02:50 +00:00
parent 1374a761eb
commit 20a0c6f9bd
5 changed files with 73 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2016-02-08 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/69283
PR c++/67835
* decl2.c (mark_used): When given a TEMPLATE_DECL, return after
setting its TREE_USED flag.
2016-02-08 Jason Merrill <jason@redhat.com>
PR c++/69657

View File

@ -5068,6 +5068,10 @@ mark_used (tree decl, tsubst_flags_t complain)
/* Set TREE_USED for the benefit of -Wunused. */
TREE_USED (decl) = 1;
if (TREE_CODE (decl) == TEMPLATE_DECL)
return true;
if (DECL_CLONED_FUNCTION_P (decl))
TREE_USED (DECL_CLONED_FUNCTION (decl)) = 1;

View File

@ -1,3 +1,10 @@
2016-02-08 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/69283
PR c++/67835
* g++.dg/cpp1y/auto-fn29.C: New test.
* g++.dg/cpp1y/auto-fn30.C: New test.
2016-02-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/69209

View File

@ -0,0 +1,34 @@
// PR c++/69283
// { dg-do compile { target c++14 } }
namespace Ape {
struct Type {};
template <typename T>
auto f1(T const& v){
return true;
}
template <typename T>
auto f2(T const& v){
return f2(v); // { dg-error "auto" }
}
}
namespace Baboon {
template <typename T>
bool f3(T const& v){
return f1(v);
}
template <typename T>
bool f4(T const& v){
f2(v);
}
}
int main(){
Ape::Type x;
Baboon::f3(x);
Baboon::f4(x);
}

View File

@ -0,0 +1,21 @@
// PR c++/67835
// { dg-do compile { target c++14 } }
template<class Tag, class T>
auto g(Tag tag, T x) {
return f(tag, x);
}
namespace abc {
struct tag {};
struct A {};
template<class T>
auto f(tag, T x) { return x; }
}
int main() {
g(abc::tag(), abc::A());
return 0;
}