[clang] [clang]: support std::meta::info for primitive types (PR #190356)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 4 06:47:51 PDT 2026
================
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -std=c++26 -freflection -fsyntax-only -verify
+
+using info = decltype(^^int);
+
+struct X { int a; }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'meta::info' to 'const X' for 1st argument}} \
+ // expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'meta::info' to 'X' for 1st argument}} \
+ // expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
+template <typename T = X, auto ptm = &X::a>
+constexpr auto ptmOp = ((T)(^^int)).*ptm; // expected-error {{no matching conversion for C-style cast from 'meta::info' to 'X'}}
+constexpr auto var = ptmOp<>; // expected-note {{in instantiation of variable template specialization 'ptmOp' requested here}}
+
+consteval void test()
+{
+ (^^char)++; // expected-error {{cannot increment value of type 'meta::info'}}
+ (^^short)++; // expected-error {{cannot increment value of type 'meta::info'}}
+ (^^int)++; // expected-error {{cannot increment value of type 'meta::info'}}
+
+ (^^char)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+ (^^short)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+ (^^int)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+}
----------------
tbaederr wrote:
What if you actually call `test`?
https://github.com/llvm/llvm-project/pull/190356
More information about the cfe-commits
mailing list