/* Protocols. */
-static tree lookup_protocol (tree, bool);
-static tree lookup_and_install_protocols (tree);
+static tree lookup_protocol (tree, bool, bool);
+static tree lookup_and_install_protocols (tree, bool);
/* Type encoding. */
/* Look up protocols and install in lang specific list. */
DUP_TYPE_OBJC_INFO (type, TYPE_MAIN_VARIANT (type));
- TYPE_OBJC_PROTOCOL_LIST (type) = lookup_and_install_protocols (protocols);
+ TYPE_OBJC_PROTOCOL_LIST (type) = lookup_and_install_protocols
+ (protocols, /* definition_required */ false);
/* For RECORD_TYPEs, point to the @interface; for 'id' and 'Class',
return the pointer to the new pointee variant. */
tree pp = TREE_VALUE (p);
if (TREE_CODE (pp) == IDENTIFIER_NODE)
- pp = lookup_protocol (pp, /* warn if deprecated */ false);
+ pp = lookup_protocol (pp, /* warn if deprecated */ false,
+ /* definition_required */ false);
if (pp == proto)
fatal_error ("protocol %qE has circular dependency",
/* Look up PROTOCOLS, and return a list of those that are found. If
none are found, return NULL. Note that this function will emit a
- warning if a protocol is found and is deprecated. */
-
+ warning if a protocol is found and is deprecated. If
+ 'definition_required', then warn if the protocol is found but is
+ not defined (ie, if we only saw a forward-declaration of the
+ protocol (as in "@protocol NSObject;") not a real definition with
+ the list of methods). */
static tree
-lookup_and_install_protocols (tree protocols)
+lookup_and_install_protocols (tree protocols, bool definition_required)
{
tree proto;
tree return_value = NULL_TREE;
for (proto = protocols; proto; proto = TREE_CHAIN (proto))
{
tree ident = TREE_VALUE (proto);
- tree p = lookup_protocol (ident, /* warn_if_deprecated */ true);
+ tree p = lookup_protocol (ident, /* warn_if_deprecated */ true,
+ definition_required);
if (p)
return_value = chainon (return_value,
objc_build_protocol_expr (tree protoname)
{
tree expr;
- tree p = lookup_protocol (protoname, /* warn if deprecated */ true);
+ tree p = lookup_protocol (protoname, /* warn if deprecated */ true,
+ /* definition_required */ false);
if (!p)
{
if (protocol_list)
CLASS_PROTOCOL_LIST (klass)
- = lookup_and_install_protocols (protocol_list);
+ = lookup_and_install_protocols (protocol_list, /* definition_required */ true);
/* Determine if 'deprecated', the only attribute we recognize
for classes, was used. Ignore all other attributes for now,
list. */
CLASS_PROTOCOL_LIST (klass)
= chainon (CLASS_PROTOCOL_LIST (klass),
- lookup_and_install_protocols (protocol_list));
+ lookup_and_install_protocols
+ (protocol_list,
+ /* definition_required */ true));
}
}
else
if (protocol_list)
CLASS_PROTOCOL_LIST (klass)
- = lookup_and_install_protocols (protocol_list);
+ = lookup_and_install_protocols
+ (protocol_list, /* definition_required */ true);
}
}
}
}
/* Looks up a protocol. If 'warn_if_deprecated' is true, a warning is
- emitted if the protocol is deprecated. */
+ emitted if the protocol is deprecated. If 'definition_required' is
+ true, a warning is emitted if a full @protocol definition has not
+ been seen. */
static tree
-lookup_protocol (tree ident, bool warn_if_deprecated)
+lookup_protocol (tree ident, bool warn_if_deprecated, bool definition_required)
{
tree chain;
PROTOCOL_NAME (chain));
}
+ if (definition_required && !PROTOCOL_DEFINED (chain))
+ warning (0, "definition of protocol %qE not found",
+ PROTOCOL_NAME (chain));
+
return chain;
}
{
tree name = TREE_VALUE (list);
- if (lookup_protocol (name, /* warn if deprecated */ false) == NULL_TREE)
+ if (lookup_protocol (name, /* warn if deprecated */ false,
+ /* definition_required */ false) == NULL_TREE)
{
tree protocol = make_node (PROTOCOL_INTERFACE_TYPE);
}
}
- protocol = lookup_protocol (name, /* warn_if_deprecated */ false);
+ protocol = lookup_protocol (name, /* warn_if_deprecated */ false,
+ /* definition_required */ false);
if (!protocol)
{
TYPE_LANG_SLOT_1 (protocol) = make_tree_vec (PROTOCOL_LANG_SLOT_ELTS);
PROTOCOL_NAME (protocol) = name;
- PROTOCOL_LIST (protocol) = lookup_and_install_protocols (list);
+ PROTOCOL_LIST (protocol) = lookup_and_install_protocols (list, /* definition_required */ false);
add_protocol (protocol);
PROTOCOL_DEFINED (protocol) = 1;
PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE;
else if (! PROTOCOL_DEFINED (protocol))
{
PROTOCOL_DEFINED (protocol) = 1;
- PROTOCOL_LIST (protocol) = lookup_and_install_protocols (list);
+ PROTOCOL_LIST (protocol) = lookup_and_install_protocols (list, /* definition_required */ false);
check_protocol_recursively (protocol, list);
}