public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] c++: __integer_pack with class argument [PR111357]
Date: Tue, 12 Sep 2023 13:27:44 -0400	[thread overview]
Message-ID: <20230912172744.1930180-1-jason@redhat.com> (raw)

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

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.
---
 gcc/cp/pt.cc                             |  2 ++
 gcc/testsuite/g++.dg/ext/integer-pack7.C | 38 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/ext/integer-pack7.C

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 838179d5fe3..b583c11eb99 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 00000000000..95b1195bef4
--- /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>();
+}

base-commit: ea5abbb263315e558c876b50c9371b90ddd5e028
-- 
2.39.3


             reply	other threads:[~2023-09-12 17:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 17:27 Jason Merrill [this message]
2023-09-12 17:34 ` Marek Polacek
2023-09-12 17:49   ` Jakub Jelinek
2023-09-22 14:35     ` [pushed] c++ __integer_pack conversion again [PR111357] Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230912172744.1930180-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).