aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-02-20 08:57:33 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-02-20 08:57:33 +0000
commitc0694c4b781c1c4e961ef74f1a70c0df7a6b67b6 (patch)
tree805d38b660862895cfdc82561ded42eea78f8a55
parent15316a6f7639a7173c375d8c3d0e24957982f27e (diff)
downloadgcc-c0694c4b781c1c4e961ef74f1a70c0df7a6b67b6.zip
gcc-c0694c4b781c1c4e961ef74f1a70c0df7a6b67b6.tar.gz
gcc-c0694c4b781c1c4e961ef74f1a70c0df7a6b67b6.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog16
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/cp/name-lookup.c2
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/cp/semantics.c11
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/ext/packed5.C16
-rw-r--r--gcc/testsuite/g++.dg/other/error8.C8
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-5.C13
9 files changed, 75 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d1dea6d..e3f51e9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,21 @@
+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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index f3821c3..1db274e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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)
{
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index e823ae3..be1b822 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -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. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 779347b..1f97a53 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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:
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 511c7bc..b7a7f4a 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9ead668c..aacaa35 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,4 +1,13 @@
-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.
diff --git a/gcc/testsuite/g++.dg/ext/packed5.C b/gcc/testsuite/g++.dg/ext/packed5.C
new file mode 100644
index 0000000..caf14d8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/packed5.C
@@ -0,0 +1,16 @@
+// PR c++/14173
+
+struct A;
+
+void foo(const A&);
+
+struct A
+{
+ A(const A&);
+};
+
+struct B
+{
+ A a;
+ A bar() { return a; }
+};
diff --git a/gcc/testsuite/g++.dg/other/error8.C b/gcc/testsuite/g++.dg/other/error8.C
index d427e3c..e461e09 100644
--- a/gcc/testsuite/g++.dg/other/error8.C
+++ b/gcc/testsuite/g++.dg/other/error8.C
@@ -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 }
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-5.C b/gcc/testsuite/g++.dg/warn/Wunused-5.C
new file mode 100644
index 0000000..06d1a05
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-5.C
@@ -0,0 +1,13 @@
+// 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 &);