mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
77010: IASTClassSpecifier#getDeclarations() returns incomplete information
This commit is contained in:
parent
3d1becef8c
commit
e58b686575
3 changed files with 89 additions and 1 deletions
|
@ -370,4 +370,45 @@ public class CompleteParseASTSymbolIteratorTest extends CompleteParseBaseTest {
|
|||
assertEquals( i.next(), helper );
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
|
||||
public void testBug77010() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write(" struct Example{ \n"); //$NON-NLS-1$
|
||||
writer.write(" int *deref(); \n"); //$NON-NLS-1$
|
||||
writer.write(" int const *deref() const; \n"); //$NON-NLS-1$
|
||||
writer.write(" int volatile *deref() volatile; \n"); //$NON-NLS-1$
|
||||
writer.write(" int const volatile *deref() const volatile; \n"); //$NON-NLS-1$
|
||||
writer.write(" }; \n"); //$NON-NLS-1$
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
|
||||
IASTClassSpecifier Example = (IASTClassSpecifier) i.next();
|
||||
assertFalse( i.hasNext() );
|
||||
i = Example.getDeclarations();
|
||||
IASTMethod deref = (IASTMethod) i.next();
|
||||
assertFalse( deref.getReturnType().isConst() );
|
||||
assertFalse( deref.getReturnType().isVolatile() );
|
||||
assertFalse( deref.isConst() );
|
||||
assertFalse( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertTrue( deref.getReturnType().isConst() );
|
||||
assertFalse( deref.getReturnType().isVolatile() );
|
||||
assertTrue( deref.isConst() );
|
||||
assertFalse( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertFalse( deref.getReturnType().isConst() );
|
||||
assertTrue( deref.getReturnType().isVolatile() );
|
||||
assertFalse( deref.isConst() );
|
||||
assertTrue( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertTrue( deref.getReturnType().isConst() );
|
||||
assertTrue( deref.getReturnType().isVolatile() );
|
||||
assertTrue( deref.isConst() );
|
||||
assertTrue( deref.isVolatile() );
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*/
|
||||
package org.eclipse.cdt.core.parser.tests;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -25,9 +27,12 @@ import org.eclipse.cdt.core.parser.ParserFactoryError;
|
|||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractTypeSpecifierDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
|
@ -93,4 +98,44 @@ public class StructuralParseTest extends TestCase {
|
|||
IASTFunction foo = (IASTFunction) template.getOwnedDeclaration();
|
||||
assertEquals( foo.getName(), "foo" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug77010() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write(" struct Example{ \n"); //$NON-NLS-1$
|
||||
writer.write(" int *deref(); \n"); //$NON-NLS-1$
|
||||
writer.write(" int const *deref() const; \n"); //$NON-NLS-1$
|
||||
writer.write(" int volatile *deref() volatile; \n"); //$NON-NLS-1$
|
||||
writer.write(" int const volatile *deref() const volatile; \n"); //$NON-NLS-1$
|
||||
writer.write(" }; \n"); //$NON-NLS-1$
|
||||
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTClassSpecifier Ex = (IASTClassSpecifier) ((IASTAbstractTypeSpecifierDeclaration)i.next()).getTypeSpecifier();
|
||||
|
||||
i = Ex.getDeclarations();
|
||||
IASTMethod deref = (IASTMethod) i.next();
|
||||
assertFalse( deref.getReturnType().isConst() );
|
||||
assertFalse( deref.getReturnType().isVolatile() );
|
||||
assertFalse( deref.isConst() );
|
||||
assertFalse( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertTrue( deref.getReturnType().isConst() );
|
||||
assertFalse( deref.getReturnType().isVolatile() );
|
||||
assertTrue( deref.isConst() );
|
||||
assertFalse( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertFalse( deref.getReturnType().isConst() );
|
||||
assertTrue( deref.getReturnType().isVolatile() );
|
||||
assertFalse( deref.isConst() );
|
||||
assertTrue( deref.isVolatile() );
|
||||
|
||||
deref = (IASTMethod) i.next();
|
||||
assertTrue( deref.getReturnType().isConst() );
|
||||
assertTrue( deref.getReturnType().isVolatile() );
|
||||
assertTrue( deref.isConst() );
|
||||
assertTrue( deref.isVolatile() );
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -935,7 +935,9 @@ public class ParserSymbolTable {
|
|||
|
||||
//if none of them are static, then the function can be overloaded if they differ in the type
|
||||
//of their implicit object parameter.
|
||||
if( origSymbol.compareCVQualifiersTo( newSymbol ) != 0 ){
|
||||
if( (origSymbol.getTypeInfo().getTypeBits()& ( ITypeInfo.isConst | ITypeInfo.isVolatile )) !=
|
||||
(newSymbol.getTypeInfo().getTypeBits() & ( ITypeInfo.isConst | ITypeInfo.isVolatile )) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue