mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
Bug 472101 - Do not include variables declared in the condition of an
if, while, or switch statement in the enclosing block scope Change-Id: Idd90d85f705af11c84f31ca830eb86682a046b87 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
e091732356
commit
f3141139f8
2 changed files with 16 additions and 6 deletions
|
@ -10091,6 +10091,16 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
assertSame(g2, g3);
|
assertSame(g2, g3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// int test() {
|
||||||
|
// extern int *e();
|
||||||
|
// if (auto r = e()) { return *r; }
|
||||||
|
// int r = 12;
|
||||||
|
// return r;
|
||||||
|
// }
|
||||||
|
public void testVariableDeclarationInIfStatement() throws Exception {
|
||||||
|
parseAndCheckBindings();
|
||||||
|
}
|
||||||
|
|
||||||
// class A : A {
|
// class A : A {
|
||||||
// };
|
// };
|
||||||
public void testRecursiveClassInheritance_357256() throws Exception {
|
public void testRecursiveClassInheritance_357256() throws Exception {
|
||||||
|
|
|
@ -1503,6 +1503,12 @@ public class CPPSemantics {
|
||||||
} else {
|
} else {
|
||||||
nodes= new IASTNode[] {initDeclaration};
|
nodes= new IASTNode[] {initDeclaration};
|
||||||
}
|
}
|
||||||
|
} else if (parent instanceof ICPPASTSwitchStatement) {
|
||||||
|
nodes = new IASTNode[] { ((ICPPASTSwitchStatement) parent).getControllerDeclaration() };
|
||||||
|
} else if (parent instanceof ICPPASTIfStatement) {
|
||||||
|
nodes = new IASTNode[] { ((ICPPASTIfStatement) parent).getConditionDeclaration() };
|
||||||
|
} else if (parent instanceof ICPPASTWhileStatement) {
|
||||||
|
nodes = new IASTNode[] { ((ICPPASTWhileStatement) parent).getConditionDeclaration() };
|
||||||
} else if (parent instanceof ICPPASTRangeBasedForStatement) {
|
} else if (parent instanceof ICPPASTRangeBasedForStatement) {
|
||||||
ICPPASTRangeBasedForStatement forStatement = (ICPPASTRangeBasedForStatement) parent;
|
ICPPASTRangeBasedForStatement forStatement = (ICPPASTRangeBasedForStatement) parent;
|
||||||
final IASTDeclaration decl = forStatement.getDeclaration();
|
final IASTDeclaration decl = forStatement.getDeclaration();
|
||||||
|
@ -1632,12 +1638,6 @@ public class CPPSemantics {
|
||||||
declaration = ((IASTDeclarationStatement) node).getDeclaration();
|
declaration = ((IASTDeclarationStatement) node).getDeclaration();
|
||||||
} else if (node instanceof ICPPASTCatchHandler) {
|
} else if (node instanceof ICPPASTCatchHandler) {
|
||||||
declaration = ((ICPPASTCatchHandler) node).getDeclaration();
|
declaration = ((ICPPASTCatchHandler) node).getDeclaration();
|
||||||
} else if (node instanceof ICPPASTSwitchStatement) {
|
|
||||||
declaration = ((ICPPASTSwitchStatement) node).getControllerDeclaration();
|
|
||||||
} else if (node instanceof ICPPASTIfStatement) {
|
|
||||||
declaration = ((ICPPASTIfStatement) node).getConditionDeclaration();
|
|
||||||
} else if (node instanceof ICPPASTWhileStatement) {
|
|
||||||
declaration = ((ICPPASTWhileStatement) node).getConditionDeclaration();
|
|
||||||
} else if (node instanceof IASTParameterDeclaration) {
|
} else if (node instanceof IASTParameterDeclaration) {
|
||||||
IASTParameterDeclaration parameterDeclaration = (IASTParameterDeclaration) node;
|
IASTParameterDeclaration parameterDeclaration = (IASTParameterDeclaration) node;
|
||||||
IASTDeclarator dtor = parameterDeclaration.getDeclarator();
|
IASTDeclarator dtor = parameterDeclaration.getDeclarator();
|
||||||
|
|
Loading…
Add table
Reference in a new issue