[pushed] c++: Add fixed test [PR88848]

Message ID 20231208184624.90158-1-polacek@redhat.com
State Committed
Commit 2a5a5d5e7d32b21205562a35b307ff69e389b996
Headers
Series [pushed] c++: Add fixed test [PR88848] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 warning Patch is already merged

Commit Message

Marek Polacek Dec. 8, 2023, 6:46 p.m. UTC
  Tested x86_64-pc-linux-gnu, applying to trunk.

-- >8 --
This one was fixed by r12-7714-g47da5198766256.

	PR c++/88848

gcc/testsuite/ChangeLog:

	* g++.dg/inherit/multiple2.C: New test.
---
 gcc/testsuite/g++.dg/inherit/multiple2.C | 35 ++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/inherit/multiple2.C


base-commit: 0c018a74eb1affe2a1fa385cdddaa93979683420
  

Patch

diff --git a/gcc/testsuite/g++.dg/inherit/multiple2.C b/gcc/testsuite/g++.dg/inherit/multiple2.C
new file mode 100644
index 00000000000..dd3d0daf248
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/multiple2.C
@@ -0,0 +1,35 @@ 
+// PR c++/88848
+// { dg-do compile { target c++17 } }
+
+template<typename>
+struct True { static constexpr bool value{ true }; };
+
+template<int VALUE>
+struct Integer { static constexpr int value{ VALUE }; };
+
+template<int VALUE, typename TYPE>
+struct Foo
+{
+  using Integer_t = Integer<VALUE>;
+
+  static TYPE get_type(Integer_t);
+};
+
+template<typename... ARGS>
+struct Bar : ARGS...
+{
+  using ARGS::get_type...;
+
+  template<int VALUE>
+  using Type_t = decltype(get_type(Integer<VALUE>{}));
+
+  Bar() { static_assert((True< Type_t<ARGS::Integer_t::value> >::value && ...)); }
+
+  static_assert((True< Type_t<ARGS::Integer_t::value> >::value && ...));
+};
+
+int main()
+{
+  Bar<Foo<4, float>, Foo<8, double>> obj;
+  return int{ sizeof(obj) };
+}