From 3d1c3406c5da06567e4ecdc5b2a35c2be93660ba Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 16 Jun 2015 14:48:56 +0000 Subject: PR c++/66387 * pt.c (tsubst_copy) [VAR_DECL]: Use process_outer_var_ref. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224521 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 + gcc/cp/pt.c | 6 +- gcc/cp/semantics.c | 2 + gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C | 123 +++++++++++++++++++++++ 4 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 15766f4d726..1ab5e8f2c3f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-06-16 Jason Merrill + + PR c++/66387 + * pt.c (tsubst_copy) [VAR_DECL]: Use process_outer_var_ref. + 2015-06-15 Nathan Sidwell PR c++/58583 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ea8c8b65a3f..9236311329d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13071,10 +13071,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (TREE_STATIC (r)) rest_of_decl_compilation (r, toplevel_bindings_p (), at_eof); - else if (decl_constant_var_p (r)) - /* A use of a local constant decays to its value. - FIXME update for core DR 696. */ - r = scalar_constant_value (r); + else + r = process_outer_var_ref (r, complain); } } /* Remember this for subsequent uses. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 59ec9047c26..a1519b9e608 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3103,6 +3103,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain) if (cp_unevaluated_operand) /* It's not a use (3.2) if we're in an unevaluated context. */ return decl; + if (decl == error_mark_node) + return decl; tree context = DECL_CONTEXT (decl); tree containing_function = current_function_decl; diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C new file mode 100644 index 00000000000..57e0ad2b288 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-ice2.C @@ -0,0 +1,123 @@ +// PR c++/66387 +// { dg-do compile { target c++14 } } + +namespace boost { +namespace hana { +namespace detail { +namespace std { +using size_t = decltype(0); +} +} +namespace ic_detail { +template struct _with_index { + template constexpr void operator()(F &&) const; +}; +template struct _times { _with_index with_index; }; +} +template struct _integral_constant { + using value_type = T; + operator value_type() const; + ic_detail::_times times; +}; +template +constexpr _integral_constant size_t{}; +template struct datatype; +} +} +namespace std { +typedef int size_t; +inline namespace __cxx11 {} +} +namespace boost { +namespace hana { +template struct when; +template struct to_impl; +template struct datatype : datatype> {}; +template struct datatype> { + using type = typename T::hana::datatype; +}; +template struct _models; +template + struct to_impl < To, + From, when < _models { +} >> ; +namespace detail { +namespace std { +template struct integer_sequence; +template using index_sequence = integer_sequence; +namespace int_seq_detail { +template struct make_index_sequence { + using type = index_sequence<0>; +}; +template struct cast_to; +template +struct cast_to> { + using type = integer_sequence; +}; +} +template +using make_integer_sequence = typename int_seq_detail::cast_to< + T, int_seq_detail::make_index_sequence<1>::type>::type; +} +} +namespace ic_detail { +template > +struct go; +template +struct go> { + using swallow = T; + template static void with_index(F f) { + swallow{(f(_integral_constant{}), 0)...}; + } +}; +template +template +constexpr void _with_index::operator()(F &&f) const { + go::with_index(f); +} +} +} +} +namespace std { +template class allocator; +template struct char_traits; +template > class basic_ostream; +namespace __cxx11 { +template , + typename = allocator<_CharT>> +class basic_stringstream; +} +typedef basic_ostream ostream; +typedef basic_stringstream stringstream; +template class basic_ostream {}; +template +class basic_iostream : public basic_ostream<_CharT> {}; +namespace __cxx11 { +template +class basic_stringstream : public basic_iostream<_CharT, _Traits> {}; +} +} +namespace hana = boost::hana; +template struct print_impl; +template void print(std::ostream os, X x) { + using Tag = typename hana::datatype::type; + print_impl::apply(os, x); +} +struct Vector; +template struct vector2 { + struct hana { + using datatype = Vector; + }; + static constexpr std::size_t size = 0; +}; +template <> struct print_impl { + template static void apply(std::ostream, vectorN) { + constexpr auto N = hana::size_t; + N.times.with_index([&](auto) { N - hana::size_t<1>; }); + } +}; +int main() { + std::stringstream ss; + vector2 v2; + print(ss, v2); +} -- cgit v1.2.3