You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
822 B
51 lines
822 B
7 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
7 years ago
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
7 years ago
|
*/
|
||
|
|
||
|
namespace recursive_call {
|
||
|
|
||
|
struct A {
|
||
|
A() { f = 0; }
|
||
|
int f;
|
||
|
A* getptr();
|
||
|
A* mk();
|
||
|
};
|
||
|
|
||
|
struct F {
|
||
|
A* mk();
|
||
|
};
|
||
|
|
||
|
int rec(A* a = nullptr) {
|
||
|
if (a == nullptr) {
|
||
|
A* a = new A();
|
||
|
int r = rec(a);
|
||
|
delete a;
|
||
|
return r;
|
||
|
}
|
||
|
|
||
|
return a->f;
|
||
|
};
|
||
|
|
||
|
int test_rec_ok() {
|
||
|
return rec(); // infer should not report here
|
||
|
}
|
||
|
|
||
|
A* rec2(F f, A* a = nullptr) {
|
||
|
if (a == nullptr) {
|
||
|
auto tmp = f.mk();
|
||
7 years ago
|
return rec2(f, tmp); // assertion failure because of abducedRefParam0 in
|
||
|
// `getptr`
|
||
7 years ago
|
}
|
||
|
return a->getptr();
|
||
|
}
|
||
|
|
||
7 years ago
|
int test_rec2_ok() {
|
||
7 years ago
|
F f;
|
||
7 years ago
|
return rec2(f)->f;
|
||
7 years ago
|
}
|
||
|
|
||
|
} // namespace recursive_call
|