Commit 50ea5861 by Nicola Pero Committed by Nicola Pero

objc-act.c (get_objc_string_decl): Use a switch instead of a chain of ifs.

2010-10-21  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c (get_objc_string_decl): Use a switch instead of a
        chain of ifs.  Use gcc_unreachable instead of abort.
        (add_objc_string): Same change.
        (generate_protocol_list): Same change - twice.
        (synth_id_with_class_suffix): Same change.
        (build_keyword_selector): Same change - twice.
        (objc_build_message_expr): Same change.
        (objc_build_selector_expr): Same change.
        (check_methods): Same change - and added missing gcc_unreachable
        for default case.
        (check_methods_accessible): Same change - twice, and added missing
        gcc_unreachable for default case in one of them.
        (start_class): Same change - and added missing gcc_unreachable for
        default case.
        (continue_class): Same change.
        (objc_gen_property_data): Same change.
        (finish_class): Same change.
        (encode_type_qualifiers): Added missing gcc_unreachable.
        (encode_type): Small code tidy up to reduce duplicated code.  Use
        gcc_unreachable instead of abort - twice.
        (encode_gnu_bitfield): Use a switch instead of a chain of ifs -
        twice.  Added missing gcc_unreachable for default case - twice.
        (dump_interface): Use a switch instead of a chain of ifs.
        (handle_impent): Same change.

