aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-02-12 15:09:01 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-02-12 15:09:01 +0000
commit45abaea89ceed7cbd6128a841605430da841064a (patch)
tree0d5298e54361908d84bce2abc0fb538a541408a9 /gcc
parent996065b44049d0e525f3e28794868fdaee722f3f (diff)
downloadgcc-45abaea89ceed7cbd6128a841605430da841064a.zip
gcc-45abaea89ceed7cbd6128a841605430da841064a.tar.gz
gcc-45abaea89ceed7cbd6128a841605430da841064a.tar.bz2
typeck2.c (process_init_constructor): Check TREE_HAS_CONSTRUCTOR before issuing missing init warning.
cp: * typeck2.c (process_init_constructor): Check TREE_HAS_CONSTRUCTOR before issuing missing init warning. testsuite: * g++.old-deja/g++.other/warn5.C: New test. From-SVN: r39605
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck2.c15
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/warn5.C19
4 files changed, 39 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d1685b3..e2c1a88 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
+ * typeck2.c (process_init_constructor): Check
+ TREE_HAS_CONSTRUCTOR before issuing missing init warning.
+
+2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
+
* pt.c (maybe_adjust_types_for_deduction, DEDUCE_ORDER case):
Remove spurious information in comment. Allow further
adjustments of REFERENCE_TYPE args.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index c62949e..1538944 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -814,12 +814,18 @@ process_init_constructor (type, init, elts)
next1 = build_functional_cast (TREE_TYPE (field),
NULL_TREE);
else
- next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE,
- NULL_TREE);
+ {
+ next1 = build (CONSTRUCTOR, NULL_TREE, NULL_TREE,
+ NULL_TREE);
+ if (init)
+ TREE_HAS_CONSTRUCTOR (next1)
+ = TREE_HAS_CONSTRUCTOR (init);
+ }
next1 = digest_init (TREE_TYPE (field), next1, 0);
/* Warn when some struct elements are implicitly initialized. */
- if (extra_warnings)
+ if (extra_warnings
+ && (!init || TREE_HAS_CONSTRUCTOR (init)))
cp_warning ("missing initializer for member `%D'", field);
}
else
@@ -835,7 +841,8 @@ process_init_constructor (type, init, elts)
/* Warn when some struct elements are implicitly initialized
to zero. */
- if (extra_warnings)
+ if (extra_warnings
+ && (!init || TREE_HAS_CONSTRUCTOR (init)))
cp_warning ("missing initializer for member `%D'", field);
/* The default zero-initialization is fine for us; don't
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4607aa8..7392506 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.old-deja/g++.other/warn5.C: New test.
+
+2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
+
* g++.old-deja/g++.pt/spec40.C: New test.
2001-02-12 Nathan Sidwell <nathan@codesourcery.com>
diff --git a/gcc/testsuite/g++.old-deja/g++.other/warn5.C b/gcc/testsuite/g++.old-deja/g++.other/warn5.C
new file mode 100644
index 0000000..4c17dc6
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/warn5.C
@@ -0,0 +1,19 @@
+// Special g++ Options: -W
+// Build don't link:
+//
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 6 Febs 2001 <nathan@codesourcery.com>
+
+// Bug 1765. We gave bogus warning on default initializer.
+
+struct X
+{
+ int i;
+};
+
+X *foo ()
+{
+ return new X (); // gets bogus warning
+}
+
+X x = {}; // WARNING - missing initializer