public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3908] c++: __integer_pack with class argument [PR111357]
@ 2023-09-12 17:27 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-09-12 17:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f73d2d61a5926f42e9e5d771d23868787ef9d800

commit r14-3908-gf73d2d61a5926f42e9e5d771d23868787ef9d800
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Sep 11 09:40:32 2023 -0400

    c++: __integer_pack with class argument [PR111357]
    
    The argument might not already be an integer.
    
            PR c++/111357
    
    gcc/cp/ChangeLog:
    
            * pt.cc (expand_integer_pack): Convert argument to int.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ext/integer-pack7.C: New test.

Diff:
---
 gcc/cp/pt.cc                             |  2 ++
 gcc/testsuite/g++.dg/ext/integer-pack7.C | 38 ++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 838179d5fe3b..b583c11eb995 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -3793,6 +3793,8 @@ expand_integer_pack (tree call, tree args, tsubst_flags_t complain,
     }
   else
     {
+      hi = perform_implicit_conversion_flags (integer_type_node, hi, complain,
+					      LOOKUP_IMPLICIT);
       hi = instantiate_non_dependent_expr (hi, complain);
       hi = cxx_constant_value (hi, complain);
       int len = valid_constant_size_p (hi) ? tree_to_shwi (hi) : -1;
diff --git a/gcc/testsuite/g++.dg/ext/integer-pack7.C b/gcc/testsuite/g++.dg/ext/integer-pack7.C
new file mode 100644
index 000000000000..95b1195bef41
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/integer-pack7.C
@@ -0,0 +1,38 @@
+// PR c++/111357
+// { dg-do compile { target c++11 } }
+
+namespace std {
+  template<typename _Tp, _Tp... _Idx>
+    struct integer_sequence
+    { };
+
+  template<typename _Tp, _Tp _Num>
+    using make_integer_sequence
+      = integer_sequence<_Tp, __integer_pack(_Num)...>;
+}
+
+using std::integer_sequence;
+using std::make_integer_sequence;
+
+template<int... V>
+void g(integer_sequence<int,V...>)
+{}
+
+template<typename ...T>
+struct c1
+{
+  static constexpr int value = 1;
+  constexpr operator int() { return value; }
+};
+template<typename T>
+struct R
+{
+	using S = make_integer_sequence<int,c1<T>{}>;
+
+	R() noexcept(noexcept(g(S())))
+	{}
+};
+int main()
+{
+        R<int>();
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-12 17:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12 17:27 [gcc r14-3908] c++: __integer_pack with class argument [PR111357] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).