mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Fixed compiler warnings.
This commit is contained in:
parent
6e96e21cf0
commit
470a007439
4 changed files with 31 additions and 35 deletions
|
@ -31,10 +31,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|||
|
||||
/**
|
||||
* Handles ambiguities for simple declarations.
|
||||
* <br>
|
||||
* <pre>
|
||||
* class C {
|
||||
* C(D); // if D a type we have a constructor, otherwise this declares the field D.
|
||||
* C(D); // If D a type we have a constructor, otherwise this declares the field D.
|
||||
* };
|
||||
* </pre>
|
||||
*/
|
||||
public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
|
||||
private IASTSimpleDeclaration fSimpleDecl;
|
||||
|
@ -49,7 +50,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
|||
|
||||
@Override
|
||||
protected void beforeResolution() {
|
||||
// populate containing scope, so that it will not be affected by the alternative branches.
|
||||
// Populate containing scope, so that it will not be affected by the alternative branches.
|
||||
IScope scope= CPPVisitor.getContainingScope(this);
|
||||
if (scope instanceof IASTInternalScope) {
|
||||
((IASTInternalScope) scope).populateCache();
|
||||
|
@ -96,17 +97,17 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
|||
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
|
||||
IASTNode nodeToReplace= this;
|
||||
|
||||
// handle nested ambiguities first
|
||||
// Handle nested ambiguities first.
|
||||
owner.replace(nodeToReplace, fSimpleDecl);
|
||||
IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0];
|
||||
dtor.accept(resolver);
|
||||
|
||||
// find nested names
|
||||
// Find nested names.
|
||||
final NameCollector nameCollector= new NameCollector();
|
||||
dtor.accept(nameCollector);
|
||||
final IASTName[] names= nameCollector.getNames();
|
||||
|
||||
// resolve names
|
||||
// Resolve names.
|
||||
boolean hasIssue= false;
|
||||
for (IASTName name : names) {
|
||||
try {
|
||||
|
@ -121,13 +122,13 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
|||
}
|
||||
}
|
||||
if (hasIssue) {
|
||||
// use the alternate version
|
||||
// Use the alternate version.
|
||||
final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl;
|
||||
parent.replace(fSimpleDecl.getDeclSpecifier(), fAltDeclSpec);
|
||||
parent.replace(dtor, fAltDtor);
|
||||
}
|
||||
|
||||
// resolve further nested ambiguities
|
||||
// Resolve further nested ambiguities.
|
||||
fSimpleDecl.accept(resolver);
|
||||
return fSimpleDecl;
|
||||
}
|
||||
|
@ -138,6 +139,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addAttribute(IASTAttribute attribute) {
|
||||
fSimpleDecl.addAttribute(attribute);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
|
@ -38,7 +37,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
|
|||
private boolean isGlobal;
|
||||
private boolean isVectored;
|
||||
|
||||
private IASTImplicitName[] implicitNames = null;
|
||||
private IASTImplicitName[] implicitNames;
|
||||
|
||||
public CPPASTDeleteExpression() {
|
||||
}
|
||||
|
@ -58,8 +57,8 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
|
|||
|
||||
@Override
|
||||
public CPPASTDeleteExpression copy(CopyStyle style) {
|
||||
CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null
|
||||
: operand.copy(style));
|
||||
CPPASTDeleteExpression copy =
|
||||
new CPPASTDeleteExpression(operand == null ? null : operand.copy(style));
|
||||
copy.isGlobal = isGlobal;
|
||||
copy.isVectored = isVectored;
|
||||
return copy(copy, style);
|
||||
|
@ -131,11 +130,12 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
|
|||
}
|
||||
}
|
||||
|
||||
if (names.isEmpty())
|
||||
if (names.isEmpty()) {
|
||||
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
|
||||
else
|
||||
} else {
|
||||
implicitNames = names.toArray(new IASTImplicitName[names.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
return implicitNames;
|
||||
}
|
||||
|
@ -198,5 +198,4 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
|
|||
operand = (IASTExpression) other;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,14 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
/**
|
||||
* Field declarator for c++.
|
||||
*/
|
||||
public class CPPASTFieldDeclarator extends CPPASTDeclarator implements
|
||||
ICPPASTFieldDeclarator, IASTAmbiguityParent {
|
||||
|
||||
public class CPPASTFieldDeclarator extends CPPASTDeclarator implements ICPPASTFieldDeclarator {
|
||||
private IASTExpression bitField;
|
||||
|
||||
public CPPASTFieldDeclarator() {
|
||||
|
@ -75,13 +72,10 @@ public class CPPASTFieldDeclarator extends CPPASTDeclarator implements
|
|||
|
||||
@Override
|
||||
public void replace(IASTNode child, IASTNode other) {
|
||||
if( child == bitField )
|
||||
{
|
||||
if (child == bitField) {
|
||||
other.setPropertyInParent(child.getPropertyInParent());
|
||||
other.setParent(child.getParent());
|
||||
bitField = (IASTExpression) other;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
public int getVisibility() {
|
||||
IASTDeclaration decl= getPrimaryDeclaration();
|
||||
if (decl == null) {
|
||||
// 12.1-5, 12.8-10 Implicit constructors and assignment operators are public
|
||||
// 12.1-5, 12.8-10 Implicit constructors and assignment operators are public.
|
||||
return ICPPASTVisibilityLabel.v_public;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
}
|
||||
|
||||
public IASTDeclaration getPrimaryDeclaration() {
|
||||
// first check if we already know it
|
||||
// First check if we already know it.
|
||||
if (declarations != null) {
|
||||
for (IASTDeclarator dtor : declarations) {
|
||||
if (dtor == null)
|
||||
|
@ -104,17 +104,17 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
IFunctionType ftype = getType();
|
||||
IType[] params = ftype.getParameterTypes();
|
||||
|
||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal
|
||||
.getPhysicalNodeOfScope(getScope());
|
||||
ICPPASTCompositeTypeSpecifier compSpec =
|
||||
(ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope());
|
||||
if (compSpec == null) {
|
||||
return null;
|
||||
}
|
||||
IASTDeclaration[] members = compSpec.getMembers();
|
||||
for (IASTDeclaration member : members) {
|
||||
IASTDeclarator[] ds = null;
|
||||
while (member instanceof ICPPASTTemplateDeclaration)
|
||||
member = ((ICPPASTTemplateDeclaration) member).getDeclaration();
|
||||
|
||||
IASTDeclarator[] ds;
|
||||
if (member instanceof IASTSimpleDeclaration) {
|
||||
ds = ((IASTSimpleDeclaration) member).getDeclarators();
|
||||
} else if (member instanceof IASTFunctionDefinition) {
|
||||
|
@ -149,10 +149,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
}
|
||||
if (ok) {
|
||||
name.setBinding(this);
|
||||
if (member instanceof IASTSimpleDeclaration)
|
||||
if (member instanceof IASTSimpleDeclaration) {
|
||||
ASTInternal.addDeclaration(this, dtor);
|
||||
else if (member instanceof IASTFunctionDefinition)
|
||||
} else if (member instanceof IASTFunctionDefinition) {
|
||||
ASTInternal.addDefinition(this, dtor);
|
||||
}
|
||||
return member;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue