re PR c++/61945 (tree check fail with -Woverloaded-virtual)
authorMarek Polacek <polacek@redhat.com>
Thu, 25 Sep 2014 12:56:57 +0000 (12:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 25 Sep 2014 12:56:57 +0000 (12:56 +0000)
PR c++/61945
* class.c (warn_hidden): Check for FUNCTION_DECL.

* g++.dg/warn/pr61945.C: New test.

From-SVN: r215597

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr61945.C [new file with mode: 0644]

index 2457ccdb734c95ecd1835910e7eaa026fc5c91d7..a11a52009b70bd4f8b3527c8498f1bcee52a455d 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-25  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/61945
+       * class.c (warn_hidden): Check for FUNCTION_DECL.
+
 2014-09-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/63249
index c4ac61bd0a04f79645fa9e899ba8461807569f04..acf5768b7d311542573e001636ab0bd77bb3828b 100644 (file)
@@ -2821,7 +2821,8 @@ warn_hidden (tree t)
       for (fn = fns; fn; fn = OVL_NEXT (fn))
        {
          fndecl = OVL_CURRENT (fn);
-         if (DECL_VINDEX (fndecl))
+         if (TREE_CODE (fndecl) == FUNCTION_DECL
+             && DECL_VINDEX (fndecl))
            {
              tree *prev = &base_fndecls;
 
index f1806f64503ec4b770579d5cd3c22762d9ad6491..953a5b2a3e500f9aa09d89e4a1674b4f695ec2d2 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-25  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/61945
+       * g++.dg/warn/pr61945.C: New test.
+
 2014-09-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/63341
diff --git a/gcc/testsuite/g++.dg/warn/pr61945.C b/gcc/testsuite/g++.dg/warn/pr61945.C
new file mode 100644 (file)
index 0000000..5584d84
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/61945
+// { dg-do compile }
+// { dg-options "-Woverloaded-virtual" }
+
+class A {
+  virtual int foo ();  // { dg-warning "was hidden" }
+};
+class B : A {
+  template <typename>
+  void foo ();         // { dg-warning "by .B::foo\\(\\)." }
+};