Skip to content

Commit dbe5cd3

Browse files
committed
[Clang] Always rebuild AST nodes when rebuild default-arg/init
Signed-off-by: yronglin <[email protected]>
1 parent e6ee9be commit dbe5cd3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5416,6 +5416,8 @@ struct EnsureImmediateInvocationInDefaultArgs
54165416
EnsureImmediateInvocationInDefaultArgs(Sema &SemaRef)
54175417
: TreeTransform(SemaRef) {}
54185418

5419+
bool AlwaysRebuild() { return true; }
5420+
54195421
// Lambda can only have immediate invocations in the default
54205422
// args of their parameters, which is transformed upon calling the closure.
54215423
// The body is not a subexpression, so we have nothing to do.

clang/test/SemaCXX/cxx11-default-member-initializers.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,25 @@ void TypeTest_Element_Test::TestBody() {
9999
&TestBody_got != expect; // expected-warning {{inequality comparison result unused}}
100100
}
101101
} // namespace test_rebuild
102+
namespace test_rebuild2 {
103+
struct F {
104+
int g;
105+
};
106+
struct H {};
107+
struct I {
108+
I(const F &);
109+
I(H);
110+
};
111+
struct L {
112+
I i = I({.g = 0});
113+
};
114+
struct N : L {};
115+
116+
void f() {
117+
delete new L; // Ok
118+
delete new N; // Ok
119+
}
120+
} // namespace test_rebuild2
102121
#endif // __cplusplus >= 201703L
103122

104123
#if __cplusplus >= 202002L

0 commit comments

Comments
 (0)