mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Bug 462348 - Perform ambiguity resolution on a method body sooner than
at the end of the class definition when necessary Change-Id: Ia5b17cfcd57f3b1d55281987b48582f084a2c11f Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
c652e20d9b
commit
198b722894
6 changed files with 62 additions and 1 deletions
|
@ -8762,4 +8762,16 @@ public class AST2TemplateTests extends AST2TestBase {
|
||||||
public void testClassSpecializationInEnumerator_457511() throws Exception {
|
public void testClassSpecializationInEnumerator_457511() throws Exception {
|
||||||
parseAndCheckBindings();
|
parseAndCheckBindings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template <typename> struct TypeTemplate {};
|
||||||
|
// template <int> struct Size_tTemplate {};
|
||||||
|
//
|
||||||
|
// template <typename... ParameterPack> struct Test {
|
||||||
|
// static constexpr int packSize() { return sizeof...(ParameterPack); }
|
||||||
|
//
|
||||||
|
// using type = TypeTemplate<Size_tTemplate<packSize()>>;
|
||||||
|
// };
|
||||||
|
public void testAmbiguityResolutionOrder_462348() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,4 +394,12 @@ public abstract class ASTNode implements IASTNode {
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If ambiguity resolution is in progress, and procesing of this node has been deferred,
|
||||||
|
* process it now. Has no effect if ambiguity resolution is not in progress.
|
||||||
|
*/
|
||||||
|
public void resolvePendingAmbiguities() {
|
||||||
|
((ASTTranslationUnit) getTranslationUnit()).resolvePendingAmbiguities(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -522,4 +522,10 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
||||||
assertNotFrozen();
|
assertNotFrozen();
|
||||||
fNodesOmitted = hasNodesOmitted;
|
fNodesOmitted = hasNodesOmitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If ambiguity resolution is in progress, and processing of 'node' has been deferred,
|
||||||
|
* process it now. Has no effect if ambiguity resolution is not in progress.
|
||||||
|
*/
|
||||||
|
public void resolvePendingAmbiguities(IASTNode node) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,26 @@ final class CPPASTAmbiguityResolver extends ASTVisitor {
|
||||||
CPPSemantics.populateCache((ICPPASTInternalScope) scope, declaration);
|
CPPSemantics.populateCache((ICPPASTInternalScope) scope, declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If 'node' has been deferred for later processing, process it now.
|
||||||
|
*/
|
||||||
|
public void resolvePendingAmbiguities(IASTNode node) {
|
||||||
|
if (!fDeferredNodes.isEmpty()) {
|
||||||
|
Deque<IASTNode> deferred = fDeferredNodes.getLast();
|
||||||
|
for (IASTNode deferredNode : deferred) {
|
||||||
|
if (deferredNode == node) {
|
||||||
|
int deferFunctions = fDeferFunctions;
|
||||||
|
fDeferFunctions = 0;
|
||||||
|
try {
|
||||||
|
deferredNode.accept(this);
|
||||||
|
} finally {
|
||||||
|
fDeferFunctions = deferFunctions;
|
||||||
|
}
|
||||||
|
deferred.remove(deferredNode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
||||||
private CPPNamespaceScope fScope;
|
private CPPNamespaceScope fScope;
|
||||||
private ICPPNamespace fBinding;
|
private ICPPNamespace fBinding;
|
||||||
private final CPPScopeMapper fScopeMapper= new CPPScopeMapper(this);
|
private final CPPScopeMapper fScopeMapper= new CPPScopeMapper(this);
|
||||||
|
private CPPASTAmbiguityResolver fAmbiguityResolver;
|
||||||
|
|
||||||
public CPPASTTranslationUnit() {
|
public CPPASTTranslationUnit() {
|
||||||
}
|
}
|
||||||
|
@ -190,11 +191,20 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolveAmbiguities() {
|
public void resolveAmbiguities() {
|
||||||
accept(new CPPASTAmbiguityResolver());
|
fAmbiguityResolver = new CPPASTAmbiguityResolver();
|
||||||
|
accept(fAmbiguityResolver);
|
||||||
|
fAmbiguityResolver = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IType createType(IASTTypeId typeid) {
|
protected IType createType(IASTTypeId typeid) {
|
||||||
return CPPVisitor.createType(typeid);
|
return CPPVisitor.createType(typeid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resolvePendingAmbiguities(IASTNode node) {
|
||||||
|
if (fAmbiguityResolver != null) {
|
||||||
|
fAmbiguityResolver.resolvePendingAmbiguities(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,6 +680,9 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
|
||||||
|
|
||||||
static ICPPEvaluation getReturnExpression(IASTFunctionDefinition functionDefinition) {
|
static ICPPEvaluation getReturnExpression(IASTFunctionDefinition functionDefinition) {
|
||||||
IASTReturnStatement returnStatement = null;
|
IASTReturnStatement returnStatement = null;
|
||||||
|
// Make sure ambiguity resolution has been performed on the function body, even
|
||||||
|
// if it's a class method and we're still processing the class declaration.
|
||||||
|
((ASTNode) functionDefinition).resolvePendingAmbiguities();
|
||||||
IASTStatement body = functionDefinition.getBody();
|
IASTStatement body = functionDefinition.getBody();
|
||||||
if (body instanceof IASTReturnStatement) {
|
if (body instanceof IASTReturnStatement) {
|
||||||
returnStatement = (IASTReturnStatement) body;
|
returnStatement = (IASTReturnStatement) body;
|
||||||
|
|
Loading…
Add table
Reference in a new issue