mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 11:45:38 +02:00
Revert "Bug 395243 - Error involving dependent expressions"
This reverts commit f429bd5482
.
This commit is contained in:
parent
8f09f3af07
commit
880ac74b26
8 changed files with 54 additions and 77 deletions
|
@ -6938,7 +6938,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
||||||
// static const int value = sizeof(waldo(f));
|
// static const int value = sizeof(waldo(f));
|
||||||
// };
|
// };
|
||||||
// typedef identity<Int<S<>::value>>::type reference;
|
// typedef identity<Int<S<>::value>>::type reference;
|
||||||
public void testDependentExpressions_395243() throws Exception {
|
public void _testDependentExpressions_395243() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,12 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
|
@ -29,33 +30,19 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
|
||||||
private static final ICPPFunctionType FUNCTION_TYPE=
|
private static final ICPPFunctionType FUNCTION_TYPE=
|
||||||
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
|
||||||
|
|
||||||
/**
|
public static ICPPFunction createForSample(IFunction sample) throws DOMException {
|
||||||
* Creates a CPPDeferredFunction given a set of overloaded functions
|
if (sample instanceof ICPPConstructor)
|
||||||
* (some of which may be templates) that the function might resolve to.
|
return new CPPUnknownConstructor(((ICPPConstructor) sample).getClassOwner());
|
||||||
* At least one candidate must be provided.
|
|
||||||
*
|
|
||||||
* @param candidates a set of overloaded functions, some of which may be templates
|
|
||||||
* @return the constructed CPPDeferredFunction
|
|
||||||
*/
|
|
||||||
public static ICPPFunction createForCandidates(ICPPFunction... candidates) {
|
|
||||||
if (candidates[0] instanceof ICPPConstructor)
|
|
||||||
return new CPPUnknownConstructor(((ICPPConstructor) candidates[0]).getClassOwner(), candidates);
|
|
||||||
|
|
||||||
final IBinding owner = candidates[0].getOwner();
|
final IBinding owner = sample.getOwner();
|
||||||
return new CPPDeferredFunction(owner, candidates[0].getNameCharArray(), candidates);
|
return new CPPDeferredFunction(owner, sample.getNameCharArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final IBinding fOwner;
|
private final IBinding fOwner;
|
||||||
private final ICPPFunction[] fCandidates;
|
|
||||||
|
|
||||||
public CPPDeferredFunction(IBinding owner, char[] name, ICPPFunction[] candidates) {
|
public CPPDeferredFunction(IBinding owner, char[] name) {
|
||||||
super(name);
|
super(name);
|
||||||
fOwner= owner;
|
fOwner= owner;
|
||||||
fCandidates = candidates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPPFunction[] getCandidates() {
|
|
||||||
return fCandidates;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,13 +8,11 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a reference to a constructor (instance), which cannot be resolved because
|
* Represents a reference to a constructor (instance), which cannot be resolved because
|
||||||
|
@ -23,11 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
public class CPPUnknownConstructor extends CPPDeferredFunction implements ICPPConstructor {
|
public class CPPUnknownConstructor extends CPPDeferredFunction implements ICPPConstructor {
|
||||||
|
|
||||||
public CPPUnknownConstructor(ICPPClassType owner) {
|
public CPPUnknownConstructor(ICPPClassType owner) {
|
||||||
super(owner, owner.getNameCharArray(), null);
|
super(owner, owner.getNameCharArray());
|
||||||
}
|
|
||||||
|
|
||||||
public CPPUnknownConstructor(ICPPClassType owner, ICPPFunction[] candidates) {
|
|
||||||
super(owner, owner.getNameCharArray(), candidates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2010, 2012 Wind River Systems, Inc. and others.
|
* Copyright (c) 2010 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,7 +7,6 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ public class CPPFunctionSet implements ICPPTwoPhaseBinding {
|
||||||
|
|
||||||
public void setToUnknown() {
|
public void setToUnknown() {
|
||||||
if (fName != null) {
|
if (fName != null) {
|
||||||
fName.setBinding(new CPPDeferredFunction(null, fName.toCharArray(), fBindings));
|
fName.setBinding(new CPPDeferredFunction(null, fName.toCharArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Mike Kucera (IBM)
|
* Mike Kucera (IBM)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -452,7 +451,7 @@ public class CPPSemantics {
|
||||||
final ASTNodeProperty namePropertyInParent = name.getPropertyInParent();
|
final ASTNodeProperty namePropertyInParent = name.getPropertyInParent();
|
||||||
if (binding == null && data.skippedScope != null) {
|
if (binding == null && data.skippedScope != null) {
|
||||||
if (data.hasFunctionArguments()) {
|
if (data.hasFunctionArguments()) {
|
||||||
binding= new CPPDeferredFunction(data.skippedScope, name.getSimpleID(), null);
|
binding= new CPPDeferredFunction(data.skippedScope, name.getSimpleID());
|
||||||
} else {
|
} else {
|
||||||
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
|
if (namePropertyInParent == IASTNamedTypeSpecifier.NAME) {
|
||||||
binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID());
|
binding= new CPPUnknownMemberClass(data.skippedScope, name.getSimpleID());
|
||||||
|
@ -2396,7 +2395,7 @@ public class CPPSemantics {
|
||||||
if (viableCount == 1)
|
if (viableCount == 1)
|
||||||
return fns[0];
|
return fns[0];
|
||||||
setTargetedFunctionsToUnknown(argTypes);
|
setTargetedFunctionsToUnknown(argTypes);
|
||||||
return CPPDeferredFunction.createForCandidates(fns);
|
return CPPDeferredFunction.createForSample(fns[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
IFunction[] ambiguousFunctions= null; // ambiguity, 2 functions are equally good
|
IFunction[] ambiguousFunctions= null; // ambiguity, 2 functions are equally good
|
||||||
|
@ -2404,7 +2403,7 @@ public class CPPSemantics {
|
||||||
|
|
||||||
// Loop over all functions
|
// Loop over all functions
|
||||||
List<FunctionCost> potentialCosts= null;
|
List<FunctionCost> potentialCosts= null;
|
||||||
ICPPFunction unknownFunction= null;
|
IFunction unknownFunction= null;
|
||||||
final CPPASTTranslationUnit tu = data.getTranslationUnit();
|
final CPPASTTranslationUnit tu = data.getTranslationUnit();
|
||||||
for (ICPPFunction fn : fns) {
|
for (ICPPFunction fn : fns) {
|
||||||
if (fn == null)
|
if (fn == null)
|
||||||
|
@ -2456,7 +2455,7 @@ public class CPPSemantics {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
setTargetedFunctionsToUnknown(argTypes);
|
setTargetedFunctionsToUnknown(argTypes);
|
||||||
return CPPDeferredFunction.createForCandidates(fns);
|
return CPPDeferredFunction.createForSample(unknownFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ambiguousFunctions != null) {
|
if (ambiguousFunctions != null) {
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -164,6 +163,7 @@ public class CPPTemplates {
|
||||||
static final int PACK_SIZE_DEFER = -1;
|
static final int PACK_SIZE_DEFER = -1;
|
||||||
static final int PACK_SIZE_FAIL = -2;
|
static final int PACK_SIZE_FAIL = -2;
|
||||||
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
|
static final int PACK_SIZE_NOT_FOUND = Integer.MAX_VALUE;
|
||||||
|
private static final ICPPFunction[] NO_FUNCTIONS = {};
|
||||||
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
static enum TypeSelection { PARAMETERS, RETURN_TYPE, PARAMETERS_AND_RETURN_TYPE }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1726,12 +1726,18 @@ public class CPPTemplates {
|
||||||
requireTemplate= false;
|
requireTemplate= false;
|
||||||
|
|
||||||
if (func instanceof ICPPFunctionTemplate) {
|
if (func instanceof ICPPFunctionTemplate) {
|
||||||
|
ICPPFunctionTemplate template= (ICPPFunctionTemplate) func;
|
||||||
|
try {
|
||||||
if (containsDependentType(fnArgs))
|
if (containsDependentType(fnArgs))
|
||||||
return new ICPPFunction[] {CPPDeferredFunction.createForCandidates(fns)};
|
return new ICPPFunction[] {CPPDeferredFunction.createForSample(template)};
|
||||||
|
|
||||||
if (requireTemplate && hasDependentArgument(tmplArgs))
|
|
||||||
return new ICPPFunction[] {CPPDeferredFunction.createForCandidates(fns)};
|
|
||||||
|
|
||||||
|
if (requireTemplate) {
|
||||||
|
if (hasDependentArgument(tmplArgs))
|
||||||
|
return new ICPPFunction[] {CPPDeferredFunction.createForSample(template)};
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return NO_FUNCTIONS;
|
||||||
|
}
|
||||||
haveTemplate= true;
|
haveTemplate= true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1797,11 +1803,15 @@ public class CPPTemplates {
|
||||||
|
|
||||||
// Extract template arguments and parameter types.
|
// Extract template arguments and parameter types.
|
||||||
if (!checkedForDependentType) {
|
if (!checkedForDependentType) {
|
||||||
|
try {
|
||||||
if (isDependentType(conversionType)) {
|
if (isDependentType(conversionType)) {
|
||||||
inst= CPPDeferredFunction.createForCandidates(functions);
|
inst= CPPDeferredFunction.createForSample(template);
|
||||||
done= true;
|
done= true;
|
||||||
}
|
}
|
||||||
checkedForDependentType= true;
|
checkedForDependentType= true;
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return functions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
CPPTemplateParameterMap map= new CPPTemplateParameterMap(1);
|
||||||
try {
|
try {
|
||||||
|
@ -1859,7 +1869,7 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] args, IASTNode point) {
|
ICPPTemplateArgument[] args, IASTNode point) {
|
||||||
try {
|
try {
|
||||||
if (target != null && isDependentType(target)) {
|
if (target != null && isDependentType(target)) {
|
||||||
return CPPDeferredFunction.createForCandidates(template);
|
return CPPDeferredFunction.createForSample(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (template instanceof ICPPConstructor || args == null)
|
if (template instanceof ICPPConstructor || args == null)
|
||||||
|
|
|
@ -145,7 +145,6 @@ public class EvalFunctionSet extends CPPEvaluation {
|
||||||
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
ICPPClassSpecialization within, int maxdepth, IASTNode point) {
|
||||||
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
ICPPTemplateArgument[] originalArguments = fFunctionSet.getTemplateArguments();
|
||||||
ICPPTemplateArgument[] arguments = originalArguments;
|
ICPPTemplateArgument[] arguments = originalArguments;
|
||||||
if (originalArguments != null)
|
|
||||||
arguments = instantiateArguments(originalArguments, tpMap, packOffset, within, point);
|
arguments = instantiateArguments(originalArguments, tpMap, packOffset, within, point);
|
||||||
|
|
||||||
IBinding originalOwner = fFunctionSet.getOwner();
|
IBinding originalOwner = fFunctionSet.getOwner();
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Nathan Ridge
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredFunction;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -186,24 +184,6 @@ public class EvalID extends CPPEvaluation {
|
||||||
return new EvalFunctionSet((CPPFunctionSet) binding, isAddressOf(expr));
|
return new EvalFunctionSet((CPPFunctionSet) binding, isAddressOf(expr));
|
||||||
}
|
}
|
||||||
if (binding instanceof ICPPUnknownBinding) {
|
if (binding instanceof ICPPUnknownBinding) {
|
||||||
ICPPTemplateArgument[] templateArgs = null;
|
|
||||||
final IASTName lastName = name.getLastName();
|
|
||||||
if (lastName instanceof ICPPASTTemplateId) {
|
|
||||||
try {
|
|
||||||
templateArgs= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) lastName);
|
|
||||||
} catch (DOMException e) {
|
|
||||||
return EvalFixed.INCOMPLETE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binding instanceof CPPDeferredFunction) {
|
|
||||||
CPPDeferredFunction deferredFunction = (CPPDeferredFunction) binding;
|
|
||||||
if (deferredFunction.getCandidates() != null) {
|
|
||||||
CPPFunctionSet functionSet = new CPPFunctionSet(deferredFunction.getCandidates(), templateArgs, null);
|
|
||||||
return new EvalFunctionSet(functionSet, isAddressOf(expr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IBinding owner = binding.getOwner();
|
IBinding owner = binding.getOwner();
|
||||||
if (owner instanceof IProblemBinding)
|
if (owner instanceof IProblemBinding)
|
||||||
return EvalFixed.INCOMPLETE;
|
return EvalFixed.INCOMPLETE;
|
||||||
|
@ -213,12 +193,21 @@ public class EvalID extends CPPEvaluation {
|
||||||
if (fieldOwnerType != null) {
|
if (fieldOwnerType != null) {
|
||||||
fieldOwner= new EvalFixed(fieldOwnerType, ValueCategory.LVALUE, Value.UNKNOWN);
|
fieldOwner= new EvalFixed(fieldOwnerType, ValueCategory.LVALUE, Value.UNKNOWN);
|
||||||
}
|
}
|
||||||
|
ICPPTemplateArgument[] templateArgs = null;
|
||||||
|
final IASTName lastName = name.getLastName();
|
||||||
|
if (lastName instanceof ICPPASTTemplateId) {
|
||||||
|
try {
|
||||||
|
templateArgs= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) lastName);
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return EvalFixed.INCOMPLETE;
|
||||||
|
}
|
||||||
|
}
|
||||||
return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr),
|
return new EvalID(fieldOwner, owner, name.getSimpleID(), isAddressOf(expr),
|
||||||
name instanceof ICPPASTQualifiedName, templateArgs);
|
name instanceof ICPPASTQualifiedName, templateArgs);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
// 9.3.1-3 Transformation to class member access within a non-static member function.
|
* 9.3.1-3 Transformation to class member access within a non-static member function.
|
||||||
|
*/
|
||||||
if (binding instanceof ICPPMember && !(binding instanceof IType)
|
if (binding instanceof ICPPMember && !(binding instanceof IType)
|
||||||
&& !(binding instanceof ICPPConstructor) &&!((ICPPMember) binding).isStatic()) {
|
&& !(binding instanceof ICPPConstructor) &&!((ICPPMember) binding).isStatic()) {
|
||||||
IType fieldOwnerType= withinNonStaticMethod(expr);
|
IType fieldOwnerType= withinNonStaticMethod(expr);
|
||||||
|
|
Loading…
Add table
Reference in a new issue