llvm-project/clang/test/Parser/parsing-reflection.cpp
Nhat Nguyen 1171450d56
[clang]: reflection operator parsing for primitive types (#164692)
(After changing the scope) This PR implements parsing the reflection
operator (^^) for primitive types. The goal is to keep the first PR
simple. In subsequent PRs, parsing for the remaining requirements will
be introduced.

This implementation is based on the fork of @katzdm.

Class `CXXReflectExpr` is introduced to represent the operand of the
reflection operator. For now, in this PR, the type std::meta::info is
not implemented yet, so when we construct an AST node CXXReflectExpr,
`VoidTy` is used as placeholder type for now.

The file `ParseReflect.cpp` is introduced, which for now only has the
function `ParseCXXReflectExpression`. It parses the operand of the
reflection operator.

---------

Co-authored-by: Shafik Yaghmour <shafik.yaghmour@intel.com>
Co-authored-by: Hubert Tong <hubert.reinterpretcast@gmail.com>
Co-authored-by: Sirraide <aeternalmail@gmail.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
Co-authored-by: Erich Keane <ekeane@nvidia.com>
2026-02-06 11:32:17 -05:00

33 lines
968 B
C++

// RUN: %clang_cc1 %s -std=c++26 -freflection -fsyntax-only -verify
struct A{};
namespace B{};
void f(){};
consteval void test()
{
(void)(^^void);
(void)(^^bool);
(void)(^^char);
(void)(^^signed char);
(void)(^^unsigned char);
(void)(^^short);
(void)(^^unsigned short);
(void)(^^int);
(void)(^^unsigned int);
(void)(^^long);
(void)(^^unsigned long);
(void)(^^long long);
(void)(^^float);
(void)(^^double);
(void)(^^const void);
(void)(^^decltype(nullptr));
(void)(^^::); // expected-error {{unknown or unimplemented reflectable entity}}
constexpr auto x = 1;
(void)(^^x); // expected-error {{unknown or unimplemented reflectable entity}}
(void)(^^A); // expected-error {{unknown or unimplemented reflectable entity}}
(void)(^^B); // expected-error {{unknown or unimplemented reflectable entity}}
(void)(^^f); // expected-error {{unknown or unimplemented reflectable entity}}
}