aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-03-24 12:40:43 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:01:30 -0700
commitc909930ea7a0c0f594f631a893686aed24427758 (patch)
tree85b01fa178b0a20aa16aa0d92c13711872e9310b /expression.c
parentWarn about users trying to use type names in expressions. (diff)
downloadsparse-c909930ea7a0c0f594f631a893686aed24427758.tar.gz
sparse-c909930ea7a0c0f594f631a893686aed24427758.tar.bz2
sparse-c909930ea7a0c0f594f631a893686aed24427758.zip
Support C types as first-class citizens, allowing type
comparisons etc: if (typeof(a) == int) { ... (although right now I don't actually do the proper comparison expansion and all comparisons return "true").
Diffstat (limited to 'expression.c')
-rw-r--r--expression.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/expression.c b/expression.c
index dc503ca..1583874 100644
--- a/expression.c
+++ b/expression.c
@@ -200,23 +200,23 @@ struct token *primary_expression(struct token *token, struct expression **tree)
case TOKEN_IDENT: {
struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
+ struct token *next = token->next;
+
+ expr = alloc_expression(token->pos, EXPR_SYMBOL);
/*
- * I'd like to support types as real first-class citizens,
- * with type comparisons etc:
+ * We support types as real first-class citizens, with type
+ * comparisons etc:
*
* if (typeof(a) == int) ..
- *
- * But for now just do normal C.
*/
if (sym && sym->namespace == NS_TYPEDEF) {
- warn(token->pos, "We don't support type expressions (yet?)");
- sym = NULL;
+ next = typename(token, &sym);
+ expr->type = EXPR_TYPE;
}
- expr = alloc_expression(token->pos, EXPR_SYMBOL);
expr->symbol_name = token->ident;
expr->symbol = sym;
- token = token->next;
+ token = next;
break;
}