Commit 90d56da8 by Richard Stallman

(duplicate_decls, pushdecl, grokdeclarator):

(store_parm_decls, combine_parm_decls, finish_function):
Use TYPE_MAIN_VARIANT when comparing against specific non-void types.

From-SVN: r1590
parent 60654f77
...@@ -1311,7 +1311,7 @@ duplicate_decls (newdecl, olddecl) ...@@ -1311,7 +1311,7 @@ duplicate_decls (newdecl, olddecl)
break; break;
} }
if (type == float_type_node if (TYPE_MAIN_VARIANT (type) == float_type_node
|| (TREE_CODE (type) == INTEGER_TYPE || (TREE_CODE (type) == INTEGER_TYPE
&& (TYPE_PRECISION (type) && (TYPE_PRECISION (type)
< TYPE_PRECISION (integer_type_node)))) < TYPE_PRECISION (integer_type_node))))
...@@ -1361,8 +1361,8 @@ duplicate_decls (newdecl, olddecl) ...@@ -1361,8 +1361,8 @@ duplicate_decls (newdecl, olddecl)
/* If -traditional, allow `unsigned int' instead of `int' /* If -traditional, allow `unsigned int' instead of `int'
in the prototype. */ in the prototype. */
&& (! (flag_traditional && (! (flag_traditional
&& TREE_VALUE (parm) == integer_type_node && TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == integer_type_node
&& TREE_VALUE (type) == unsigned_type_node))) && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == unsigned_type_node)))
{ {
errmsg = "prototype for `%s' follows and argument %d"; errmsg = "prototype for `%s' follows and argument %d";
break; break;
...@@ -1786,7 +1786,8 @@ pushdecl (x) ...@@ -1786,7 +1786,8 @@ pushdecl (x)
if (IDENTIFIER_IMPLICIT_DECL (name) != 0 if (IDENTIFIER_IMPLICIT_DECL (name) != 0
/* If this real decl matches the implicit, don't complain. */ /* If this real decl matches the implicit, don't complain. */
&& ! (TREE_CODE (x) == FUNCTION_DECL && ! (TREE_CODE (x) == FUNCTION_DECL
&& TREE_TYPE (TREE_TYPE (x)) == integer_type_node)) && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (x)))
== integer_type_node)))
pedwarn ("`%s' was previously implicitly declared to return `int'", pedwarn ("`%s' was previously implicitly declared to return `int'",
IDENTIFIER_POINTER (name)); IDENTIFIER_POINTER (name));
...@@ -3523,7 +3524,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -3523,7 +3524,8 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
/* Long double is a special combination. */ /* Long double is a special combination. */
if ((specbits & 1 << (int) RID_LONG) && type == double_type_node) if ((specbits & 1 << (int) RID_LONG)
&& TYPE_MAIN_VARIANT (type) == double_type_node)
{ {
specbits &= ~ (1 << (int) RID_LONG); specbits &= ~ (1 << (int) RID_LONG);
type = long_double_type_node; type = long_double_type_node;
...@@ -3844,7 +3846,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -3844,7 +3846,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
#ifndef TRADITIONAL_RETURN_FLOAT #ifndef TRADITIONAL_RETURN_FLOAT
/* Traditionally, declaring return type float means double. */ /* Traditionally, declaring return type float means double. */
if (flag_traditional && type == float_type_node) if (flag_traditional && TYPE_MAIN_VARIANT (type) == float_type_node)
type = double_type_node; type = double_type_node;
#endif /* TRADITIONAL_RETURN_FLOAT */ #endif /* TRADITIONAL_RETURN_FLOAT */
...@@ -4007,6 +4009,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4007,6 +4009,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
if (decl_context == PARM) if (decl_context == PARM)
{ {
tree type_as_written = type; tree type_as_written = type;
tree main_type;
/* A parameter declared as an array of T is really a pointer to T. /* 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. */ One declared as a function is really a pointer to a function. */
...@@ -4040,15 +4043,17 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4040,15 +4043,17 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
When there is a prototype, this is overridden later. */ When there is a prototype, this is overridden later. */
DECL_ARG_TYPE (decl) = type; DECL_ARG_TYPE (decl) = type;
if (type == float_type_node) main_type = TYPE_MAIN_VARIANT (type);
if (main_type == float_type_node)
DECL_ARG_TYPE (decl) = double_type_node; DECL_ARG_TYPE (decl) = double_type_node;
/* Don't use TYPE_PREISION to decide whether to promote, /* Don't use TYPE_PREISION to decide whether to promote,
because we should convert short if it's the same size as int, 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. */ but we should not convert long if it's the same size as int. */
else if (type == char_type_node || type == signed_char_type_node else if (main_type == char_type_node
|| type == unsigned_char_type_node || main_type == signed_char_type_node
|| type == short_integer_type_node || main_type == unsigned_char_type_node
|| type == short_unsigned_type_node) || main_type == short_integer_type_node
|| main_type == short_unsigned_type_node)
{ {
if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node) if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)
&& TREE_UNSIGNED (type)) && TREE_UNSIGNED (type))
...@@ -5398,7 +5403,7 @@ store_parm_decls () ...@@ -5398,7 +5403,7 @@ store_parm_decls ()
/* Traditionally, a parm declared float is actually a double. */ /* Traditionally, a parm declared float is actually a double. */
if (found && flag_traditional if (found && flag_traditional
&& TREE_TYPE (found) == float_type_node) && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == float_type_node)
TREE_TYPE (found) = double_type_node; TREE_TYPE (found) = double_type_node;
/* If no declaration found, default to int. */ /* If no declaration found, default to int. */
...@@ -5522,8 +5527,8 @@ store_parm_decls () ...@@ -5522,8 +5527,8 @@ store_parm_decls ()
/* If -traditional, allow `int' argument to match /* If -traditional, allow `int' argument to match
`unsigned' prototype. */ `unsigned' prototype. */
else if (! (flag_traditional else if (! (flag_traditional
&& TREE_TYPE (parm) == integer_type_node && TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == integer_type_node
&& TREE_VALUE (type) == unsigned_type_node)) && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == unsigned_type_node))
error ("argument `%s' doesn't match prototype", error ("argument `%s' doesn't match prototype",
IDENTIFIER_POINTER (DECL_NAME (parm))); IDENTIFIER_POINTER (DECL_NAME (parm)));
} }
...@@ -5678,7 +5683,7 @@ combine_parm_decls (specparms, parmlist, void_at_end) ...@@ -5678,7 +5683,7 @@ combine_parm_decls (specparms, parmlist, void_at_end)
/* Traditionally, a parm declared float is actually a double. */ /* Traditionally, a parm declared float is actually a double. */
if (found && flag_traditional if (found && flag_traditional
&& TREE_TYPE (found) == float_type_node) && TYPE_MAIN_VARIANT (TREE_TYPE (found)) == float_type_node)
TREE_TYPE (found) = double_type_node; TREE_TYPE (found) = double_type_node;
/* If no declaration found, default to int. */ /* If no declaration found, default to int. */
...@@ -5793,7 +5798,8 @@ finish_function (nested) ...@@ -5793,7 +5798,8 @@ finish_function (nested)
#ifdef DEFAULT_MAIN_RETURN #ifdef DEFAULT_MAIN_RETURN
if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")) if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main"))
{ {
if (TREE_TYPE (TREE_TYPE (fndecl)) != integer_type_node) if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
!= integer_type_node)
warning_with_decl (fndecl, "return type of `%s' is not `int'"); warning_with_decl (fndecl, "return type of `%s' is not `int'");
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment