1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 391190: Using address as template argument.

This commit is contained in:
Markus Schorn 2012-10-05 09:16:27 +02:00 committed by Sergey Prigogin
parent 96385656cc
commit 5d6ea978bb
3 changed files with 24 additions and 2 deletions

View file

@ -6056,4 +6056,19 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testPointerToMemberAsDependentExpression_391001() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
// class Memory { };
// Memory memory;
// template<Memory* m> struct Container {
// struct iterator {
// int test;
// };
// };
// int main() {
// Container<&memory>::iterator it;
// it.test; // Field 'test' could not be resolved
// }
public void testAddressAsTemplateArgument_391190() throws Exception {
parseAndCheckBindings(getAboveComment(), CPP, true);
}
}

View file

@ -370,7 +370,10 @@ public class Value implements IValue {
* Tests whether the value depends on a template parameter.
*/
public static boolean isDependentValue(IValue nonTypeValue) {
return nonTypeValue != null && nonTypeValue.getEvaluation() != null;
if (nonTypeValue == null)
return false;
ICPPEvaluation eval = nonTypeValue.getEvaluation();
return eval != null && eval.isValueDependent();
}
/**

View file

@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@ -159,6 +160,9 @@ class PDOMCPPClassScope implements ICPPClassScope, IIndexScope {
if (!lookup.isPrefixLookup()) {
if (CharArrayUtils.equals(fBinding.getNameCharArray(), nameChars)) {
if (CPPClassScope.shallReturnConstructors(lookup.getLookupName(), false)){
if (fBinding instanceof ICPPClassSpecialization) {
return ((ICPPClassSpecialization) fBinding).getConstructors(lookup.getLookupPoint());
}
return fBinding.getConstructors();
}
return new IBinding[] {getClassNameBinding()};