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);
|
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>
|
// template<typename T>
|
||||||
// struct basic_string {
|
// struct basic_string {
|
||||||
// basic_string& operator+=(const T* s);
|
// basic_string& operator+=(const T* s);
|
||||||
|
@ -3759,34 +3778,34 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
//
|
//
|
||||||
// template<typename _Iterator>
|
// template<typename _Iterator>
|
||||||
// struct iterator_traits {
|
// struct iterator_traits {
|
||||||
// typedef typename _Iterator::reference reference;
|
// typedef typename _Iterator::reference reference;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// template<typename _Tp>
|
// template<typename _Tp>
|
||||||
// struct iterator_traits<_Tp*> {
|
// struct iterator_traits<_Tp*> {
|
||||||
// typedef _Tp& reference;
|
// typedef _Tp& reference;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// template<typename _Iterator, typename _Container>
|
// template<typename _Iterator, typename _Container>
|
||||||
// struct normal_iterator {
|
// struct normal_iterator {
|
||||||
// typedef iterator_traits<_Iterator> traits_type;
|
// typedef iterator_traits<_Iterator> traits_type;
|
||||||
// typedef typename traits_type::reference reference;
|
// typedef typename traits_type::reference reference;
|
||||||
// reference operator*() const;
|
// reference operator*() const;
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// template <typename T> struct vector {
|
// template <typename T> struct vector {
|
||||||
// typedef T* pointer;
|
// typedef T* pointer;
|
||||||
// typedef normal_iterator<pointer, vector> iterator;
|
// typedef normal_iterator<pointer, vector> iterator;
|
||||||
// iterator begin();
|
// iterator begin();
|
||||||
// iterator end();
|
// iterator end();
|
||||||
// };
|
// };
|
||||||
//
|
//
|
||||||
// typedef basic_string<char> string;
|
// typedef basic_string<char> string;
|
||||||
//
|
//
|
||||||
// void test() {
|
// void test() {
|
||||||
// vector<string> v;
|
// vector<string> v;
|
||||||
// for (auto s : v) {
|
// for (auto s : v) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
public void testTypedefPreservation_380498_3() throws Exception {
|
public void testTypedefPreservation_380498_3() throws Exception {
|
||||||
BindingAssertionHelper ba= getAssertionHelper();
|
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.IValue;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameterPackType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
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;
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +26,7 @@ public class CPPTemplateTypeArgument implements ICPPTemplateArgument {
|
||||||
private final IType fOriginalType;
|
private final IType fOriginalType;
|
||||||
|
|
||||||
public CPPTemplateTypeArgument(IType type) {
|
public CPPTemplateTypeArgument(IType type) {
|
||||||
this(type, type);
|
this(SemanticUtil.getSimplifiedType(type), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPTemplateTypeArgument(IType simplifiedType, IType originalType) {
|
public CPPTemplateTypeArgument(IType simplifiedType, IType originalType) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
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.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.TDEF;
|
||||||
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
|
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.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
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.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -1202,11 +1202,9 @@ public class CPPTemplates {
|
||||||
ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer;
|
ICPPPointerToMemberType ptm = (ICPPPointerToMemberType) typeContainer;
|
||||||
IType memberOfClass = ptm.getMemberOfClass();
|
IType memberOfClass = ptm.getMemberOfClass();
|
||||||
IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within, point);
|
IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within, point);
|
||||||
if (newMemberOfClass instanceof IQualifierType) {
|
IType classType = SemanticUtil.getNestedType(newMemberOfClass, CVTYPE | TDEF);
|
||||||
newMemberOfClass = ((IQualifierType) newMemberOfClass).getType();
|
if (!(classType instanceof ICPPClassType || classType instanceof UniqueType
|
||||||
}
|
|| classType instanceof ICPPUnknownBinding)) {
|
||||||
if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType
|
|
||||||
|| newMemberOfClass instanceof ICPPUnknownBinding)) {
|
|
||||||
return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE);
|
return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE);
|
||||||
}
|
}
|
||||||
if (newNestedType != nestedType || newMemberOfClass != memberOfClass) {
|
if (newNestedType != nestedType || newMemberOfClass != memberOfClass) {
|
||||||
|
|
|
@ -318,7 +318,7 @@ public class SemanticUtil {
|
||||||
/**
|
/**
|
||||||
* Simplifies type by resolving typedefs within the given type.
|
* Simplifies type by resolving typedefs within the given type.
|
||||||
*/
|
*/
|
||||||
static IType getSimplifiedType(IType type) {
|
public static IType getSimplifiedType(IType type) {
|
||||||
if (type instanceof ICPPFunctionType) {
|
if (type instanceof ICPPFunctionType) {
|
||||||
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
final ICPPFunctionType ft = (ICPPFunctionType) type;
|
||||||
IType ret = null;
|
IType ret = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue