summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-09 07:28:10 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2005-03-09 07:28:10 +0000
commit36145d1de793bf080a329c7d004d7be45f6628da (patch)
treeeae4d082b5125cdbc718dbc2af1ebb736c775972 /gcc
parentbc762cf3d1657b4274e4b9f4a2af3b2361a406b5 (diff)
downloadgcc-36145d1de793bf080a329c7d004d7be45f6628da.tar.gz
PR c++/20142
* cp-tree.h (target_type): Remove. * decl.c (layout_var_decl): Remove #if 0'd code. (cp_finish_decl): Remove dead code. * init.c (build_vec_init): When determining whether or not the element type has an asignment operator, look through all array dimensions. * typeck.c (target_type): Remove. PR c++/20142 * g++.dg/init/array18.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96170 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c8
-rw-r--r--gcc/cp/init.c19
-rw-r--r--gcc/cp/name-lookup.c3
-rw-r--r--gcc/cp/typeck.c16
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/init/array18.C21
8 files changed, 51 insertions, 33 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3048511f23b..a5dba31ddef 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+2005-03-08 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/20142
+ * cp-tree.h (target_type): Remove.
+ * decl.c (layout_var_decl): Remove #if 0'd code.
+ (cp_finish_decl): Remove dead code.
+ * init.c (build_vec_init): When determining whether or not the
+ element type has an asignment operator, look through all array
+ dimensions.
+ * typeck.c (target_type): Remove.
+
2005-03-07 Mark Mitchell <mark@codesourcery.com>
* class.c (finish_struct_1): Do not warn about non-virtual
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d7144242d6d..22d5f17a0cd 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4267,7 +4267,6 @@ extern tree fold_if_not_in_template (tree);
extern int string_conv_p (tree, tree, int);
extern tree cp_truthvalue_conversion (tree);
extern tree condition_conversion (tree);
-extern tree target_type (tree);
extern tree require_complete_type (tree);
extern tree complete_type (tree);
extern tree complete_type_or_else (tree, tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dfc1790a175..fbb264e9640 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3940,9 +3940,6 @@ static void
layout_var_decl (tree decl)
{
tree type = TREE_TYPE (decl);
-#if 0
- tree ttype = target_type (type);
-#endif
/* If we haven't already layed out this declaration, do so now.
Note that we must not call complete type for an external object
@@ -4710,7 +4707,6 @@ void
cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
{
tree type;
- tree ttype = NULL_TREE;
tree cleanup;
const char *asmspec = NULL;
int was_readonly = 0;
@@ -4795,10 +4791,6 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
goto finish_end;
}
- if (TREE_CODE (decl) != FUNCTION_DECL)
- ttype = target_type (type);
-
-
/* A reference will be modified here, as it is initialized. */
if (! DECL_EXTERNAL (decl)
&& TREE_READONLY (decl)
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index d572bca344e..c526bb14511 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2388,6 +2388,9 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array)
tree atype = TREE_TYPE (base);
/* The type of an element in the array. */
tree type = TREE_TYPE (atype);
+ /* The element type reached after removing all outer array
+ types. */
+ tree inner_elt_type;
/* The type of a pointer to an element in the array. */
tree ptype;
tree stmt_expr;
@@ -2403,15 +2406,17 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array)
if (maxindex == NULL_TREE || maxindex == error_mark_node)
return error_mark_node;
+ inner_elt_type = strip_array_types (atype);
if (init
&& (from_array == 2
- ? (!CLASS_TYPE_P (type) || !TYPE_HAS_COMPLEX_ASSIGN_REF (type))
+ ? (!CLASS_TYPE_P (inner_elt_type)
+ || !TYPE_HAS_COMPLEX_ASSIGN_REF (inner_elt_type))
: !TYPE_NEEDS_CONSTRUCTING (type))
&& ((TREE_CODE (init) == CONSTRUCTOR
/* Don't do this if the CONSTRUCTOR might contain something
that might throw and require us to clean up. */
&& (CONSTRUCTOR_ELTS (init) == NULL_TREE
- || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (target_type (type))))
+ || ! TYPE_HAS_NONTRIVIAL_DESTRUCTOR (inner_elt_type)))
|| from_array))
{
/* Do non-default initialization of POD arrays resulting from
@@ -2602,14 +2607,12 @@ build_vec_init (tree base, tree maxindex, tree init, int from_array)
/* Flatten multi-dimensional array since build_vec_delete only
expects one-dimensional array. */
if (TREE_CODE (type) == ARRAY_TYPE)
- {
- m = cp_build_binary_op (MULT_EXPR, m,
- array_type_nelts_total (type));
- type = strip_array_types (type);
- }
+ m = cp_build_binary_op (MULT_EXPR, m,
+ array_type_nelts_total (type));
finish_cleanup_try_block (try_block);
- e = build_vec_delete_1 (rval, m, type, sfk_base_destructor,
+ e = build_vec_delete_1 (rval, m,
+ inner_elt_type, sfk_base_destructor,
/*use_global_delete=*/0);
finish_cleanup (e, try_block);
}
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index accd35210ec..e861a660393 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -4644,6 +4644,9 @@ pushtag (tree name, tree type, int globalize)
else
d = pushdecl_with_scope (d, b);
+ if (d == error_mark_node)
+ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
+
/* FIXME what if it gets a name from typedef? */
if (ANON_AGGRNAME_P (name))
DECL_IGNORED_P (d) = 1;
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9de7b24d0a2..1639b54532b 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -59,22 +59,6 @@ static void maybe_warn_about_returning_address_of_local (tree);
static tree lookup_destructor (tree, tree, tree);
static tree convert_arguments (tree, tree, tree, int);
-/* Return the target type of TYPE, which means return T for:
- T*, T&, T[], T (...), and otherwise, just T. */
-
-tree
-target_type (tree type)
-{
- type = non_reference (type);
- while (TREE_CODE (type) == POINTER_TYPE
- || TREE_CODE (type) == ARRAY_TYPE
- || TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE
- || TYPE_PTRMEM_P (type))
- type = TREE_TYPE (type);
- return type;
-}
-
/* Do `exp = require_complete_type (exp);' to make sure exp
does not have an incomplete type. (That includes void types.)
Returns the error_mark_node if the VALUE does not have
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6c1ac228a1f..c7bdbe1f81e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-03-08 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/20142
+ * g++.dg/init/array18.C: New test.
+
2005-03-09 Ben Elliston <bje@au.ibm.com>
* consistency.vlad/vlad.exp: Remove trailing semicolons.
diff --git a/gcc/testsuite/g++.dg/init/array18.C b/gcc/testsuite/g++.dg/init/array18.C
new file mode 100644
index 00000000000..1cb5dba3841
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/array18.C
@@ -0,0 +1,21 @@
+// PR c++/20142
+
+int n=4;
+
+struct A
+{
+ A() {}
+ A& operator= (const A&) { --n; return *this; }
+};
+
+struct B
+{
+ A x[2][2];
+};
+
+int main()
+{
+ B b;
+ b = b;
+ return n;
+}