1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-14 20:45:22 +02:00

Bug 376246: Name resolution in catch handler of function definition.

This commit is contained in:
Markus Schorn 2012-04-26 10:13:11 +02:00
parent ba5775f033
commit 755d3975a6
2 changed files with 14 additions and 6 deletions

View file

@ -9592,4 +9592,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions", assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
functions[calls.length - 1], functions[calls.length - 2]); functions[calls.length - 1], functions[calls.length - 2]);
} }
// void f(int x) try {
// } catch(...) {
// (void)x;
// }
public void testParentScopeOfCatchHandler_376246() throws Exception {
parseAndCheckBindings();
}
} }

View file

@ -13,11 +13,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics; package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -1264,7 +1260,11 @@ public class CPPVisitor extends ASTQueries {
} else if (parent instanceof IASTStatement) { } else if (parent instanceof IASTStatement) {
scope = getContainingScope((IASTStatement) parent); scope = getContainingScope((IASTStatement) parent);
} else if (parent instanceof IASTFunctionDefinition) { } else if (parent instanceof IASTFunctionDefinition) {
IASTFunctionDeclarator fnDeclarator = ((IASTFunctionDefinition) parent).getDeclarator(); final IASTFunctionDefinition fdef = (IASTFunctionDefinition) parent;
if (statement instanceof ICPPASTCatchHandler)
return fdef.getScope();
IASTFunctionDeclarator fnDeclarator = fdef.getDeclarator();
IASTName name = findInnermostDeclarator(fnDeclarator).getName(); IASTName name = findInnermostDeclarator(fnDeclarator).getName();
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
IASTName[] ns = ((ICPPASTQualifiedName) name).getNames(); IASTName[] ns = ((ICPPASTQualifiedName) name).getNames();