1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

bug 263987, bug 193982, bug 216443, bug 248669 and more: tuning up GCC ErrorParser patterns

This commit is contained in:
Andrew Gvozdev 2010-02-04 21:50:24 +00:00
parent 1f8978eea3
commit 1c874e61a4
4 changed files with 125 additions and 32 deletions

View file

@ -50,17 +50,24 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
public static final String[] GCC_ERROR_STREAM3_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion", public static final String[] GCC_ERROR_STREAM3_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion",
"conversion for the latter"}; "conversion for the latter"};
public static final String[] GCC_ERROR_STREAM4 = {"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp: In member function `", public static final String[] GCC_ERROR_STREAM4 = {
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp: In member function `",
" NumericType RPNEvaluator<NumericType>::evaluate(const char*) [with ", " NumericType = int8]':", " NumericType RPNEvaluator<NumericType>::evaluate(const char*) [with ", " NumericType = int8]':",
"C:/QNX630/workspace/System/src/CommonScriptClasses.cpp:609: instantiated from here", "C:/QNX630/workspace/System/src/CommonScriptClasses.cpp:609: instantiated from here",
"C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `", "C:/QNX630/workspace/System/inc/RPNEvaluator.hpp:370: error: ISO C++ says that `",
" char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ", " char& String::operator[](unsigned int)' and `operator[]' are ambiguous even ",
" though the worst conversion for the former is better than the worst ", " conversion for the latter"}; " though the worst conversion for the former is better than the worst ",
" conversion for the latter",
};
public static final int GCC_ERROR_STREAM4_WARNINGS = 0; public static final int GCC_ERROR_STREAM4_WARNINGS = 0;
public static final int GCC_ERROR_STREAM4_ERRORS = 1; public static final int GCC_ERROR_STREAM4_ERRORS = 1;
public static final String[] GCC_ERROR_STREAM4_FILENAMES = {"RPNEvaluator.hpp"}; public static final String[] GCC_ERROR_STREAM4_FILENAMES = {"RPNEvaluator.hpp"};
public static final String[] GCC_ERROR_STREAM4_DESCRIPTIONS = {"ISO C++", "are ambiguous", "worst conversion for", public static final String[] GCC_ERROR_STREAM4_DESCRIPTIONS = {
"conversion for the latter"}; "ISO C++",
"are ambiguous",
"worst conversion for",
"conversion for the latter"
};
public static final String[] GCC_ERROR_STREAM5 = { public static final String[] GCC_ERROR_STREAM5 = {
"make -k all", "make -k all",
@ -72,7 +79,8 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
"main.c:6: error: parse error before \"return\"", "main.c:6: error: parse error before \"return\"",
"main.c:7:2: warning: no newline at end of file", "main.c:7:2: warning: no newline at end of file",
"make: *** [hallo.o] Error 1", "make: *** [hallo.o] Error 1",
"make: Target `all' not remade because of errors." }; "make: Target `all' not remade because of errors."
};
public static final int GCC_ERROR_STREAM5_WARNINGS = 1; public static final int GCC_ERROR_STREAM5_WARNINGS = 1;
public static final int GCC_ERROR_STREAM5_ERRORS = 2; public static final int GCC_ERROR_STREAM5_ERRORS = 2;
public static final String[] GCC_ERROR_STREAM5_FILENAMES = {"main.c"}; public static final String[] GCC_ERROR_STREAM5_FILENAMES = {"main.c"};
@ -138,5 +146,82 @@ public class GCCErrorParserTests extends GenericErrorParserTests {
); );
} }
public void testGccErrorMessages_C90Comments_bug193982() throws IOException {
runParserTest(
new String[] {
"Myfile.c:66:3: warning: C++ style comments are not allowed in ISO C90",
"Myfile.c:66:3: warning: (this will be reported only once per input file)",
},
0, // errors
1, // warnings
new String[] {"Myfile.c"},
new String[] {"C++ style comments are not allowed in ISO C90"},
new String[] {GCC_ERROR_PARSER_ID}
);
}
public void testGccErrorMessages_ConflictingTypes() throws IOException {
runParserTest(
new String[] {
"bar.h:42: error: conflicting types for 'jmp_buf'",
"foo.c:12: warning: conflicting types for built-in function `memset'",
},
1, // errors
1, // warnings
new String[] {"bar.h", "foo.c"},
new String[] {
"conflicting types for 'jmp_buf'",
"conflicting types for built-in function `memset'",
},
new String[] {GCC_ERROR_PARSER_ID}
);
}
public void testGccErrorMessages_InstantiatedFromHere() throws IOException {
runParserTest(
new String[] {
"C:/QNX630/workspace/System/src/CommonScriptClasses.cpp:609: instantiated from here",
},
0, // errors
0, // warnings
1, // infos
new String[] {"CommonScriptClasses.cpp"},
new String[] {"instantiated from here"},
new String[] {GCC_ERROR_PARSER_ID}
);
}
public void testGccErrorMessages_Infos() throws IOException {
runParserTest(
new String[] {
"foo.c:5: note: Offset of packed bit-field 'b' has changed in GCC 4.4",
"bar.c:7: Info: foo undeclared, assumed to return int",
},
0, // errors
0, // warnings
2, // infos
new String[] {"bar.c", "foo.c"},
new String[] {
"Offset of packed bit-field 'b' has changed in GCC 4.4",
"foo undeclared, assumed to return int",
},
new String[] {GCC_ERROR_PARSER_ID}
);
}
public void testGccErrorMessages_DangerousFunction_bug248669() throws IOException {
runParserTest(
new String[] {
"mktemp.o(.text+0x19): In function 'main':",
"mktemp.c:15: the use of 'mktemp' is dangerous, better use 'mkstemp'",
},
0, // errors
1, // warnings
new String[] {"mktemp.c"},
new String[] {"the use of 'mktemp' is dangerous, better use 'mkstemp'",},
new String[] {GCC_ERROR_PARSER_ID}
);
}
} }

