Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndrew Niefer2005-07-20 18:50:36 +0000
committerAndrew Niefer2005-07-20 18:50:36 +0000
commit6992f6f2484618e8714f8926984bc2fd529cb714 (patch)
tree75fef16a0b34fb62c23074bea572480ac02c100c /core
parent3aa6c3c3010d5ab1d055f4c350aa0cb8162e52b6 (diff)
downloadorg.eclipse.cdt-6992f6f2484618e8714f8926984bc2fd529cb714.tar.gz
org.eclipse.cdt-6992f6f2484618e8714f8926984bc2fd529cb714.tar.xz
org.eclipse.cdt-6992f6f2484618e8714f8926984bc2fd529cb714.zip
fix bug 90652
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java30
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java26
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java23
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java54
4 files changed, 80 insertions, 53 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
index 86ed3860b5e..287ae5a930f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecFailingTest.java
@@ -179,36 +179,6 @@ public class AST2CPPSpecFailingTest extends AST2SpecBaseTest {
}
}
-
- /**
- [--Start Example(CPP 10.2-3b):
- struct U { static int i; };
- struct V : U { };
- struct W : U { using U::i; };
- struct X : V, W { void foo(); };
- void X::foo() {
- i; //finds U::i in two ways: as W::i and U::i in V
- // no ambiguity because U::i is static
- }
- --End Example]
- */
- public void test10_2s3b() { // TODO raised bug 90652
- StringBuffer buffer = new StringBuffer();
- buffer.append("struct U { static int i; };\n"); //$NON-NLS-1$
- buffer.append("struct V : U { };\n"); //$NON-NLS-1$
- buffer.append("struct W : U { using U::i; };\n"); //$NON-NLS-1$
- buffer.append("struct X : V, W { void foo(); };\n"); //$NON-NLS-1$
- buffer.append("void X::foo() {\n"); //$NON-NLS-1$
- buffer.append("i; //finds U::i in two ways: as W::i and U::i in V\n"); //$NON-NLS-1$
- buffer.append("// no ambiguity because U::i is static\n"); //$NON-NLS-1$
- buffer.append("}\n"); //$NON-NLS-1$
- try {
- parse(buffer.toString(), ParserLanguage.CPP, true, 0);
- assertTrue(false);
- } catch (Exception e) {
- }
- }
-
/**
[--Start Example(CPP 14.5.3-1):
template<class T> class task;
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
index a7281027270..a8c19fb9152 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java
@@ -5290,6 +5290,32 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
}
/**
+ [--Start Example(CPP 10.2-3b):
+ struct U { static int i; };
+ struct V : U { };
+ struct W : U { using U::i; };
+ struct X : V, W { void foo(); };
+ void X::foo() {
+ i; //finds U::i in two ways: as W::i and U::i in V
+ // no ambiguity because U::i is static
+ }
+ --End Example]
+ */
+ public void test10_2s3b() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("struct U { static int i; };\n"); //$NON-NLS-1$
+ buffer.append("struct V : U { };\n"); //$NON-NLS-1$
+ buffer.append("struct W : U { using U::i; };\n"); //$NON-NLS-1$
+ buffer.append("struct X : V, W { void foo(); };\n"); //$NON-NLS-1$
+ buffer.append("void X::foo() {\n"); //$NON-NLS-1$
+ buffer.append("i; //finds U::i in two ways: as W::i and U::i in V\n"); //$NON-NLS-1$
+ buffer.append("// no ambiguity because U::i is static\n"); //$NON-NLS-1$
+ buffer.append("}\n"); //$NON-NLS-1$
+
+ parse(buffer.toString(), ParserLanguage.CPP, true, 0);
+ }
+
+ /**
[--Start Example(CPP 10.2-4):
class A {
public:
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 826624c42d4..9c9fa3f5230 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -5048,5 +5048,28 @@ public class AST2CPPTests extends AST2BaseTest {
public void testBug78800() throws Exception {
parseAndCheckBindings( "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;" ); //$NON-NLS-1$
}
+
+ public void test10_2s3b() throws Exception {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("struct U { static int i; }; \n"); //$NON-NLS-1$
+ buffer.append("struct V : U { }; \n"); //$NON-NLS-1$
+ buffer.append("struct W : U { using U::i; }; \n"); //$NON-NLS-1$
+ buffer.append("struct X : V, W { void foo(); }; \n"); //$NON-NLS-1$
+ buffer.append("void X::foo() { \n"); //$NON-NLS-1$
+ buffer.append(" i; \n"); //$NON-NLS-1$
+ buffer.append("} \n"); //$NON-NLS-1$
+
+ IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP, true, true );
+ CPPNameCollector col = new CPPNameCollector();
+ tu.accept( col );
+
+ ICPPField i = (ICPPField) col.getName(1).resolveBinding();
+ ICPPUsingDeclaration using = (ICPPUsingDeclaration) col.getName(6).resolveBinding();
+ ICPPDelegate [] delegates = using.getDelegates();
+ assertEquals( delegates.length, 1 );
+ assertSame( i, delegates[0].getBinding() );
+
+ assertSame( i, col.getName(16).resolveBinding() );
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
index 639d572b4ea..1701cbdf193 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java
@@ -1236,37 +1236,45 @@ public class CPPSemantics {
}
IBinding binding = ( n instanceof IBinding) ? (IBinding)n : ((IASTName)n).resolveBinding();
+ while( binding instanceof ICPPDelegate ){
+ binding = ((ICPPDelegate)binding).getBinding();
+ }
Object [] objs = ( names instanceof Object[] ) ? (Object[])names : null;
int idx = ( objs != null && objs.length > 0 ) ? 0 : -1;
Object o = ( idx != -1 ) ? objs[idx++] : names;
while( o != null ) {
IBinding b = ( o instanceof IBinding ) ? (IBinding) o : ((IASTName)o).resolveBinding();
- if( binding != b )
- return true;
-
- boolean ok = false;
- //3.4.5-4 if the id-expression in a class member access is a qualified id... the result
- //is not required to be a unique base class...
- if( binding instanceof ICPPClassType ){
- IASTNode parent = data.astName.getParent();
- if( parent instanceof ICPPASTQualifiedName &&
- parent.getPropertyInParent() == IASTFieldReference.FIELD_NAME )
- {
- ok = true;
+ if( b instanceof ICPPUsingDeclaration ){
+ objs = ArrayUtil.append( Object.class, objs, ((ICPPUsingDeclaration)b).getDelegates() );
+ } else {
+ while( b instanceof ICPPDelegate ){
+ b = ((ICPPDelegate)b).getBinding();
+ }
+ if( binding != b )
+ return true;
+
+ boolean ok = false;
+ //3.4.5-4 if the id-expression in a class member access is a qualified id... the result
+ //is not required to be a unique base class...
+ if( binding instanceof ICPPClassType ){
+ IASTNode parent = data.astName.getParent();
+ if( parent instanceof ICPPASTQualifiedName &&
+ parent.getPropertyInParent() == IASTFieldReference.FIELD_NAME )
+ {
+ ok = true;
+ }
}
- }
- //it is not ambiguous if they are the same thing and it is static or an enumerator
- if( binding instanceof IEnumerator ||
- (binding instanceof IFunction && ((ICPPInternalFunction)binding).isStatic( false )) ||
- (binding instanceof IVariable && ((IVariable)binding).isStatic()) )
- {
- ok = true;
+ //it is not ambiguous if they are the same thing and it is static or an enumerator
+ if( binding instanceof IEnumerator ||
+ (binding instanceof IFunction && ((ICPPInternalFunction)binding).isStatic( false )) ||
+ (binding instanceof IVariable && ((IVariable)binding).isStatic()) )
+ {
+ ok = true;
+ }
+ if( !ok )
+ return true;
}
- if( !ok )
- return true;
-
- next:
if( idx > -1 && idx < objs.length )
o = objs[idx++];
else

Back to the top