diff options
author | Jason Merrill <jason@redhat.com> | 2010-07-20 13:34:18 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-07-20 13:34:18 -0400 |
commit | a397bb72552072c13621e4e8e2b534746d497c9a (patch) | |
tree | abe1aca6b2dbd2b28974f2d0c26771db07ea03b4 /gcc | |
parent | caa4a25077716782796a7c133fc8ba166ed177d2 (diff) | |
download | gcc-a397bb72552072c13621e4e8e2b534746d497c9a.zip gcc-a397bb72552072c13621e4e8e2b534746d497c9a.tar.gz gcc-a397bb72552072c13621e4e8e2b534746d497c9a.tar.bz2 |
re PR c++/44967 ([C++0x] decltype of method call dependent on pack expansion crashes)
PR c++/44967
* pt.c (tsubst_copy_and_build): Handle partial substitution of
CALL_EXPR.
From-SVN: r162343
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/sfinae2.C | 39 |
4 files changed, 63 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 124fbe2..b2b0279 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-07-20 Jason Merrill <jason@redhat.com> + + PR c++/44967 + * pt.c (tsubst_copy_and_build): Handle partial substitution of + CALL_EXPR. + 2010-07-19 Jason Merrill <jason@redhat.com> PR c++/44996 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 0ccd8d9..a992d6f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12500,6 +12500,15 @@ tsubst_copy_and_build (tree t, } } + if (processing_template_decl + && (type_dependent_expression_p (function) + || any_type_dependent_arguments_p (call_args))) + { + ret = build_nt_call_vec (function, call_args); + KOENIG_LOOKUP_P (ret) = koenig_p; + goto call_out; + } + /* We do not perform argument-dependent lookup if normal lookup finds a non-function, in accordance with the expected resolution of DR 218. */ @@ -12512,15 +12521,14 @@ tsubst_copy_and_build (tree t, || TREE_CODE (function) == IDENTIFIER_NODE) /* Only do this when substitution turns a dependent call into a non-dependent call. */ - && type_dependent_expression_p_push (t) - && !any_type_dependent_arguments_p (call_args)) + && type_dependent_expression_p_push (t)) function = perform_koenig_lookup (function, call_args); if (TREE_CODE (function) == IDENTIFIER_NODE) { unqualified_name_lookup_error (function); - release_tree_vector (call_args); - return error_mark_node; + ret = error_mark_node; + goto call_out; } /* Remember that there was a reference to this entity. */ @@ -12551,6 +12559,7 @@ tsubst_copy_and_build (tree t, koenig_p, complain); + call_out: release_tree_vector (call_args); return ret; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 402d31d..902c9cd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-20 Jason Merrill <jason@redhat.com> + + PR c++/44967 + * g++.dg/cpp0x/sfinae2.C: New. + 2010-07-20 Richard Guenther <rguenther@suse.de> PR lto/42696 diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae2.C b/gcc/testsuite/g++.dg/cpp0x/sfinae2.C new file mode 100644 index 0000000..b9ef70d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae2.C @@ -0,0 +1,39 @@ +// PR c++/44967 +// { dg-options -std=c++0x } + +template <typename T> T&& declval(); + +template<typename T1, typename T2, typename... Args> +struct has_construct +{ + typedef char one; + typedef struct {char _m[2]; } two; + + template<typename U1, typename U2, typename... Args2> + static decltype(declval<U1>().construct(declval<U2*>(), declval<Args2>()...), one()) test(int); + template<typename, typename, typename...> + static two test(...); + + static const bool value = sizeof(test<T1, T2, Args...>(0)) == 1; +}; + + +struct A0 +{}; + +struct A1 +{ + void construct(int*, int); +}; + +template<typename _Tp> +struct A2 +{ + template<typename _Tp1, typename... _Args> + void construct(_Tp1*, _Args&&...) {} +}; + +#define SA(X) static_assert(X,#X) +SA((!has_construct<A0, int, int>::value)); // ok +SA((has_construct<A1, int, int>::value)); // bang +SA((has_construct<A2<int>, int>::value)); // bang |