mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-05 22:50:23 +00:00
If merely redefining a CONST with same value, just issue a warning.
This commit is contained in:
parent
ca446b471d
commit
cb21e44e94
|
@ -112,7 +112,7 @@ DIM SHARED ConsoleMode, No_C_Compile_Mode, Cloud, NoIDEMode
|
|||
DIM SHARED VerboseMode AS _BYTE, CMDLineFile AS STRING
|
||||
|
||||
DIM SHARED totalUnusedVariables AS LONG, usedVariableList$, bypassNextVariable AS _BYTE
|
||||
DIM SHARED totalWarnings AS LONG, warningListItems AS LONG
|
||||
DIM SHARED totalWarnings AS LONG, warningListItems AS LONG, lastWarningHeader AS STRING
|
||||
DIM SHARED ExeIconSet AS LONG
|
||||
DIM SHARED VersionInfoSet AS _BYTE
|
||||
|
||||
|
@ -1435,6 +1435,7 @@ usedVariableList$ = ""
|
|||
totalUnusedVariables = 0
|
||||
totalWarnings = 0
|
||||
warningListItems = 0
|
||||
lastWarningHeader = ""
|
||||
REDIM SHARED warning$(1000)
|
||||
uniquenumbern = 0
|
||||
|
||||
|
@ -2353,7 +2354,31 @@ DO
|
|||
hashres = HashFind(hashname$, hashchkflags, hashresflags, hashresref)
|
||||
DO WHILE hashres
|
||||
IF hashresflags AND HASHFLAG_CONSTANT THEN
|
||||
IF constsubfunc(hashresref) = subfuncn THEN a$ = "Name already in use": GOTO errmes
|
||||
IF constsubfunc(hashresref) = subfuncn THEN
|
||||
'If merely redefining a CONST with same value
|
||||
'just issue a warning instead of an error
|
||||
issueWarning = 0
|
||||
IF t AND ISSTRING THEN
|
||||
IF conststring(hashresref) = e$ THEN issueWarning = -1
|
||||
ELSE
|
||||
IF t AND ISFLOAT THEN
|
||||
IF constfloat(hashresref) = constval## THEN issueWarning = -1
|
||||
ELSE
|
||||
IF t AND ISUNSIGNED THEN
|
||||
IF constuinteger(hashresref) = constval~&& THEN issueWarning = -1
|
||||
ELSE
|
||||
IF constinteger(hashresref) = constval&& THEN issueWarning = -1
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
IF issueWarning THEN
|
||||
addWarning 0, "Constant already defined (same value):"
|
||||
addWarning linenumber, n$
|
||||
GOTO constAddDone
|
||||
ELSE
|
||||
a$ = "Name already in use": GOTO errmes
|
||||
END IF
|
||||
END IF
|
||||
END IF
|
||||
IF hashresflags AND HASHFLAG_RESERVED THEN
|
||||
a$ = "Name already in use": GOTO errmes
|
||||
|
@ -2391,6 +2416,8 @@ DO
|
|||
END IF
|
||||
END IF
|
||||
|
||||
constAddDone:
|
||||
|
||||
IF pending THEN
|
||||
'l$ = l$ + sp2 + ","
|
||||
GOTO constdefpendingpp
|
||||
|
@ -24994,11 +25021,19 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE)
|
|||
END SUB
|
||||
|
||||
SUB addWarning (lineNumber AS LONG, text$)
|
||||
IF lineNumber > 0 THEN
|
||||
totalWarnings = totalWarnings + 1
|
||||
ELSE
|
||||
IF lastWarningHeader = text$ THEN
|
||||
EXIT SUB
|
||||
ELSE
|
||||
lastWarningHeader = text$
|
||||
END IF
|
||||
END IF
|
||||
|
||||
warningListItems = warningListItems + 1
|
||||
IF warningListItems > UBOUND(warning$) THEN REDIM _PRESERVE warning$(warningListItems + 999)
|
||||
|
||||
warning$(warningListItems) = MKL$(lineNumber) + text$
|
||||
IF lineNumber > 0 THEN totalWarnings = totalWarnings + 1
|
||||
END SUB
|
||||
|
||||
'$INCLUDE:'utilities\strings.bas'
|
||||
|
|
Loading…
Reference in a new issue