aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--check.c1
-rw-r--r--pre-process.c26
-rw-r--r--show-parse.c3
-rw-r--r--symbol.c3
-rw-r--r--symbol.h3
5 files changed, 34 insertions, 2 deletions
diff --git a/check.c b/check.c
index 33df1bd5..06228899 100644
--- a/check.c
+++ b/check.c
@@ -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;
}
diff --git a/symbol.c b/symbol.c
index 84f299b2..b88f8c8a 100644
--- a/symbol.c
+++ b/symbol.c
@@ -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);
diff --git a/symbol.h b/symbol.h
index 8732b4f1..b763b25f 100644
--- a/symbol.h
+++ b/symbol.h
@@ -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)