Skip to content

Commit f5a30cf

Browse files
committed
add check
1 parent 967b4d0 commit f5a30cf

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ Bug Fixes in This Version
459459
- Fixed a crash triggered by unterminated ``__has_embed``. (#GH162953)
460460
- Accept empty enumerations in MSVC-compatible C mode. (#GH114402)
461461
- Fixed false-positive shadow diagnostics for lambdas in explicit object member functions. (#GH163731)
462+
- Fixed a incorrect diagnostic for ambiguous function call that use a
463+
designated-initializer as template argument. (#GH166784)
462464

463465
Bug Fixes to Compiler Builtins
464466
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaInit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,6 +2937,8 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity,
29372937
}
29382938

29392939
FieldDecl *KnownField = D->getFieldDecl();
2940+
if (KnownField && KnownField->getParent() != RD)
2941+
KnownField = nullptr;
29402942
if (!KnownField) {
29412943
const IdentifierInfo *FieldName = D->getFieldName();
29422944
ValueDecl *VD = SemaRef.tryLookupUnambiguousFieldDecl(RD, FieldName);

clang/test/SemaTemplate/temp_arg_nontype_cxx2c.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,26 @@ namespace error_on_type_instantiation {
134134
template void g<int>();
135135
// expected-note@-1 {{in instantiation of function template specialization}}
136136
}
137+
138+
namespace GH166784 {
139+
140+
struct A {
141+
int a;
142+
};
143+
struct B {
144+
int b;
145+
};
146+
template <A a> void f() {
147+
static_assert(a.a == 42);
148+
}
149+
template <B b> void f() {
150+
static_assert(b.b == 42);
151+
}
152+
153+
using T1 = decltype(f<{.a = 42}>());
154+
using T2 = decltype(f<A{.a = 42}>());
155+
156+
using T3 = decltype(f<{.b = 42}>());
157+
using T4 = decltype(f<B{.b = 42}>());
158+
159+
} // namespace GH166784

0 commit comments

Comments
 (0)