1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

fix bug 93980 for C++

This commit is contained in:
Andrew Niefer 2005-05-18 21:08:47 +00:00
parent 238118db0b
commit 9ae1ab54c8

View file

@ -31,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier; import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTExpressionList; import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference; import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTForStatement; import org.eclipse.cdt.core.dom.ast.IASTForStatement;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression; import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
@ -125,6 +126,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTCompoundStatementExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointer;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTPointerToMember;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier; import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTSimpleDeclSpecifier;
@ -817,6 +819,8 @@ public class CPPVisitor {
return ((ICPPASTFunctionDeclarator)fdef.getDeclarator()).getFunctionScope(); return ((ICPPASTFunctionDeclarator)fdef.getDeclarator()).getFunctionScope();
} }
if( scope == null )
return getContainingScope( parent );
return scope; return scope;
} }
@ -1527,8 +1531,12 @@ public class CPPVisitor {
( spec.isUnsigned() ? CPPBasicType.IS_SHORT : 0 ); ( spec.isUnsigned() ? CPPBasicType.IS_SHORT : 0 );
if( spec instanceof IGPPASTSimpleDeclSpecifier ){ if( spec instanceof IGPPASTSimpleDeclSpecifier ){
IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) spec; IGPPASTSimpleDeclSpecifier gspec = (IGPPASTSimpleDeclSpecifier) spec;
bits |= ( gspec.isLongLong() ? GPPBasicType.IS_LONGLONG : 0 ); if( gspec.getTypeofExpression() != null ){
type = new GPPBasicType( spec.getType(), bits, getExpressionType(gspec.getTypeofExpression()) ); type = getExpressionType( gspec.getTypeofExpression() );
} else {
bits |= ( gspec.isLongLong() ? GPPBasicType.IS_LONGLONG : 0 );
type = new GPPBasicType( spec.getType(), bits, getExpressionType(gspec.getTypeofExpression()) );
}
} else { } else {
type = new CPPBasicType( spec.getType(), bits ); type = new CPPBasicType( spec.getType(), bits );
} }
@ -1777,6 +1785,14 @@ public class CPPVisitor {
return ((IArrayType)t).getType(); return ((IArrayType)t).getType();
} catch( DOMException e ){ } catch( DOMException e ){
} }
} else if( expression instanceof IGNUASTCompoundStatementExpression ){
IASTCompoundStatement compound = ((IGNUASTCompoundStatementExpression)expression).getCompoundStatement();
IASTStatement [] statements = compound.getStatements();
if( statements.length > 0 ){
IASTStatement st = statements[ statements.length - 1 ];
if( st instanceof IASTExpressionStatement )
return getExpressionType( ((IASTExpressionStatement)st).getExpression() );
}
} }
return null; return null;
} }