mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 45203. Added more tests and fixed issues uncovered by them.
This commit is contained in:
parent
4726136341
commit
2cb5f8a29a
2 changed files with 21 additions and 9 deletions
|
@ -243,8 +243,18 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
|
|||
// #define MACRO(t1, v1, t2, v3, t4, v4) t1 v1; t2 b; C v3; prefix##t4 v4
|
||||
|
||||
// MACRO(A, a, B, c, D, d);
|
||||
public void testMacro() throws Exception {
|
||||
public void testMacro_1() throws Exception {
|
||||
assertDefined("A", "B", "MACRO");
|
||||
assertDeclared();
|
||||
}
|
||||
|
||||
// typedef int INT;
|
||||
// #define MACRO(x) extern INT x
|
||||
|
||||
// MACRO(a);
|
||||
// INT b;
|
||||
public void testMacro_2() throws Exception {
|
||||
assertDefined("MACRO", "INT"); // INT has to be defined because it is used outside of MACRO.
|
||||
assertDeclared();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,6 +271,9 @@ public class BindingClassifier {
|
|||
if (fProcessedDefinedBindings.contains(binding))
|
||||
return;
|
||||
|
||||
if (fAst.getDeclarationsInAST(binding).length != 0)
|
||||
return; // Declared locally
|
||||
|
||||
if (!canForwardDeclare(binding))
|
||||
defineBinding(binding);
|
||||
|
||||
|
@ -318,7 +321,8 @@ public class BindingClassifier {
|
|||
} else if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
|
||||
canDeclare = fPreferences.forwardDeclareFunctions;
|
||||
} else if (binding instanceof IVariable) {
|
||||
canDeclare = fPreferences.forwardDeclareExternalVariables;
|
||||
if (((IVariable) binding).isExtern())
|
||||
canDeclare = fPreferences.forwardDeclareExternalVariables;
|
||||
}
|
||||
|
||||
if (canDeclare && !fPreferences.forwardDeclareTemplates
|
||||
|
@ -364,9 +368,8 @@ public class BindingClassifier {
|
|||
if (!markAsDefined(binding))
|
||||
return;
|
||||
|
||||
if (fAst.getDefinitionsInAST(binding).length != 0) {
|
||||
if (fAst.getDefinitionsInAST(binding).length != 0)
|
||||
return; // Defined locally
|
||||
}
|
||||
|
||||
List<IBinding> requiredBindings = getRequiredBindings(binding);
|
||||
for (IBinding requiredBinding : requiredBindings) {
|
||||
|
@ -381,11 +384,8 @@ public class BindingClassifier {
|
|||
|
||||
private void defineBindingForName(IASTName name) {
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (isPartOfExternalMacroDefinition(name)) {
|
||||
markAsDefined(binding);
|
||||
} else {
|
||||
if (!isPartOfExternalMacroDefinition(name))
|
||||
defineBinding(binding);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -432,7 +432,6 @@ public class BindingClassifier {
|
|||
private class BindingCollector extends ASTVisitor {
|
||||
BindingCollector() {
|
||||
super(true);
|
||||
shouldVisitImplicitNames = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -996,6 +995,9 @@ public class BindingClassifier {
|
|||
|
||||
@Override
|
||||
public int visit(IASTName name) {
|
||||
if (isPartOfExternalMacroDefinition(name))
|
||||
return PROCESS_CONTINUE;
|
||||
|
||||
// Add the binding associated with the name to the bindings that can be declared
|
||||
// (we assume that all bindings which have to be defined are already explicitly handled
|
||||
// elsewhere).
|
||||
|
|
Loading…
Add table
Reference in a new issue