mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fixed a regression in name resolution.
This commit is contained in:
parent
b1f1dc77f0
commit
84e46a7b17
4 changed files with 38 additions and 20 deletions
|
@ -3704,6 +3704,25 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
bh.assertNonProblem("func(p)", 4, ICPPFunction.class);
|
||||
}
|
||||
|
||||
// template <class T>
|
||||
// struct C {
|
||||
// typedef void (T::*PMF)();
|
||||
// C(PMF member);
|
||||
// };
|
||||
//
|
||||
// struct A {
|
||||
// void m();
|
||||
// };
|
||||
//
|
||||
// typedef A B;
|
||||
//
|
||||
// void test() {
|
||||
// new C<B>(&B::m);
|
||||
// }
|
||||
public void testTypedef() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct basic_string {
|
||||
// basic_string& operator+=(const T* s);
|
||||
|
@ -3759,34 +3778,34 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
//
|
||||
// template<typename _Iterator>
|
||||
// struct iterator_traits {
|
||||
// typedef typename _Iterator::reference reference;
|
||||
// typedef typename _Iterator::reference reference;
|
||||
// };
|
||||
//
|
||||
// template<typename _Tp>
|
||||
// struct iterator_traits<_Tp*> {
|
||||
// typedef _Tp& reference;
|
||||
// typedef _Tp& reference;
|
||||
// };
|
||||
//
|
||||
// template<typename _Iterator, typename _Container>
|
||||
// struct normal_iterator {
|
||||
// typedef iterator_traits<_Iterator> traits_type;
|
||||
// typedef typename traits_type::reference reference;
|
||||
// reference operator*() const;
|
||||
// typedef iterator_traits<_Iterator> traits_type;
|
||||
// typedef typename traits_type::reference reference;
|
||||
// reference operator*() const;
|
||||
// };
|
||||
//
|
||||
// template <typename T> struct vector {
|
||||
// typedef T* pointer;
|
||||
// typedef normal_iterator<pointer, vector> iterator;
|
||||
// iterator begin();
|
||||
// iterator end();
|
||||
// typedef T* pointer;
|
||||
// typedef normal_iterator<pointer, vector> iterator;
|
||||
// iterator begin();
|
||||
// iterator end();
|
||||
// };
|
||||
//
|
||||
// typedef basic_string<char> string;
|
||||
//
|
||||
// void test() {
|
||||
// vector<string> v;
|
||||
// for (auto s : v) {
|
||||
// }
|
||||
// vector<string> v;
|
||||
// for (auto s : v) {
|
||||
// }
|
||||
// }
|
||||
public void testTypedefPreservation_380498_3() throws Exception {
|
||||
BindingAssertionHelper ba= getAssertionHelper();
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
|
||||
/**
|
||||
|
@ -25,7 +26,7 @@ public class CPPTemplateTypeArgument implements ICPPTemplateArgument {
|
|||
private final IType fOriginalType;
|
||||
|
||||
public CPPTemplateTypeArgument(IType type) {
|
||||
this(type, type);
|
||||
this(SemanticUtil.getSimplifiedType(type), type);
|
||||
}
|
||||
|
||||
public CPPTemplateTypeArgument(IType simplifiedType, IType originalType) {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
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.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
|
||||
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;
|
||||
|
||||
|
@ -44,7 +45,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -1202,11 +1202,9 @@ public class CPPTemplates {
|
|||
ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer;
|
||||
IType memberOfClass = ptm.getMemberOfClass();
|
||||
IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within, point);
|
||||
if (newMemberOfClass instanceof IQualifierType) {
|
||||
newMemberOfClass = ((IQualifierType) newMemberOfClass).getType();
|
||||
}
|
||||
if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType
|
||||
|| newMemberOfClass instanceof ICPPUnknownBinding)) {
|
||||
IType classType = SemanticUtil.getNestedType(newMemberOfClass, CVTYPE | TDEF);
|
||||
if (!(classType instanceof ICPPClassType || classType instanceof UniqueType
|
||||
|| classType instanceof ICPPUnknownBinding)) {
|
||||
return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE);
|
||||
}
|
||||
if (newNestedType != nestedType || newMemberOfClass != memberOfClass) {
|
||||
|
|
|
@ -318,7 +318,7 @@ public class SemanticUtil {
|
|||
/**
|
||||
* Simplifies type by resolving typedefs within the given type.
|
||||
*/
|
||||
static IType getSimplifiedType(IType type) {
|
||||
public static IType getSimplifiedType(IType type) {
|
||||
if (type instanceof ICPPFunctionType) {
|
||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||
IType ret = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue