On Thu, Feb 26, 2015 at 01:26:01PM +0100, Kai Tietz wrote: > > @@ -2935,7 +2935,7 @@ cxx_eval_constant_expression (const constexpr_ctx > > *ctx, tree t, > > constexpr_ctx new_ctx; > > tree r = t; > > > > - if (t == error_mark_node) > > + if (t == NULL_TREE || t == error_mark_node) > > { > > *non_constant_p = true; > > return t; > > Just one nit. Shouldn't we return here always error_mark_node instead?
Oops, I think so. 2015-02-26 Marek Polacek <pola...@redhat.com> PR c++/65202 * constexpr.c (cxx_eval_constant_expression): Handle null tree. * g++.dg/cpp1y/pr65202.C: New test. diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c index 32a23ff7..84209de 100644 --- gcc/cp/constexpr.c +++ gcc/cp/constexpr.c @@ -2935,10 +2935,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, constexpr_ctx new_ctx; tree r = t; - if (t == error_mark_node) + if (t == NULL_TREE || t == error_mark_node) { *non_constant_p = true; - return t; + return error_mark_node; } if (CONSTANT_CLASS_P (t)) { diff --git gcc/testsuite/g++.dg/cpp1y/pr65202.C gcc/testsuite/g++.dg/cpp1y/pr65202.C index e69de29..602b264 100644 --- gcc/testsuite/g++.dg/cpp1y/pr65202.C +++ gcc/testsuite/g++.dg/cpp1y/pr65202.C @@ -0,0 +1,26 @@ +// // PR c++/65202 +// { dg-do compile { target c++14 } } + +template <typename T> struct is_move_constructible; +template <typename T> struct is_move_assignable; +template <int, typename T> using enable_if_t = int; +namespace adl { +template < + typename L, typename R, + enable_if_t<is_move_constructible<L>() && is_move_assignable<L>(), int>...> +constexpr auto adl_swap(L &l, R &r) -> decltype(swap(l, r)) { + return; +} +template <typename L, typename R> +auto swap(L &l, R &r) noexcept(noexcept(adl::adl_swap(l, r))) + -> decltype(adl::adl_swap(l, r)); +namespace ns { +template <typename T> struct foo {}; +template <typename T> void swap(foo<T> &, foo<T> &); +struct bar; + +int main() +{ + foo<ns::bar> f; + adl::swap(f, f) +} // { dg-error "" } Marek