2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
* c-common.h (objc_finish_function): New.
(objc_non_volatilized_type): Removed.
(objc_type_quals_match): Removed.
* stub-objc.c (objc_finish_function): New.
(objc_non_volatilized_type): Removed.
(objc_type_quals_match): Removed.
In gcc/objc/:
2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_build_volatilized_type): Removed.
(objc_non_volatilized_type): Removed.
(objc_type_quals_match): Removed.
(local_variables_to_volatilize): New.
(objc_volatilize_decl): Add the decl to volatilize to
local_variables_to_volatilize, but don't volatilize it yet.
(objc_finish_function): New.
* objc-act.h (local_variables_to_volatilize): New.
In gcc/cp/:
2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
* decl.c (finish_function): Call objc_finish_function when
compiling Objective-C++.
* call.c (standard_conversion): Do not call
objc_non_volatilized_type().
(implicit_conversion): Same change.
* typeck.c (comp_ptr_ttypes_real): Same change.
In gcc/:
2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
* c-decl.c (finish_function): Call objc_finish_function in
Objective-C.
* c-typeck.c (convert_for_assignment): Do not call
objc_type_quals_match().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167318
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * c-decl.c (finish_function): Call objc_finish_function in
+ Objective-C.
+ * c-typeck.c (convert_for_assignment): Do not call
+ objc_type_quals_match().
+
2010-11-30 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46722
finish_function (void)
{
tree fndecl = current_function_decl;
+
+ if (c_dialect_objc ())
+ objc_finish_function ();
if (TREE_CODE (fndecl) == FUNCTION_DECL
&& targetm.calls.promote_prototypes (TREE_TYPE (fndecl)))
+2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * c-common.h (objc_finish_function): New.
+ (objc_non_volatilized_type): Removed.
+ (objc_type_quals_match): Removed.
+ * stub-objc.c (objc_finish_function): New.
+ (objc_non_volatilized_type): Removed.
+ (objc_type_quals_match): Removed.
+
2010-11-30 Joseph Myers <joseph@codesourcery.com>
* c-common.h (parse_optimize_options): Declare.
extern void objc_check_decl (tree);
extern void objc_check_global_decl (tree);
extern tree objc_common_type (tree, tree);
-extern tree objc_non_volatilized_type (tree);
extern bool objc_compare_types (tree, tree, int, tree);
extern bool objc_have_common_type (tree, tree, int, tree);
extern bool objc_diagnose_private_ivar (tree);
extern void objc_volatilize_decl (tree);
-extern bool objc_type_quals_match (tree, tree);
extern tree objc_rewrite_function_call (tree, tree);
extern tree objc_message_selector (void);
extern tree objc_lookup_ivar (tree, tree);
extern bool objc_is_property_ref (tree);
extern bool objc_string_ref_type_p (tree);
extern void objc_check_format_arg (tree, tree);
+extern void objc_finish_function (void);
/* The following are provided by the C and C++ front-ends, and called by
ObjC/ObjC++. */
}
tree
-objc_non_volatilized_type (tree type)
-{
- return type;
-}
-
-tree
objc_common_type (tree ARG_UNUSED (type1), tree ARG_UNUSED (type2))
{
return 0;
{
}
-bool
-objc_type_quals_match (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp))
-{
- return false;
-}
-
tree
objc_rewrite_function_call (tree function, tree ARG_UNUSED (first_param))
{
tree ARG_UNUSED (args_list))
{
}
+
+void
+objc_finish_function (void)
+{
+}
if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
& ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
{
- /* Types differing only by the presence of the 'volatile'
- qualifier are acceptable if the 'volatile' has been added
- in by the Objective-C EH machinery. */
- if (!objc_type_quals_match (ttl, ttr))
- WARN_FOR_QUALIFIERS (location, 0,
- G_("passing argument %d of %qE discards "
- "%qv qualifier from pointer target type"),
- G_("assignment discards %qv qualifier "
- "from pointer target type"),
- G_("initialization discards %qv qualifier "
- "from pointer target type"),
- G_("return discards %qv qualifier from "
- "pointer target type"),
- TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
+ WARN_FOR_QUALIFIERS (location, 0,
+ G_("passing argument %d of %qE discards "
+ "%qv qualifier from pointer target type"),
+ G_("assignment discards %qv qualifier "
+ "from pointer target type"),
+ G_("initialization discards %qv qualifier "
+ "from pointer target type"),
+ G_("return discards %qv qualifier from "
+ "pointer target type"),
+ TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl));
}
/* If this is not a case of ignoring a mismatch in signedness,
no warning. */
+2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * decl.c (finish_function): Call objc_finish_function when
+ compiling Objective-C++.
+ * call.c (standard_conversion): Do not call
+ objc_non_volatilized_type().
+ (implicit_conversion): Same change.
+ * typeck.c (comp_ptr_ttypes_real): Same change.
+
2010-11-30 Joseph Myers <joseph@codesourcery.com>
* cp-gimplify.c, cp-lang.c, cvt.c, cxx-pretty-print.c, error.c,
&& TREE_CODE (TREE_TYPE (from)) != FUNCTION_TYPE)
{
tree nfrom = TREE_TYPE (from);
- if (c_dialect_objc ())
- nfrom = objc_non_volatilized_type (nfrom);
from = build_pointer_type
(cp_build_qualified_type (void_type_node,
cp_type_quals (nfrom)));
|| expr == error_mark_node)
return NULL;
- if (c_dialect_objc ())
- from = objc_non_volatilized_type (from);
-
if (TREE_CODE (to) == REFERENCE_TYPE)
conv = reference_binding (to, from, expr, c_cast_p, flags);
else
if (fndecl == NULL_TREE)
return error_mark_node;
+ if (c_dialect_objc ())
+ objc_finish_function ();
+
gcc_assert (!defer_mark_used_calls);
defer_mark_used_calls = true;
so the usual checks are not appropriate. */
if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
{
- /* In Objective-C++, some types may have been 'volatilized' by
- the compiler for EH; when comparing them here, the volatile
- qualification must be ignored. */
- tree nv_to = objc_non_volatilized_type (to);
- tree nv_from = objc_non_volatilized_type (from);
-
- if (!at_least_as_qualified_p (nv_to, nv_from))
+ if (!at_least_as_qualified_p (to, from))
return 0;
- if (!at_least_as_qualified_p (nv_from, nv_to))
+ if (!at_least_as_qualified_p (from, to))
{
if (constp == 0)
return 0;
}
if (constp > 0)
- constp &= TYPE_READONLY (nv_to);
+ constp &= TYPE_READONLY (to);
}
if (TREE_CODE (to) == VECTOR_TYPE)
+2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
+
+ * objc-act.c (objc_build_volatilized_type): Removed.
+ (objc_non_volatilized_type): Removed.
+ (objc_type_quals_match): Removed.
+ (local_variables_to_volatilize): New.
+ (objc_volatilize_decl): Add the decl to volatilize to
+ local_variables_to_volatilize, but don't volatilize it yet.
+ (objc_finish_function): New.
+ * objc-act.h (local_variables_to_volatilize): New.
+
2010-11-29 Nicola Pero <nicola.pero@meta-innovation.com>
Mike Stump <mikestump@comcast.net>
static char *errbuf; /* Buffer for error diagnostics */
+/* An array of all the local variables in the current function that
+ need to be marked as volatile. */
+VEC(tree,gc) *local_variables_to_volatilize = NULL;
+
\f
static int flag_typed_selectors;
return s;
}
-/* Build a type differing from TYPE only in that TYPE_VOLATILE is set.
- Unlike tree.c:build_qualified_type(), preserve TYPE_LANG_SPECIFIC in the
- process. */
-static tree
-objc_build_volatilized_type (tree type)
-{
- tree t;
-
- /* Check if we have not constructed the desired variant already. */
- for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
- {
- /* The type qualifiers must (obviously) match up. */
- if (!TYPE_VOLATILE (t)
- || (TYPE_READONLY (t) != TYPE_READONLY (type))
- || (TYPE_RESTRICT (t) != TYPE_RESTRICT (type)))
- continue;
-
- /* For pointer types, the pointees (and hence their TYPE_LANG_SPECIFIC
- info, if any) must match up. */
- if (POINTER_TYPE_P (t)
- && (TREE_TYPE (t) != TREE_TYPE (type)))
- continue;
-
- /* Only match up the types which were previously volatilized in similar fashion and not
- because they were declared as such. */
- if (!lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (t)))
- continue;
-
- /* Everything matches up! */
- return t;
- }
-
- /* Ok, we could not re-use any of the pre-existing variants. Create
- a new one. */
- t = build_variant_type_copy (type);
- TYPE_VOLATILE (t) = 1;
-
- TYPE_ATTRIBUTES (t) = merge_attributes (TYPE_ATTRIBUTES (type),
- tree_cons (get_identifier ("objc_volatilized"),
- NULL_TREE,
- NULL_TREE));
- if (TREE_CODE (t) == ARRAY_TYPE)
- TREE_TYPE (t) = objc_build_volatilized_type (TREE_TYPE (t));
-
- /* Set up the canonical type information. */
- if (TYPE_STRUCTURAL_EQUALITY_P (type))
- SET_TYPE_STRUCTURAL_EQUALITY (t);
- else if (TYPE_CANONICAL (type) != type)
- TYPE_CANONICAL (t) = objc_build_volatilized_type (TYPE_CANONICAL (type));
- else
- TYPE_CANONICAL (t) = t;
-
- return t;
-}
-
/* Mark DECL as being 'volatile' for purposes of Darwin
_setjmp()/_longjmp() exception handling. Called from
objc_mark_locals_volatile(). */
&& (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL))
{
- tree t = TREE_TYPE (decl);
+ if (local_variables_to_volatilize == NULL)
+ local_variables_to_volatilize = VEC_alloc (tree, gc, 8);
- t = objc_build_volatilized_type (t);
+ VEC_safe_push (tree, gc, local_variables_to_volatilize, decl);
+ }
+}
- TREE_TYPE (decl) = t;
- TREE_THIS_VOLATILE (decl) = 1;
- TREE_SIDE_EFFECTS (decl) = 1;
- DECL_REGISTER (decl) = 0;
+/* Called when parsing of a function completes; if any local variables
+ in the function were marked as variables to volatilize, change them
+ to volatile. We do this at the end of the function when the
+ warnings about discarding 'volatile' have already been produced.
+ We are making the variables as volatile just to force the compiler
+ to preserve them between setjmp/longjmp, but we don't want warnings
+ for them as they aren't really volatile. */
+void
+objc_finish_function (void)
+{
+ /* If there are any local variables to volatilize, volatilize them. */
+ if (local_variables_to_volatilize)
+ {
+ int i;
+ tree decl;
+ FOR_EACH_VEC_ELT (tree, local_variables_to_volatilize, i, decl)
+ {
+ tree t = TREE_TYPE (decl);
+
+ t = build_qualified_type (t, TYPE_QUALS (t) | TYPE_QUAL_VOLATILE);
+ TREE_TYPE (decl) = t;
+ TREE_THIS_VOLATILE (decl) = 1;
+ TREE_SIDE_EFFECTS (decl) = 1;
+ DECL_REGISTER (decl) = 0;
#ifndef OBJCPLUS
- C_DECL_REGISTER (decl) = 0;
+ C_DECL_REGISTER (decl) = 0;
#endif
+ }
+
+ /* Now we delete the vector. This sets it to NULL as well. */
+ VEC_free (tree, gc, local_variables_to_volatilize);
}
}
return false;
}
-/* Check if LTYP and RTYP have the same type qualifiers. If either type
- lives in the volatilized hash table, ignore the 'volatile' bit when
- making the comparison. */
-
-bool
-objc_type_quals_match (tree ltyp, tree rtyp)
-{
- int lquals = TYPE_QUALS (ltyp), rquals = TYPE_QUALS (rtyp);
-
- if (lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (ltyp)))
- lquals &= ~TYPE_QUAL_VOLATILE;
-
- if (lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (rtyp)))
- rquals &= ~TYPE_QUAL_VOLATILE;
-
- return (lquals == rquals);
-}
-
#ifndef OBJCPLUS
/* Determine if CHILD is derived from PARENT. The routine assumes that
both parameters are RECORD_TYPEs, and is non-reflexive. */
error ("redeclaration of Objective-C class %qs", IDENTIFIER_POINTER (id));
}
-/* Return a non-volatalized version of TYPE. */
-
-tree
-objc_non_volatilized_type (tree type)
-{
- if (lookup_attribute ("objc_volatilized", TYPE_ATTRIBUTES (type)))
- type = build_qualified_type (type, (TYPE_QUALS (type) & ~TYPE_QUAL_VOLATILE));
- return type;
-}
-
/* Construct a PROTOCOLS-qualified variant of INTERFACE, where
INTERFACE may either name an Objective-C class, or refer to the
special 'id' or 'Class' types. If INTERFACE is not a valid ObjC
error_at (try_locus, "%<-fobjc-exceptions%> is required to enable Objective-C exception syntax");
}
+ /* Collect the list of local variables. We'll mark them as volatile
+ at the end of compilation of this function to prevent them being
+ clobbered by setjmp/longjmp. */
if (flag_objc_sjlj_exceptions)
objc_mark_locals_volatile (NULL);
}
#define SIZEHASHTABLE 257
+/* An array of all the local variables in the current function that
+ need to be marked as volatile. */
+extern GTY(()) VEC(tree,gc) *local_variables_to_volatilize;
+
/* Objective-C/Objective-C++ @implementation list. */
struct GTY(()) imp_entry {