diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 150c0c949f3..f52ecf91b20 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -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 struct B{}; // template <> diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 700f42d10e1..914bbee1cdb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -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 {