summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-05-27 01:29:40 (EDT)
committer Sergey Prigogin2013-05-28 00:47:08 (EDT)
commit9b1c2b0313fa0f0e6b878a2a4c74ae0dc463f134 (patch)
treec51c1d100567e5ed71b6641f9420d2094bd1b2b9
parent57260c389d6b25d3e8aceacb93b95e94ff840974 (diff)
downloadorg.eclipse.cdt-9b1c2b0313fa0f0e6b878a2a4c74ae0dc463f134.zip
org.eclipse.cdt-9b1c2b0313fa0f0e6b878a2a4c74ae0dc463f134.tar.gz
org.eclipse.cdt-9b1c2b0313fa0f0e6b878a2a4c74ae0dc463f134.tar.bz2
Bug 409100 - __is_base_of doesn't work with typedefrefs/changes/67/13167/3
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>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java5
2 files changed, 15 insertions, 0 deletions
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 150c0c9..f52ecf9 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 <bool> 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 700f42d..914bbee 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 {