diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index e9b45c96e7a..a964886ff26 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -4689,6 +4689,19 @@ public class AST2Tests extends AST2TestBase { parseAndCheckBindings(code, C, true); parseAndCheckBindings(code, CPP, true); } + + // struct test { + // int field; + // }; + // + // int main() { + // struct test t; + // const typeof(t) x; + // x.field; + // } + public void testTypeofInsideQualifier_471907() throws Exception { + parseAndCheckBindings(getAboveComment(), C); + } // void test(int count) { // switch(count) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java index 604be21a982..f585a406707 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CQualifierType.java @@ -10,22 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IProblemBinding; -import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier; import org.eclipse.cdt.core.dom.ast.c.ICQualifierType; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; -import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.core.runtime.CoreException; public class CQualifierType implements ICQualifierType, ITypeContainer, ISerializableType { @@ -38,7 +29,7 @@ public class CQualifierType implements ICQualifierType, ITypeContainer, ISeriali * CQualifierType has an IBasicType to keep track of the basic type information. */ public CQualifierType(ICASTDeclSpecifier declSpec) { - this.type = resolveType(declSpec); + this.type = CVisitor.createBaseType(declSpec); this.isConst = declSpec.isConst(); this.isVolatile = declSpec.isVolatile(); this.isRestrict = declSpec.isRestrict(); @@ -95,32 +86,6 @@ public class CQualifierType implements ICQualifierType, ITypeContainer, ISeriali return isRestrict; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IQualifierType#getType() - */ - private IType resolveType(ICASTDeclSpecifier declSpec) { - IBinding b = null; - if (declSpec instanceof ICASTTypedefNameSpecifier) { - ICASTTypedefNameSpecifier nameSpec = (ICASTTypedefNameSpecifier) declSpec; - b = nameSpec.getName().resolveBinding(); - } else if (declSpec instanceof IASTElaboratedTypeSpecifier) { - IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) declSpec; - b = elabTypeSpec.getName().resolveBinding(); - } else if (declSpec instanceof IASTCompositeTypeSpecifier) { - IASTCompositeTypeSpecifier compTypeSpec = (IASTCompositeTypeSpecifier) declSpec; - b = compTypeSpec.getName().resolveBinding(); - } else if (declSpec instanceof IASTEnumerationSpecifier) { - return new CEnumeration(((IASTEnumerationSpecifier) declSpec).getName()); - } else { - return new CBasicType((ICASTSimpleDeclSpecifier) declSpec); - } - - if (b instanceof IType && !(b instanceof IProblemBinding)) - return (IType) b; - - return new ProblemType(ISemanticProblem.TYPE_UNRESOLVED_NAME); - } - @Override public IType getType() { return type;