mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Another typedef preservation fix.
This commit is contained in:
parent
88a41df697
commit
c0903d7ad9
3 changed files with 27 additions and 11 deletions
|
@ -4813,6 +4813,29 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertEquals("vector<Element>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
|
assertEquals("vector<Element>::const_iterator", ASTTypeUtil.getType(it.getType(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename T> class char_traits {};
|
||||||
|
// template <typename C, typename T = char_traits<C>> class basic_string {};
|
||||||
|
//
|
||||||
|
// template <typename T> struct vector {
|
||||||
|
// typedef T* iterator;
|
||||||
|
// iterator begin();
|
||||||
|
// iterator end();
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// typedef basic_string<char> string;
|
||||||
|
//
|
||||||
|
// void test() {
|
||||||
|
// vector<string> v;
|
||||||
|
// for (auto s : v) {
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
public void testTypedefPreservation_380498_3() throws Exception {
|
||||||
|
BindingAssertionHelper ba= getAssertionHelper();
|
||||||
|
ICPPVariable s = ba.assertNonProblem("s :", "s", ICPPVariable.class);
|
||||||
|
assertTrue(s.getType() instanceof ITypedef);
|
||||||
|
assertEquals("string", ASTTypeUtil.getType(s.getType(), false));
|
||||||
|
}
|
||||||
|
|
||||||
// int f() {
|
// int f() {
|
||||||
// return 5;
|
// return 5;
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1262,7 +1262,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg != null) {
|
if (arg != null) {
|
||||||
IType t= arg.getTypeValue();
|
IType t= arg.getOriginalTypeValue();
|
||||||
if (t != null)
|
if (t != null)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.LVALUE;
|
||||||
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.PRVALUE;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
|
||||||
|
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
|
@ -126,15 +128,6 @@ public class EvalID extends CPPEvaluation {
|
||||||
@Override
|
@Override
|
||||||
public IValue getValue(IASTNode point) {
|
public IValue getValue(IASTNode point) {
|
||||||
// Name lookup is not needed here because it was already done in the "instantiate" method.
|
// Name lookup is not needed here because it was already done in the "instantiate" method.
|
||||||
// IBinding nameOwner = fNameOwner;
|
|
||||||
// if (nameOwner == null && fFieldOwner != null)
|
|
||||||
// nameOwner = (IBinding) fFieldOwner.getTypeOrFunctionSet(point);
|
|
||||||
//
|
|
||||||
// if (nameOwner instanceof ICPPClassType) {
|
|
||||||
// ICPPEvaluation eval = resolveName((ICPPClassType) nameOwner, fTemplateArgs, point);
|
|
||||||
// if (eval != null)
|
|
||||||
// return eval.getValue(point);
|
|
||||||
// }
|
|
||||||
return Value.create(this);
|
return Value.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +287,7 @@ public class EvalID extends CPPEvaluation {
|
||||||
} else if (nameOwner instanceof IType) {
|
} else if (nameOwner instanceof IType) {
|
||||||
IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point);
|
IType type = CPPTemplates.instantiateType((IType) nameOwner, tpMap, packOffset, within, point);
|
||||||
if (type instanceof IBinding)
|
if (type instanceof IBinding)
|
||||||
nameOwner = (IBinding) type;
|
nameOwner = (IBinding) getNestedType(type, TDEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)
|
if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding)
|
||||||
|
|
Loading…
Add table
Reference in a new issue