mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Name resolution for dependent names, bug 257194.
This commit is contained in:
parent
b0c1b22007
commit
d10ad69f49
3 changed files with 55 additions and 6 deletions
|
@ -69,6 +69,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -283,8 +284,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
// template < class T > class A { typedef int TYPE; };
|
||||
// template < class T > A<T>::TYPE foo(T);
|
||||
// template < class T > A<T>::TYPE foo(T);
|
||||
// template < class T > typename A<T>::TYPE foo(T);
|
||||
// template < class T > typename A<T>::TYPE foo(T);
|
||||
public void testStackOverflow_2() throws Exception {
|
||||
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
|
||||
CPPNameCollector col = new CPPNameCollector();
|
||||
|
@ -3481,4 +3482,36 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
bh.assertNonProblem("f1();", 2, ICPPUnknownBinding.class, IFunction.class);
|
||||
}
|
||||
|
||||
// template<typename T> class XT {
|
||||
// typename T::template type<T::a> x;
|
||||
// typename T::template type<typename T::A> y;
|
||||
// using T::b;
|
||||
// using typename T::B;
|
||||
// void m() {
|
||||
// T::f();
|
||||
// typename T::F();
|
||||
// }
|
||||
// };
|
||||
public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
parseAndCheckBindings(code, ParserLanguage.CPP);
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
ICPPUnknownBinding b= bh.assertNonProblem("a>", 1);
|
||||
assertFalse(b instanceof IType);
|
||||
b= bh.assertNonProblem("A>", 1);
|
||||
assertTrue(b instanceof IType);
|
||||
|
||||
ICPPUsingDeclaration ud= bh.assertNonProblem("b;", 1);
|
||||
b= (ICPPUnknownBinding) ud.getDelegates()[0];
|
||||
assertFalse(b instanceof IType);
|
||||
ud= bh.assertNonProblem("B;", 1);
|
||||
b= (ICPPUnknownBinding) ud.getDelegates()[0];
|
||||
assertTrue(b instanceof IType);
|
||||
|
||||
b= bh.assertNonProblem("f();", 1);
|
||||
assertFalse(b instanceof IType);
|
||||
b= bh.assertNonProblem("F();", 1);
|
||||
assertTrue(b instanceof IType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,14 @@ import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
|
||||
|
@ -213,6 +215,10 @@ public class Value implements IValue {
|
|||
cv= ((IVariable) b).getInitialValue();
|
||||
} else if (b instanceof IEnumerator) {
|
||||
cv= ((IEnumerator) b).getValue();
|
||||
} else if (b instanceof ICPPUnknownBinding && !(b instanceof IType)) {
|
||||
return "#0x0fffffff";
|
||||
// mstodo unknown bindings must be stored with the value, such that they can
|
||||
// be instantiated lated on, bug 245027
|
||||
}
|
||||
if (cv != null)
|
||||
return toObject(cv);
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
@ -124,11 +126,19 @@ public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
|||
}
|
||||
}
|
||||
if (!type) {
|
||||
if (parent instanceof ICPPASTNamedTypeSpecifier ||
|
||||
parent instanceof ICPPASTBaseSpecifier ||
|
||||
parent instanceof ICPPASTConstructorChainInitializer) {
|
||||
if (parent instanceof ICPPASTBaseSpecifier ||
|
||||
parent instanceof ICPPASTConstructorChainInitializer ||
|
||||
parent instanceof ICPPASTTypenameExpression) {
|
||||
type= true;
|
||||
} else if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||
} else if (parent instanceof ICPPASTNamedTypeSpecifier) {
|
||||
ICPPASTNamedTypeSpecifier nts= (ICPPASTNamedTypeSpecifier) parent;
|
||||
type= nts.isTypename();
|
||||
} else if (parent instanceof ICPPASTUsingDeclaration) {
|
||||
ICPPASTUsingDeclaration ud= (ICPPASTUsingDeclaration) parent;
|
||||
type= ud.isTypename();
|
||||
}
|
||||
|
||||
if (!type && parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
|
||||
function= true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue