diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1994-11-30 15:48:00 -0500 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1994-11-30 15:48:00 -0500 |
commit | caab5771c8058e7a6ea92c5d806bcd69e2c9b2c1 (patch) | |
tree | 4e42d30449fdc621e04c34e1bba44b3e52a9e53d /gcc/c-common.c | |
parent | 077e4b01177f4ed1a03f7903a8ace2e7bbfa366c (diff) | |
download | gcc-caab5771c8058e7a6ea92c5d806bcd69e2c9b2c1.zip gcc-caab5771c8058e7a6ea92c5d806bcd69e2c9b2c1.tar.gz gcc-caab5771c8058e7a6ea92c5d806bcd69e2c9b2c1.tar.bz2 |
(decl_attribute): Allow special names (e.g, `word') for mode
attribute.
From-SVN: r8582
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index f3844e2..e420756 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -297,27 +297,36 @@ found_attr:; && TREE_CODE (TREE_VALUE (args)) == IDENTIFIER_NODE) { int i; - char *specified_name - = IDENTIFIER_POINTER (TREE_VALUE (args)); + char *specified_name = IDENTIFIER_POINTER (TREE_VALUE (args)); + enum machine_mode mode = VOIDmode; + tree typefm; + + /* Give this decl a type with the specified mode. + First check for the special modes. */ + if (! strcmp (specified_name, "byte") + || ! strcmp (specified_name, "__byte__")) + mode = byte_mode; + else if (!strcmp (specified_name, "word") + || ! strcmp (specified_name, "__word__")) + mode = word_mode; + else if (! strcmp (specified_name, "pointer") + || !strcmp (specified_name, "__pointer__")) + mode = ptr_mode; + else + for (i = 0; i < NUM_MACHINE_MODES; i++) + if (!strcmp (specified_name, GET_MODE_NAME (i))) + mode = (enum machine_mode) i; - /* Give this decl a type with the specified mode. */ - for (i = 0; i < NUM_MACHINE_MODES; i++) - if (!strcmp (specified_name, GET_MODE_NAME (i))) - { - tree typefm - = type_for_mode (i, TREE_UNSIGNED (type)); - if (typefm != 0) - { - TREE_TYPE (decl) = type = typefm; - DECL_SIZE (decl) = 0; - layout_decl (decl, 0); - } - else - error ("no data type for mode `%s'", specified_name); - break; - } - if (i == NUM_MACHINE_MODES) + if (mode == VOIDmode) error_with_decl (decl, "unknown machine mode `%s'", specified_name); + else if ((typefm = type_for_mode (mode, TREE_UNSIGNED (type))) == 0) + error_with_decl (decl, "no data type for mode `%s'", specified_name); + else + { + TREE_TYPE (decl) = type = typefm; + DECL_SIZE (decl) = 0; + layout_decl (decl, 0); + } } else if ((!strcmp (IDENTIFIER_POINTER (name), "section") || !strcmp (IDENTIFIER_POINTER (name), "__section__")) |