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
This commit is contained in:
Nathan Sidwell 2001-02-12 15:09:01 +00:00 committed by Nathan Sidwell
parent 996065b440
commit 45abaea89c
4 changed files with 39 additions and 4 deletions

View File

@ -1,3 +1,8 @@
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):

View File

@ -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

View File

@ -1,3 +1,7 @@
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.

View File

@ -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