mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
fix bug 86346
This commit is contained in:
parent
2d33ca0657
commit
ad1ab8d1d2
5 changed files with 56 additions and 7 deletions
|
@ -2041,6 +2041,26 @@ public class AST2CPPTests extends AST2BaseTest {
|
||||||
assertSame( printf, r2 );
|
assertSame( printf, r2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBug86346() throws Exception {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("struct S; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("extern S a; \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("void g( S ); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("void h() { \n"); //$NON-NLS-1$
|
||||||
|
buffer.append(" g( a ); \n"); //$NON-NLS-1$
|
||||||
|
buffer.append("} \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
|
||||||
|
CPPNameCollector col = new CPPNameCollector();
|
||||||
|
tu.getVisitor().visitTranslationUnit(col);
|
||||||
|
|
||||||
|
ICPPClassType S = (ICPPClassType) col.getName(0).resolveBinding();
|
||||||
|
IFunction g = (IFunction) col.getName(3).resolveBinding();
|
||||||
|
|
||||||
|
assertInstances( col, S, 3 );
|
||||||
|
assertInstances( col, g, 2 );
|
||||||
|
}
|
||||||
|
|
||||||
public void testBug86288() throws Exception
|
public void testBug86288() throws Exception
|
||||||
{
|
{
|
||||||
String code = "int *foo( int *b ) { return (int *)(b); }"; //$NON-NLS-1$
|
String code = "int *foo( int *b ) { return (int *)(b); }"; //$NON-NLS-1$
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,14 +26,14 @@ public interface ICPPBase {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public ICPPClassType getBaseClass();
|
public ICPPClassType getBaseClass() throws DOMException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The visibility qualifier applied to the base class.
|
* The visibility qualifier applied to the base class.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getVisibility();
|
public int getVisibility() throws DOMException;
|
||||||
|
|
||||||
public static final int v_private = ICPPASTBaseSpecifier.v_private;
|
public static final int v_private = ICPPASTBaseSpecifier.v_private;
|
||||||
public static final int v_protected = ICPPASTBaseSpecifier.v_protected;
|
public static final int v_protected = ICPPASTBaseSpecifier.v_protected;
|
||||||
|
@ -43,6 +44,6 @@ public interface ICPPBase {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isVirtual();
|
public boolean isVirtual() throws DOMException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,32 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
public class CPPBaseClause implements ICPPBase {
|
public class CPPBaseClause implements ICPPBase {
|
||||||
|
static public class CPPBaseProblem extends ProblemBinding implements ICPPBase {
|
||||||
|
public CPPBaseProblem( int id, char[] arg ) {
|
||||||
|
super( id, arg );
|
||||||
|
}
|
||||||
|
public ICPPClassType getBaseClass() throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVisibility() throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVirtual() throws DOMException {
|
||||||
|
throw new DOMException( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
ICPPASTBaseSpecifier base = null;
|
ICPPASTBaseSpecifier base = null;
|
||||||
|
|
||||||
public CPPBaseClause( ICPPASTBaseSpecifier base ){
|
public CPPBaseClause( ICPPASTBaseSpecifier base ){
|
||||||
|
|
|
@ -305,8 +305,12 @@ public class CPPClassType implements ICPPClassType, ICPPBinding {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
|
||||||
*/
|
*/
|
||||||
public ICPPBase [] getBases() {
|
public ICPPBase [] getBases() {
|
||||||
if( definition == null )
|
if( definition == null ){
|
||||||
return null; //TODO
|
checkForDefinition();
|
||||||
|
if( definition == null ){
|
||||||
|
return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) };
|
||||||
|
}
|
||||||
|
}
|
||||||
ICPPASTBaseSpecifier [] bases = definition.getBaseSpecifiers();
|
ICPPASTBaseSpecifier [] bases = definition.getBaseSpecifiers();
|
||||||
if( bases.length == 0 )
|
if( bases.length == 0 )
|
||||||
return ICPPBase.EMPTY_BASE_ARRAY;
|
return ICPPBase.EMPTY_BASE_ARRAY;
|
||||||
|
|
|
@ -517,6 +517,8 @@ public class CPPSemantics {
|
||||||
ICPPClassType cls = (ICPPClassType) t;
|
ICPPClassType cls = (ICPPClassType) t;
|
||||||
ICPPBase[] bases = cls.getBases();
|
ICPPBase[] bases = cls.getBases();
|
||||||
for( int i = 0; i < bases.length; i++ ){
|
for( int i = 0; i < bases.length; i++ ){
|
||||||
|
if( bases[i] instanceof IProblemBinding )
|
||||||
|
continue;
|
||||||
getAssociatedScopes( bases[i].getBaseClass(), namespaces, classes );
|
getAssociatedScopes( bases[i].getBaseClass(), namespaces, classes );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1744,8 +1746,12 @@ public class CPPSemantics {
|
||||||
ICPPConstructor [] constructors = ((ICPPClassType)t).getConstructors();
|
ICPPConstructor [] constructors = ((ICPPClassType)t).getConstructors();
|
||||||
|
|
||||||
if( constructors.length > 0 ){
|
if( constructors.length > 0 ){
|
||||||
//the list out of Arrays.asList does not support remove, which we need
|
if( constructors.length == 1 && constructors[0] instanceof IProblemBinding )
|
||||||
constructor = (ICPPConstructor) resolveFunction( data, constructors );
|
constructor = null;
|
||||||
|
else {
|
||||||
|
//the list out of Arrays.asList does not support remove, which we need
|
||||||
|
constructor = (ICPPConstructor) resolveFunction( data, constructors );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if( constructor != null && constructor.isExplicit() ){
|
if( constructor != null && constructor.isExplicit() ){
|
||||||
constructor = null;
|
constructor = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue