1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 07:15:39 +02:00

compilation warnings

This commit is contained in:
Andrew Gvozdev 2010-04-30 04:24:13 +00:00
parent 6aaacce746
commit 068c62ae83
6 changed files with 35 additions and 20 deletions

View file

@ -63,8 +63,9 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
fOutputParser.processLine("-c test.c"); // multiline //$NON-NLS-1$ fOutputParser.processLine("-c test.c"); // multiline //$NON-NLS-1$
fOutputParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition //$NON-NLS-1$ fOutputParser.processLine("gcc -D 'SUM(x, y) = (x) + (y)' -c test.c"); // more complex macro definition //$NON-NLS-1$
@SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("MACRO1=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("MACRO1=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("MACRO2=value2")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("MACRO2=value2")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("MACRO3=")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("MACRO3=")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("MACRO4=value4")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("MACRO4=value4")); //$NON-NLS-1$
@ -85,7 +86,8 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
public void testParsingSymbolDefinitions_bug80271() { public void testParsingSymbolDefinitions_bug80271() {
fOutputParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\perfilescdtest\\source.c"); // PR 80271 //$NON-NLS-1$ fOutputParser.processLine("gcc -DMACRO1 -I ..\\inc -c ..\\perfilescdtest\\source.c"); // PR 80271 //$NON-NLS-1$
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); @SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("MACRO1=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("MACRO1=1")); //$NON-NLS-1$
assertTrue(sumSymbols.size() == 1); assertTrue(sumSymbols.size() == 1);
} }
@ -94,7 +96,8 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
fOutputParser.processLine("../src/bug186065.cc:8: error: missing terminating \" character"); // PR 80271 //$NON-NLS-1$ fOutputParser.processLine("../src/bug186065.cc:8: error: missing terminating \" character"); // PR 80271 //$NON-NLS-1$
fOutputParser.processLine("gcc -DBUG186065_IS_FIXED test.c"); //$NON-NLS-1$ fOutputParser.processLine("gcc -DBUG186065_IS_FIXED test.c"); //$NON-NLS-1$
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); @SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("BUG186065_IS_FIXED=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("BUG186065_IS_FIXED=1")); //$NON-NLS-1$
assertTrue(sumSymbols.size() == 1); assertTrue(sumSymbols.size() == 1);
} }
@ -107,7 +110,8 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
fOutputParser.processLine("/usr/gcc-tool-x -DE test5.c"); //$NON-NLS-1$ fOutputParser.processLine("/usr/gcc-tool-x -DE test5.c"); //$NON-NLS-1$
fOutputParser.processLine("/usr/gcc/something_else -DF test6.c"); //$NON-NLS-1$ fOutputParser.processLine("/usr/gcc/something_else -DF test6.c"); //$NON-NLS-1$
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); @SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("C=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("C=1")); //$NON-NLS-1$
@ -121,7 +125,8 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
fOutputParser.processLine("gcc -DA test1.c; gcc -DB test2.c"); //$NON-NLS-1$ fOutputParser.processLine("gcc -DA test1.c; gcc -DB test2.c"); //$NON-NLS-1$
fOutputParser.processLine("nix -DC; gcc -DD test2.c"); //$NON-NLS-1$ fOutputParser.processLine("nix -DC; gcc -DD test2.c"); //$NON-NLS-1$
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); @SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$
assertFalse(sumSymbols.contains("C=1")); //$NON-NLS-1$ assertFalse(sumSymbols.contains("C=1")); //$NON-NLS-1$
@ -141,7 +146,8 @@ public abstract class BaseBOPConsoleParserTests extends BaseTestCase {
fOutputParser.processLine("sh -c 'gcc -DAA test1.c; gcc -DBB test2.c'"); //$NON-NLS-1$ fOutputParser.processLine("sh -c 'gcc -DAA test1.c; gcc -DBB test2.c'"); //$NON-NLS-1$
fOutputParser.processLine("sh -c 'nix -DCC; gcc -DDD test2.c'"); //$NON-NLS-1$ fOutputParser.processLine("sh -c 'nix -DCC; gcc -DDD test2.c'"); //$NON-NLS-1$
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS); @SuppressWarnings("unchecked")
List<String> sumSymbols = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.SYMBOL_DEFINITIONS);
assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("A=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("B=1")); //$NON-NLS-1$
assertTrue(sumSymbols.contains("C=1")); //$NON-NLS-1$ assertTrue(sumSymbols.contains("C=1")); //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2007 IBM Corporation and others. * Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -69,8 +69,9 @@ public class GCCScannerInfoConsoleParserTests extends BaseBOPConsoleParserTests
fOutputParser.processLine("-Imultiline3\\"); //$NON-NLS-1$ fOutputParser.processLine("-Imultiline3\\"); //$NON-NLS-1$
fOutputParser.processLine(" -DAA=\"BB\" test.c"); //$NON-NLS-1$ fOutputParser.processLine(" -DAA=\"BB\" test.c"); //$NON-NLS-1$
List sumIncludes = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS); @SuppressWarnings("unchecked")
assertTrue(sumIncludes.contains("/dir/include")); //$NON-NLS-1$ List<String> sumIncludes = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.INCLUDE_PATHS);
assertTrue(sumIncludes.contains("/dir/include")); //$NON-NLS-1$
assertTrue(sumIncludes.contains("c:\\dir\\include")); //$NON-NLS-1$ assertTrue(sumIncludes.contains("c:\\dir\\include")); //$NON-NLS-1$
assertTrue(sumIncludes.contains("D:/dir/include")); //$NON-NLS-1$ assertTrue(sumIncludes.contains("D:/dir/include")); //$NON-NLS-1$
assertTrue(sumIncludes.contains("/dir2/include")); //$NON-NLS-1$ assertTrue(sumIncludes.contains("/dir2/include")); //$NON-NLS-1$

View file

@ -20,22 +20,27 @@ import java.util.Map;
* *
* @author vhirsl * @author vhirsl
*/ */
@SuppressWarnings("rawtypes")
public interface IScannerInfoCollector { public interface IScannerInfoCollector {
/** /**
* Contribute to resource's scanner configuration * Contribute to resource's scanner configuration
* *
* @param resource - if used from within Eclipse it is expected that resource is a * @param resource
* member of <code>org.eclipse.core.resources.IResource</code> hierarchy. * <li> {@link org.eclipse.core.resources.IResource} if used from within Eclipse.</li>
* If used outside of Eclipse then resource is expected to be a * <li> {@link java.io.File} if used outside of Eclipse.</li>
* <code>java.io.File<code> type. * <li> {@code Integer} if represents command ID.</li>
* @param scannerInfo - a map of key - list pairs, where key is the type of extra info * @param scannerInfo - a map of key - list pairs, where key is the type of extra info
* i.e. target specific options or imacros commands,... * i.e. target specific options or imacros commands, for example
* <li>{@code Map<ScannerInfoTypes, List<String>>}</li>
* <li>{@code Map<ScannerInfoTypes, List<CCommandDSC>>}</li>
*/ */
public void contributeToScannerConfig(Object resource, Map scannerInfo); public void contributeToScannerConfig(Object resource, Map scannerInfo);
/** /**
* @return specific piece of discovered scanner info for a resource * @return specific piece of discovered scanner info for a resource
* discovered during the last collection cycle * discovered during the last collection cycle, can be:
* <li>{@code List<String>}</li>
* <li>{@code List<CCommandDSC>}</li>
*/ */
public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type); public List getCollectedScannerInfo(Object resource, ScannerInfoTypes type);

View file

@ -63,11 +63,12 @@ public class GCCSpecsRunSIProvider extends DefaultRunSIProvider {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean) * @see org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider#prepareArguments(boolean)
*/ */
@Override @Override
protected String[] prepareArguments(boolean isDefaultCommand) { protected String[] prepareArguments(boolean isDefaultCommand) {
if (collector == null) if (collector == null)
return fCompileArguments; return fCompileArguments;
@SuppressWarnings("unchecked")
List<String> tso = collector.getCollectedScannerInfo(resource.getProject(), ScannerInfoTypes.TARGET_SPECIFIC_OPTION); List<String> tso = collector.getCollectedScannerInfo(resource.getProject(), ScannerInfoTypes.TARGET_SPECIFIC_OPTION);
if (tso == null || tso.size() == 0) { if (tso == null || tso.size() == 0) {
return fCompileArguments; return fCompileArguments;

View file

@ -95,7 +95,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
this.context = new InfoContext(project); this.context = new InfoContext(project);
} }
public synchronized void contributeToScannerConfig(Object resource, Map scannerInfo, boolean isBuiltinConfig) { public synchronized void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") Map scannerInfo, boolean isBuiltinConfig) {
this.isBuiltinConfig= isBuiltinConfig; this.isBuiltinConfig= isBuiltinConfig;
try { try {
contributeToScannerConfig(resource, scannerInfo); contributeToScannerConfig(resource, scannerInfo);
@ -108,7 +108,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map) * @see org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector#contributeToScannerConfig(java.lang.Object, java.util.Map)
*/ */
public synchronized void contributeToScannerConfig(Object resource, Map scannerInfo) { public synchronized void contributeToScannerConfig(Object resource, @SuppressWarnings("rawtypes") Map scannerInfo) {
// check the resource // check the resource
String errorMessage = null; String errorMessage = null;
if (resource == null) { if (resource == null) {
@ -141,6 +141,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
for (Object name : scannerInfo.keySet()) { for (Object name : scannerInfo.keySet()) {
ScannerInfoTypes siType = (ScannerInfoTypes) name; ScannerInfoTypes siType = (ScannerInfoTypes) name;
@SuppressWarnings("unchecked")
List<String> delta = (List<String>) scannerInfo.get(siType); List<String> delta = (List<String>) scannerInfo.get(siType);
List<String> discovered = discoveredSI.get(siType); List<String> discovered = discoveredSI.get(siType);
@ -344,7 +345,7 @@ public class PerProjectSICollector implements IScannerInfoCollector3, IScannerIn
if (errorMessage != null) { if (errorMessage != null) {
TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$ TraceUtil.outputError("PerProjectSICollector.getCollectedScannerInfo : ", errorMessage); //$NON-NLS-1$
} }
else if (project.equals(((IResource)resource).getProject())) { else if (resource!=null && project.equals(((IResource)resource).getProject())) {
rv = discoveredSI.get(type); rv = discoveredSI.get(type);
} }
return rv; return rv;

View file

@ -61,10 +61,11 @@ public class SCDMakefileGenerator extends DefaultRunSIProvider {
return generateMakefile(resource.getProject().getName()); return generateMakefile(resource.getProject().getName());
} }
private boolean generateMakefile(String projectName) { private boolean generateMakefile(String projectName) {
boolean rc = false; boolean rc = false;
if (collector instanceof IScannerInfoCollector2) { if (collector instanceof IScannerInfoCollector2) {
IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector; IScannerInfoCollector2 collector2 = (IScannerInfoCollector2) collector;
@SuppressWarnings("unchecked")
List<CCommandDSC> commands = collector2.getCollectedScannerInfo( List<CCommandDSC> commands = collector2.getCollectedScannerInfo(
resource.getProject(), ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND); resource.getProject(), ScannerInfoTypes.UNDISCOVERED_COMPILER_COMMAND);
if (commands != null && commands.size() > 0) { if (commands != null && commands.size() > 0) {