[PATCH] D156108: Rebase, extend the test a bit

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 05:07:56 PDT 2023


Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156108

Files:
  clang/test/SemaTemplate/gh61159.cpp


Index: clang/test/SemaTemplate/gh61159.cpp
===================================================================
--- clang/test/SemaTemplate/gh61159.cpp
+++ clang/test/SemaTemplate/gh61159.cpp
@@ -1,21 +1,39 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 // expected-no-diagnostics
 
-
 namespace GH61159 {
-template<typename T>
-struct X {
-  struct impl;
+template <typename T> struct X {
+  struct I;
 };
 
+template <> struct X<int>::I {
+  template <int ct> constexpr int f() { return ct; };
+
+  int data = 3;
+};
 
-template <>
-struct X<int>::impl {
-    template<int ct>
-    int f() { return ct; };
+template <typename T> struct X<T>::I {
+  template <T ct> constexpr T f() { return ct + 1; };
+  T data = 7;
 };
 
-void foo() {
-    X<int>::impl{}.f<17>();
-}
-}
+static_assert(X<int>::I{}.f<17>() == 17);
+static_assert(X<int>::I{}.data == 3);
+static_assert(X<short>::I{}.data == 7);
+static_assert(X<short>::I{}.f<18>() == 19);
+
+template <typename T> struct Y {
+  struct I;
+};
+
+template <> struct Y<int> {
+  struct I {
+    template <int ct> constexpr int f() { return ct; };
+    int data = 3;
+  };
+};
+
+static_assert(Y<int>::I{}.f<17>() == 17);
+static_assert(Y<int>::I{}.data == 3);
+
+} // namespace GH61159


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156108.543477.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230724/d929ef7a/attachment.bin>


More information about the cfe-commits mailing list