mirror of
https://github.com/cc65/cc65.git
synced 2024-07-01 08:29:37 +00:00
Allow conditional directives within .STRUCT7:UNION and .ENUM
git-svn-id: svn://svn.cc65.org/cc65/trunk@2672 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
57cc152ad6
commit
5ef1f65c9b
|
@ -321,7 +321,7 @@ void DoConditionals (void)
|
||||||
SetIfCond (D, 1);
|
SetIfCond (D, 1);
|
||||||
SkipUntilSep ();
|
SkipUntilSep ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IfCond = GetCurrentIfCond ();
|
IfCond = GetCurrentIfCond ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ void DoConditionals (void)
|
||||||
|
|
||||||
case TOK_IFP816:
|
case TOK_IFP816:
|
||||||
D = AllocIf (".IFP816", 1);
|
D = AllocIf (".IFP816", 1);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
if (IfCond) {
|
if (IfCond) {
|
||||||
SetIfCond (D, GetCPU() == CPU_65816);
|
SetIfCond (D, GetCPU() == CPU_65816);
|
||||||
}
|
}
|
||||||
|
@ -413,6 +413,39 @@ void DoConditionals (void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int CheckConditionals (void)
|
||||||
|
/* Check if the current token is one that starts a conditional directive, and
|
||||||
|
* call DoConditionals if so. Return true if a conditional directive was found,
|
||||||
|
* return false otherwise.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
switch (Tok) {
|
||||||
|
case TOK_ELSE:
|
||||||
|
case TOK_ELSEIF:
|
||||||
|
case TOK_ENDIF:
|
||||||
|
case TOK_IF:
|
||||||
|
case TOK_IFBLANK:
|
||||||
|
case TOK_IFCONST:
|
||||||
|
case TOK_IFDEF:
|
||||||
|
case TOK_IFNBLANK:
|
||||||
|
case TOK_IFNCONST:
|
||||||
|
case TOK_IFNDEF:
|
||||||
|
case TOK_IFNREF:
|
||||||
|
case TOK_IFP02:
|
||||||
|
case TOK_IFP816:
|
||||||
|
case TOK_IFPC02:
|
||||||
|
case TOK_IFPSC02:
|
||||||
|
case TOK_IFREF:
|
||||||
|
DoConditionals ();
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CheckOpenIfs (void)
|
void CheckOpenIfs (void)
|
||||||
/* Called from the scanner before closing an input file. Will check for any
|
/* Called from the scanner before closing an input file. Will check for any
|
||||||
* open .ifs in this file.
|
* open .ifs in this file.
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000 Ullrich von Bassewitz */
|
/* (C) 2000-2003 Ullrich von Bassewitz */
|
||||||
/* Wacholderweg 14 */
|
/* Römerstraße 52 */
|
||||||
/* D-70597 Stuttgart */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@musoftware.de */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* This software is provided 'as-is', without any expressed or implied */
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
@ -47,6 +47,12 @@
|
||||||
void DoConditionals (void);
|
void DoConditionals (void);
|
||||||
/* Catch all for conditional directives */
|
/* Catch all for conditional directives */
|
||||||
|
|
||||||
|
int CheckConditionals (void);
|
||||||
|
/* Check if the current token is one that starts a conditional directive, and
|
||||||
|
* call DoConditionals if so. Return true if a conditional directive was found,
|
||||||
|
* return false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
void CheckOpenIfs (void);
|
void CheckOpenIfs (void);
|
||||||
/* Called from the scanner before closing an input file. Will check for any
|
/* Called from the scanner before closing an input file. Will check for any
|
||||||
* open .ifs in this file.
|
* open .ifs in this file.
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "addrsize.h"
|
#include "addrsize.h"
|
||||||
|
|
||||||
/* ca65 */
|
/* ca65 */
|
||||||
|
#include "condasm.h"
|
||||||
#include "enum.h"
|
#include "enum.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
|
@ -75,11 +76,19 @@ void DoEnum (void)
|
||||||
|
|
||||||
SymEntry* Sym;
|
SymEntry* Sym;
|
||||||
ExprNode* EnumExpr;
|
ExprNode* EnumExpr;
|
||||||
|
|
||||||
|
/* Skip empty lines */
|
||||||
|
if (Tok == TOK_SEP) {
|
||||||
|
NextTok ();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* The format is "identifier [ = value ]" */
|
/* The format is "identifier [ = value ]" */
|
||||||
if (Tok != TOK_IDENT) {
|
if (Tok != TOK_IDENT) {
|
||||||
ErrorSkip ("Identifier expected");
|
/* Maybe it's a conditional? */
|
||||||
|
if (!CheckConditionals ()) {
|
||||||
|
ErrorSkip ("Identifier expected");
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "addrsize.h"
|
#include "addrsize.h"
|
||||||
|
|
||||||
/* ca65 */
|
/* ca65 */
|
||||||
|
#include "condasm.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "nexttok.h"
|
#include "nexttok.h"
|
||||||
|
@ -187,8 +188,10 @@ static long DoStructInternal (long Offs, unsigned Type)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Error ("Invalid storage allocator in struct/union");
|
if (!CheckConditionals ()) {
|
||||||
SkipUntilSep ();
|
/* Not a conditional directive */
|
||||||
|
ErrorSkip ("Invalid storage allocator in struct/union");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next member */
|
/* Next member */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user