View file

@ -17,6 +17,7 @@ import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -144,9 +145,9 @@ public abstract class GenericErrorParserTests extends TestCase {
} }
if (expectedDescriptions != null) { if (expectedDescriptions != null) {
assertNotNull(markerGenerator.lastDescription); assertNotNull(markerGenerator.descriptions);
for (int i = 0; i < expectedDescriptions.length; i++) { for (int i = 0; i < expectedDescriptions.length; i++) {
assertEquals(expectedDescriptions[i],markerGenerator.lastDescription); assertEquals(expectedDescriptions[i],markerGenerator.descriptions.get(i));
} }
} }
} }
@ -194,7 +195,7 @@ public abstract class GenericErrorParserTests extends TestCase {
public int numInfos; public int numInfos;
public int numMarkers; public int numMarkers;
public ArrayList uniqFiles; public ArrayList uniqFiles;
public String lastDescription; public List<String> descriptions;
private Comparator fFileNameComparator; private Comparator fFileNameComparator;
public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) { public void addMarker(IResource file, int lineNumber, String errorDesc, int severity, String errorVar) {
@ -220,7 +221,7 @@ public abstract class GenericErrorParserTests extends TestCase {
numInfos++; numInfos++;
} }
lastDescription = problemMarkerInfo.description; descriptions.add(problemMarkerInfo.description);
numMarkers++; numMarkers++;
} }
@ -230,6 +231,7 @@ public abstract class GenericErrorParserTests extends TestCase {
numWarnings = 0; numWarnings = 0;
numInfos = 0; numInfos = 0;
uniqFiles = new ArrayList(0); uniqFiles = new ArrayList(0);
descriptions = new ArrayList<String>(0);
fFileNameComparator = new FileNameComparator(); fFileNameComparator = new FileNameComparator();
} }
} }

View file

