mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Bug 393513. Graceful handling of ambiguous template arguments.
This commit is contained in:
parent
d722553646
commit
9016a57d56
4 changed files with 25 additions and 6 deletions
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
|
@ -276,7 +277,11 @@ public class CPPASTFieldReference extends ASTNode
|
|||
n= ns[ns.length - 1];
|
||||
}
|
||||
if (n instanceof ICPPASTTemplateId) {
|
||||
try {
|
||||
args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
|
||||
} catch (DOMException e) {
|
||||
return EvalFixed.INCOMPLETE;
|
||||
}
|
||||
}
|
||||
return new EvalID(ownerEval, qualifier, name.getSimpleID(), false, true, args);
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
|
@ -1669,7 +1670,7 @@ public class CPPTemplates {
|
|||
* @return an array of template arguments, currently modeled as IType objects.
|
||||
* The empty ICPPTemplateArgument array is returned if id is {@code null}
|
||||
*/
|
||||
public static ICPPTemplateArgument[] createTemplateArgumentArray(ICPPASTTemplateId id) {
|
||||
public static ICPPTemplateArgument[] createTemplateArgumentArray(ICPPASTTemplateId id) throws DOMException {
|
||||
ICPPTemplateArgument[] result= ICPPTemplateArgument.EMPTY_ARGUMENTS;
|
||||
if (id != null) {
|
||||
IASTNode[] args= id.getTemplateArguments();
|
||||
|
@ -1681,6 +1682,9 @@ public class CPPTemplates {
|
|||
} else if (arg instanceof ICPPASTExpression) {
|
||||
ICPPASTExpression expr= (ICPPASTExpression) arg;
|
||||
result[i]= new CPPTemplateNonTypeArgument(expr.getEvaluation(), expr);
|
||||
} else if (arg instanceof ICPPASTAmbiguousTemplateArgument) {
|
||||
IProblemBinding problem = new ProblemBinding(id, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS);
|
||||
throw new DOMException(problem);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected type: " + arg.getClass().getName()); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -196,7 +196,11 @@ public class EvalID extends CPPEvaluation {
|
|||
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),
|
||||
name instanceof ICPPASTQualifiedName, templateArgs);
|
||||
|
|
|
@ -20,7 +20,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
|
@ -116,11 +118,15 @@ public class LookupData extends ScopeLookupData {
|
|||
if (n == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
ICPPTemplateArgument[] args = null;
|
||||
if (n instanceof ICPPASTTemplateId) {
|
||||
fTemplateArguments= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
|
||||
} else {
|
||||
fTemplateArguments= null;
|
||||
try {
|
||||
args= CPPTemplates.createTemplateArgumentArray((ICPPASTTemplateId) n);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
fTemplateArguments= args;
|
||||
configureWith(n);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue