diff options
| author | Linus Torvalds <torvalds@penguin.transmeta.com> | 2003-06-02 15:52:25 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:49 -0700 |
| commit | 0caa57484e2a1374d6c66c5549bc2da5cce7a889 (patch) | |
| tree | 0fd0b8d6b437447f5b4bc9751eff768157477971 | |
| parent | 13ae3d014537752efff7fa5c964b83b747ac5d76 (diff) | |
| download | sparse-dev-0caa57484e2a1374d6c66c5549bc2da5cce7a889.tar.gz | |
Get rid of "#pragma" lines for now, while still keeping a
path to eventually start parsing them.
Basic approach: we'll replace the pragma line with some kind
of internal attribute-looking thing for the front end.
| -rw-r--r-- | check.c | 1 | ||||
| -rw-r--r-- | pre-process.c | 26 | ||||
| -rw-r--r-- | show-parse.c | 3 | ||||
| -rw-r--r-- | symbol.c | 3 | ||||
| -rw-r--r-- | symbol.h | 3 |
5 files changed, 34 insertions, 2 deletions
@@ -113,6 +113,7 @@ int main(int argc, char **argv) add_pre_buffer("#define __GNUC_MINOR__ 95\n"); add_pre_buffer("#define __func__ \"function\"\n"); add_pre_buffer("#define __extension__\n"); + add_pre_buffer("#define __pragma__\n"); add_pre_buffer("extern void *__builtin_memcpy(void *, const void *, unsigned long);\n"); add_pre_buffer("extern void * __builtin_return_address(int);\n"); add_pre_buffer("#define __builtin_stdarg_start(a,b) ((a) = (__builtin_va_list)(&(b)))\n"); diff --git a/pre-process.c b/pre-process.c index 173904d8..5bbe32cc 100644 --- a/pre-process.c +++ b/pre-process.c @@ -877,6 +877,31 @@ static int handle_add_include(struct stream *stream, struct token *head, struct } } +/* + * We replace "#pragma xxx" with "__pragma__" in the token + * stream. Just as an example. + * + * We'll just #define that away for now, but the theory here + * is that we can use this to insert arbitrary token sequences + * to turn the pragma's into internal front-end sequences for + * when we actually start caring about them. + * + * So eventually this will turn into some kind of extended + * __attribute__() like thing, except called __pragma__(xxx). + */ +static int handle_pragma(struct stream *stream, struct token *head, struct token *token) +{ + struct token *next = head->next; + + token->ident = &pragma_ident; + token->pos.newline = 1; + token->pos.whitespace = 1; + token->pos.pos = 1; + head->next = token; + token->next = next; + return 1; +} + static int handle_preprocessor_command(struct stream *stream, struct token *head, struct ident *ident, struct token *token) { int i; @@ -895,6 +920,7 @@ static int handle_preprocessor_command(struct stream *stream, struct token *head { "warning", handle_warning }, { "error", handle_error }, { "include", handle_include }, + { "pragma", handle_pragma }, // our internal preprocessor tokens { "nostdinc", handle_nostdinc }, diff --git a/show-parse.c b/show-parse.c index 644892d7..2c2cdb42 100644 --- a/show-parse.c +++ b/show-parse.c @@ -308,7 +308,6 @@ void show_symbol(struct symbol *sym) case SYM_FN: printf("\n"); show_statement(type->stmt); - printf(".L%p:\n", type->stmt->ret); printf("\tret\n"); break; @@ -415,6 +414,8 @@ int show_statement(struct statement *stmt) FOR_EACH_PTR(stmt->stmts, s) { last = show_statement(s); } END_FOR_EACH_PTR; + if (stmt->ret) + printf(".L%p:\n", stmt->ret); return last; } @@ -498,6 +498,8 @@ IDENT(__asm__); IDENT(__asm); IDENT(asm); IDENT(__volatile__); IDENT(__volatile); IDENT(volatile); IDENT(__attribute__); IDENT(__attribute); +__IDENT(pragma, "__pragma__"); + void init_symbols(void) { int stream = init_stream("builtin", -1); @@ -528,6 +530,7 @@ void init_symbols(void) hash_ident(&__volatile___ident); hash_ident(&__volatile_ident); hash_ident(&volatile_ident); + hash_ident(&pragma_ident); for (ptr = symbol_init_table; ptr->name; ptr++) { struct symbol *sym; sym = create_symbol(stream, ptr->name, SYM_NODE, NS_TYPEDEF); @@ -171,7 +171,8 @@ extern struct ident __asm___ident, __volatile_ident, volatile_ident, __attribute___ident, - __attribute_ident; + __attribute_ident, + pragma_ident; #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE) |
