mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
Bug 259460.
This commit is contained in:
parent
692c985d53
commit
fdf3bd4146
3 changed files with 21 additions and 4 deletions
|
@ -6279,12 +6279,22 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
}
|
||||
|
||||
// struct A {
|
||||
// void method() {
|
||||
// B method(B p, int& a = y) { // B is not defined
|
||||
// B b;
|
||||
// int x = y + 1;
|
||||
// return b;
|
||||
// }
|
||||
// struct B {};
|
||||
// int& x = y; // y is not defined
|
||||
// int y;
|
||||
// };
|
||||
public void _testScopeOfClassMember_259460() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||
public void testScopeOfClassMember_259460() throws Exception {
|
||||
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
|
||||
ba.assertNonProblem("B b", 1, ICPPClassType.class);
|
||||
ba.assertProblem("B p", 1);
|
||||
ba.assertProblem("B method", 1);
|
||||
ba.assertNonProblem("y + 1;", 1, ICPPField.class);
|
||||
ba.assertNonProblem("y) {", 1, ICPPField.class);
|
||||
ba.assertProblem("y; // y is not defined", 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1739,7 +1739,7 @@ public class CPPSemantics {
|
|||
if (temp instanceof IProblemBinding)
|
||||
continue;
|
||||
|
||||
if (!(temp instanceof ICPPMember) && !declaredBefore)
|
||||
if (!(temp instanceof ICPPMember) && !(temp instanceof IType) && !declaredBefore)
|
||||
continue;
|
||||
if (temp instanceof ICPPUsingDeclaration) {
|
||||
IBinding[] bindings = ((ICPPUsingDeclaration) temp).getDelegates();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -31,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
|
@ -292,6 +294,11 @@ class LookupData {
|
|||
|
||||
IASTNode parent = astName.getParent();
|
||||
while (parent != null && !(parent instanceof IASTFunctionDefinition)) {
|
||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||
if (prop == IASTParameterDeclaration.DECL_SPECIFIER ||
|
||||
prop == IASTFunctionDefinition.DECL_SPECIFIER) {
|
||||
return false;
|
||||
}
|
||||
parent = parent.getParent();
|
||||
}
|
||||
if (parent instanceof IASTFunctionDefinition) {
|
||||
|
|
Loading…
Add table
Reference in a new issue