summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-11-30 21:55:39 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-11-30 21:55:39 +0000
commit6c39e757f6ef3dd6c470cd0293dacd8e94e0fe47 (patch)
tree8172aebfe61894b96734ffe92ed52f31bce5003d
parent1ab3acf4666620a8f37107698cd01a2a4a716552 (diff)
downloadgcc-6c39e757f6ef3dd6c470cd0293dacd8e94e0fe47.tar.gz
In gcc/c-family/: 2010-11-30 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/c-family/: 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(). From-SVN: r167318
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/c-decl.c3
-rw-r--r--gcc/c-family/ChangeLog9
-rw-r--r--gcc/c-family/c-common.h3
-rw-r--r--gcc/c-family/stub-objc.c17
-rw-r--r--gcc/c-typeck.c24
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/call.c5
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/typeck.c12
-rw-r--r--gcc/objc/ChangeLog11
-rw-r--r--gcc/objc/objc-act.c131
-rw-r--r--gcc/objc/objc-act.h4
13 files changed, 106 insertions, 132 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b4fe46515f7..d169fc9dd92 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index bab402d90f8..b1055b039e9 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -8184,6 +8184,9 @@ void
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)))
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 7593aa0da30..84eef7d7453 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,12 @@
+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.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 620836fef2b..7e261e88df3 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -998,12 +998,10 @@ extern tree objc_is_object_ptr (tree);
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);
@@ -1065,6 +1063,7 @@ extern const char * objc_maybe_printable_name (tree, int);
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++. */
diff --git a/gcc/c-family/stub-objc.c b/gcc/c-family/stub-objc.c
index e1e3090f768..fbf7ece1e97 100644
--- a/gcc/c-family/stub-objc.c
+++ b/gcc/c-family/stub-objc.c
@@ -67,12 +67,6 @@ objc_check_global_decl (tree ARG_UNUSED (decl))
}
tree
-objc_non_volatilized_type (tree type)
-{
- return type;
-}
-
-tree
objc_common_type (tree ARG_UNUSED (type1), tree ARG_UNUSED (type2))
{
return 0;
@@ -97,12 +91,6 @@ objc_volatilize_decl (tree ARG_UNUSED (decl))
{
}
-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))
{
@@ -461,3 +449,8 @@ objc_check_format_arg (tree ARG_UNUSED (format_arg),
tree ARG_UNUSED (args_list))
{
}
+
+void
+objc_finish_function (void)
+{
+}
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 09e9ca73039..65d255abd13 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -5605,20 +5605,16 @@ convert_for_assignment (location_t location, tree type, tree rhs,
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. */
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7c0d7bff6da..706c974ae4a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+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,
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 0f016ca324a..6a11217ed9b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -872,8 +872,6 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
&& 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)));
@@ -1483,9 +1481,6 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
|| 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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c494e1c0b92..f772d605b82 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12811,6 +12811,9 @@ finish_function (int flags)
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;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index df31d875dca..80aa725d251 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7869,16 +7869,10 @@ comp_ptr_ttypes_real (tree to, tree from, int constp)
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;
@@ -7886,7 +7880,7 @@ comp_ptr_ttypes_real (tree to, tree from, int constp)
}
if (constp > 0)
- constp &= TYPE_READONLY (nv_to);
+ constp &= TYPE_READONLY (to);
}
if (TREE_CODE (to) == VECTOR_TYPE)
diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index adb56b913ef..90765eb93e5 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,14 @@
+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>
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 8de8e255e24..b9cb6508ec6 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -405,6 +405,10 @@ static int objc_collecting_ivars = 0;
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;
+
static int flag_typed_selectors;
@@ -2257,61 +2261,6 @@ objc_build_struct (tree klass, tree fields, tree super_name)
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(). */
@@ -2324,17 +2273,44 @@ objc_volatilize_decl (tree decl)
&& (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);
}
}
@@ -2691,24 +2667,6 @@ objc_have_common_type (tree ltyp, tree rtyp, int argno, tree callee)
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. */
@@ -2828,16 +2786,6 @@ objc_check_global_decl (tree decl)
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
@@ -5353,6 +5301,9 @@ objc_begin_try_stmt (location_t try_locus, tree body)
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);
}
diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h
index 6403161da7b..7e8e4184880 100644
--- a/gcc/objc/objc-act.h
+++ b/gcc/objc/objc-act.h
@@ -253,6 +253,10 @@ extern GTY ((length ("SIZEHASHTABLE"))) hash *als_name_hash_list;
#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 {