Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ Bug Fixes in This Version
- Fixed a crash triggered by unterminated ``__has_embed``. (#GH162953)
- Accept empty enumerations in MSVC-compatible C mode. (#GH114402)
- Fixed false-positive shadow diagnostics for lambdas in explicit object member functions. (#GH163731)
- Fixed an incorrect diagnostic for ambiguous function call that uses a
designated-initializer as template argument. (#GH166784)

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/Sema/SemaInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2937,6 +2937,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
}

FieldDecl *KnownField = D->getFieldDecl();
if (KnownField && KnownField->getParent() != RD)
KnownField = nullptr;
Comment on lines +2940 to +2941
Copy link
Contributor

Choose a reason for hiding this comment

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

We need some comments/explanation for this workaround.

If this is related to cache, is it possible for us to fix that instead?

Copy link
Member Author

@Backl1ght Backl1ght Nov 9, 2025

Choose a reason for hiding this comment

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

We need some comments/explanation for this workaround.

I have update a more detailed pr description.

If this is related to cache, is it possible for us to fix that instead?

No I think, the saved FieldDecl will be used in later actions while anonymous structs/unions require us to use saved FieldDecl. Another possible way is clear the saved FieldDecl somewhere, but I can not find a proper place.

if (!KnownField) {
const IdentifierInfo *FieldName = D->getFieldName();
ValueDecl *VD = SemaRef.tryLookupUnambiguousFieldDecl(RD, FieldName);
Expand Down
23 changes: 23 additions & 0 deletions clang/test/SemaTemplate/temp_arg_nontype_cxx2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,26 @@ namespace error_on_type_instantiation {
template void g<int>();
// expected-note@-1 {{in instantiation of function template specialization}}
}

namespace GH166784 {

struct A {
int a;
};
struct B {
int b;
};
template <A a> void f() {
static_assert(a.a == 42);
}
template <B b> void f() {
static_assert(b.b == 42);
}

using T1 = decltype(f<{.a = 42}>());
using T2 = decltype(f<A{.a = 42}>());

using T3 = decltype(f<{.b = 42}>());
using T4 = decltype(f<B{.b = 42}>());

} // namespace GH166784
Loading