mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 22:35:43 +02:00
Bug 409100 - __is_base_of doesn't work with typedef
Change-Id: I3d108ef673d8e9f8feb799c1bc451bec8855cea4 Reviewed-on: https://git.eclipse.org/r/13167 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
57260c389d
commit
9b1c2b0313
2 changed files with 15 additions and 0 deletions
|
@ -10154,6 +10154,16 @@ public class AST2CPPTests extends AST2TestBase {
|
|||
public void testIsBaseOf_399353() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
// struct base {};
|
||||
// struct derived : base {};
|
||||
// typedef derived derived2;
|
||||
// const bool value = __is_base_of(base, derived2);
|
||||
public void testIsBaseOf_409100() throws Exception {
|
||||
BindingAssertionHelper b = getAssertionHelper();
|
||||
IVariable var = b.assertNonProblem("value");
|
||||
assertEquals(1 /*true */, var.getInitialValue().numericalValue().longValue());
|
||||
}
|
||||
|
||||
// template <bool> struct B{};
|
||||
// template <>
|
||||
|
|
|
@ -69,12 +69,15 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinary;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.TypeTraits;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||
|
||||
/**
|
||||
* Represents values of variables, enumerators or expressions. The primary purpose of
|
||||
* the representation is to support instantiation of templates with non-type template parameters.
|
||||
|
@ -349,6 +352,8 @@ public class Value implements IValue {
|
|||
IType type1, IType type2, IASTNode point) {
|
||||
switch (operator) {
|
||||
case __is_base_of:
|
||||
type1 = SemanticUtil.getNestedType(type1, TDEF);
|
||||
type2 = SemanticUtil.getNestedType(type2, TDEF);
|
||||
if (type1 instanceof ICPPClassType && type2 instanceof ICPPClassType) {
|
||||
return ClassTypeHelper.isSubclass((ICPPClassType) type2, (ICPPClassType) type1) ? 1 : 0;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue