]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/14199 (Unjustified warning about unused variable)
authorMark Mitchell <mark@codesourcery.com>
Fri, 20 Feb 2004 08:57:33 +0000 (08:57 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 20 Feb 2004 08:57:33 +0000 (08:57 +0000)
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

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/name-lookup.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/packed5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/other/error8.C
gcc/testsuite/g++.dg/warn/Wunused-5.C [new file with mode: 0644]

index d1dea6dd76181f7fdcb8783d1479b1489c6d4b03..e3f51e9e048de5fe0c1781219f3153f87c05e088 100644 (file)
@@ -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
index f3821c34a127640b2fe9e8d69b2b0fe2b3f75898..1db274eddd198991c4212dd236c12ae78efb6bfb 100644 (file)
@@ -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)
     {
index e823ae3845842ac9f9bb4e9f6bcc57a113588359..be1b8228353298658cf3b50738b3313040c1d5b3 100644 (file)
@@ -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.  */
index 779347b0f53b6249d71e4cee62bf536e7e8303e7..1f97a536b23af261f76b2b7dbaa521c4e2333793 100644 (file)
@@ -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:
index 511c7bc934865e98d446efa1839dca1faa5e1ae7..b7a7f4a919bca97c6c0b24669e90b9516a2154c0 100644 (file)
@@ -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.  */
index 9ead668c15e7cf17ed74f25f82c3d61422d4f59f..aacaa358c99ee526e8cf420ae1119bc4060b1dc2 100644 (file)
@@ -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 (file)
index 0000000..caf14d8
--- /dev/null
@@ -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; }
+};
index d427e3c4c61623c3e70fbfad7064db52a073992a..e461e0919c8347e149c3d24b2f62ef0c0d3f41d1 100644 (file)
@@ -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 (file)
index 0000000..06d1a05
--- /dev/null
@@ -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 &);