aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
parentUse the "look up multiple namespaces" facility (diff)
downloadsparse-d7aeb76801cf76d495d15ab96fa09fe139dfb480.tar.gz
sparse-d7aeb76801cf76d495d15ab96fa09fe139dfb480.tar.bz2
sparse-d7aeb76801cf76d495d15ab96fa09fe139dfb480.zip
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 48414c3..dc503ca 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;
}