Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2004-04-23 03:49:31 +0000
committerJohn Camelon2004-04-23 03:49:31 +0000
commit34f1154c4f4c7b867344a7d45453f73b72a70d32 (patch)
tree60b76d02e0f6713a4a034bd17d0987409312db8c
parent7d0db414636ad8c5219166a257b6bf61cc46c1c8 (diff)
downloadorg.eclipse.cdt-34f1154c4f4c7b867344a7d45453f73b72a70d32.tar.gz
org.eclipse.cdt-34f1154c4f4c7b867344a7d45453f73b72a70d32.tar.xz
org.eclipse.cdt-34f1154c4f4c7b867344a7d45453f73b72a70d32.zip
Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47926
-rw-r--r--core/org.eclipse.cdt.core.tests/ChangeLog3
-rw-r--r--core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java25
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/ChangeLog-parser3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java33
5 files changed, 50 insertions, 26 deletions
diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index 9ec4ffb974e..bb2d567e81e 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -1,4 +1,7 @@
2004-04-22 John Camelon
+ Added CompleteParseASTTest:testBug47926().
+
+2004-04-22 John Camelon
Updated test clients for IExpressionParser interface changes.
Added QuickParseASTTests.testBug59179().
diff --git a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java
index 4f1714ed406..1fb6b56a7f0 100644
--- a/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java
+++ b/core/org.eclipse.cdt.core.tests/failures/org/eclipse/cdt/core/parser/failedTests/FailedCompleteParseASTTest.java
@@ -136,28 +136,5 @@ public class FailedCompleteParseASTTest extends CompleteParseBaseTest
// IASTVariable x = (IASTVariable) i.next();
// assertFalse( i.hasNext() );
// assertAllReferences( 4 /*should be 5 */, createTaskList( new Task( cl /* , 2 */ ), new Task( a), new Task( pm), new Task( f2)));
- }
-
-
-
- public void testBug47926() throws Exception{
- StringBuffer buffer = new StringBuffer();
- buffer.append( "void f () {} \n" );
- buffer.append( "class A { }; \n" );
- buffer.append( "void main() { A * a = new A(); a->f(); } ");
-
- Iterator i = parse( buffer.toString() ).getDeclarations();
-
- IASTFunction f = (IASTFunction) i.next();
- IASTClassSpecifier classA = (IASTClassSpecifier)((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
-
- IASTFunction main = (IASTFunction) i.next();
-
- Iterator fnIter = getDeclarations( main );
- IASTVariable a = (IASTVariable) fnIter.next();
-
- //there should be no reference to f, but there is
- //assertAllReferences( 3, createTaskList( new Task( classA, 2 ), new Task( a ) ) );
- assertAllReferences( 4, createTaskList( new Task( classA, 2 ), new Task( a ), new Task( f ) ) );
- }
+ }
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
index a129d263f69..d87ab9d948d 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
@@ -1644,5 +1644,17 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertFalse( i.hasNext() );
}
+
+ public void testBug47926() throws Exception
+ {
+ Iterator i = parse( "void f() {} class A {}; void main() { A * a = new A(); a->f(); }", false ).getDeclarations();
+ IASTFunction f = (IASTFunction) i.next();
+ IASTClassSpecifier A = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next() ).getTypeSpecifier();
+ IASTFunction main = (IASTFunction) i.next();
+ assertFalse( i.hasNext() );
+ i = getDeclarations( main );
+ IASTVariable a = (IASTVariable) i.next();
+ assertAllReferences( 3, createTaskList( new Task( A, 2 ), new Task( a )));
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser
index a675da122a1..1495085848b 100644
--- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser
+++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser
@@ -1,4 +1,7 @@
2004-04-22 John Camelon
+ Fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=47926
+
+2004-04-22 John Camelon
Partial fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=59686
2004-04-22 John Camelon
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
index 2fde29a715f..31f7e58f7a5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
@@ -1056,7 +1056,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
// Try to figure out the result that this expression evaluates to
ExpressionResult expressionResult = getExpressionResultType(scope, kind, lhs, rhs, thirdExpression, typeId, literal, symbol);
-
+
+ if( symbol == null )
+ purgeBadReferences( kind, rhs );
+
+
// expression results could be empty, but should not be null
// assert expressionResult != null : expressionResult; //throw new ASTSemanticException();
@@ -1069,7 +1073,32 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return expression;
}
- /*
+ /**
+ * @param kind
+ * @param rhs
+ */
+ private void purgeBadReferences(Kind kind, IASTExpression rhs) {
+ if( rhs == null ) return;
+ if( kind == Kind.POSTFIX_ARROW_IDEXPRESSION || kind == Kind.POSTFIX_ARROW_TEMPL_IDEXP ||
+ kind == Kind.POSTFIX_DOT_IDEXPRESSION || kind == Kind.POSTFIX_DOT_TEMPL_IDEXPRESS )
+ {
+ ASTExpression astExpression = (ASTExpression) rhs;
+ Iterator refs = astExpression.getReferences().iterator();
+ String idExpression = astExpression.getIdExpression();
+ if( !idExpression.equals( ""))
+ {
+ while( refs.hasNext() )
+ {
+ IASTReference r = (IASTReference) refs.next();
+ if( r.getName().equals( idExpression ) )
+ refs.remove();
+ }
+ }
+ }
+
+ }
+
+ /*
* Try and dereference the symbol in the expression
*/
private ISymbol getExpressionSymbol(

Back to the top