File tree 3 files changed +28
-4
lines changed 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -732,6 +732,9 @@ Bug Fixes in This Version
732
732
``thread_local `` instead of ``_Thread_local ``.
733
733
Fixes (`#70068 <https://github.com/llvm/llvm-project/issues/70068 >`_) and
734
734
(`#69167 <https://github.com/llvm/llvm-project/issues/69167 >`_)
735
+ - Clang now accepts anonymous members initialized with designated initializers
736
+ inside templates.
737
+ Fixes (`#65143 <https://github.com/llvm/llvm-project/issues/65143 >`_)
735
738
736
739
Bug Fixes to Compiler Builtins
737
740
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -11722,21 +11722,23 @@ TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
11722
11722
bool ExprChanged = false;
11723
11723
for (const DesignatedInitExpr::Designator &D : E->designators()) {
11724
11724
if (D.isFieldDesignator()) {
11725
- Desig.AddDesignator(Designator::CreateFieldDesignator(
11726
- D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
11727
11725
if (D.getFieldDecl()) {
11728
11726
FieldDecl *Field = cast_or_null<FieldDecl>(
11729
11727
getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
11730
11728
if (Field != D.getFieldDecl())
11731
11729
// Rebuild the expression when the transformed FieldDecl is
11732
11730
// different to the already assigned FieldDecl.
11733
11731
ExprChanged = true;
11732
+ if (Field->isAnonymousStructOrUnion())
11733
+ continue;
11734
11734
} else {
11735
11735
// Ensure that the designator expression is rebuilt when there isn't
11736
11736
// a resolved FieldDecl in the designator as we don't want to assign
11737
11737
// a FieldDecl to a pattern designator that will be instantiated again.
11738
11738
ExprChanged = true;
11739
11739
}
11740
+ Desig.AddDesignator(Designator::CreateFieldDesignator(
11741
+ D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
11740
11742
continue;
11741
11743
}
11742
11744
Original file line number Diff line number Diff line change @@ -9,17 +9,36 @@ union S {
9
9
};
10
10
11
11
void f (int x, auto ) {
12
- const S result { // expected-error {{field designator (null) does not refer to any field in type 'const S'}}
12
+ const S result {
13
13
.a = x
14
14
};
15
15
}
16
16
17
17
void g (void ) {
18
- f (0 , 0 ); // expected-note {{in instantiation of function template specialization 'PR61118::f<int>' requested here}}
18
+ f (0 , 0 );
19
19
}
20
20
21
21
} // end namespace PR61118
22
22
23
+ namespace GH65143 {
24
+ struct Inner {
25
+ int a;
26
+ };
27
+
28
+ struct Outer {
29
+ struct {
30
+ Inner inner;
31
+ };
32
+ };
33
+
34
+ template <int val> void f () {
35
+ constexpr Outer x{.inner = {val}};
36
+ static_assert (x.inner .a == val);
37
+ }
38
+
39
+ void bar () { f<4 >(); }
40
+ }
41
+
23
42
namespace GH62156 {
24
43
union U1 {
25
44
int x;
You can’t perform that action at this time.
0 commit comments