1
0
Fork 0
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:
Sergey Prigogin 2014-04-20 17:04:10 -07:00
parent 6e96e21cf0
commit 470a007439
4 changed files with 31 additions and 35 deletions

View file

@ -31,10 +31,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
/** /**
* Handles ambiguities for simple declarations. * Handles ambiguities for simple declarations.
* <br> * <pre>
* class C { * 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 { public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration {
private IASTSimpleDeclaration fSimpleDecl; private IASTSimpleDeclaration fSimpleDecl;
@ -49,7 +50,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
@Override @Override
protected void beforeResolution() { 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); IScope scope= CPPVisitor.getContainingScope(this);
if (scope instanceof IASTInternalScope) { if (scope instanceof IASTInternalScope) {
((IASTInternalScope) scope).populateCache(); ((IASTInternalScope) scope).populateCache();
@ -96,17 +97,17 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent();
IASTNode nodeToReplace= this; IASTNode nodeToReplace= this;
// handle nested ambiguities first // Handle nested ambiguities first.
owner.replace(nodeToReplace, fSimpleDecl); owner.replace(nodeToReplace, fSimpleDecl);
IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0]; IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0];
dtor.accept(resolver); dtor.accept(resolver);
// find nested names // Find nested names.
final NameCollector nameCollector= new NameCollector(); final NameCollector nameCollector= new NameCollector();
dtor.accept(nameCollector); dtor.accept(nameCollector);
final IASTName[] names= nameCollector.getNames(); final IASTName[] names= nameCollector.getNames();
// resolve names // Resolve names.
boolean hasIssue= false; boolean hasIssue= false;
for (IASTName name : names) { for (IASTName name : names) {
try { try {
@ -121,13 +122,13 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
} }
} }
if (hasIssue) { if (hasIssue) {
// use the alternate version // Use the alternate version.
final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl; final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl;
parent.replace(fSimpleDecl.getDeclSpecifier(), fAltDeclSpec); parent.replace(fSimpleDecl.getDeclSpecifier(), fAltDeclSpec);
parent.replace(dtor, fAltDtor); parent.replace(dtor, fAltDtor);
} }
// resolve further nested ambiguities // Resolve further nested ambiguities.
fSimpleDecl.accept(resolver); fSimpleDecl.accept(resolver);
return fSimpleDecl; return fSimpleDecl;
} }
@ -138,6 +139,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement
} }
@Override @Override
@Deprecated
public void addAttribute(IASTAttribute attribute) { public void addAttribute(IASTAttribute attribute) {
fSimpleDecl.addAttribute(attribute); fSimpleDecl.addAttribute(attribute);
} }

View file

@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; 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.IASTExpression;
import org.eclipse.cdt.core.dom.ast.IASTImplicitName; import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
@ -38,7 +37,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
private boolean isGlobal; private boolean isGlobal;
private boolean isVectored; private boolean isVectored;
private IASTImplicitName[] implicitNames = null; private IASTImplicitName[] implicitNames;
public CPPASTDeleteExpression() { public CPPASTDeleteExpression() {
} }
@ -58,8 +57,8 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
@Override @Override
public CPPASTDeleteExpression copy(CopyStyle style) { public CPPASTDeleteExpression copy(CopyStyle style) {
CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null CPPASTDeleteExpression copy =
: operand.copy(style)); new CPPASTDeleteExpression(operand == null ? null : operand.copy(style));
copy.isGlobal = isGlobal; copy.isGlobal = isGlobal;
copy.isVectored = isVectored; copy.isVectored = isVectored;
return copy(copy, style); return copy(copy, style);
@ -131,10 +130,11 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
} }
} }
if (names.isEmpty()) if (names.isEmpty()) {
implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY; implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY;
else } else {
implicitNames = names.toArray(new IASTImplicitName[names.size()]); implicitNames = names.toArray(new IASTImplicitName[names.size()]);
}
} }
return implicitNames; return implicitNames;
@ -163,7 +163,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
if (action.shouldVisitExpressions) { if (action.shouldVisitExpressions) {
switch (action.leave(this)) { switch (action.leave(this)) {
case ASTVisitor.PROCESS_ABORT: return false; case ASTVisitor.PROCESS_ABORT: return false;
case ASTVisitor.PROCESS_SKIP: return true; case ASTVisitor.PROCESS_SKIP: return true;
default: break; default: break;
} }
} }
@ -198,5 +198,4 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr
operand = (IASTExpression) other; operand = (IASTExpression) other;
} }
} }
} }

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* John Camelon (IBM) - Initial API and implementation * John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -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.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/** /**
* Field declarator for c++. * Field declarator for c++.
*/ */
public class CPPASTFieldDeclarator extends CPPASTDeclarator implements public class CPPASTFieldDeclarator extends CPPASTDeclarator implements ICPPASTFieldDeclarator {
ICPPASTFieldDeclarator, IASTAmbiguityParent {
private IASTExpression bitField; private IASTExpression bitField;
public CPPASTFieldDeclarator() { public CPPASTFieldDeclarator() {
@ -75,13 +72,10 @@ public class CPPASTFieldDeclarator extends CPPASTDeclarator implements
@Override @Override
public void replace(IASTNode child, IASTNode other) { public void replace(IASTNode child, IASTNode other) {
if( child == bitField ) if (child == bitField) {
{ other.setPropertyInParent(child.getPropertyInParent());
other.setPropertyInParent( child.getPropertyInParent() ); other.setParent(child.getParent());
other.setParent( child.getParent() );
bitField = (IASTExpression) other; bitField = (IASTExpression) other;
} }
} }
} }

View file

@ -50,7 +50,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
public int getVisibility() { public int getVisibility() {
IASTDeclaration decl= getPrimaryDeclaration(); IASTDeclaration decl= getPrimaryDeclaration();
if (decl == null) { 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; return ICPPASTVisibilityLabel.v_public;
} }
@ -86,7 +86,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
} }
public IASTDeclaration getPrimaryDeclaration() { public IASTDeclaration getPrimaryDeclaration() {
// first check if we already know it // First check if we already know it.
if (declarations != null) { if (declarations != null) {
for (IASTDeclarator dtor : declarations) { for (IASTDeclarator dtor : declarations) {
if (dtor == null) if (dtor == null)
@ -104,17 +104,17 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
IFunctionType ftype = getType(); IFunctionType ftype = getType();
IType[] params = ftype.getParameterTypes(); IType[] params = ftype.getParameterTypes();
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal ICPPASTCompositeTypeSpecifier compSpec =
.getPhysicalNodeOfScope(getScope()); (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope());
if (compSpec == null) { if (compSpec == null) {
return null; return null;
} }
IASTDeclaration[] members = compSpec.getMembers(); IASTDeclaration[] members = compSpec.getMembers();
for (IASTDeclaration member : members) { for (IASTDeclaration member : members) {
IASTDeclarator[] ds = null;
while (member instanceof ICPPASTTemplateDeclaration) while (member instanceof ICPPASTTemplateDeclaration)
member = ((ICPPASTTemplateDeclaration) member).getDeclaration(); member = ((ICPPASTTemplateDeclaration) member).getDeclaration();
IASTDeclarator[] ds;
if (member instanceof IASTSimpleDeclaration) { if (member instanceof IASTSimpleDeclaration) {
ds = ((IASTSimpleDeclaration) member).getDeclarators(); ds = ((IASTSimpleDeclaration) member).getDeclarators();
} else if (member instanceof IASTFunctionDefinition) { } else if (member instanceof IASTFunctionDefinition) {
@ -149,10 +149,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
} }
if (ok) { if (ok) {
name.setBinding(this); name.setBinding(this);
if (member instanceof IASTSimpleDeclaration) if (member instanceof IASTSimpleDeclaration) {
ASTInternal.addDeclaration(this, dtor); ASTInternal.addDeclaration(this, dtor);
else if (member instanceof IASTFunctionDefinition) } else if (member instanceof IASTFunctionDefinition) {
ASTInternal.addDefinition(this, dtor); ASTInternal.addDefinition(this, dtor);
}
return member; return member;
} }
} }