From-SVN: r165803
parent 05b7a48a
2010-10-21 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (get_objc_string_decl): Use a switch instead of a
chain of ifs. Use gcc_unreachable instead of abort.
(add_objc_string): Same change.
(generate_protocol_list): Same change - twice.
(synth_id_with_class_suffix): Same change.
(build_keyword_selector): Same change - twice.
(objc_build_message_expr): Same change.
(objc_build_selector_expr): Same change.
(check_methods): Same change - and added missing gcc_unreachable
for default case.
(check_methods_accessible): Same change - twice, and added missing
gcc_unreachable for default case in one of them.
(start_class): Same change - and added missing gcc_unreachable for
default case.
(continue_class): Same change.
(objc_gen_property_data): Same change.
(finish_class): Same change.
(encode_type_qualifiers): Added missing gcc_unreachable.
(encode_type): Small code tidy up to reduce duplicated code. Use
gcc_unreachable instead of abort - twice.
(encode_gnu_bitfield): Use a switch instead of a chain of ifs -
twice. Added missing gcc_unreachable for default case - twice.
(dump_interface): Use a switch instead of a chain of ifs.
(handle_impent): Same change.
2010-10-20 Nicola Pero <nicola.pero@meta-innovation.com> 2010-10-20 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.h (objc_inherit_code): Removed. * objc-act.h (objc_inherit_code): Removed.
......
...@@ -3089,20 +3089,26 @@ get_objc_string_decl (tree ident, enum string_section section) ...@@ -3089,20 +3089,26 @@ get_objc_string_decl (tree ident, enum string_section section)
{ {
tree chain; tree chain;
if (section == class_names) switch (section)
{
case class_names:
chain = class_names_chain; chain = class_names_chain;
else if (section == meth_var_names) break;
case meth_var_names:
chain = meth_var_names_chain; chain = meth_var_names_chain;
else if (section == meth_var_types) break;
case meth_var_types:
chain = meth_var_types_chain; chain = meth_var_types_chain;
else break;
abort (); default:
gcc_unreachable ();
}
for (; chain != 0; chain = TREE_CHAIN (chain)) for (; chain != 0; chain = TREE_CHAIN (chain))
if (TREE_VALUE (chain) == ident) if (TREE_VALUE (chain) == ident)
return (TREE_PURPOSE (chain)); return (TREE_PURPOSE (chain));
abort (); gcc_unreachable ();
return NULL_TREE; return NULL_TREE;
} }
...@@ -3519,23 +3525,23 @@ add_objc_string (tree ident, enum string_section section) ...@@ -3519,23 +3525,23 @@ add_objc_string (tree ident, enum string_section section)
char buf[256]; char buf[256];
buf[0] = 0; buf[0] = 0;
if (section == class_names) switch (section)
{ {
case class_names:
chain = &class_names_chain; chain = &class_names_chain;
sprintf (buf, "_OBJC_CLASS_NAME_%d", class_names_idx++); sprintf (buf, "_OBJC_CLASS_NAME_%d", class_names_idx++);
} break;
else if (section == meth_var_names) case meth_var_names:
{
chain = &meth_var_names_chain; chain = &meth_var_names_chain;
sprintf (buf, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++); sprintf (buf, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++);
} break;
else if (section == meth_var_types) case meth_var_types:
{
chain = &meth_var_types_chain; chain = &meth_var_types_chain;
sprintf (buf, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++); sprintf (buf, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++);
} break;
else default:
gcc_unreachable (); gcc_unreachable ();
}
while (*chain) while (*chain)
{ {
...@@ -6100,13 +6106,18 @@ generate_protocol_list (tree i_or_p) ...@@ -6100,13 +6106,18 @@ generate_protocol_list (tree i_or_p)
const char *ref_name; const char *ref_name;
VEC(constructor_elt,gc) *v = NULL; VEC(constructor_elt,gc) *v = NULL;
if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE switch (TREE_CODE (i_or_p))
|| TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE) {
case CLASS_INTERFACE_TYPE:
case CATEGORY_INTERFACE_TYPE:
plist = CLASS_PROTOCOL_LIST (i_or_p); plist = CLASS_PROTOCOL_LIST (i_or_p);
else if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE) break;
case PROTOCOL_INTERFACE_TYPE:
plist = PROTOCOL_LIST (i_or_p); plist = PROTOCOL_LIST (i_or_p);
else break;
abort (); default:
gcc_unreachable ();
}
/* Compute size. */ /* Compute size. */
for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto)) for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto))
...@@ -6134,14 +6145,20 @@ generate_protocol_list (tree i_or_p) ...@@ -6134,14 +6145,20 @@ generate_protocol_list (tree i_or_p)
/* static struct objc_protocol *refs[n]; */ /* static struct objc_protocol *refs[n]; */
if (TREE_CODE (i_or_p) == PROTOCOL_INTERFACE_TYPE) switch (TREE_CODE (i_or_p))
{
case PROTOCOL_INTERFACE_TYPE:
ref_name = synth_id_with_class_suffix ("_OBJC_PROTOCOL_REFS", i_or_p); ref_name = synth_id_with_class_suffix ("_OBJC_PROTOCOL_REFS", i_or_p);
else if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE) break;
case CLASS_INTERFACE_TYPE:
ref_name = synth_id_with_class_suffix ("_OBJC_CLASS_PROTOCOLS", i_or_p); ref_name = synth_id_with_class_suffix ("_OBJC_CLASS_PROTOCOLS", i_or_p);
else if (TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE) break;
case CATEGORY_INTERFACE_TYPE:
ref_name = synth_id_with_class_suffix ("_OBJC_CATEGORY_PROTOCOLS", i_or_p); ref_name = synth_id_with_class_suffix ("_OBJC_CATEGORY_PROTOCOLS", i_or_p);
else break;
abort (); default:
gcc_unreachable ();
}
ptype = build_pointer_type (objc_protocol_template); ptype = build_pointer_type (objc_protocol_template);
array_type = build_sized_array_type (ptype, size + 3); array_type = build_sized_array_type (ptype, size + 3);
...@@ -6465,14 +6482,15 @@ synth_id_with_class_suffix (const char *preamble, tree ctxt) ...@@ -6465,14 +6482,15 @@ synth_id_with_class_suffix (const char *preamble, tree ctxt)
{ {
static char string[BUFSIZE]; static char string[BUFSIZE];
if (TREE_CODE (ctxt) == CLASS_IMPLEMENTATION_TYPE switch (TREE_CODE (ctxt))
|| TREE_CODE (ctxt) == CLASS_INTERFACE_TYPE)
{ {
case CLASS_IMPLEMENTATION_TYPE:
case CLASS_INTERFACE_TYPE:
sprintf (string, "%s_%s", preamble, sprintf (string, "%s_%s", preamble,
IDENTIFIER_POINTER (CLASS_NAME (ctxt))); IDENTIFIER_POINTER (CLASS_NAME (ctxt)));
} break;
else if (TREE_CODE (ctxt) == CATEGORY_IMPLEMENTATION_TYPE case CATEGORY_IMPLEMENTATION_TYPE:
|| TREE_CODE (ctxt) == CATEGORY_INTERFACE_TYPE) case CATEGORY_INTERFACE_TYPE:
{ {
/* We have a category. */ /* We have a category. */
const char *const class_name const char *const class_name
...@@ -6480,14 +6498,17 @@ synth_id_with_class_suffix (const char *preamble, tree ctxt) ...@@ -6480,14 +6498,17 @@ synth_id_with_class_suffix (const char *preamble, tree ctxt)
const char *const class_super_name const char *const class_super_name
= IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context)); = IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context));
sprintf (string, "%s_%s_%s", preamble, class_name, class_super_name); sprintf (string, "%s_%s_%s", preamble, class_name, class_super_name);
break;
} }
else if (TREE_CODE (ctxt) == PROTOCOL_INTERFACE_TYPE) case PROTOCOL_INTERFACE_TYPE:
{ {
const char *protocol_name = IDENTIFIER_POINTER (PROTOCOL_NAME (ctxt)); const char *protocol_name = IDENTIFIER_POINTER (PROTOCOL_NAME (ctxt));
sprintf (string, "%s_%s", preamble, protocol_name); sprintf (string, "%s_%s", preamble, protocol_name);
break;
}
default:
gcc_unreachable ();
} }
else
abort ();
return string; return string;
} }
...@@ -6562,12 +6583,17 @@ build_keyword_selector (tree selector) ...@@ -6562,12 +6583,17 @@ build_keyword_selector (tree selector)
/* Scan the selector to see how much space we'll need. */ /* Scan the selector to see how much space we'll need. */
for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain)) for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain))
{ {
if (TREE_CODE (selector) == KEYWORD_DECL) switch (TREE_CODE (selector))
{
case KEYWORD_DECL:
key_name = KEYWORD_KEY_NAME (key_chain); key_name = KEYWORD_KEY_NAME (key_chain);
else if (TREE_CODE (selector) == TREE_LIST) break;
case TREE_LIST:
key_name = TREE_PURPOSE (key_chain); key_name = TREE_PURPOSE (key_chain);
else break;
abort (); default:
gcc_unreachable ();
}
if (key_name) if (key_name)
len += IDENTIFIER_LENGTH (key_name) + 1; len += IDENTIFIER_LENGTH (key_name) + 1;
...@@ -6582,18 +6608,21 @@ build_keyword_selector (tree selector) ...@@ -6582,18 +6608,21 @@ build_keyword_selector (tree selector)
for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain)) for (key_chain = selector; key_chain; key_chain = TREE_CHAIN (key_chain))
{ {
if (TREE_CODE (selector) == KEYWORD_DECL) switch (TREE_CODE (selector))
key_name = KEYWORD_KEY_NAME (key_chain);
else if (TREE_CODE (selector) == TREE_LIST)
{ {
case KEYWORD_DECL:
key_name = KEYWORD_KEY_NAME (key_chain);
break;
case TREE_LIST:
key_name = TREE_PURPOSE (key_chain); key_name = TREE_PURPOSE (key_chain);
/* The keyword decl chain will later be used as a function argument /* The keyword decl chain will later be used as a function
chain. Unhook the selector itself so as to not confuse other argument chain. Unhook the selector itself so as to not
parts of the compiler. */ confuse other parts of the compiler. */
TREE_PURPOSE (key_chain) = NULL_TREE; TREE_PURPOSE (key_chain) = NULL_TREE;
break;
default:
gcc_unreachable ();
} }
else
abort ();
if (key_name) if (key_name)
strcat (buf, IDENTIFIER_POINTER (key_name)); strcat (buf, IDENTIFIER_POINTER (key_name));
...@@ -6885,13 +6914,18 @@ objc_build_message_expr (tree mess) ...@@ -6885,13 +6914,18 @@ objc_build_message_expr (tree mess)
return error_mark_node; return error_mark_node;
/* Obtain the full selector name. */ /* Obtain the full selector name. */
if (TREE_CODE (args) == IDENTIFIER_NODE) switch (TREE_CODE (args))
{
case IDENTIFIER_NODE:
/* A unary selector. */ /* A unary selector. */
sel_name = args; sel_name = args;
else if (TREE_CODE (args) == TREE_LIST) break;
case TREE_LIST:
sel_name = build_keyword_selector (args); sel_name = build_keyword_selector (args);
else break;
abort (); default:
gcc_unreachable ();
}
/* Build the parameter list to give to the method. */ /* Build the parameter list to give to the method. */
if (TREE_CODE (args) == TREE_LIST) if (TREE_CODE (args) == TREE_LIST)
...@@ -7382,13 +7416,18 @@ objc_build_selector_expr (location_t loc, tree selnamelist) ...@@ -7382,13 +7416,18 @@ objc_build_selector_expr (location_t loc, tree selnamelist)
tree selname; tree selname;
/* Obtain the full selector name. */ /* Obtain the full selector name. */
if (TREE_CODE (selnamelist) == IDENTIFIER_NODE) switch (TREE_CODE (selnamelist))
{
case IDENTIFIER_NODE:
/* A unary selector. */ /* A unary selector. */
selname = selnamelist; selname = selnamelist;
else if (TREE_CODE (selnamelist) == TREE_LIST) break;
case TREE_LIST:
selname = build_keyword_selector (selnamelist); selname = build_keyword_selector (selnamelist);
else break;
abort (); default:
gcc_unreachable ();
}
/* If we are required to check @selector() expressions as they /* If we are required to check @selector() expressions as they
are found, check that the selector has been declared. */ are found, check that the selector has been declared. */
...@@ -8069,14 +8108,19 @@ check_methods (tree chain, tree list, int mtype) ...@@ -8069,14 +8108,19 @@ check_methods (tree chain, tree list, int mtype)
{ {
if (first) if (first)
{ {
if (TREE_CODE (objc_implementation_context) switch (TREE_CODE (objc_implementation_context))
== CLASS_IMPLEMENTATION_TYPE) {
case CLASS_IMPLEMENTATION_TYPE:
warning (0, "incomplete implementation of class %qE", warning (0, "incomplete implementation of class %qE",
CLASS_NAME (objc_implementation_context)); CLASS_NAME (objc_implementation_context));
else if (TREE_CODE (objc_implementation_context) break;
== CATEGORY_IMPLEMENTATION_TYPE) case CATEGORY_IMPLEMENTATION_TYPE:
warning (0, "incomplete implementation of category %qE", warning (0, "incomplete implementation of category %qE",
CLASS_SUPER_NAME (objc_implementation_context)); CLASS_SUPER_NAME (objc_implementation_context));
break;
default:
gcc_unreachable ();
}
first = 0; first = 0;
} }
...@@ -8138,33 +8182,42 @@ check_methods_accessible (tree chain, tree context, int mtype) ...@@ -8138,33 +8182,42 @@ check_methods_accessible (tree chain, tree context, int mtype)
if (lookup_method (list, chain)) if (lookup_method (list, chain))
break; break;
else if (TREE_CODE (context) == CLASS_IMPLEMENTATION_TYPE switch (TREE_CODE (context))
|| TREE_CODE (context) == CLASS_INTERFACE_TYPE) {
case CLASS_IMPLEMENTATION_TYPE:
case CLASS_INTERFACE_TYPE:
context = (CLASS_SUPER_NAME (context) context = (CLASS_SUPER_NAME (context)
? lookup_interface (CLASS_SUPER_NAME (context)) ? lookup_interface (CLASS_SUPER_NAME (context))
: NULL_TREE); : NULL_TREE);
break;
else if (TREE_CODE (context) == CATEGORY_IMPLEMENTATION_TYPE case CATEGORY_IMPLEMENTATION_TYPE:
|| TREE_CODE (context) == CATEGORY_INTERFACE_TYPE) case CATEGORY_INTERFACE_TYPE:
context = (CLASS_NAME (context) context = (CLASS_NAME (context)
? lookup_interface (CLASS_NAME (context)) ? lookup_interface (CLASS_NAME (context))
: NULL_TREE); : NULL_TREE);
else break;
abort (); default:
gcc_unreachable ();
}
} }
if (context == NULL_TREE) if (context == NULL_TREE)
{ {
if (first) if (first)
{ {
if (TREE_CODE (objc_implementation_context) switch (TREE_CODE (objc_implementation_context))
== CLASS_IMPLEMENTATION_TYPE) {
case CLASS_IMPLEMENTATION_TYPE:
warning (0, "incomplete implementation of class %qE", warning (0, "incomplete implementation of class %qE",
CLASS_NAME (objc_implementation_context)); CLASS_NAME (objc_implementation_context));
else if (TREE_CODE (objc_implementation_context) break;
== CATEGORY_IMPLEMENTATION_TYPE) case CATEGORY_IMPLEMENTATION_TYPE:
warning (0, "incomplete implementation of category %qE", warning (0, "incomplete implementation of category %qE",
CLASS_SUPER_NAME (objc_implementation_context)); CLASS_SUPER_NAME (objc_implementation_context));
break;
default:
gcc_unreachable ();
}
first = 0; first = 0;
} }
warning (0, "method definition for %<%c%E%> not found", warning (0, "method definition for %<%c%E%> not found",
...@@ -8307,8 +8360,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, ...@@ -8307,8 +8360,9 @@ start_class (enum tree_code code, tree class_name, tree super_name,
decl); decl);
} }
if (code == CLASS_IMPLEMENTATION_TYPE) switch (code)
{ {
case CLASS_IMPLEMENTATION_TYPE:
{ {
tree chain; tree chain;
...@@ -8358,33 +8412,30 @@ start_class (enum tree_code code, tree class_name, tree super_name, ...@@ -8358,33 +8412,30 @@ start_class (enum tree_code code, tree class_name, tree super_name,
CLASS_SUPER_NAME (objc_implementation_context) CLASS_SUPER_NAME (objc_implementation_context)
= CLASS_SUPER_NAME (implementation_template); = CLASS_SUPER_NAME (implementation_template);
} }
} break;
else if (code == CLASS_INTERFACE_TYPE) case CLASS_INTERFACE_TYPE:
{
if (lookup_interface (class_name)) if (lookup_interface (class_name))
#ifdef OBJCPLUS #ifdef OBJCPLUS
error ("duplicate interface declaration for class %qE", error ("duplicate interface declaration for class %qE", class_name);
#else #else
warning (0, "duplicate interface declaration for class %qE", warning (0, "duplicate interface declaration for class %qE", class_name);
#endif #endif
class_name);
else else
add_class (klass, class_name); add_class (klass, class_name);
if (protocol_list) if (protocol_list)
CLASS_PROTOCOL_LIST (klass) CLASS_PROTOCOL_LIST (klass)
= lookup_and_install_protocols (protocol_list); = lookup_and_install_protocols (protocol_list);
} break;
else if (code == CATEGORY_INTERFACE_TYPE) case CATEGORY_INTERFACE_TYPE:
{ {
tree class_category_is_assoc_with; tree class_category_is_assoc_with;
/* For a category, class_name is really the name of the class that /* For a category, class_name is really the name of the class that
the following set of methods will be associated with. We must the following set of methods will be associated with. We must
find the interface so that can derive the objects template. */ find the interface so that can derive the objects template. */
if (!(class_category_is_assoc_with = lookup_interface (class_name))) if (!(class_category_is_assoc_with = lookup_interface (class_name)))
{ {
error ("cannot find interface declaration for %qE", error ("cannot find interface declaration for %qE",
...@@ -8398,9 +8449,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, ...@@ -8398,9 +8449,9 @@ start_class (enum tree_code code, tree class_name, tree super_name,
CLASS_PROTOCOL_LIST (klass) CLASS_PROTOCOL_LIST (klass)
= lookup_and_install_protocols (protocol_list); = lookup_and_install_protocols (protocol_list);
} }
break;
else if (code == CATEGORY_IMPLEMENTATION_TYPE) case CATEGORY_IMPLEMENTATION_TYPE:
{
/* Reset for multiple classes per file. */ /* Reset for multiple classes per file. */
method_slot = 0; method_slot = 0;
...@@ -8416,6 +8467,9 @@ start_class (enum tree_code code, tree class_name, tree super_name, ...@@ -8416,6 +8467,9 @@ start_class (enum tree_code code, tree class_name, tree super_name,
class_name); class_name);
exit (FATAL_EXIT_CODE); exit (FATAL_EXIT_CODE);
} }
break;
default:
gcc_unreachable ();
} }
return klass; return klass;
} }
...@@ -8423,8 +8477,10 @@ start_class (enum tree_code code, tree class_name, tree super_name, ...@@ -8423,8 +8477,10 @@ start_class (enum tree_code code, tree class_name, tree super_name,
static tree static tree
continue_class (tree klass) continue_class (tree klass)
{ {
if (TREE_CODE (klass) == CLASS_IMPLEMENTATION_TYPE switch (TREE_CODE (klass))
|| TREE_CODE (klass) == CATEGORY_IMPLEMENTATION_TYPE) {
case CLASS_IMPLEMENTATION_TYPE:
case CATEGORY_IMPLEMENTATION_TYPE:
{ {
struct imp_entry *imp_entry; struct imp_entry *imp_entry;
...@@ -8434,11 +8490,9 @@ continue_class (tree klass) ...@@ -8434,11 +8490,9 @@ continue_class (tree klass)
check_ivars (implementation_template, klass); check_ivars (implementation_template, klass);
/* code generation */ /* code generation */
#ifdef OBJCPLUS #ifdef OBJCPLUS
push_lang_context (lang_name_c); push_lang_context (lang_name_c);
#endif #endif
build_private_template (implementation_template); build_private_template (implementation_template);
uprivate_record = CLASS_STATIC_TEMPLATE (implementation_template); uprivate_record = CLASS_STATIC_TEMPLATE (implementation_template);
objc_instance_type = build_pointer_type (uprivate_record); objc_instance_type = build_pointer_type (uprivate_record);
...@@ -8460,33 +8514,30 @@ continue_class (tree klass) ...@@ -8460,33 +8514,30 @@ continue_class (tree klass)
imp_count++; imp_count++;
else else
cat_count++; cat_count++;
#ifdef OBJCPLUS #ifdef OBJCPLUS
pop_lang_context (); pop_lang_context ();
#endif /* OBJCPLUS */ #endif /* OBJCPLUS */
return get_class_ivars (implementation_template, true); return get_class_ivars (implementation_template, true);
break;
} }
case CLASS_INTERFACE_TYPE:
else if (TREE_CODE (klass) == CLASS_INTERFACE_TYPE)
{ {
#ifdef OBJCPLUS #ifdef OBJCPLUS
push_lang_context (lang_name_c); push_lang_context (lang_name_c);
#endif /* OBJCPLUS */ #endif /* OBJCPLUS */
objc_collecting_ivars = 1; objc_collecting_ivars = 1;
build_private_template (klass); build_private_template (klass);
objc_collecting_ivars = 0; objc_collecting_ivars = 0;
#ifdef OBJCPLUS #ifdef OBJCPLUS
pop_lang_context (); pop_lang_context ();
#endif /* OBJCPLUS */ #endif /* OBJCPLUS */
return NULL_TREE; return NULL_TREE;
break;
} }
default:
else
return error_mark_node; return error_mark_node;
}
} }
/* This routine builds a property ivar name. */ /* This routine builds a property ivar name. */
...@@ -8844,7 +8895,9 @@ objc_gen_property_data (tree klass, tree class_methods) ...@@ -8844,7 +8895,9 @@ objc_gen_property_data (tree klass, tree class_methods)
static void static void
finish_class (tree klass) finish_class (tree klass)
{ {
if (TREE_CODE (klass) == CLASS_IMPLEMENTATION_TYPE) switch (TREE_CODE (klass))
{
case CLASS_IMPLEMENTATION_TYPE:
{ {
/* All code generation is done in finish_objc. */ /* All code generation is done in finish_objc. */
...@@ -8864,9 +8917,9 @@ finish_class (tree klass) ...@@ -8864,9 +8917,9 @@ finish_class (tree klass)
"class", "class",
CLASS_NAME (objc_implementation_context)); CLASS_NAME (objc_implementation_context));
} }
break;
} }
case CATEGORY_IMPLEMENTATION_TYPE:
else if (TREE_CODE (klass) == CATEGORY_IMPLEMENTATION_TYPE)
{ {
tree category = lookup_category (implementation_template, CLASS_SUPER_NAME (klass)); tree category = lookup_category (implementation_template, CLASS_SUPER_NAME (klass));
...@@ -8886,8 +8939,9 @@ finish_class (tree klass) ...@@ -8886,8 +8939,9 @@ finish_class (tree klass)
"category", "category",
CLASS_SUPER_NAME (objc_implementation_context)); CLASS_SUPER_NAME (objc_implementation_context));
} }
break;
} }
else default:
{ {
/* Process properties of the class. */ /* Process properties of the class. */
tree x; tree x;
...@@ -8920,8 +8974,8 @@ finish_class (tree klass) ...@@ -8920,8 +8974,8 @@ finish_class (tree klass)
tree setter_decl, selector; tree setter_decl, selector;
tree ret_type = build_tree_list (NULL_TREE, void_type_node); tree ret_type = build_tree_list (NULL_TREE, void_type_node);
/* setter name. */ /* setter name. */
key_name = get_identifier (objc_build_property_setter_name ( key_name = get_identifier (objc_build_property_setter_name
PROPERTY_NAME (x), false)); (PROPERTY_NAME (x), false));
arg_type = build_tree_list (NULL_TREE, type); arg_type = build_tree_list (NULL_TREE, type);
arg_name = get_identifier ("_value"); arg_name = get_identifier ("_value");
/* For now, no attributes. */ /* For now, no attributes. */
...@@ -8941,6 +8995,7 @@ finish_class (tree klass) ...@@ -8941,6 +8995,7 @@ finish_class (tree klass)
IDENTIFIER_POINTER (PROPERTY_IVAR_NAME (x))); IDENTIFIER_POINTER (PROPERTY_IVAR_NAME (x)));
} }
} }
}
} }
static tree static tree
...@@ -9089,6 +9144,8 @@ encode_type_qualifiers (tree declspecs) ...@@ -9089,6 +9144,8 @@ encode_type_qualifiers (tree declspecs)
obstack_1grow (&util_obstack, 'R'); obstack_1grow (&util_obstack, 'R');
else if (ridpointers[(int) RID_ONEWAY] == TREE_VALUE (spec)) else if (ridpointers[(int) RID_ONEWAY] == TREE_VALUE (spec))
obstack_1grow (&util_obstack, 'V'); obstack_1grow (&util_obstack, 'V');
else
gcc_unreachable ();
} }
} }
...@@ -9492,9 +9549,10 @@ encode_type (tree type, int curtype, int format) ...@@ -9492,9 +9549,10 @@ encode_type (tree type, int curtype, int format)
case 8: c = TYPE_UNSIGNED (type) ? 'C' : 'c'; break; case 8: c = TYPE_UNSIGNED (type) ? 'C' : 'c'; break;
case 16: c = TYPE_UNSIGNED (type) ? 'S' : 's'; break; case 16: c = TYPE_UNSIGNED (type) ? 'S' : 's'; break;
case 32: case 32:
{
tree int_type = type;
if (flag_next_runtime) if (flag_next_runtime)
{ {
tree int_type;
/* Another legacy kludge for compatiblity with /* Another legacy kludge for compatiblity with
gcc-3.3: 32-bit longs are encoded as 'l' or 'L', gcc-3.3: 32-bit longs are encoded as 'l' or 'L',
but not always. For typedefs, we need to use 'i' but not always. For typedefs, we need to use 'i'
...@@ -9505,25 +9563,17 @@ encode_type (tree type, int curtype, int format) ...@@ -9505,25 +9563,17 @@ encode_type (tree type, int curtype, int format)
== (unsigned) curtype)) == (unsigned) curtype))
? TYPE_MAIN_VARIANT (type) ? TYPE_MAIN_VARIANT (type)
: type); : type);
}
if (int_type == long_unsigned_type_node if (int_type == long_unsigned_type_node
|| int_type == long_integer_type_node) || int_type == long_integer_type_node)
c = TYPE_UNSIGNED (type) ? 'L' : 'l'; c = TYPE_UNSIGNED (type) ? 'L' : 'l';
else else
c = TYPE_UNSIGNED (type) ? 'I' : 'i'; c = TYPE_UNSIGNED (type) ? 'I' : 'i';
} }
else
{
if (type == long_unsigned_type_node
|| type == long_integer_type_node)
c = TYPE_UNSIGNED (type) ? 'L' : 'l';
else
c = TYPE_UNSIGNED (type) ? 'I' : 'i';
}
break; break;
case 64: c = TYPE_UNSIGNED (type) ? 'Q' : 'q'; break; case 64: c = TYPE_UNSIGNED (type) ? 'Q' : 'q'; break;
case 128: c = TYPE_UNSIGNED (type) ? 'T' : 't'; break; case 128: c = TYPE_UNSIGNED (type) ? 'T' : 't'; break;
default: abort (); default: gcc_unreachable ();
} }
obstack_1grow (&util_obstack, c); obstack_1grow (&util_obstack, c);
break; break;
...@@ -9538,7 +9588,7 @@ encode_type (tree type, int curtype, int format) ...@@ -9538,7 +9588,7 @@ encode_type (tree type, int curtype, int format)
case 64: c = 'd'; break; case 64: c = 'd'; break;
case 96: case 96:
case 128: c = 'D'; break; case 128: c = 'D'; break;
default: abort (); default: gcc_unreachable ();
} }
obstack_1grow (&util_obstack, c); obstack_1grow (&util_obstack, c);
break; break;
...@@ -9622,37 +9672,48 @@ encode_gnu_bitfield (int position, tree type, int size) ...@@ -9622,37 +9672,48 @@ encode_gnu_bitfield (int position, tree type, int size)
if (integer_zerop (TYPE_MIN_VALUE (type))) if (integer_zerop (TYPE_MIN_VALUE (type)))
/* Unsigned integer types. */ /* Unsigned integer types. */
{ {
if (TYPE_MODE (type) == QImode) switch (TYPE_MODE (type))
charType = 'C'; {
else if (TYPE_MODE (type) == HImode) case QImode:
charType = 'S'; charType = 'C'; break;
else if (TYPE_MODE (type) == SImode) case HImode:
charType = 'S'; break;
case SImode:
{ {
if (type == long_unsigned_type_node) if (type == long_unsigned_type_node)
charType = 'L'; charType = 'L';
else else
charType = 'I'; charType = 'I';
break;
}
case DImode:
charType = 'Q'; break;
default:
gcc_unreachable ();
} }
else if (TYPE_MODE (type) == DImode)
charType = 'Q';
} }
else else
/* Signed integer types. */ /* Signed integer types. */
{ {
if (TYPE_MODE (type) == QImode) switch (TYPE_MODE (type))
charType = 'c'; {
else if (TYPE_MODE (type) == HImode) case QImode:
charType = 's'; charType = 'c'; break;
else if (TYPE_MODE (type) == SImode) case HImode:
charType = 's'; break;
case SImode:
{ {
if (type == long_integer_type_node) if (type == long_integer_type_node)
charType = 'l'; charType = 'l';
else else
charType = 'i'; charType = 'i';
break;
}
case DImode:
charType = 'q'; break;
default:
gcc_unreachable ();
} }
else if (TYPE_MODE (type) == DImode)
charType = 'q';
} }
} }
else else
...@@ -10501,14 +10562,15 @@ dump_interface (FILE *fp, tree chain) ...@@ -10501,14 +10562,15 @@ dump_interface (FILE *fp, tree chain)
{ {
const char *name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (chain)); const char *name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (chain));
if (TREE_CODE (chain) == CATEGORY_IMPLEMENTATION_TYPE switch (TREE_CODE (chain))
|| TREE_CODE (chain) == CATEGORY_INTERFACE_TYPE)
{ {
case CATEGORY_IMPLEMENTATION_TYPE:
case CATEGORY_INTERFACE_TYPE:
fprintf (fp, " (%s)\n", name); fprintf (fp, " (%s)\n", name);
} break;
else default:
{
fprintf (fp, " : %s\n", name); fprintf (fp, " : %s\n", name);
break;
} }
} }
else else
...@@ -10815,7 +10877,9 @@ handle_impent (struct imp_entry *impent) ...@@ -10815,7 +10877,9 @@ handle_impent (struct imp_entry *impent)
objc_implementation_context = impent->imp_context; objc_implementation_context = impent->imp_context;
implementation_template = impent->imp_template; implementation_template = impent->imp_template;
if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE) switch (TREE_CODE (impent->imp_context))
{
case CLASS_IMPLEMENTATION_TYPE:
{ {
const char *const class_name = const char *const class_name =
IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context));
...@@ -10824,8 +10888,9 @@ handle_impent (struct imp_entry *impent) ...@@ -10824,8 +10888,9 @@ handle_impent (struct imp_entry *impent)
sprintf (string, "%sobjc_class_name_%s", sprintf (string, "%sobjc_class_name_%s",
(flag_next_runtime ? "." : "__"), class_name); (flag_next_runtime ? "." : "__"), class_name);
break;
} }
else if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) case CATEGORY_IMPLEMENTATION_TYPE:
{ {
const char *const class_name = const char *const class_name =
IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context));
...@@ -10836,13 +10901,16 @@ handle_impent (struct imp_entry *impent) ...@@ -10836,13 +10901,16 @@ handle_impent (struct imp_entry *impent)
+ strlen (class_super_name) + 30); + strlen (class_super_name) + 30);
/* Do the same for categories. Even though no references to /* Do the same for categories. Even though no references to
these symbols are generated automatically by the compiler, it these symbols are generated automatically by the compiler,
gives you a handle to pull them into an archive by hand. */ it gives you a handle to pull them into an archive by
hand. */
sprintf (string, "*%sobjc_category_name_%s_%s", sprintf (string, "*%sobjc_category_name_%s_%s",
(flag_next_runtime ? "." : "__"), class_name, class_super_name); (flag_next_runtime ? "." : "__"), class_name, class_super_name);
break;
} }
else default:
return; return;
}
#ifdef ASM_DECLARE_CLASS_REFERENCE #ifdef ASM_DECLARE_CLASS_REFERENCE
if (flag_next_runtime) if (flag_next_runtime)
......
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