Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-10 11:58:41 +0000
committerMarkus Schorn2008-04-10 11:58:41 +0000
commit3c104b3f4c70dbd30b6129567fe3e17ade0b0b9c (patch)
tree85b363528fb4ff45e5bb3da47d2531001800fc62 /core/org.eclipse.cdt.core
parent772a60e5b64e324d8abfb15eaa9cab969f41e77b (diff)
downloadorg.eclipse.cdt-3c104b3f4c70dbd30b6129567fe3e17ade0b0b9c.tar.gz
org.eclipse.cdt-3c104b3f4c70dbd30b6129567fe3e17ade0b0b9c.tar.xz
org.eclipse.cdt-3c104b3f4c70dbd30b6129567fe3e17ade0b0b9c.zip
Fix warnings.
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java40
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java22
3 files changed, 35 insertions, 42 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
index 19067ffb96..03abd908a6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java
@@ -550,8 +550,7 @@ public class CVisitor {
if( scope != null && scope instanceof ICFunctionScope ){
CFunctionScope functionScope = (CFunctionScope) scope;
ILabel [] labels = functionScope.getLabels();
- for( int i = 0; i < labels.length; i++ ){
- ILabel label = labels[i];
+ for (ILabel label : labels) {
if( CharArrayUtils.equals( label.getNameCharArray(), gotoName) ){
return label;
}
@@ -639,9 +638,9 @@ public class CVisitor {
try {
char [] p = fieldReference.getFieldName().toCharArray();
IField [] fields = ((ICompositeType) type).getFields();
- for ( int i = 0; i < fields.length; i++ ) {
- if( CharArrayUtils.equals( fields[i].getNameCharArray(), 0, p.length, p, true ) ){
- result = (IBinding[]) ArrayUtil.append( IBinding.class, result, fields[i] );
+ for (IField field : fields) {
+ if( CharArrayUtils.equals( field.getNameCharArray(), 0, p.length, p, true ) ){
+ result = (IBinding[]) ArrayUtil.append( IBinding.class, result, field );
}
}
return ArrayUtil.trim( IBinding.class, result );
@@ -1391,8 +1390,8 @@ public class CVisitor {
if( prefixMap != null ){
IBinding [] result = null;
Object [] vals = prefixMap.valueArray();
- for ( int i = 0; i < vals.length; i++ ) {
- result = (IBinding[]) ArrayUtil.append( IBinding.class, result, ((IASTName) vals[i]).resolveBinding() );
+ for (Object val : vals) {
+ result = (IBinding[]) ArrayUtil.append( IBinding.class, result, ((IASTName) val).resolveBinding() );
}
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
@@ -1472,9 +1471,9 @@ public class CVisitor {
}
//also have to check for any nested structs
IASTDeclaration [] nested = ((ICASTCompositeTypeSpecifier)declSpec).getMembers();
- for( int i = 0; i < nested.length; i++ ){
- if( nested[i] instanceof IASTSimpleDeclaration ){
- IASTDeclSpecifier d = ((IASTSimpleDeclaration)nested[i]).getDeclSpecifier();
+ for (IASTDeclaration element : nested) {
+ if( element instanceof IASTSimpleDeclaration ){
+ IASTDeclSpecifier d = ((IASTSimpleDeclaration)element).getDeclSpecifier();
if( d instanceof ICASTCompositeTypeSpecifier || d instanceof IASTEnumerationSpecifier ) {
Object obj = checkForBinding( scope, d, name, typesOnly, prefixMap );
if( prefixMap == null && resultName == null ){
@@ -1496,8 +1495,7 @@ public class CVisitor {
}
//check enumerators
IASTEnumerator [] list = ((ICASTEnumerationSpecifier) declSpec).getEnumerators();
- for( int i = 0; i < list.length; i++ ) {
- IASTEnumerator enumerator = list[i];
+ for (IASTEnumerator enumerator : list) {
if( enumerator == null ) break;
tempName = enumerator.getName();
if( scope != null )
@@ -1573,8 +1571,7 @@ public class CVisitor {
if( declaration instanceof IASTSimpleDeclaration ){
IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration;
IASTDeclarator [] declarators = simpleDeclaration.getDeclarators();
- for( int i = 0; i < declarators.length; i++ ){
- IASTDeclarator declarator = declarators[i];
+ for (IASTDeclarator declarator : declarators) {
while( declarator.getNestedDeclarator() != null ){
declarator = declarator.getNestedDeclarator();
}
@@ -1641,8 +1638,7 @@ public class CVisitor {
}
boolean begun = ( beginAtLoc == AT_BEGINNING );
if( list != null ){
- for( int i = 0; i < list.length; i++ ){
- IASTNode node = list[i];
+ for (IASTNode node : list) {
if( node == blockItem ){
begun = true;
continue;
@@ -1784,7 +1780,6 @@ public class CVisitor {
* @param declSpec the IASTDeclSpecifier used to determine if the base type is a CQualifierType or not
* @return the base IType
*/
- @SuppressWarnings("null")
public static IType createBaseType( IASTDeclSpecifier declSpec ) {
if( declSpec instanceof IGCCASTSimpleDeclSpecifier ){
IASTExpression exp = ((IGCCASTSimpleDeclSpecifier)declSpec).getTypeofExpression();
@@ -1804,6 +1799,8 @@ public class CVisitor {
name = ((IASTCompositeTypeSpecifier) declSpec).getName();
} else if( declSpec instanceof IASTEnumerationSpecifier ){
name = ((IASTEnumerationSpecifier)declSpec).getName();
+ } else {
+ return new ProblemBinding(declSpec, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, declSpec.getRawSignature().toCharArray() );
}
binding = name.resolveBinding();
@@ -1860,9 +1857,9 @@ public class CVisitor {
continue;
IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators();
- for( int j = 0; j < dtors.length; j++ ){
- if( CharArrayUtils.equals( dtors[j].getName().toCharArray(), n ) ){
- return dtors[j];
+ for (IASTDeclarator dtor : dtors) {
+ if( CharArrayUtils.equals( dtor.getName().toCharArray(), n ) ){
+ return dtor;
}
}
}
@@ -2051,8 +2048,7 @@ public class CVisitor {
char [] n = name.toCharArray();
if( scope instanceof ICFunctionScope ){
ILabel [] labels = ((CFunctionScope)scope).getLabels();
- for( int i = 0; i < labels.length; i++ ){
- ILabel label = labels[i];
+ for (ILabel label : labels) {
if (prefixLookup) {
if (CharArrayUtils.equals(label.getNameCharArray(),
0, n.length, n, true)) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index d3ac738eb7..9ad332ff5f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -516,8 +516,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
IScope tuScope = translationUnit.getScope();
IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope);
- for(int i=0; i<bindings.length; i++) {
- ASTInternal.addBinding(tuScope, bindings[i]);
+ for (IBinding binding : bindings) {
+ ASTInternal.addBinding(tuScope, binding);
}
}
} catch (Exception e2) {
@@ -1667,12 +1667,12 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
declaration = ((IASTSimpleDeclaration) decl);
IASTDeclarator[] decltors = declaration.getDeclarators();
- for (int k = 0; k < decltors.length; k++) {
+ for (IASTDeclarator decltor : decltors) {
boolean decltorOk = false;
- for (int j = 0; j < parmNames.length; j++) {
+ for (IASTName parmName : parmNames) {
if (CharArrayUtils.equals(
- decltors[k].getName().toCharArray(),
- parmNames[j].toCharArray())) {
+ decltor.getName().toCharArray(),
+ parmName.toCharArray())) {
decltorOk = true;
break;
}
@@ -1855,7 +1855,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
return new CASTDeclarator();
}
- @SuppressWarnings("fallthrough")
protected void consumeArrayModifiers(List<IASTNode> arrayMods)
throws EndOfFileException, BacktrackException {
@@ -1890,7 +1889,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tSTAR:
isVarSized = true;
consume();
- // deliberate fall through
+ break outerLoop;
default:
break outerLoop;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index c5d39af6f2..8167cbba2d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -742,22 +742,20 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
throwExpression, throwToken.getOffset(), o); // fix for 95225
}
- @SuppressWarnings("fallthrough")
@Override
protected IASTExpression relationalExpression() throws BacktrackException, EndOfFileException {
IASTExpression firstExpression = shiftExpression();
for (;;) {
- switch (LT(1)) {
+ final int lt1 = LT(1);
+ switch (lt1) {
case IToken.tGT:
- if (templateIdScopes.size() > 0
- && templateIdScopes.peek() == IToken.tLT) {
- return firstExpression;
- }
- // fall through
case IToken.tLT:
case IToken.tLTEQUAL:
case IToken.tGTEQUAL:
+ if (lt1 == IToken.tGT && templateIdScopes.size() > 0 && templateIdScopes.peek() == IToken.tLT)
+ return firstExpression;
+
IToken m = mark();
int t = consume().getType();
@@ -791,7 +789,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (supportMinAndMaxOperators
&& (LT(1) == IGCCToken.tMIN || LT(1) == IGCCToken.tMAX)) {
int new_operator = 0;
- switch (LT(1)) {
+ switch (lt1) {
case IGCCToken.tMAX:
consume();
new_operator = IGPPASTBinaryExpression.op_max;
@@ -2492,8 +2490,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
// as a work around just flatten them.
if (subName instanceof ICPPASTQualifiedName) {
IASTName[] subNames= ((ICPPASTQualifiedName) subName).getNames();
- for (int j = 0; j < subNames.length; j++) {
- subName = subNames[j];
+ for (IASTName subName2 : subNames) {
+ subName = subName2;
result.addName(subName);
}
}
@@ -4188,8 +4186,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
IScope tuScope = translationUnit.getScope();
IBinding[] bindings = builtinBindingsProvider.getBuiltinBindings(tuScope);
- for(int i=0; i<bindings.length; i++) {
- ASTInternal.addBinding(tuScope, bindings[i]);
+ for (IBinding binding : bindings) {
+ ASTInternal.addBinding(tuScope, binding);
}
}
} catch (Exception e2) {

Back to the top