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

Removed warnings.

This commit is contained in:
John Camelon 2004-05-17 18:16:43 +00:00
parent 9f21cf4d4a
commit 787b5dfcc3
8 changed files with 262 additions and 334 deletions

View file

@ -385,15 +385,13 @@ public class DeclarationWrapper implements IDeclaratorOwner
throw new ASTSemanticException( (IProblem)null ); throw new ASTSemanticException( (IProblem)null );
return createFieldASTNode(declarator, false ); return createFieldASTNode(declarator, false );
} }
else
{
if (isFunction) if (isFunction)
return createFunctionASTNode(declarator, false); return createFunctionASTNode(declarator, false);
else else
if( declarator.hasFunctionBody() ) if( declarator.hasFunctionBody() )
throw new ASTSemanticException( (IProblem)null ); throw new ASTSemanticException( (IProblem)null );
return createVariableASTNode(declarator, false); return createVariableASTNode(declarator, false);
}
} }
/** /**
* @param declarator * @param declarator
@ -418,19 +416,13 @@ public class DeclarationWrapper implements IDeclaratorOwner
{ {
if( isFunction) if( isFunction)
return createMethodASTNode(declarator, true); return createMethodASTNode(declarator, true);
else
return createFieldASTNode(declarator, true ); return createFieldASTNode(declarator, true );
} }
else
{
if (isFunction) if (isFunction)
return createFunctionASTNode(declarator, true); return createFunctionASTNode(declarator, true);
else
return createVariableASTNode(declarator, true); return createVariableASTNode(declarator, true);
} }
}
List convertedParms = createParameterList( declarator.getParameters() ); List convertedParms = createParameterList( declarator.getParameters() );
IASTAbstractDeclaration abs = null; IASTAbstractDeclaration abs = null;
abs = abs =
@ -450,18 +442,15 @@ public class DeclarationWrapper implements IDeclaratorOwner
getStartingOffset(), getStartingLine(), d getStartingOffset(), getStartingLine(), d
.getNameStartOffset(), d.getNameEndOffset(), d .getNameStartOffset(), d.getNameEndOffset(), d
.getNameLine()); .getNameLine());
else {
if( isWithinClass ) if( isWithinClass )
return astFactory.createField( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode() ); return astFactory.createField( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode() );
else
return astFactory.createVariable( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() ); return astFactory.createVariable( scope, nameDuple, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() );
}
} }
else
{
throw new BacktrackException(); throw new BacktrackException();
}
} }
/** /**

View file

@ -147,7 +147,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
public IToken consume(int type) throws EndOfFileException, BacktrackException { public IToken consume(int type) throws EndOfFileException, BacktrackException {
if (LT(1) == type) if (LT(1) == type)
return consume(); return consume();
else
throw backtrack; throw backtrack;
} }
@ -565,8 +564,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER); declarator.addPointerOperator(ASTPointerOperator.RESTRICT_POINTER);
break; break;
} }
else
{
if( extension.isValidCVModifier( language, IToken.t_restrict )) if( extension.isValidCVModifier( language, IToken.t_restrict ))
{ {
result = consume( IToken.t_restrict ); result = consume( IToken.t_restrict );
@ -574,7 +571,7 @@ public class ExpressionParser implements IExpressionParser, IParserData {
break; break;
} }
throw backtrack; throw backtrack;
}
default : default :
if( extension.isValidCVModifier( language, LT(1))) if( extension.isValidCVModifier( language, LT(1)))
@ -925,7 +922,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
throw backtrack; throw backtrack;
} }
} }
else
return firstExpression; return firstExpression;
} }
@ -1199,8 +1195,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
backup(mark); backup(mark);
return firstExpression; return firstExpression;
} }
else
{
IASTExpression.Kind expressionKind = null; IASTExpression.Kind expressionKind = null;
switch (t.getType()) switch (t.getType())
{ {
@ -1244,7 +1238,6 @@ public class ExpressionParser implements IExpressionParser, IParserData {
logException( "relationalExpression::createExpression()", e ); //$NON-NLS-1$ logException( "relationalExpression::createExpression()", e ); //$NON-NLS-1$
throw backtrack; throw backtrack;
} }
}
break; break;
default : default :
if( extension.isValidRelationalExpressionStart(language, LT(1))) if( extension.isValidRelationalExpressionStart(language, LT(1)))
@ -2548,16 +2541,11 @@ public class ExpressionParser implements IExpressionParser, IParserData {
try try
{ {
if( t instanceof INumericToken ) if( t instanceof INumericToken )
{
return astFactory.createExpression( return astFactory.createExpression(
IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, IASTExpression.Kind.PRIMARY_INTEGER_LITERAL,
((INumericToken)t).getIntegerValue(), isHex); ((INumericToken)t).getIntegerValue(), isHex);
}
else
{
return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, null, null, t.getImage(), null ); return astFactory.createExpression( scope, IASTExpression.Kind.PRIMARY_INTEGER_LITERAL, null, null, null, null, null, t.getImage(), null );
} }
}
catch (ASTSemanticException e1) catch (ASTSemanticException e1)
{ {
throw backtrack; throw backtrack;

View file

@ -267,13 +267,8 @@ public abstract class Parser extends ExpressionParser implements IParser
astUD.acceptElement(requestor); astUD.acceptElement(requestor);
return astUD; return astUD;
} }
else
{
throw backtrack; throw backtrack;
} }
}
else
{
boolean typeName = false; boolean typeName = false;
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING ); setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.POST_USING );
@ -281,7 +276,6 @@ public abstract class Parser extends ExpressionParser implements IParser
{ {
typeName = true; typeName = true;
consume(IToken.t_typename); consume(IToken.t_typename);
} }
setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY ); setCompletionValues(scope, CompletionKind.TYPE_REFERENCE, Key.NAMESPACE_ONLY );
@ -318,11 +312,8 @@ public abstract class Parser extends ExpressionParser implements IParser
setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION ); setCompletionValues(scope, getCompletionKindForDeclaration(scope, null), Key.DECLARATION );
return declaration; return declaration;
} }
else
{
throw backtrack; throw backtrack;
}
}
} }
/** /**
* Implements Linkage specification in the ANSI C++ grammar. * Implements Linkage specification in the ANSI C++ grammar.
@ -391,8 +382,8 @@ public abstract class Parser extends ExpressionParser implements IParser
linkage.exitScope( requestor ); linkage.exitScope( requestor );
return linkage; return linkage;
} }
else // single declaration // single declaration
{
IASTLinkageSpecification linkage; IASTLinkageSpecification linkage;
try try
{ {
@ -411,7 +402,7 @@ public abstract class Parser extends ExpressionParser implements IParser
declaration(linkage, null, null); declaration(linkage, null, null);
linkage.exitScope( requestor ); linkage.exitScope( requestor );
return linkage; return linkage;
}
} }
/** /**
* *
@ -464,8 +455,6 @@ public abstract class Parser extends ExpressionParser implements IParser
return templateInstantiation; return templateInstantiation;
} }
else
{
consume(IToken.tLT); consume(IToken.tLT);
if (LT(1) == IToken.tGT) if (LT(1) == IToken.tGT)
{ {
@ -493,7 +482,7 @@ public abstract class Parser extends ExpressionParser implements IParser
templateSpecialization.exitScope(requestor); templateSpecialization.exitScope(requestor);
return templateSpecialization; return templateSpecialization;
} }
}
try try
{ {
@ -1110,8 +1099,6 @@ public abstract class Parser extends ExpressionParser implements IParser
} }
return declaration; return declaration;
} }
else
{
IASTDeclaration declaration = (IASTDeclaration)i.next(); IASTDeclaration declaration = (IASTDeclaration)i.next();
endDeclaration( declaration ); endDeclaration( declaration );
declaration.enterScope( requestor ); declaration.enterScope( requestor );
@ -1131,9 +1118,6 @@ public abstract class Parser extends ExpressionParser implements IParser
return declaration; return declaration;
} }
}
else
{
try try
{ {
@ -1155,7 +1139,7 @@ public abstract class Parser extends ExpressionParser implements IParser
logException( "simpleDeclaration:createTypeSpecDeclaration", e1 ); //$NON-NLS-1$ logException( "simpleDeclaration:createTypeSpecDeclaration", e1 ); //$NON-NLS-1$
throw backtrack; throw backtrack;
} }
}
return null; return null;
} }
@ -3203,9 +3187,7 @@ public abstract class Parser extends ExpressionParser implements IParser
protected void handleClassSpecifier( IASTClassSpecifier classSpecifier ) throws EndOfFileException protected void handleClassSpecifier( IASTClassSpecifier classSpecifier ) throws EndOfFileException
{ {
cleanupLastToken(); cleanupLastToken();
if( classSpecifier instanceof IASTOffsetableNamedElement )
handleOffsetableNamedElement( classSpecifier ); handleOffsetableNamedElement( classSpecifier );
} }

View file

@ -41,16 +41,14 @@ public class ParserMessages {
* @return * @return
*/ */
public static String getString(String key) { public static String getString(String key) {
if( resourceBundle == null ){ if( resourceBundle == null )
return '#' + key +'#'; return '#' + key +'#';
} else {
try { try {
return resourceBundle.getString(key); return resourceBundle.getString(key);
} catch (MissingResourceException e) { } catch (MissingResourceException e) {
return '!' + key + '!'; return '!' + key + '!';
} }
} }
}
/** /**
* Gets a string from the resource bundle and formats it with the argument * Gets a string from the resource bundle and formats it with the argument

View file

@ -154,22 +154,25 @@ public class QuickParseCallback extends NullSourceElementRequestor implements IQ
// case 3: 1 is null // case 3: 1 is null
if( currentMacro == null ) if( currentMacro == null )
{
if( currentDeclaration.getStartingOffset() < currentInclusion.getStartingOffset() ) if( currentDeclaration.getStartingOffset() < currentInclusion.getStartingOffset() )
return updateDeclarationIterator(); return updateDeclarationIterator();
else
return updateInclusionIterator(); return updateInclusionIterator();
}
if( currentInclusion == null ) if( currentInclusion == null )
{
if( currentDeclaration.getStartingOffset() < currentMacro.getStartingOffset() ) if( currentDeclaration.getStartingOffset() < currentMacro.getStartingOffset() )
return updateDeclarationIterator(); return updateDeclarationIterator();
else
return updateMacroIterator(); return updateMacroIterator();
}
if( currentDeclaration == null ) if( currentDeclaration == null )
{
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() ) if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() )
return updateInclusionIterator(); return updateInclusionIterator();
else
return updateMacroIterator(); return updateMacroIterator();
}
// case 4: none are null // case 4: none are null
if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() && if( currentInclusion.getStartingOffset() < currentMacro.getStartingOffset() &&

View file

@ -496,13 +496,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
iterator.next(); iterator.next();
return pst.getCompilationUnit(); return pst.getCompilationUnit();
} }
else
{
return scopeToSymbol(currentScope); return scopeToSymbol(currentScope);
} }
}
protected IContainerSymbol scopeToSymbol(IASTScope currentScope) protected IContainerSymbol scopeToSymbol(IASTScope currentScope)
{ {
if( currentScope instanceof ASTScope ) if( currentScope instanceof ASTScope )
@ -935,8 +930,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{ {
ASTNode referenced = (definition != null) ? definition : declaration; ASTNode referenced = (definition != null) ? definition : declaration;
if( referenced instanceof IASTMethod ) if( referenced instanceof IASTMethod )
return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced ); return new ASTMethodReference( offset, referenceElementName, (IASTMethod)referenced );
else
return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)referenced ); return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)referenced );
} }
else if( ( symbol.getType() == TypeInfo.t_type ) || else if( ( symbol.getType() == TypeInfo.t_type ) ||
@ -1279,10 +1274,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
// assert lhsInfo != null : "Malformed Expression"; // assert lhsInfo != null : "Malformed Expression";
return null; return null;
} }
else {
return startingScope; return startingScope;
} }
}
/* /*
* Conditional Expression conversion * Conditional Expression conversion

View file

@ -56,12 +56,9 @@ public class BranchTracker {
return taken; return taken;
} }
else
{
branches.push( FALSE ); branches.push( FALSE );
return false; return false;
} }
}
public boolean queryCurrentBranchForElif() public boolean queryCurrentBranchForElif()
{ {

View file

@ -400,7 +400,6 @@ public class Scanner implements IScanner {
// multiline comment // multiline comment
if (skipOverMultilineComment()) if (skipOverMultilineComment())
break; break;
else
c = getChar( true ); c = getChar( true );
continue; continue;
} else { } else {
@ -851,14 +850,9 @@ public class Scanner implements IScanner {
{ {
c = getChar(); c = getChar();
if( c == '#' ) if( c == '#' )
{
return true; return true;
}
else
{
ungetChar( c ); ungetChar( c );
} }
}
ungetChar( c ); ungetChar( c );
return false; return false;
@ -922,12 +916,9 @@ public class Scanner implements IScanner {
// consume \ \r \n and then continue // consume \ \r \n and then continue
return getChar(true); return getChar(true);
} }
else
{
// consume the \ \r and then continue // consume the \ \r and then continue
return c; return c;
} }
}
if (c == '\n') if (c == '\n')
{ {
@ -1024,7 +1015,6 @@ public class Scanner implements IScanner {
} else if( c == '.' ){ } else if( c == '.' ){
if( getChar() == '.' ) if( getChar() == '.' )
return newConstantToken( IToken.tELLIPSIS ); return newConstantToken( IToken.tELLIPSIS );
else
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true ); handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
} else { } else {
ungetChar( c ); ungetChar( c );
@ -1502,7 +1492,6 @@ public class Scanner implements IScanner {
if( buff == null ) return null; if( buff == null ) return null;
continue; // back to top of loop continue; // back to top of loop
} }
else
ungetChar( next ); ungetChar( next );
} }
break; break;
@ -1540,13 +1529,10 @@ public class Scanner implements IScanner {
if (tokenTypeObject != null) if (tokenTypeObject != null)
return newConstantToken(((Integer) tokenTypeObject).intValue()); return newConstantToken(((Integer) tokenTypeObject).intValue());
else
{
if( scannerExtension.isExtensionKeyword( scannerData.getLanguage(), ident ) ) if( scannerExtension.isExtensionKeyword( scannerData.getLanguage(), ident ) )
return newExtensionToken( scannerExtension.createExtensionToken(scannerData, ident )); return newExtensionToken( scannerExtension.createExtensionToken(scannerData, ident ));
return newToken(IToken.tIDENTIFIER, ident); return newToken(IToken.tIDENTIFIER, ident);
} }
}
/** /**
* @param token * @param token
@ -2023,8 +2009,6 @@ public class Scanner implements IScanner {
c = getChar(); c = getChar();
continue; continue;
} }
else
{
token = processKeywordOrIdentifier( secondBuffer, pasting ); token = processKeywordOrIdentifier( secondBuffer, pasting );
if (token == null) if (token == null)
{ {
@ -2033,13 +2017,9 @@ public class Scanner implements IScanner {
} }
return token; return token;
} }
}
else
{
ungetChar( next ); ungetChar( next );
handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead ); handleProblem( IProblem.SCANNER_BAD_CHARACTER, ucnBuffer.toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
} }
}
handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead ); handleProblem( IProblem.SCANNER_BAD_CHARACTER, new Character( (char)c ).toString(), getCurrentOffset(), false, true, throwExceptionOnBadCharacterRead );
c = getChar(); c = getChar();
@ -2259,11 +2239,10 @@ public class Scanner implements IScanner {
{ {
return newToken( IToken.tSTRING, buff.toString()); return newToken( IToken.tSTRING, buff.toString());
} else { }
handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true ); handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true );
c = getChar(); c = getChar();
continue; continue;
}
} else { } else {
switch (c) { switch (c) {
@ -2776,7 +2755,7 @@ public class Scanner implements IScanner {
if( c == '\n' ){ if( c == '\n' ){
c = getChar(); c = getChar();
continue; continue;
} else { }
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE ); StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
ungetChar( c ); ungetChar( c );
potentialErrorMessage.append( buffer ); potentialErrorMessage.append( buffer );
@ -2784,7 +2763,6 @@ public class Scanner implements IScanner {
potentialErrorMessage.append( (char)c ); potentialErrorMessage.append( (char)c );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true); handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true);
return; return;
}
} else if( c == '\r' || c == '\n' || c == NOCHAR ){ } else if( c == '\r' || c == '\n' || c == NOCHAR ){
StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE ); StringBuffer potentialErrorMessage = new StringBuffer( POUND_DEFINE );
potentialErrorMessage.append( buffer ); potentialErrorMessage.append( buffer );
@ -3110,7 +3088,7 @@ public class Scanner implements IScanner {
if( index == -1 ){ if( index == -1 ){
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, expansion.getName(), getCurrentOffset(), false, true ); handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, expansion.getName(), getCurrentOffset(), false, true );
return; return;
} else { }
buffer.append('\"'); buffer.append('\"');
String value = (String)parameterValuesForStringizing.elementAt(index); String value = (String)parameterValuesForStringizing.elementAt(index);
char val [] = value.toCharArray(); char val [] = value.toCharArray();
@ -3134,7 +3112,7 @@ public class Scanner implements IScanner {
} }
} }
buffer.append('\"'); buffer.append('\"');
}
} else { } else {
switch( t.getType() ) switch( t.getType() )
{ {