@ -49,21 +49,24 @@ CDTGNUAssemblerErrorParser.name=CDT GNU Assembler Error Parser
CDTGNULinkerErrorParser.name=CDT GNU Linker Error Parser CDTGNULinkerErrorParser.name=CDT GNU Linker Error Parser
CDTWorkingDirLocator.name=CDT CWD Locator CDTWorkingDirLocator.name=CDT CWD Locator
CDTGNUMakeErrorParser.name=CDT GNU Make Error Parser 7.0 CDTGNUMakeErrorParser.name=CDT GNU Make Error Parser 7.0
CDTVisualCErrorParser.name=CDT Visual C Error Parser
CDTGNUMakeErrorParser.name.deprecated=CDT GNU Make Error Parser 6.0 (Deprecated) CDTGNUMakeErrorParser.name.deprecated=CDT GNU Make Error Parser 6.0 (Deprecated)
CDTVisualCErrorParser.name=CDT Visual C Error Parser
CDTRegexErrorParser.name=CDT Regular Expression Error Parser CDTRegexErrorParser.name=CDT Regular Expression Error Parser
CDTGNUMakeErrorParser.regex.ReportedOnlyOnce=.*\\(Each undeclared identifier is reported only once.* CDTGNUCErrorParser.regex.ReportedOnlyOnce=(.*?):([0-9]+):([0-9]+:)? .*\\(Each undeclared identifier is reported only once.*
CDTGNUMakeErrorParser.regex.ForEachFunctionItAppearsIn=.*for each function it appears in.\\).* CDTGNUCErrorParser.regex.ForEachFunctionItAppearsIn=(.*?):([0-9]+):([0-9]+:)? .*for each function it appears in.\\).*
CDTGNUMakeErrorParser.regex.InstantiatedFrom=.*instantiated from .* CDTGNUCErrorParser.regex.ReportedOnlyOncePerInputFile=(.*?):([0-9]+):([0-9]+:)? .*this will be reported only once per input file.*
CDTGNUMakeErrorParser.regex.GenericNote=.* note:.* CDTGNUCErrorParser.regex.InstantiatedFromHere=(.*?):([0-9]+):([0-9]+:)?\\s*(.*instantiated from here.*)
CDTGNUMakeErrorParser.regex.ParseErrorBefore=(.*?):([0-9]+):([0-9]+:)? (parse error before.*[`'"](.*)'"].*) CDTGNUCErrorParser.regex.GenericInfo=(.*?):([0-9]+):([0-9]+:)?\\s*(([Nn]ote)|(NOTE)|([Ii]nfo)|(INFO)): (.*)
CDTGNUMakeErrorParser.regex.ErrorUndeclared=(.*?):([0-9]+):([0-9]+:)? [Ee]rror: ([`'"](.*)['"] undeclared .*) CDTGNUCErrorParser.regex.ParseErrorBefore=(.*?):([0-9]+):([0-9]+:)? (parse error before.*[`'"](.*)['"].*)
CDTGNUMakeErrorParser.regex.GenericError=(.*?):([0-9]+):([0-9]+:)?\\s*(([Ee]rror)|(ERROR)): (.*) CDTGNUCErrorParser.regex.ErrorUndeclared=(.*?):([0-9]+):([0-9]+:)? [Ee]rror: ([`'"](.*)['"] undeclared .*)
CDTGNUMakeErrorParser.regex.DefinedButNotUsed=(.*?):([0-9]+):([0-9]+:)? [Ww]arning: ([`'"](.*)['"] defined but not used.*) CDTGNUCErrorParser.regex.ErrorConflictingTypesFor=(.*?):([0-9]+):([0-9]+:)? [Ee]rror: (conflicting types for .*[`'"](.*)['"].*)
CDTGNUMakeErrorParser.regex.ConflictingTypesFor=(.*?):([0-9]+):([0-9]+:)? [Ww]arning: (conflicting types for .*[`'"](.*)['"].*) CDTGNUCErrorParser.regex.GenericError=(.*?):([0-9]+):([0-9]+:)?\\s*(([Ee]rror)|(ERROR)): (.*)
CDTGNUMakeErrorParser.regex.GenericWarning=(.*?):([0-9]+):([0-9]+:)?\\s*(([Ww]arning)|(WARNING)): (.*) CDTGNUCErrorParser.regex.DefinedButNotUsed=(.*?):([0-9]+):([0-9]+:)? [Ww]arning: ([`'"](.*)['"] defined but not used.*)
CDTGNUMakeErrorParser.regex.OtherError=(.*?):([0-9]+):([0-9]+:)? (.*) CDTGNUCErrorParser.regex.WarningConflictingTypesFor=(.*?):([0-9]+):([0-9]+:)? [Ww]arning: (conflicting types for .*[`'"](.*)['"].*)
CDTGNUCErrorParser.regex.WarningDangerousFunction=(.*?):([0-9]+):([0-9]+:)? ([Ww]arning:)?\\s*(the use of [`'"](.*)['"] is dangerous, better use [`'"](.*)['"].*)
CDTGNUCErrorParser.regex.GenericWarning=(.*?):([0-9]+):([0-9]+:)?\\s*(([Ww]arning)|(WARNING)): (.*)
CDTGNUCErrorParser.regex.OtherError=(.*?):([0-9]+):([0-9]+:)? (.*)
PathEntryContainerInitializer=Path Entry Container Initializer PathEntryContainerInitializer=Path Entry Container Initializer

View file

@ -157,17 +157,20 @@
class="org.eclipse.cdt.core.errorparsers.RegexErrorParser" class="org.eclipse.cdt.core.errorparsers.RegexErrorParser"
id="org.eclipse.cdt.core.GCCErrorParser" id="org.eclipse.cdt.core.GCCErrorParser"
name="%CDTGNUCErrorParser.name"> name="%CDTGNUCErrorParser.name">
<pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUMakeErrorParser.regex.ReportedOnlyOnce" severity="Ignore"/> <pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUCErrorParser.regex.ReportedOnlyOnce" severity="Ignore"/>
<pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUMakeErrorParser.regex.ForEachFunctionItAppearsIn" severity="Ignore"/> <pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUCErrorParser.regex.ForEachFunctionItAppearsIn" severity="Ignore"/>
<pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUMakeErrorParser.regex.InstantiatedFrom" severity="Ignore"/> <pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUCErrorParser.regex.ReportedOnlyOncePerInputFile" severity="Ignore"/>
<pattern description-expr="" eat-processed-line="true" file-expr="" line-expr="" regex="%CDTGNUMakeErrorParser.regex.GenericNote" severity="Ignore"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.ErrorUndeclared" severity="Error" variable-expr="$5"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.ParseErrorBefore" severity="Error" variable-expr="$5"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.ErrorConflictingTypesFor" severity="Error" variable-expr="$5"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.ErrorUndeclared" severity="Error" variable-expr="$5"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.ParseErrorBefore" severity="Error" variable-expr="$5"/>
<pattern description-expr="$7" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.GenericError" severity="Error"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.DefinedButNotUsed" severity="Warning" variable-expr="$5"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.DefinedButNotUsed" severity="Warning" variable-expr="$5"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.WarningConflictingTypesFor" severity="Warning" variable-expr="$5"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.ConflictingTypesFor" severity="Warning" variable-expr="$5"/> <pattern description-expr="$5" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.WarningDangerousFunction" severity="Warning" variable-expr="$6"/>
<pattern description-expr="$7" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.GenericWarning" severity="Warning"/> <pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.InstantiatedFromHere" severity="Info"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUMakeErrorParser.regex.OtherError" severity="Error"/> <pattern description-expr="$7" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.GenericError" severity="Error"/>
<pattern description-expr="$7" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.GenericWarning" severity="Warning"/>
<pattern description-expr="$9" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.GenericInfo" severity="Info"/>
<pattern description-expr="$4" eat-processed-line="true" file-expr="$1" line-expr="$2" regex="%CDTGNUCErrorParser.regex.OtherError" severity="Error"/>
</errorparser> </errorparser>
</extension> </extension>
<extension <extension