danix800 added inline comments.
================
Comment at: clang/lib/AST/ASTImporter.cpp:3936-3937
+ return std::move(Err);
+ if (ToInitializer)
+ ToField->setInClassInitializer(ToInitializer);
return ToField;
----------------
balazske wrote:
> danix800 wrote:
> > Initializer could indirectly depends on this field and set the initializer
> > while importing.
> > `setInClassInitializer()` asserts that initializer should not be set more
> > than once:
> >
> > ```
> > static int ref_A();
> > static int ref_B();
> > struct A {
> > int a = ref_B();
> > };
> > struct B {
> > int b = ref_A();
> > };
> > int ref_B() { B b; return b.b; }
> > int ref_A() { A a; return a.a; }
> > ```
> This example code really causes problems. But import of `Expr` is not checked
> for recursion, the assertion in the new code fails for this test.
>
> Why do you want to use such code? It looks to cause infinite loop when
> executed. Even code like `class A { int b{b}; };` is probably not correct.
Like `int a{a};` this testcase is minimized to just show what might cause the
problem.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155574/new/
https://reviews.llvm.org/D155574
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits