aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.6/gcc/cp/class.c
diff options
context:
space:
mode:
authorJing Yu <jingyu@google.com>2012-02-15 15:40:16 -0800
committerJing Yu <jingyu@google.com>2012-02-15 15:40:16 -0800
commit3f73d6ef90458b45bbbb33ef4c2b174d4662a22d (patch)
tree1b5f0d96c51b51168b3713058a1b62e92f1136eb /gcc-4.6/gcc/cp/class.c
parentd7030123e04baab5dbff9c9ee04c0de99bd9a774 (diff)
downloadtoolchain_gcc-3f73d6ef90458b45bbbb33ef4c2b174d4662a22d.tar.gz
toolchain_gcc-3f73d6ef90458b45bbbb33ef4c2b174d4662a22d.tar.bz2
toolchain_gcc-3f73d6ef90458b45bbbb33ef4c2b174d4662a22d.zip
Sync down FSF r184235@google/gcc-4_6_2-mobile branch
1) Get mostly new patches from FSF gcc-4.6 branch 2) Fix PR52129 3) Insert GNU-stack note for all ARM targets Change-Id: I2b9926981210e517e4021242908074319a91d6bd
Diffstat (limited to 'gcc-4.6/gcc/cp/class.c')
-rw-r--r--gcc-4.6/gcc/cp/class.c87
1 files changed, 78 insertions, 9 deletions
diff --git a/gcc-4.6/gcc/cp/class.c b/gcc-4.6/gcc/cp/class.c
index a3d010203..9f2a7c1ef 100644
--- a/gcc-4.6/gcc/cp/class.c
+++ b/gcc-4.6/gcc/cp/class.c
@@ -1,6 +1,6 @@
/* Functions related to building classes and their related objects.
Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Michael Tiemann (tiemann@cygnus.com)
@@ -464,7 +464,14 @@ build_simple_base_path (tree expr, tree binfo)
/* Is this the base field created by build_base_field? */
if (TREE_CODE (field) == FIELD_DECL
&& DECL_FIELD_IS_BASE (field)
- && TREE_TYPE (field) == type)
+ && TREE_TYPE (field) == type
+ /* If we're looking for a field in the most-derived class,
+ also check the field offset; we can have two base fields
+ of the same type if one is an indirect virtual base and one
+ is a direct non-virtual base. */
+ && (BINFO_INHERITANCE_CHAIN (d_binfo)
+ || tree_int_cst_equal (byte_position (field),
+ BINFO_OFFSET (binfo))))
{
/* We don't use build_class_member_access_expr here, as that
has unnecessary checks, and more importantly results in
@@ -541,6 +548,10 @@ convert_to_base_statically (tree expr, tree base)
{
tree pointer_type;
+ /* If this is a non-empty base, use a COMPONENT_REF. */
+ if (!is_empty_class (BINFO_TYPE (base)))
+ return build_simple_base_path (expr, base);
+
pointer_type = build_pointer_type (expr_type);
/* We use fold_build2 and fold_convert below to simplify the trees
@@ -2295,10 +2306,7 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
else
BV_VCALL_INDEX (*virtuals) = NULL_TREE;
- if (lost)
- BV_LOST_PRIMARY (*virtuals) = true;
- else
- BV_LOST_PRIMARY (*virtuals) = false;
+ BV_LOST_PRIMARY (*virtuals) = lost;
}
/* Called from modify_all_vtables via dfs_walk. */
@@ -2917,7 +2925,7 @@ check_field_decl (tree field,
if (!warned && errorcount > oldcount)
{
inform (DECL_SOURCE_LOCATION (field), "unrestricted unions "
- "only available with -std=c++0x or -std=gnu++0x");
+ "only available with -std=c++11 or -std=gnu++11");
warned = true;
}
}
@@ -4349,6 +4357,40 @@ type_has_user_provided_default_constructor (tree t)
return false;
}
+/* If default-initialization leaves part of TYPE uninitialized, returns
+ a DECL for the field or TYPE itself (DR 253). */
+
+tree
+default_init_uninitialized_part (tree type)
+{
+ tree t, r, binfo;
+ int i;
+
+ type = strip_array_types (type);
+ if (!CLASS_TYPE_P (type))
+ return type;
+ if (type_has_user_provided_default_constructor (type))
+ return NULL_TREE;
+ for (binfo = TYPE_BINFO (type), i = 0;
+ BINFO_BASE_ITERATE (binfo, i, t); ++i)
+ {
+ r = default_init_uninitialized_part (BINFO_TYPE (t));
+ if (r)
+ return r;
+ }
+ for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
+ if (TREE_CODE (t) == FIELD_DECL
+ && !DECL_ARTIFICIAL (t)
+ && !DECL_INITIAL (t))
+ {
+ r = default_init_uninitialized_part (TREE_TYPE (t));
+ if (r)
+ return DECL_P (r) ? r : t;
+ }
+
+ return NULL_TREE;
+}
+
/* Returns true iff for class T, a synthesized default constructor
would be constexpr. */
@@ -5706,6 +5748,27 @@ finish_struct_1 (tree t)
/* Finish debugging output for this type. */
rest_of_type_compilation (t, ! LOCAL_CLASS_P (t));
+
+ if (TYPE_TRANSPARENT_AGGR (t))
+ {
+ tree field = first_field (t);
+ if (field == NULL_TREE || error_operand_p (field))
+ {
+ error ("type transparent class %qT does not have any fields", t);
+ TYPE_TRANSPARENT_AGGR (t) = 0;
+ }
+ else if (DECL_ARTIFICIAL (field))
+ {
+ if (DECL_FIELD_IS_BASE (field))
+ error ("type transparent class %qT has base classes", t);
+ else
+ {
+ gcc_checking_assert (DECL_VIRTUAL_P (field));
+ error ("type transparent class %qT has virtual functions", t);
+ }
+ TYPE_TRANSPARENT_AGGR (t) = 0;
+ }
+ }
}
/* When T was built up, the member declarations were added in reverse
@@ -8384,9 +8447,15 @@ cp_get_virtual_function_decl (tree ref, tree known_type)
{
HOST_WIDE_INT index = tree_low_cst (OBJ_TYPE_REF_TOKEN (ref), 1);
HOST_WIDE_INT i = 0;
- tree v = BINFO_VIRTUALS (TYPE_BINFO (known_type));
+ tree binfo = TYPE_BINFO (known_type);
+ tree v;
tree fndecl;
-
+
+ if (!binfo)
+ return NULL_TREE;
+
+ v = BINFO_VIRTUALS (TYPE_BINFO (known_type));
+
while (v && i != index)
{
i += (TARGET_VTABLE_USES_DESCRIPTORS