aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/expression.c
diff options
authorLinus Torvalds <torvalds@evo.osdl.org>2004-03-24 10:54:50 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:01:29 -0700
commitd7aeb76801cf76d495d15ab96fa09fe139dfb480 (patch)
tree1344aa69d464a6a4e13ae47e45f93f9fc304aaff /expression.c
parentabae88c8e3ae1a4493805bd8b471bb77f472fd37 (diff)
downloadsparse-dev-d7aeb76801cf76d495d15ab96fa09fe139dfb480.tar.gz
Warn about users trying to use type names in expressions.
I think I'll allow type expressions at some point, since it shouldn't actually be all that hard, and would even clean some stuff up. But for now, we'll just warn about non-C code.
Diffstat (limited to 'expression.c')
-rw-r--r--expression.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/expression.c b/expression.c
index 48414c3e..dc503cae 100644
--- a/expression.c
+++ b/expression.c
@@ -199,9 +199,23 @@ struct token *primary_expression(struct token *token, struct expression **tree)
break;
case TOKEN_IDENT: {
+ struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
+
+ /*
+ * I'd like to 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;
+ }
expr = alloc_expression(token->pos, EXPR_SYMBOL);
expr->symbol_name = token->ident;
- expr->symbol = lookup_symbol(token->ident, NS_SYMBOL);
+ expr->symbol = sym;
token = token->next;
break;
}