[hackers] [scc] Join #if and #ifdef || Roberto E. Vargas Caballero
commit 167690b43dd4a0f6279bd9e8dd6f4aa84a3ca375
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jul 27 10:50:09 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jul 27 10:50:09 2015 +0200
Join #if and #ifdef
diff --git a/cc1/cpp.c b/cc1/cpp.c
index 093e474..9099840 100644
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
_AT_@ -451,58 +451,53 @@ usererr(void)
}
static void
-ifclause(int isdef)
+ifclause(int negate, int isifdef)
{
Symbol *sym;
unsigned n;
int status;
+ Node *expr;
if (cppctx == NR_COND-1)
error("too much nesting levels of conditional inclusion");
-
n = cppctx++;
- if (yytoken != IDEN) {
- error("no macro name given in #%s directive",
- (isdef) ? "ifdef" : "ifndef");
- }
- sym = lookup(NS_CPP);
- next();
-
- status = (sym->flags & ISDEFINED) != 0 == isdef;
+ if (isifdef) {
+ if (yytoken != IDEN) {
+ error("no macro name given in #%s directive",
+ (negate) ? "ifndef" : "ifdef");
+ }
+ sym = lookup(NS_CPP);
+ next();
+ status = (sym->flags & ISDEFINED) != 0;
+ } else {
+ if ((expr = iconstexpr()) == NULL)
+ error("parameter of #if is not an integer constant expression");
+ status = expr->sym->u.i != 0;
+ }
- if (!(ifstatus[n] = status))
+ if (negate)
+ status = !status;
+ if ((ifstatus[n] = status) == 0)
++cppoff;
}
static void
cppif(void)
{
- Node *expr;
- int status;
- unsigned n;
-
- if (cppctx == NR_COND-1)
- error("too much nesting levels of conditional inclusion");
- n = cppctx++;
-
- if ((expr = iconstexpr()) == NULL)
- error("parameter of #if is not an integer constant expression");
- status = expr->sym->u.i != 0;
- if (!(ifstatus[n] = status))
- ++cppoff;
+ ifclause(0, 0);
}
static void
ifdef(void)
{
- ifclause(1);
+ ifclause(0, 1);
}
static void
ifndef(void)
{
- ifclause(0);
+ ifclause(1, 1);
}
static void
Received on Mon Jul 27 2015 - 17:09:31 CEST
This archive was generated by hypermail 2.3.0
: Mon Jul 27 2015 - 17:12:12 CEST