aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Wood <wood@gnu.org>1993-04-09 23:11:51 +0000
committerTom Wood <wood@gnu.org>1993-04-09 23:11:51 +0000
commit8b40563cd804ed4dac2a294cb417621768c66312 (patch)
tree1bd9acc2245fc38a14f03b2cfe9ae727e53dad05
parenta604ca2693ddad05591634f0d298e4581c150649 (diff)
downloadgcc-8b40563cd804ed4dac2a294cb417621768c66312.zip
gcc-8b40563cd804ed4dac2a294cb417621768c66312.tar.gz
gcc-8b40563cd804ed4dac2a294cb417621768c66312.tar.bz2
(comptypes, convert_for_assignment): Check for Objective-C protocols (non-reflexive use of maybe_objc_comptypes).
(comptypes, convert_for_assignment): Check for Objective-C protocols (non-reflexive use of maybe_objc_comptypes). (comp_target_types): Rewrite so that maybe_objc_comptypes checks protocols when processing an Objective-C module. For C modules, the code path is unchanged. (convert_for_assignment): Improve the error message for incompatible message arguments. From-SVN: r4067
-rw-r--r--gcc/c-typeck.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 1bbbfda..4d1a694 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -460,7 +460,7 @@ comptypes (type1, type2)
}
case RECORD_TYPE:
- return maybe_objc_comptypes (t1, t2);
+ return maybe_objc_comptypes (t1, t2, 0);
}
return 0;
}
@@ -472,8 +472,30 @@ static int
comp_target_types (ttl, ttr)
tree ttl, ttr;
{
- int val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
- TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
+ int val = 0;
+
+ if (doing_objc_thang)
+ {
+ /* Give maybe_objc_comptypes a crack at letting these types through. */
+ val = maybe_objc_comptypes (ttl, ttr, 1);
+
+ if (val != 1 && !pedantic)
+ {
+ /* Ignore pointer qualifiers recursively. This way char **
+ and const char ** are compatible. */
+ if (TREE_CODE (ttl) == POINTER_TYPE
+ && TREE_CODE (ttr) == POINTER_TYPE)
+ return comp_target_types (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
+ TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
+ else
+ return comptypes (ttl, ttr);
+ }
+ }
+
+ if (val != 1)
+ val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
+ TYPE_MAIN_VARIANT (TREE_TYPE (ttr)));
+
if (val == 2 && pedantic)
pedwarn ("types are not quite compatible");
return val;
@@ -4118,6 +4140,9 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
{
overflow_warning (rhs);
+ /* Check for Objective-C protocols. This will issue a warning if
+ there are protocol violations. No need to use the return value. */
+ maybe_objc_comptypes (type, rhstype, 0);
return rhs;
}
@@ -4232,8 +4257,16 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
if (!errtype)
{
if (funname)
- error ("incompatible type for argument %d of `%s'",
- parmnum, IDENTIFIER_POINTER (funname));
+ {
+ tree selector = maybe_building_objc_message_expr ();
+
+ if (selector && parmnum > 2)
+ error ("incompatible type for argument %d of `%s'",
+ parmnum - 2, IDENTIFIER_POINTER (selector));
+ else
+ error ("incompatible type for argument %d of `%s'",
+ parmnum, IDENTIFIER_POINTER (funname));
+ }
else
error ("incompatible type for argument %d of indirect function call",
parmnum);