aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-09-01 19:13:19 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1994-09-01 19:13:19 -0400
commitaae43c5f402c830a993c2f4c93966c8512182d19 (patch)
tree15d546c1820a7b43f8905c75a3c0b458fe415713
parent1a655ca39b582ef0a30d39d597fdee65fb162992 (diff)
downloadgcc-aae43c5f402c830a993c2f4c93966c8512182d19.zip
gcc-aae43c5f402c830a993c2f4c93966c8512182d19.tar.gz
gcc-aae43c5f402c830a993c2f4c93966c8512182d19.tar.bz2
(convert_arguments): Give proper warnings when converting
COMPLEX_TYPE; widen check to include all integral types. From-SVN: r8012
-rw-r--r--gcc/c-typeck.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index d828ce7..d09399b 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -1659,13 +1659,22 @@ convert_arguments (typelist, values, name, fundecl)
{
int formal_prec = TYPE_PRECISION (type);
- if (TREE_CODE (type) != REAL_TYPE
+ if (INTEGRAL_TYPE_P (type)
&& TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
warn_for_assignment ("%s as integer rather than floating due to prototype", (char *) 0, name, parmnum + 1);
+ else if (TREE_CODE (type) == COMPLEX_TYPE
+ && TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
+ warn_for_assignment ("%s as complex rather than floating due to prototype", (char *) 0, name, parmnum + 1);
else if (TREE_CODE (type) == REAL_TYPE
- && TREE_CODE (TREE_TYPE (val)) != REAL_TYPE)
+ && INTEGRAL_TYPE_P (TREE_TYPE (val)))
warn_for_assignment ("%s as floating rather than integer due to prototype", (char *) 0, name, parmnum + 1);
else if (TREE_CODE (type) == REAL_TYPE
+ && TREE_CODE (TREE_TYPE (val)) == COMPLEX_TYPE)
+ warn_for_assignment ("%s as floating rather than complex due to prototype", (char *) 0, name, parmnum + 1);
+ /* ??? At some point, messages should be written about
+ conversions between complex types, but that's too messy
+ to do now. */
+ else if (TREE_CODE (type) == REAL_TYPE
&& TREE_CODE (TREE_TYPE (val)) == REAL_TYPE)
{
/* Warn if any argument is passed as `float',
@@ -1674,10 +1683,8 @@ convert_arguments (typelist, values, name, fundecl)
warn_for_assignment ("%s as `float' rather than `double' due to prototype", (char *) 0, name, parmnum + 1);
}
/* Detect integer changing in width or signedness. */
- else if ((TREE_CODE (type) == INTEGER_TYPE
- || TREE_CODE (type) == ENUMERAL_TYPE)
- && (TREE_CODE (TREE_TYPE (val)) == INTEGER_TYPE
- || TREE_CODE (TREE_TYPE (val)) == ENUMERAL_TYPE))
+ else if (INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (TREE_TYPE (val)))
{
tree would_have_been = default_conversion (val);
tree type1 = TREE_TYPE (would_have_been);