mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
Bug 498393 - Do not cache bases computed when a class is incomplete
Change-Id: Ieddb15ff1cd784710a19d85879bb0d7b40f425b3
This commit is contained in:
parent
c180a3e798
commit
d3d7a4e84a
4 changed files with 34 additions and 2 deletions
|
@ -10149,6 +10149,30 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
public void testOverloadedOperatorWithInheritanceDistance_335387() throws Exception {
|
public void testOverloadedOperatorWithInheritanceDistance_335387() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct Object {
|
||||||
|
// bool IsOk() const;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct Bitmap;
|
||||||
|
//
|
||||||
|
// struct Region : Object {
|
||||||
|
// Region(const Bitmap& bmp) {
|
||||||
|
// Union(bmp);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// void Union(const Region&);
|
||||||
|
// void Union(const Bitmap&);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct Bitmap : Object {};
|
||||||
|
//
|
||||||
|
// void waldo(Bitmap& icon) {
|
||||||
|
// icon.IsOk(); // ERROR: "Method 'IsOk' could not be resolved"
|
||||||
|
// }
|
||||||
|
public void testBaseComputationWhileTypeIsIncomplete_498393() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// namespace ns {int a;}
|
// namespace ns {int a;}
|
||||||
// using ns::a;
|
// using ns::a;
|
||||||
|
|
|
@ -26,6 +26,8 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
|
||||||
*/
|
*/
|
||||||
public interface ICPPBase extends Cloneable {
|
public interface ICPPBase extends Cloneable {
|
||||||
public static final ICPPBase[] EMPTY_BASE_ARRAY = {};
|
public static final ICPPBase[] EMPTY_BASE_ARRAY = {};
|
||||||
|
/** @since 6.0 */
|
||||||
|
public static final ICPPBase[] NO_BASES_BECAUSE_TYPE_IS_INCOMPLETE = {};
|
||||||
|
|
||||||
public static final int v_private = ICPPASTBaseSpecifier.v_private;
|
public static final int v_private = ICPPASTBaseSpecifier.v_private;
|
||||||
public static final int v_protected = ICPPASTBaseSpecifier.v_protected;
|
public static final int v_protected = ICPPASTBaseSpecifier.v_protected;
|
||||||
|
|
|
@ -317,7 +317,13 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
|
||||||
@Override
|
@Override
|
||||||
public ICPPBase[] getBases() {
|
public ICPPBase[] getBases() {
|
||||||
if (bases == null) {
|
if (bases == null) {
|
||||||
bases = ClassTypeHelper.getBases(this);
|
ICPPBase[] result = ClassTypeHelper.getBases(this);
|
||||||
|
// Do not cache the computed bases if the class is incomplete.
|
||||||
|
// When the class becomes complete, the answer may be different.
|
||||||
|
if (result != ICPPBase.NO_BASES_BECAUSE_TYPE_IS_INCOMPLETE) {
|
||||||
|
bases = result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return bases;
|
return bases;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class ClassTypeHelper {
|
||||||
if (backup != null)
|
if (backup != null)
|
||||||
return backup.getBases();
|
return backup.getBases();
|
||||||
|
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
return ICPPBase.NO_BASES_BECAUSE_TYPE_IS_INCOMPLETE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue