Commit c0694c4b by Mark Mitchell Committed by Mark Mitchell

re PR c++/14199 (Unjustified warning about unused variable)

	PR c++/14199
	* pt.c (tsubst_copy): Call mark_used for a PARM_DECL.

	PR c++/14173
	* semantics.c (begin_class_definition): Set TYPE_PACKED correctly
	for all type variants.

	PR c++/14173
	* g++.dg/ext/packed5.C: New test.

	PR c++/14199
	* g++.dg/warn/Wunused-5.C: New test.

	PR c++/13927
	* decl.c (duplicate_decls): Return error_mark_node for invalid
	redeclarations.
	* name-lookup.c (push_namespace): Ignore the return value from
	pushdecl.
	* pt.c (push_template_decl_real): Robustify.

	PR c++/13927
	* g++.dg/other/error8.C: Remove XFAIL markers.

From-SVN: r78159
parent 15316a6f
2004-02-20 Mark Mitchell <mark@codesourcery.com>
PR c++/14199
* pt.c (tsubst_copy): Call mark_used for a PARM_DECL.
PR c++/14173
* semantics.c (begin_class_definition): Set TYPE_PACKED correctly
for all type variants.
2004-02-19 Mark Mitchell <mark@codesourcery.com>
PR c++/13927
* decl.c (duplicate_decls): Return error_mark_node for invalid
redeclarations.
* name-lookup.c (push_namespace): Ignore the return value from
pushdecl.
* pt.c (push_template_decl_real): Robustify.
PR c++/14186
* name-lookup.c (push_class_level_binding): Do not complain about
adding a binding for a member whose name is the same as the
......
......@@ -1319,10 +1319,7 @@ duplicate_decls (tree newdecl, tree olddecl)
olddecl = TREE_VALUE (olddecl);
cp_error_at ("previous declaration of `%#D'", olddecl);
/* New decl is completely inconsistent with the old one =>
tell caller to replace the old one. */
return NULL_TREE;
return error_mark_node;
}
else if (!types_match)
{
......
......@@ -3080,7 +3080,7 @@ push_namespace (tree name)
/* Make a new namespace, binding the name to it. */
d = build_lang_decl (NAMESPACE_DECL, name, void_type_node);
DECL_CONTEXT (d) = FROB_CONTEXT (current_namespace);
d = pushdecl (d);
pushdecl (d);
if (anon)
{
/* Clear DECL_NAME for the benefit of debugging back ends. */
......
......@@ -2774,6 +2774,9 @@ push_template_decl_real (tree decl, int is_friend)
int is_partial;
int new_template_p = 0;
if (decl == error_mark_node)
return decl;
/* See if this is a partial specialization. */
is_partial = (DECL_IMPLICIT_TYPEDEF_P (decl)
&& TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE
......@@ -7381,6 +7384,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
case PARM_DECL:
r = retrieve_local_specialization (t);
my_friendly_assert (r != NULL, 20020903);
mark_used (r);
return r;
case CONST_DECL:
......
......@@ -2042,7 +2042,16 @@ begin_class_definition (tree t)
maybe_process_partial_specialization (t);
pushclass (t);
TYPE_BEING_DEFINED (t) = 1;
TYPE_PACKED (t) = flag_pack_struct;
if (flag_pack_struct)
{
tree v;
TYPE_PACKED (t) = 1;
/* Even though the type is being defined for the first time
here, there might have been a forward declaration, so there
might be cv-qualified variants of T. */
for (v = TYPE_NEXT_VARIANT (t); v; v = TYPE_NEXT_VARIANT (v))
TYPE_PACKED (v) = 1;
}
/* Reset the interface data, at the earliest possible
moment, as it might have been set via a class foo;
before. */
......
2004-02-19 Mark Mitchell <mark@codesourcery.com>
2004-02-20 Mark Mitchell <mark@codesourcery.com>
PR c++/13927
* g++.dg/other/error8.C: Remove XFAIL markers.
PR c++/14173
* g++.dg/ext/packed5.C: New test.
PR c++/14199
* g++.dg/warn/Wunused-5.C: New test.
PR c++/14186
* g++.dg/lookup/member1.C: New test.
......
// PR c++/14173
struct A;
void foo(const A&);
struct A
{
A(const A&);
};
struct B
{
A a;
A bar() { return a; }
};
......@@ -5,8 +5,8 @@
void foo(void)
{
union { int alpha; int beta; }; // { dg-error "previous declaration `int alpha'" }
double alpha; // { dg-error "declaration of" }
union { int alpha; int beta; }; // { dg-error "previous declaration of `int alpha'" }
double alpha; // { dg-error "redeclared" }
}
// This checks both the templated version, and the position of the diagnostic
......@@ -22,5 +22,5 @@ void tfoo(void)
}
// The duplicated error messages are xfailed for now (tracked in the PR)
// { dg-bogus "" "duplicate error messages" { xfail *-*-* } 8 }
// { dg-bogus "" "duplicate error messages" { xfail *-*-* } 9 }
// { dg-bogus "" "duplicate error messages" { target *-*-* } 8 }
// { dg-bogus "" "duplicate error messages" { target *-*-* } 9 }
// PR c++/14199
// { dg-options "-W -Wall -Wunused" }
struct X {
static void foo ();
};
template <typename T>
void foo (const T &t) {
t.foo();
}
template void foo (const X &);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment