Skip to content

[interop] Pass template names and named constants as template arguments - #62

Open
conrade-ctc wants to merge 2 commits into
compiler-research:mainfrom
chicagotrading:pr-c-template-args
Open

[interop] Pass template names and named constants as template arguments#62
conrade-ctc wants to merge 2 commits into
compiler-research:mainfrom
chicagotrading:pr-c-template-args

Conversation

@conrade-ctc

@conrade-ctc conrade-ctc commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

A template argument can now name a template or a constant. A class or alias template name becomes a template-template argument. A constexpr variable or an enum constant becomes an expression, so Sema reads its value. true and false become bool values. The first commit fixes a separate bug: is_integral rejected a leading minus, so a negative literal became a type name.

The by-name paths need CppInterOp compiler-research/CppInterOp#1074, which resolves the name. Before this merges, the CppInterOp pin moves to the commit that carries #1074 and the capability probe goes away. Do not merge this before #1074.

Emery Conrad added 2 commits September 8, 2026 10:05
is_integral rejects a leading minus, so the comma-split fallback in
AppendTypesSlow reads a negative literal as a type name. Accept the sign.

Co-developed-with-the-help-of: Claude Code (Opus 5, human in the loop)
A class or alias template name becomes a template-template argument. The
argument carries the name and a null type. A constexpr variable or an enum
constant goes through as its qualified name, so Sema builds an expression.
true and false become bool values.

The by-name paths need a CppInterOp that resolves the name. An older one
reads the name as an integer literal and instantiates a garbage value.
Probe for CppInterOp's SupportsNamedTemplateArguments export, and skip the
test when it is absent.

Co-developed-with-the-help-of: Claude Code (Fable 5, human in the loop)
#else
static const bool Supported = [] {
// CppInterOp is dlopen'ed RTLD_LOCAL; its exports need its own handle.
void* handle = dlopen(cppinterop_paths().Library.c_str(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a weird way to check if a feature is there or not. Can’t we rely on the version hash, for example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The probe guards a window, not a permanent difference. cppjit pins CppInterOp by commit sha. The current pin (9802d619) predates #1074, so Cpp::GetNamed does not resolve a named constant yet. Without the guard, the by-name tests fail on the pinned build.

I looked at the version hash. Cpp::GetVersion() reads the VERSION file, which is the same before and after #1074. Cpp::GetBuildInfo() has no git sha, and a sha has no order, so a check cannot express "at least this commit".

So I think the pin is already the version check. My proposal: drop the probe and hold this PR until #1074 merges. Then I rebase, move the pin to a commit that carries #1074, and the by-name tests run unconditionally. This matches #63, which waited on #1101 the same way. The removal is ready locally.

Tell me if you prefer a different order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants