aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-05-14 17:20:47 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2002-05-14 17:20:47 +0000
commit94e6e4c4f3d7533ab1de7b709e3b3305d3d8e52d (patch)
tree8e6a21c939257492f2f1761473f122f6de4c33dd /gcc/cp/tree.c
parente5f5feea65f904d95c6f7aded34f8d2f447141e9 (diff)
downloadgcc-94e6e4c4f3d7533ab1de7b709e3b3305d3d8e52d.zip
gcc-94e6e4c4f3d7533ab1de7b709e3b3305d3d8e52d.tar.gz
gcc-94e6e4c4f3d7533ab1de7b709e3b3305d3d8e52d.tar.bz2
cp-tree.h (struct lang_type): Added non_zero_init.
* cp-tree.h (struct lang_type): Added non_zero_init. (CLASS_NON_ZERO_INIT_P): New macro. (zero_init_p, force_store_init_value, build_forced_zero_init): Declare. * class.c (check_field_decls): Test non_zero_init. * cvt.c (convert_to_pointer_force): Use cp_convert_to_pointer for zero-to-NULL conversions. * decl.c (obscure_complex_init): Don't reset DECL_INITIAL of a type that needs zero-initialization without zeros. (check_initializer_decl): Compute zero-initializer for types that require a non-trivial one. * init.c (build_forced_zero_init): New function. (build_default_init): Use it. * tree.c (zero_init_p): New function. * typeck2.c (force_store_init_value): New function. (process_init_constructor): Create non-trivial zero-initializers for array members and class fields. From-SVN: r53461
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 02d5a4b..9a52cc0 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1,6 +1,6 @@
/* Language-dependent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
@@ -1901,6 +1901,27 @@ pod_type_p (t)
return 1;
}
+/* Returns 1 iff zero initialization of type T means actually storing
+ zeros in it. */
+
+int
+zero_init_p (t)
+ tree t;
+{
+ t = strip_array_types (t);
+
+ /* NULL pointers to data members are initialized with -1. */
+ if (TYPE_PTRMEM_P (t))
+ return 0;
+
+ /* Classes that contain types that can't be zero-initialized, cannot
+ be zero-initialized themselves. */
+ if (CLASS_TYPE_P (t) && CLASSTYPE_NON_ZERO_INIT_P (t))
+ return 0;
+
+ return 1;
+}
+
/* Table of valid C++ attributes. */
const struct attribute_spec cxx_attribute_table[] =
{