aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2010-05-01 13:52:52 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2010-05-01 06:52:52 -0700
commit13ead6d8c5322fec7b7118c3e1b6ac8b794bcebd (patch)
tree61653883121e1f403603f32c64b09c9142fc308b
parent619dea2d5c764e83340099eea2f33296e148b4da (diff)
downloadgcc-13ead6d8c5322fec7b7118c3e1b6ac8b794bcebd.zip
gcc-13ead6d8c5322fec7b7118c3e1b6ac8b794bcebd.tar.gz
gcc-13ead6d8c5322fec7b7118c3e1b6ac8b794bcebd.tar.bz2
Revert the accidental checkin in revision 158918.
gcc/cp/ 2010-05-01 H.J. Lu <hongjiu.lu@intel.com> PR c++/43951 * init.c (build_new_1): Revert the accidental checkin in revision 158918. gcc/testsuite/ 2010-05-01 H.J. Lu <hongjiu.lu@intel.com> PR c++/43951 * g++.dg/init/new28.C: New. From-SVN: r158959
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/init.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/init/new28.C27
4 files changed, 43 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1818d0c..51559e8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR c++/43951
+ * init.c (build_new_1): Revert the accidental checkin in
+ revision 158918.
+
2010-04-30 Jason Merrill <jason@redhat.com>
PR c++/43868
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 70e3d38..4fc90e6 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1911,13 +1911,13 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
is_initialized = (TYPE_NEEDS_CONSTRUCTING (elt_type) || *init != NULL);
- if (*init == NULL)
+ if (*init == NULL && !type_has_user_provided_constructor (elt_type))
{
- bool maybe_uninitialized_error = false;
+ bool uninitialized_error = false;
/* A program that calls for default-initialization [...] of an
entity of reference type is ill-formed. */
if (CLASSTYPE_REF_FIELDS_NEED_INIT (elt_type))
- maybe_uninitialized_error = true;
+ uninitialized_error = true;
/* A new-expression that creates an object of type T initializes
that object as follows:
@@ -1932,9 +1932,9 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
const-qualified type, the program is ill-formed; */
if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (elt_type))
- maybe_uninitialized_error = true;
+ uninitialized_error = true;
- if (maybe_uninitialized_error)
+ if (uninitialized_error)
{
if (complain & tf_error)
diagnose_uninitialized_cst_or_ref_member (elt_type,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4ef7a6f..8e1b4847 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR c++/43951
+ * g++.dg/init/new28.C: New.
+
2010-04-30 Iain Sandoe <iains@gcc.gnu.org>
PR objc++/32052
diff --git a/gcc/testsuite/g++.dg/init/new28.C b/gcc/testsuite/g++.dg/init/new28.C
new file mode 100644
index 0000000..41a78be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/new28.C
@@ -0,0 +1,27 @@
+// PR c++/43951
+// { dg-do run }
+// { dg-options "-O2" }
+
+extern "C" void abort ();
+
+class Foo
+{
+public:
+ Foo () : xxx (1) {};
+ const int xxx;
+};
+Foo *
+bar ()
+{
+ return new Foo;
+}
+
+int
+main ()
+{
+ Foo *p = bar ();
+
+ if (p->xxx != 1)
+ abort ();
+ return 0;
+}