Merge remote-tracking branch 'upstream/master' into pcenginetarget
This commit is contained in:
@@ -2316,21 +2316,25 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
<sect1><tt>.ISMNEM, .ISMNEMONIC</tt><label id=".ISMNEMONIC"><p>
|
<sect1><tt>.DEFINEDMACRO</tt><label id=".DEFINEDMACRO"><p>
|
||||||
|
|
||||||
Builtin function. The function expects an identifier as argument in braces.
|
Builtin function. The function expects an identifier as argument in braces.
|
||||||
The argument is evaluated, and the function yields "true" if the identifier
|
The argument is evaluated, and the function yields "true" if the identifier
|
||||||
is defined as an instruction mnemonic that is recognized by the assembler.
|
has already been defined as the name of a macro. Otherwise the function yields
|
||||||
Example:
|
false. Example:
|
||||||
|
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
.if .not .ismnemonic(ina)
|
.macro add foo
|
||||||
.macro ina
|
clc
|
||||||
clc
|
adc foo
|
||||||
adc #$01
|
.endmacro
|
||||||
.endmacro
|
|
||||||
.endif
|
.if .definedmacro(add)
|
||||||
|
add #$01
|
||||||
|
.else
|
||||||
|
clc
|
||||||
|
adc #$01
|
||||||
|
.endif
|
||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
@@ -3158,6 +3162,23 @@ Here's a list of all control commands and a description, what they do:
|
|||||||
the feature in more detail.
|
the feature in more detail.
|
||||||
|
|
||||||
|
|
||||||
|
<sect1><tt>.ISMNEM, .ISMNEMONIC</tt><label id=".ISMNEMONIC"><p>
|
||||||
|
|
||||||
|
Builtin function. The function expects an identifier as argument in braces.
|
||||||
|
The argument is evaluated, and the function yields "true" if the identifier
|
||||||
|
is defined as an instruction mnemonic that is recognized by the assembler.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
<tscreen><verb>
|
||||||
|
.if .not .ismnemonic(ina)
|
||||||
|
.macro ina
|
||||||
|
clc
|
||||||
|
adc #$01
|
||||||
|
.endmacro
|
||||||
|
.endif
|
||||||
|
</verb></tscreen>
|
||||||
|
|
||||||
|
|
||||||
<sect1><tt>.LINECONT</tt><label id=".LINECONT"><p>
|
<sect1><tt>.LINECONT</tt><label id=".LINECONT"><p>
|
||||||
|
|
||||||
Switch on or off line continuations using the backslash character
|
Switch on or off line continuations using the backslash character
|
||||||
|
|||||||
@@ -418,30 +418,22 @@ static ExprNode* FuncDefined (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static ExprNode* FuncIsMnemonic (void)
|
static ExprNode* FuncDefinedMacro (void)
|
||||||
/* Handle the .ISMNEMONIC, .ISMNEM builtin function */
|
/* Handle the .DEFINEDMACRO builtin function */
|
||||||
{
|
{
|
||||||
int Instr = -1;
|
Macro* Mac = 0;
|
||||||
|
|
||||||
/* Check for a macro or an instruction depending on UbiquitousIdents */
|
/* Check if the identifier is a macro */
|
||||||
|
|
||||||
if (CurTok.Tok == TOK_IDENT) {
|
if (CurTok.Tok == TOK_IDENT) {
|
||||||
if (UbiquitousIdents) {
|
Mac = FindMacro (&CurTok.SVal);
|
||||||
/* Macros CAN be instructions, so check for them first */
|
|
||||||
if (FindMacro (&CurTok.SVal) == 0) {
|
|
||||||
Instr = FindInstruction (&CurTok.SVal);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Macros and symbols may NOT use the names of instructions, so just check for the instruction */
|
|
||||||
Instr = FindInstruction (&CurTok.SVal);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Error ("Identifier expected.");
|
Error ("Identifier expected.");
|
||||||
}
|
}
|
||||||
/* Skip the name */
|
/* Skip the name */
|
||||||
NextTok ();
|
NextTok ();
|
||||||
|
|
||||||
return GenLiteralExpr (Instr > 0);
|
return GenLiteralExpr (Mac != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -462,6 +454,36 @@ static ExprNode* FuncHiWord (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static ExprNode* FuncIsMnemonic (void)
|
||||||
|
/* Handle the .ISMNEMONIC, .ISMNEM builtin function */
|
||||||
|
{
|
||||||
|
int Instr = -1;
|
||||||
|
|
||||||
|
/* Check for a macro or an instruction depending on UbiquitousIdents */
|
||||||
|
|
||||||
|
if (CurTok.Tok == TOK_IDENT) {
|
||||||
|
if (UbiquitousIdents) {
|
||||||
|
/* Macros CAN be instructions, so check for them first */
|
||||||
|
if (FindMacro (&CurTok.SVal) == 0) {
|
||||||
|
Instr = FindInstruction (&CurTok.SVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Macros and symbols may NOT use the names of instructions, so just check for the instruction */
|
||||||
|
Instr = FindInstruction (&CurTok.SVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Error ("Identifier expected.");
|
||||||
|
}
|
||||||
|
/* Skip the name */
|
||||||
|
NextTok ();
|
||||||
|
|
||||||
|
return GenLiteralExpr (Instr > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExprNode* FuncLoByte (void)
|
ExprNode* FuncLoByte (void)
|
||||||
/* Handle the .LOBYTE builtin function */
|
/* Handle the .LOBYTE builtin function */
|
||||||
{
|
{
|
||||||
@@ -1094,8 +1116,8 @@ static ExprNode* Factor (void)
|
|||||||
N = Function (FuncDefined);
|
N = Function (FuncDefined);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_ISMNEMONIC:
|
case TOK_DEFINEDMACRO:
|
||||||
N = Function (FuncIsMnemonic);
|
N = Function (FuncDefinedMacro);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_HIBYTE:
|
case TOK_HIBYTE:
|
||||||
@@ -1106,6 +1128,10 @@ static ExprNode* Factor (void)
|
|||||||
N = Function (FuncHiWord);
|
N = Function (FuncHiWord);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOK_ISMNEMONIC:
|
||||||
|
N = Function (FuncIsMnemonic);
|
||||||
|
break;
|
||||||
|
|
||||||
case TOK_LOBYTE:
|
case TOK_LOBYTE:
|
||||||
N = Function (FuncLoByte);
|
N = Function (FuncLoByte);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -83,3 +83,4 @@ unsigned char CComments = 0; /* Allow C like comments */
|
|||||||
unsigned char ForceRange = 0; /* Force values into expected range */
|
unsigned char ForceRange = 0; /* Force values into expected range */
|
||||||
unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
|
unsigned char UnderlineInNumbers = 0; /* Allow underlines in numbers */
|
||||||
unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */
|
unsigned char AddrSize = 0; /* Allow .ADDRSIZE function */
|
||||||
|
|
||||||
|
|||||||
@@ -1989,6 +1989,7 @@ static CtrlDesc CtrlCmdTab [] = {
|
|||||||
{ ccNone, DoDebugInfo },
|
{ ccNone, DoDebugInfo },
|
||||||
{ ccNone, DoDefine },
|
{ ccNone, DoDefine },
|
||||||
{ ccNone, DoUnexpected }, /* .DEFINED */
|
{ ccNone, DoUnexpected }, /* .DEFINED */
|
||||||
|
{ ccNone, DoUnexpected }, /* .DEFINEDMACRO */
|
||||||
{ ccNone, DoDelMac },
|
{ ccNone, DoDelMac },
|
||||||
{ ccNone, DoDestructor },
|
{ ccNone, DoDestructor },
|
||||||
{ ccNone, DoDWord },
|
{ ccNone, DoDWord },
|
||||||
|
|||||||
@@ -132,165 +132,166 @@ struct DotKeyword {
|
|||||||
const char* Key; /* MUST be first field */
|
const char* Key; /* MUST be first field */
|
||||||
token_t Tok;
|
token_t Tok;
|
||||||
} DotKeywords [] = {
|
} DotKeywords [] = {
|
||||||
{ ".A16", TOK_A16 },
|
{ ".A16", TOK_A16 },
|
||||||
{ ".A8", TOK_A8 },
|
{ ".A8", TOK_A8 },
|
||||||
{ ".ADDR", TOK_ADDR },
|
{ ".ADDR", TOK_ADDR },
|
||||||
{ ".ADDRSIZE", TOK_ADDRSIZE },
|
{ ".ADDRSIZE", TOK_ADDRSIZE },
|
||||||
{ ".ALIGN", TOK_ALIGN },
|
{ ".ALIGN", TOK_ALIGN },
|
||||||
{ ".AND", TOK_BOOLAND },
|
{ ".AND", TOK_BOOLAND },
|
||||||
{ ".ASCIIZ", TOK_ASCIIZ },
|
{ ".ASCIIZ", TOK_ASCIIZ },
|
||||||
{ ".ASSERT", TOK_ASSERT },
|
{ ".ASSERT", TOK_ASSERT },
|
||||||
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
|
{ ".AUTOIMPORT", TOK_AUTOIMPORT },
|
||||||
{ ".BANK", TOK_BANK },
|
{ ".BANK", TOK_BANK },
|
||||||
{ ".BANKBYTE", TOK_BANKBYTE },
|
{ ".BANKBYTE", TOK_BANKBYTE },
|
||||||
{ ".BANKBYTES", TOK_BANKBYTES },
|
{ ".BANKBYTES", TOK_BANKBYTES },
|
||||||
{ ".BITAND", TOK_AND },
|
{ ".BITAND", TOK_AND },
|
||||||
{ ".BITNOT", TOK_NOT },
|
{ ".BITNOT", TOK_NOT },
|
||||||
{ ".BITOR", TOK_OR },
|
{ ".BITOR", TOK_OR },
|
||||||
{ ".BITXOR", TOK_XOR },
|
{ ".BITXOR", TOK_XOR },
|
||||||
{ ".BLANK", TOK_BLANK },
|
{ ".BLANK", TOK_BLANK },
|
||||||
{ ".BSS", TOK_BSS },
|
{ ".BSS", TOK_BSS },
|
||||||
{ ".BYT", TOK_BYTE },
|
{ ".BYT", TOK_BYTE },
|
||||||
{ ".BYTE", TOK_BYTE },
|
{ ".BYTE", TOK_BYTE },
|
||||||
{ ".CASE", TOK_CASE },
|
{ ".CASE", TOK_CASE },
|
||||||
{ ".CHARMAP", TOK_CHARMAP },
|
{ ".CHARMAP", TOK_CHARMAP },
|
||||||
{ ".CODE", TOK_CODE },
|
{ ".CODE", TOK_CODE },
|
||||||
{ ".CONCAT", TOK_CONCAT },
|
{ ".CONCAT", TOK_CONCAT },
|
||||||
{ ".CONDES", TOK_CONDES },
|
{ ".CONDES", TOK_CONDES },
|
||||||
{ ".CONST", TOK_CONST },
|
{ ".CONST", TOK_CONST },
|
||||||
{ ".CONSTRUCTOR", TOK_CONSTRUCTOR },
|
{ ".CONSTRUCTOR", TOK_CONSTRUCTOR },
|
||||||
{ ".CPU", TOK_CPU },
|
{ ".CPU", TOK_CPU },
|
||||||
{ ".DATA", TOK_DATA },
|
{ ".DATA", TOK_DATA },
|
||||||
{ ".DBG", TOK_DBG },
|
{ ".DBG", TOK_DBG },
|
||||||
{ ".DBYT", TOK_DBYT },
|
{ ".DBYT", TOK_DBYT },
|
||||||
{ ".DEBUGINFO", TOK_DEBUGINFO },
|
{ ".DEBUGINFO", TOK_DEBUGINFO },
|
||||||
{ ".DEF", TOK_DEFINED },
|
{ ".DEF", TOK_DEFINED },
|
||||||
{ ".DEFINE", TOK_DEFINE },
|
{ ".DEFINE", TOK_DEFINE },
|
||||||
{ ".DEFINED", TOK_DEFINED },
|
{ ".DEFINED", TOK_DEFINED },
|
||||||
{ ".DELMAC", TOK_DELMAC },
|
{ ".DEFINEDMACRO", TOK_DEFINEDMACRO },
|
||||||
{ ".DELMACRO", TOK_DELMAC },
|
{ ".DELMAC", TOK_DELMAC },
|
||||||
{ ".DESTRUCTOR", TOK_DESTRUCTOR },
|
{ ".DELMACRO", TOK_DELMAC },
|
||||||
{ ".DWORD", TOK_DWORD },
|
{ ".DESTRUCTOR", TOK_DESTRUCTOR },
|
||||||
{ ".ELSE", TOK_ELSE },
|
{ ".DWORD", TOK_DWORD },
|
||||||
{ ".ELSEIF", TOK_ELSEIF },
|
{ ".ELSE", TOK_ELSE },
|
||||||
{ ".END", TOK_END },
|
{ ".ELSEIF", TOK_ELSEIF },
|
||||||
{ ".ENDENUM", TOK_ENDENUM },
|
{ ".END", TOK_END },
|
||||||
{ ".ENDIF", TOK_ENDIF },
|
{ ".ENDENUM", TOK_ENDENUM },
|
||||||
{ ".ENDMAC", TOK_ENDMACRO },
|
{ ".ENDIF", TOK_ENDIF },
|
||||||
{ ".ENDMACRO", TOK_ENDMACRO },
|
{ ".ENDMAC", TOK_ENDMACRO },
|
||||||
{ ".ENDPROC", TOK_ENDPROC },
|
{ ".ENDMACRO", TOK_ENDMACRO },
|
||||||
{ ".ENDREP", TOK_ENDREP },
|
{ ".ENDPROC", TOK_ENDPROC },
|
||||||
{ ".ENDREPEAT", TOK_ENDREP },
|
{ ".ENDREP", TOK_ENDREP },
|
||||||
{ ".ENDSCOPE", TOK_ENDSCOPE },
|
{ ".ENDREPEAT", TOK_ENDREP },
|
||||||
{ ".ENDSTRUCT", TOK_ENDSTRUCT },
|
{ ".ENDSCOPE", TOK_ENDSCOPE },
|
||||||
{ ".ENDUNION", TOK_ENDUNION },
|
{ ".ENDSTRUCT", TOK_ENDSTRUCT },
|
||||||
{ ".ENUM", TOK_ENUM },
|
{ ".ENDUNION", TOK_ENDUNION },
|
||||||
{ ".ERROR", TOK_ERROR },
|
{ ".ENUM", TOK_ENUM },
|
||||||
{ ".EXITMAC", TOK_EXITMACRO },
|
{ ".ERROR", TOK_ERROR },
|
||||||
{ ".EXITMACRO", TOK_EXITMACRO },
|
{ ".EXITMAC", TOK_EXITMACRO },
|
||||||
{ ".EXPORT", TOK_EXPORT },
|
{ ".EXITMACRO", TOK_EXITMACRO },
|
||||||
{ ".EXPORTZP", TOK_EXPORTZP },
|
{ ".EXPORT", TOK_EXPORT },
|
||||||
{ ".FARADDR", TOK_FARADDR },
|
{ ".EXPORTZP", TOK_EXPORTZP },
|
||||||
{ ".FATAL", TOK_FATAL },
|
{ ".FARADDR", TOK_FARADDR },
|
||||||
{ ".FEATURE", TOK_FEATURE },
|
{ ".FATAL", TOK_FATAL },
|
||||||
{ ".FILEOPT", TOK_FILEOPT },
|
{ ".FEATURE", TOK_FEATURE },
|
||||||
{ ".FOPT", TOK_FILEOPT },
|
{ ".FILEOPT", TOK_FILEOPT },
|
||||||
{ ".FORCEIMPORT", TOK_FORCEIMPORT },
|
{ ".FOPT", TOK_FILEOPT },
|
||||||
{ ".FORCEWORD", TOK_FORCEWORD },
|
{ ".FORCEIMPORT", TOK_FORCEIMPORT },
|
||||||
{ ".GLOBAL", TOK_GLOBAL },
|
{ ".FORCEWORD", TOK_FORCEWORD },
|
||||||
{ ".GLOBALZP", TOK_GLOBALZP },
|
{ ".GLOBAL", TOK_GLOBAL },
|
||||||
{ ".HIBYTE", TOK_HIBYTE },
|
{ ".GLOBALZP", TOK_GLOBALZP },
|
||||||
{ ".HIBYTES", TOK_HIBYTES },
|
{ ".HIBYTE", TOK_HIBYTE },
|
||||||
{ ".HIWORD", TOK_HIWORD },
|
{ ".HIBYTES", TOK_HIBYTES },
|
||||||
{ ".I16", TOK_I16 },
|
{ ".HIWORD", TOK_HIWORD },
|
||||||
{ ".I8", TOK_I8 },
|
{ ".I16", TOK_I16 },
|
||||||
{ ".IDENT", TOK_MAKEIDENT },
|
{ ".I8", TOK_I8 },
|
||||||
{ ".IF", TOK_IF },
|
{ ".IDENT", TOK_MAKEIDENT },
|
||||||
{ ".IFBLANK", TOK_IFBLANK },
|
{ ".IF", TOK_IF },
|
||||||
{ ".IFCONST", TOK_IFCONST },
|
{ ".IFBLANK", TOK_IFBLANK },
|
||||||
{ ".IFDEF", TOK_IFDEF },
|
{ ".IFCONST", TOK_IFCONST },
|
||||||
{ ".IFNBLANK", TOK_IFNBLANK },
|
{ ".IFDEF", TOK_IFDEF },
|
||||||
{ ".IFNCONST", TOK_IFNCONST },
|
{ ".IFNBLANK", TOK_IFNBLANK },
|
||||||
{ ".IFNDEF", TOK_IFNDEF },
|
{ ".IFNCONST", TOK_IFNCONST },
|
||||||
{ ".IFNREF", TOK_IFNREF },
|
{ ".IFNDEF", TOK_IFNDEF },
|
||||||
{ ".IFP02", TOK_IFP02 },
|
{ ".IFNREF", TOK_IFNREF },
|
||||||
{ ".IFP816", TOK_IFP816 },
|
{ ".IFP02", TOK_IFP02 },
|
||||||
{ ".IFPC02", TOK_IFPC02 },
|
{ ".IFP816", TOK_IFP816 },
|
||||||
{ ".IFPSC02", TOK_IFPSC02 },
|
{ ".IFPC02", TOK_IFPC02 },
|
||||||
{ ".IFREF", TOK_IFREF },
|
{ ".IFPSC02", TOK_IFPSC02 },
|
||||||
{ ".IMPORT", TOK_IMPORT },
|
{ ".IFREF", TOK_IFREF },
|
||||||
{ ".IMPORTZP", TOK_IMPORTZP },
|
{ ".IMPORT", TOK_IMPORT },
|
||||||
{ ".INCBIN", TOK_INCBIN },
|
{ ".IMPORTZP", TOK_IMPORTZP },
|
||||||
{ ".INCLUDE", TOK_INCLUDE },
|
{ ".INCBIN", TOK_INCBIN },
|
||||||
{ ".INTERRUPTOR", TOK_INTERRUPTOR },
|
{ ".INCLUDE", TOK_INCLUDE },
|
||||||
{ ".ISMNEM", TOK_ISMNEMONIC },
|
{ ".INTERRUPTOR", TOK_INTERRUPTOR },
|
||||||
{ ".ISMNEMONIC", TOK_ISMNEMONIC },
|
{ ".ISMNEM", TOK_ISMNEMONIC },
|
||||||
{ ".LEFT", TOK_LEFT },
|
{ ".ISMNEMONIC", TOK_ISMNEMONIC },
|
||||||
{ ".LINECONT", TOK_LINECONT },
|
{ ".LEFT", TOK_LEFT },
|
||||||
{ ".LIST", TOK_LIST },
|
{ ".LINECONT", TOK_LINECONT },
|
||||||
{ ".LISTBYTES", TOK_LISTBYTES },
|
{ ".LIST", TOK_LIST },
|
||||||
{ ".LOBYTE", TOK_LOBYTE },
|
{ ".LISTBYTES", TOK_LISTBYTES },
|
||||||
{ ".LOBYTES", TOK_LOBYTES },
|
{ ".LOBYTE", TOK_LOBYTE },
|
||||||
{ ".LOCAL", TOK_LOCAL },
|
{ ".LOBYTES", TOK_LOBYTES },
|
||||||
{ ".LOCALCHAR", TOK_LOCALCHAR },
|
{ ".LOCAL", TOK_LOCAL },
|
||||||
{ ".LOWORD", TOK_LOWORD },
|
{ ".LOCALCHAR", TOK_LOCALCHAR },
|
||||||
{ ".MAC", TOK_MACRO },
|
{ ".LOWORD", TOK_LOWORD },
|
||||||
{ ".MACPACK", TOK_MACPACK },
|
{ ".MAC", TOK_MACRO },
|
||||||
{ ".MACRO", TOK_MACRO },
|
{ ".MACPACK", TOK_MACPACK },
|
||||||
{ ".MATCH", TOK_MATCH },
|
{ ".MACRO", TOK_MACRO },
|
||||||
{ ".MAX", TOK_MAX },
|
{ ".MATCH", TOK_MATCH },
|
||||||
{ ".MID", TOK_MID },
|
{ ".MAX", TOK_MAX },
|
||||||
{ ".MIN", TOK_MIN },
|
{ ".MID", TOK_MID },
|
||||||
{ ".MOD", TOK_MOD },
|
{ ".MIN", TOK_MIN },
|
||||||
{ ".NOT", TOK_BOOLNOT },
|
{ ".MOD", TOK_MOD },
|
||||||
{ ".NULL", TOK_NULL },
|
{ ".NOT", TOK_BOOLNOT },
|
||||||
{ ".OR", TOK_BOOLOR },
|
{ ".NULL", TOK_NULL },
|
||||||
{ ".ORG", TOK_ORG },
|
{ ".OR", TOK_BOOLOR },
|
||||||
{ ".OUT", TOK_OUT },
|
{ ".ORG", TOK_ORG },
|
||||||
{ ".P02", TOK_P02 },
|
{ ".OUT", TOK_OUT },
|
||||||
{ ".P816", TOK_P816 },
|
{ ".P02", TOK_P02 },
|
||||||
{ ".PAGELEN", TOK_PAGELENGTH },
|
{ ".P816", TOK_P816 },
|
||||||
{ ".PAGELENGTH", TOK_PAGELENGTH },
|
{ ".PAGELEN", TOK_PAGELENGTH },
|
||||||
{ ".PARAMCOUNT", TOK_PARAMCOUNT },
|
{ ".PAGELENGTH", TOK_PAGELENGTH },
|
||||||
{ ".PC02", TOK_PC02 },
|
{ ".PARAMCOUNT", TOK_PARAMCOUNT },
|
||||||
{ ".POPCPU", TOK_POPCPU },
|
{ ".PC02", TOK_PC02 },
|
||||||
{ ".POPSEG", TOK_POPSEG },
|
{ ".POPCPU", TOK_POPCPU },
|
||||||
{ ".PROC", TOK_PROC },
|
{ ".POPSEG", TOK_POPSEG },
|
||||||
{ ".PSC02", TOK_PSC02 },
|
{ ".PROC", TOK_PROC },
|
||||||
{ ".PUSHCPU", TOK_PUSHCPU },
|
{ ".PSC02", TOK_PSC02 },
|
||||||
{ ".PUSHSEG", TOK_PUSHSEG },
|
{ ".PUSHCPU", TOK_PUSHCPU },
|
||||||
{ ".REF", TOK_REFERENCED },
|
{ ".PUSHSEG", TOK_PUSHSEG },
|
||||||
{ ".REFERENCED", TOK_REFERENCED },
|
{ ".REF", TOK_REFERENCED },
|
||||||
{ ".RELOC", TOK_RELOC },
|
{ ".REFERENCED", TOK_REFERENCED },
|
||||||
{ ".REPEAT", TOK_REPEAT },
|
{ ".RELOC", TOK_RELOC },
|
||||||
{ ".RES", TOK_RES },
|
{ ".REPEAT", TOK_REPEAT },
|
||||||
{ ".RIGHT", TOK_RIGHT },
|
{ ".RES", TOK_RES },
|
||||||
{ ".RODATA", TOK_RODATA },
|
{ ".RIGHT", TOK_RIGHT },
|
||||||
{ ".SCOPE", TOK_SCOPE },
|
{ ".RODATA", TOK_RODATA },
|
||||||
{ ".SEGMENT", TOK_SEGMENT },
|
{ ".SCOPE", TOK_SCOPE },
|
||||||
{ ".SET", TOK_SET },
|
{ ".SEGMENT", TOK_SEGMENT },
|
||||||
{ ".SETCPU", TOK_SETCPU },
|
{ ".SET", TOK_SET },
|
||||||
{ ".SHL", TOK_SHL },
|
{ ".SETCPU", TOK_SETCPU },
|
||||||
{ ".SHR", TOK_SHR },
|
{ ".SHL", TOK_SHL },
|
||||||
{ ".SIZEOF", TOK_SIZEOF },
|
{ ".SHR", TOK_SHR },
|
||||||
{ ".SMART", TOK_SMART },
|
{ ".SIZEOF", TOK_SIZEOF },
|
||||||
{ ".SPRINTF", TOK_SPRINTF },
|
{ ".SMART", TOK_SMART },
|
||||||
{ ".STRAT", TOK_STRAT },
|
{ ".SPRINTF", TOK_SPRINTF },
|
||||||
{ ".STRING", TOK_STRING },
|
{ ".STRAT", TOK_STRAT },
|
||||||
{ ".STRLEN", TOK_STRLEN },
|
{ ".STRING", TOK_STRING },
|
||||||
{ ".STRUCT", TOK_STRUCT },
|
{ ".STRLEN", TOK_STRLEN },
|
||||||
{ ".TAG", TOK_TAG },
|
{ ".STRUCT", TOK_STRUCT },
|
||||||
{ ".TCOUNT", TOK_TCOUNT },
|
{ ".TAG", TOK_TAG },
|
||||||
{ ".TIME", TOK_TIME },
|
{ ".TCOUNT", TOK_TCOUNT },
|
||||||
{ ".UNDEF", TOK_UNDEF },
|
{ ".TIME", TOK_TIME },
|
||||||
{ ".UNDEFINE", TOK_UNDEF },
|
{ ".UNDEF", TOK_UNDEF },
|
||||||
{ ".UNION", TOK_UNION },
|
{ ".UNDEFINE", TOK_UNDEF },
|
||||||
{ ".VERSION", TOK_VERSION },
|
{ ".UNION", TOK_UNION },
|
||||||
{ ".WARNING", TOK_WARNING },
|
{ ".VERSION", TOK_VERSION },
|
||||||
{ ".WORD", TOK_WORD },
|
{ ".WARNING", TOK_WARNING },
|
||||||
{ ".XMATCH", TOK_XMATCH },
|
{ ".WORD", TOK_WORD },
|
||||||
{ ".XOR", TOK_BOOLXOR },
|
{ ".XMATCH", TOK_XMATCH },
|
||||||
{ ".ZEROPAGE", TOK_ZEROPAGE },
|
{ ".XOR", TOK_BOOLXOR },
|
||||||
|
{ ".ZEROPAGE", TOK_ZEROPAGE },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ typedef enum token_t {
|
|||||||
TOK_DEBUGINFO,
|
TOK_DEBUGINFO,
|
||||||
TOK_DEFINE,
|
TOK_DEFINE,
|
||||||
TOK_DEFINED,
|
TOK_DEFINED,
|
||||||
|
TOK_DEFINEDMACRO,
|
||||||
TOK_DELMAC,
|
TOK_DELMAC,
|
||||||
TOK_DESTRUCTOR,
|
TOK_DESTRUCTOR,
|
||||||
TOK_DWORD,
|
TOK_DWORD,
|
||||||
|
|||||||
@@ -391,6 +391,12 @@ unsigned SizeOf (const Type* T)
|
|||||||
case T_VOID:
|
case T_VOID:
|
||||||
return 0; /* Assume voids have size zero */
|
return 0; /* Assume voids have size zero */
|
||||||
|
|
||||||
|
/* Beware: There's a chance that this triggers problems in other parts
|
||||||
|
of the compiler. The solution is to fix the callers, because calling
|
||||||
|
SizeOf() with a function type as argument is bad. */
|
||||||
|
case T_FUNC:
|
||||||
|
return 0; /* Size of function is unknown */
|
||||||
|
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
case T_UCHAR:
|
case T_UCHAR:
|
||||||
return SIZEOF_CHAR;
|
return SIZEOF_CHAR;
|
||||||
@@ -404,7 +410,6 @@ unsigned SizeOf (const Type* T)
|
|||||||
return SIZEOF_INT;
|
return SIZEOF_INT;
|
||||||
|
|
||||||
case T_PTR:
|
case T_PTR:
|
||||||
case T_FUNC: /* Maybe pointer to function */
|
|
||||||
return SIZEOF_PTR;
|
return SIZEOF_PTR;
|
||||||
|
|
||||||
case T_LONG:
|
case T_LONG:
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
/* Generator attributes */
|
/* Generator attributes */
|
||||||
#define GEN_NOPUSH 0x01 /* Don't push lhs */
|
#define GEN_NOPUSH 0x01 /* Don't push lhs */
|
||||||
#define GEN_COMM 0x02 /* Operator is commutative */
|
#define GEN_COMM 0x02 /* Operator is commutative */
|
||||||
|
#define GEN_NOFUNC 0x04 /* Not allowed for function pointers */
|
||||||
|
|
||||||
/* Map a generator function and its attributes to a token */
|
/* Map a generator function and its attributes to a token */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -2042,6 +2043,11 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
Tok = CurTok.Tok;
|
Tok = CurTok.Tok;
|
||||||
NextToken ();
|
NextToken ();
|
||||||
|
|
||||||
|
/* If lhs is a function, convert it to pointer to function */
|
||||||
|
if (IsTypeFunc (Expr->Type)) {
|
||||||
|
Expr->Type = PointerTo (Expr->Type);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the lhs on stack */
|
/* Get the lhs on stack */
|
||||||
GetCodePos (&Mark1);
|
GetCodePos (&Mark1);
|
||||||
ltype = TypeOf (Expr->Type);
|
ltype = TypeOf (Expr->Type);
|
||||||
@@ -2059,6 +2065,11 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
/* Get the right hand side */
|
/* Get the right hand side */
|
||||||
MarkedExprWithCheck (hienext, &Expr2);
|
MarkedExprWithCheck (hienext, &Expr2);
|
||||||
|
|
||||||
|
/* If rhs is a function, convert it to pointer to function */
|
||||||
|
if (IsTypeFunc (Expr2.Type)) {
|
||||||
|
Expr2.Type = PointerTo (Expr2.Type);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for a constant expression */
|
/* Check for a constant expression */
|
||||||
rconst = (ED_IsConstAbs (&Expr2) && ED_CodeRangeIsEmpty (&Expr2));
|
rconst = (ED_IsConstAbs (&Expr2) && ED_CodeRangeIsEmpty (&Expr2));
|
||||||
if (!rconst) {
|
if (!rconst) {
|
||||||
@@ -2066,6 +2077,22 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
|||||||
LoadExpr (CF_NONE, &Expr2);
|
LoadExpr (CF_NONE, &Expr2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some operations aren't allowed on function pointers */
|
||||||
|
if ((Gen->Flags & GEN_NOFUNC) != 0) {
|
||||||
|
/* Output only one message even if both sides are wrong */
|
||||||
|
if (IsTypeFuncPtr (Expr->Type)) {
|
||||||
|
Error ("Invalid left operand for relational operator");
|
||||||
|
/* Avoid further errors */
|
||||||
|
ED_MakeConstAbsInt (Expr, 0);
|
||||||
|
ED_MakeConstAbsInt (&Expr2, 0);
|
||||||
|
} else if (IsTypeFuncPtr (Expr2.Type)) {
|
||||||
|
Error ("Invalid right operand for relational operator");
|
||||||
|
/* Avoid further errors */
|
||||||
|
ED_MakeConstAbsInt (Expr, 0);
|
||||||
|
ED_MakeConstAbsInt (&Expr2, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure, the types are compatible */
|
/* Make sure, the types are compatible */
|
||||||
if (IsClassInt (Expr->Type)) {
|
if (IsClassInt (Expr->Type)) {
|
||||||
if (!IsClassInt (Expr2.Type) && !(IsClassPtr(Expr2.Type) && ED_IsNullPtr(Expr))) {
|
if (!IsClassInt (Expr2.Type) && !(IsClassPtr(Expr2.Type) && ED_IsNullPtr(Expr))) {
|
||||||
@@ -2600,6 +2627,13 @@ static void parsesub (ExprDesc* Expr)
|
|||||||
int rscale; /* Scale factor for the result */
|
int rscale; /* Scale factor for the result */
|
||||||
|
|
||||||
|
|
||||||
|
/* lhs cannot be function or pointer to function */
|
||||||
|
if (IsTypeFunc (Expr->Type) || IsTypeFuncPtr (Expr->Type)) {
|
||||||
|
Error ("Invalid left operand for binary operator `-'");
|
||||||
|
/* Make it pointer to char to avoid further errors */
|
||||||
|
Expr->Type = type_uchar;
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the MINUS token */
|
/* Skip the MINUS token */
|
||||||
NextToken ();
|
NextToken ();
|
||||||
|
|
||||||
@@ -2616,6 +2650,13 @@ static void parsesub (ExprDesc* Expr)
|
|||||||
/* Parse the right hand side */
|
/* Parse the right hand side */
|
||||||
MarkedExprWithCheck (hie9, &Expr2);
|
MarkedExprWithCheck (hie9, &Expr2);
|
||||||
|
|
||||||
|
/* rhs cannot be function or pointer to function */
|
||||||
|
if (IsTypeFunc (Expr2.Type) || IsTypeFuncPtr (Expr2.Type)) {
|
||||||
|
Error ("Invalid right operand for binary operator `-'");
|
||||||
|
/* Make it pointer to char to avoid further errors */
|
||||||
|
Expr2.Type = type_uchar;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for a constant rhs expression */
|
/* Check for a constant rhs expression */
|
||||||
if (ED_IsConstAbs (&Expr2) && ED_CodeRangeIsEmpty (&Expr2)) {
|
if (ED_IsConstAbs (&Expr2) && ED_CodeRangeIsEmpty (&Expr2)) {
|
||||||
|
|
||||||
@@ -2775,11 +2816,11 @@ static void hie6 (ExprDesc* Expr)
|
|||||||
/* Handle greater-than type comparators */
|
/* Handle greater-than type comparators */
|
||||||
{
|
{
|
||||||
static const GenDesc hie6_ops [] = {
|
static const GenDesc hie6_ops [] = {
|
||||||
{ TOK_LT, GEN_NOPUSH, g_lt },
|
{ TOK_LT, GEN_NOPUSH | GEN_NOFUNC, g_lt },
|
||||||
{ TOK_LE, GEN_NOPUSH, g_le },
|
{ TOK_LE, GEN_NOPUSH | GEN_NOFUNC, g_le },
|
||||||
{ TOK_GE, GEN_NOPUSH, g_ge },
|
{ TOK_GE, GEN_NOPUSH | GEN_NOFUNC, g_ge },
|
||||||
{ TOK_GT, GEN_NOPUSH, g_gt },
|
{ TOK_GT, GEN_NOPUSH | GEN_NOFUNC, g_gt },
|
||||||
{ TOK_INVALID, 0, 0 }
|
{ TOK_INVALID, 0, 0 }
|
||||||
};
|
};
|
||||||
hie_compare (hie6_ops, Expr, ShiftExpr);
|
hie_compare (hie6_ops, Expr, ShiftExpr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ else
|
|||||||
EXE :=
|
EXE :=
|
||||||
DEL = $(RM) $1
|
DEL = $(RM) $1
|
||||||
MKDIR = mkdir $1
|
MKDIR = mkdir $1
|
||||||
RMDIR = rmdir $1
|
RMDIR = $(RM) -r $1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
WORKDIR := ../testwrk
|
WORKDIR := ../testwrk
|
||||||
|
|||||||
26
test/err/cc65150311-1.c
Normal file
26
test/err/cc65150311-1.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
++p; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-10.c
Normal file
26
test/err/cc65150311-10.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = &func - p; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-11.c
Normal file
26
test/err/cc65150311-11.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = func - p; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-2.c
Normal file
26
test/err/cc65150311-2.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = (p > &func); /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-3.c
Normal file
26
test/err/cc65150311-3.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = (p > func); /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-4.c
Normal file
26
test/err/cc65150311-4.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = func - func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-5.c
Normal file
26
test/err/cc65150311-5.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = func - &func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-6.c
Normal file
26
test/err/cc65150311-6.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = &func - func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-7.c
Normal file
26
test/err/cc65150311-7.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = &func - &func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-8.c
Normal file
26
test/err/cc65150311-8.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = p - &func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
26
test/err/cc65150311-9.c
Normal file
26
test/err/cc65150311-9.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
n = p - func; /* invalid C */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
38
test/val/cc65150311.c
Normal file
38
test/val/cc65150311.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
!!DESCRIPTION!! function pointer bugs
|
||||||
|
!!ORIGIN!! testsuite
|
||||||
|
!!LICENCE!! Public Domain
|
||||||
|
!!AUTHOR!! Greg
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
see: http://www.cc65.org/mailarchive/2015-03/11726.html
|
||||||
|
and: http://www.cc65.org/mailarchive/2015-03/11734.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int func(void) {return 0;}
|
||||||
|
static int (*p)(void);
|
||||||
|
static int n;
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
p = func;
|
||||||
|
n = (p == &func);
|
||||||
|
n = (p == func);
|
||||||
|
|
||||||
|
/* the following are not valid C and should go into seperate tests that MUST fail */
|
||||||
|
/*
|
||||||
|
++p;
|
||||||
|
n = (p > &func);
|
||||||
|
n = (p > func);
|
||||||
|
n = func - func;
|
||||||
|
n = func - &func;
|
||||||
|
n = &func - func;
|
||||||
|
n = &func - &func;
|
||||||
|
n = p - &func;
|
||||||
|
n = p - func;
|
||||||
|
n = &func - p;
|
||||||
|
n = func - p;
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user