diff options
author | Richard Henderson <rth@cygnus.com> | 1999-09-07 21:51:16 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 1999-09-07 21:51:16 -0700 |
commit | c530479e15d804667c83dfb738ce9cae035de9f2 (patch) | |
tree | cc01394964ac75996779fc8fc5ebdb1781aeb69c /gcc/c-decl.c | |
parent | 472236af04ca7daa01b6b5b1a00dafaf91d31f1f (diff) | |
download | gcc-c530479e15d804667c83dfb738ce9cae035de9f2.zip gcc-c530479e15d804667c83dfb738ce9cae035de9f2.tar.gz gcc-c530479e15d804667c83dfb738ce9cae035de9f2.tar.bz2 |
c-typeck.c (type_lists_compatible_p): Use simple_type_promotes_to.
* c-typeck.c (type_lists_compatible_p): Use simple_type_promotes_to.
(self_promoting_type_p): Delete.
(self_promoting_args_p): Move ...
* c-common.c: ... here.
(c_common_nodes_and_builtins): Initialize lang_type_promotes_to.
(simple_type_promotes_to): New.
* builtins.c (lang_type_promotes_to): New.
(expand_builtin_va_arg): Use it to give diagnostic for illegal types.
* c-tree.h (C_PROMOTING_INTEGER_TYPE_P): Move ...
* c-common.h: ... here.
(self_promoting_args_p, simple_type_promotes_to): Declare.
* c-decl.c (duplicate_decls): Use simple_type_promotes_to.
(grokdeclarator): Likewise.
* tree.h (lang_type_promotes_to): Declare.
* cp-tree.h (C_PROMOTING_INTEGER_TYPE_P): Delete.
* typeck.c (self_promoting_args_p): Delete.
* gcc.dg/va-arg-1.c: New.
From-SVN: r29180
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index c2d04c1..eecc4f6 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1664,8 +1664,7 @@ duplicate_decls (newdecl, olddecl, different_binding_level) break; } - if (TYPE_MAIN_VARIANT (type) == float_type_node - || C_PROMOTING_INTEGER_TYPE_P (type)) + if (simple_type_promotes_to (type) != NULL_TREE) { error ("An argument type that has a default promotion can't match an empty parameter name list declaration."); break; @@ -4858,7 +4857,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) if (decl_context == PARM) { tree type_as_written = type; - tree main_type; + tree promoted_type; /* A parameter declared as an array of T is really a pointer to T. One declared as a function is really a pointer to a function. */ @@ -4892,25 +4891,16 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) (For example, shorts and chars are passed as ints.) When there is a prototype, this is overridden later. */ - DECL_ARG_TYPE (decl) = type; - main_type = (type == error_mark_node - ? error_mark_node - : TYPE_MAIN_VARIANT (type)); - if (main_type == float_type_node) - DECL_ARG_TYPE (decl) = double_type_node; - /* Don't use TYPE_PRECISION to decide whether to promote, - because we should convert short if it's the same size as int, - but we should not convert long if it's the same size as int. */ - else if (TREE_CODE (main_type) != ERROR_MARK - && C_PROMOTING_INTEGER_TYPE_P (main_type)) + if (type == error_mark_node) + promoted_type = type; + else { - if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node) - && TREE_UNSIGNED (type)) - DECL_ARG_TYPE (decl) = unsigned_type_node; - else - DECL_ARG_TYPE (decl) = integer_type_node; + promoted_type = simple_type_promotes_to (type); + if (! promoted_type) + promoted_type = type; } + DECL_ARG_TYPE (decl) = promoted_type; DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written; } else if (decl_context == FIELD) |