Permalink
Browse files

Strict mode compiler issue with 11.7.3 and 11.7.4 (#327)

  • Loading branch information...
gquerret committed Nov 17, 2018
1 parent f9a1d11 commit 335b2dda0550010a450d53946af8469f982da9b7
@@ -26,7 +26,6 @@
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.ResourceCollection;
public class CompilationAttributes implements ICompilationAttributes {
@@ -67,9 +66,9 @@
private int fileList = 0;
// Internal use
private final Task parent;
private final PCT parent;
public CompilationAttributes(Task parent) {
public CompilationAttributes(PCT parent) {
this.parent = parent;
}
@@ -404,6 +403,7 @@ public int getFileList() {
}
protected void writeCompilationProcedure(File f, Charset c) {
boolean bAbove12 = parent.getVersion().compareTo(new DLCVersion(12, 0, "0")) >= 0;
try (FileOutputStream fos = new FileOutputStream(f);
OutputStreamWriter osw = new OutputStreamWriter(fos, c);
BufferedWriter bw = new BufferedWriter(osw)) {
@@ -421,10 +421,14 @@ protected void writeCompilationProcedure(File f, Charset c) {
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipXREF AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DEFINE INPUT PARAMETER ipOptions AS CHARACTER NO-UNDO.");
bw.newLine();
bw.write("DO ON STOP UNDO, RETRY: IF RETRY THEN DO: COMPILER:ERROR = TRUE. RETURN. END.");
bw.newLine();
bw.write("COMPILE VALUE(ipSrcFile) ");
if (bAbove12)
bw.write("OPTIONS ipOptions ");
if (isSaveR())
bw.write("SAVE INTO VALUE(ipSaveDir) ");
bw.write(" DEBUG-LIST VALUE(ipDbg) ");
@@ -557,6 +557,10 @@ protected long getRCodeVersion() {
return version.getrCodeVersion();
}
protected DLCVersion getVersion() {
return version;
}
public int getAntLoggerLever() {
try {
List<BuildListener> listeners = getProject().getBuildListeners();
@@ -119,8 +119,20 @@ DEFINE VARIABLE iFileList AS INTEGER NO-UNDO.
DEFINE VARIABLE hSrcProc AS HANDLE NO-UNDO.
ASSIGN hSrcProc = SOURCE-PROCEDURE.
DEFINE VARIABLE majorMinor AS DECIMAL NO-UNDO.
DEFINE VARIABLE bAbove101 AS LOGICAL NO-UNDO INITIAL TRUE.
ASSIGN bAbove101 = (DECIMAL(REPLACE(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, '.') + 1), '.', SESSION:NUMERIC-DECIMAL-POINT)) GT 10.1).
DEFINE VARIABLE bAboveEq117 AS LOGICAL NO-UNDO INITIAL FALSE.
DEFINE VARIABLE bAboveEq1173 AS LOGICAL NO-UNDO INITIAL FALSE.
DEFINE VARIABLE bAboveEq12 AS LOGICAL NO-UNDO INITIAL FALSE.
ASSIGN majorMinor = DECIMAL(REPLACE(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, '.') + 1), '.', SESSION:NUMERIC-DECIMAL-POINT)).
ASSIGN bAbove101 = majorMinor GT 10.1.
ASSIGN bAboveEq117 = (majorMinor GE 11.7).
&IF DECIMAL(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, '.') + 1)) GE 11 &THEN
// PROVERSION(1) available since v11
ASSIGN bAboveEq1173 = (majorMinor GT 11.7) OR ((majorMinor EQ 11.7) AND (INTEGER(ENTRY(3, PROVERSION(1), '.')) GE 3)). /* FIXME Check exact version number */
&ENDIF
ASSIGN bAboveEq12 = (majorMinor GE 12).
PROCEDURE setOption.
DEFINE INPUT PARAMETER ipName AS CHARACTER NO-UNDO.
@@ -181,11 +193,11 @@ PROCEDURE initModule:
END.
COMPILER:MULTI-COMPILE = multiComp.
IF lOptFullKw THEN
ASSIGN cOpts = 'require-full-keywords'.
ASSIGN cOpts = 'require-full-keywords' + (IF bAboveEq12 THEN ':warning' ELSE IF bAboveEq1173 THEN ':error' ELSE '').
IF lOptFldQlf THEN
ASSIGN cOpts = cOpts + (IF cOpts EQ '' THEN '' ELSE ',') + 'require-field-qualifiers'.
ASSIGN cOpts = cOpts + (IF cOpts EQ '' THEN '' ELSE ',') + 'require-field-qualifiers' + (IF bAboveEq12 THEN ':warning' ELSE IF bAboveEq1173 THEN ':error' ELSE '').
IF lOptFullNames THEN
ASSIGN cOpts = cOpts + (IF cOpts EQ '' THEN '' ELSE ',') + 'require-full-names'.
ASSIGN cOpts = cOpts + (IF cOpts EQ '' THEN '' ELSE ',') + 'require-full-names' + (IF bAboveEq12 THEN ':warning' ELSE IF bAboveEq1173 THEN ':error' ELSE '').
IF ProgPerc GT 0 THEN DO:
ASSIGN iNrSteps = 100 / ProgPerc.
@@ -354,8 +366,11 @@ PROCEDURE compileXref.
ELSE
ASSIGN debugListingFile = ?.
/* Before 11.7.3, strict mode compiler was throwing errors. 11.7.3 introduced :warning and :error but that doesn't work
correctly, so we still stay with the old behavior. I expect OE 12 to fix this issue. */
/* them into warnings */
&IF DECIMAL(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, '.') + 1)) GE 11.7 &THEN
IF (cOpts GT "") AND (DECIMAL(REPLACE(SUBSTRING(PROVERSION, 1, INDEX(PROVERSION, '.') + 1), '.', SESSION:NUMERIC-DECIMAL-POINT)) GE 11.7) THEN DO:
IF (cOpts GT "") AND bAboveEq117 AND (NOT bAboveEq12) THEN DO:
EMPTY TEMP-TABLE ttWarnings.
COMPILE VALUE(IF lRelative THEN ipInFile ELSE ipInDir + '/':U + ipInFile) SAVE=FALSE OPTIONS cOpts NO-ERROR.
IF COMPILER:ERROR THEN DO i = 1 TO COMPILER:NUM-MESSAGES:
@@ -376,7 +391,7 @@ PROCEDURE compileXref.
RUN pctcomp.p (IF lRelative THEN ipInFile ELSE ipInDir + '/':U + ipInFile,
cSaveDir, debugListingFile,
IF Lst AND NOT LstPrepro THEN PCTDir + '/':U + ipInFile ELSE ?,
preprocessFile, cStrXrefFile, cXrefFile).
preprocessFile, cStrXrefFile, cXrefFile, IF bAboveEq12 THEN cOpts ELSE "").
ASSIGN opError = COMPILER:ERROR.
IF NOT opError THEN DO:
@@ -395,6 +410,8 @@ PROCEDURE compileXref.
OUTPUT STREAM sWarnings TO VALUE(warningsFile).
DO i = 1 TO COMPILER:NUM-MESSAGES:
IF bAbove101 THEN DO:
/* Pointless message coming from strict mode compiler */
IF COMPILER:GET-NUMBER(i) EQ 2411 THEN NEXT.
/* Messages 2363, 3619 and 3623 are in fact warnings (from -checkdbe switch) */
IF (COMPILER:GET-MESSAGE-TYPE(i) EQ 2) OR (COMPILER:GET-NUMBER(i) EQ 2363) OR (COMPILER:GET-NUMBER(i) EQ 3619) OR (COMPILER:GET-NUMBER(i) EQ 3623) THEN DO:
IF (LOOKUP(STRING(COMPILER:GET-NUMBER(i)), SESSION:SUPPRESS-WARNINGS-LIST) EQ 0) THEN DO:

0 comments on commit 335b2dd

Please sign in to comment.