+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):
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
/* 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
+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.
--- /dev/null
+// 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