1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-08 00:35:49 +02:00

Bug 522509 - Handle typedefs in __is_class builtin

Change-Id: Ief3efa8e660ab1f7ec11788be8dad69da2501aa6
This commit is contained in:
Nathan Ridge 2017-09-20 00:15:59 -04:00
parent ef5147a046
commit 2aeb75d147
2 changed files with 10 additions and 4 deletions

View file

@ -12387,4 +12387,12 @@ public class AST2CPPTests extends AST2CPPTestBase {
public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws Exception {
parseAndCheckBindings();
}
// class C {};
// typedef C D;
// constexpr bool waldo = __is_class(D);
public void testIsClassBuiltinOnTypedef_522509() throws Exception {
BindingAssertionHelper helper = getAssertionHelper();
helper.assertVariableValue("waldo", 1);
}
}

View file

@ -34,6 +34,7 @@ import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_is_union;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_sizeof;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeid;
import static org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression.op_typeof;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
@ -51,7 +52,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IValue;
import org.eclipse.cdt.core.dom.ast.IVariable;
@ -390,9 +390,7 @@ public class ValueFactory {
}
private static IValue applyUnaryTypeIdOperator(int operator, IType type, IASTNode point) {
while (type instanceof IQualifierType) {
type = ((IQualifierType) type).getType();
}
type = SemanticUtil.getNestedType(type, TDEF | CVTYPE);
switch (operator) {
case op_sizeof: