]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/92695 (P1064R0 - virtual constexpr fails if object taken from...
authorJakub Jelinek <jakub@redhat.com>
Fri, 20 Dec 2019 17:26:28 +0000 (18:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 20 Dec 2019 17:26:28 +0000 (18:26 +0100)
Backported from mainline
2019-11-28  Jakub Jelinek  <jakub@redhat.com>

PR c++/92695
* decl2.c (mark_used): Don't call note_vague_linkage_fn for pure
virtual functions, even if they are declared inline.

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

From-SVN: r279661

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

index 83a9adc288a887bc5afa3bde4ee48b763534b454..d95f679907e2701b4e7c5af1684b790b3b39fe3c 100644 (file)
@@ -1,6 +1,12 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92695
+       * decl2.c (mark_used): Don't call note_vague_linkage_fn for pure
+       virtual functions, even if they are declared inline.
+
        2019-11-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/92524
index 6f23ee1cd3fe853a13840f3b68ca11f823b4f86e..a46cbce08f4db8f5797580b414becd4f60924245 100644 (file)
@@ -5501,8 +5501,11 @@ mark_used (tree decl, tsubst_flags_t complain)
        vec_safe_push (no_linkage_decls, decl);
     }
 
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl)
-      && !DECL_INITIAL (decl) && !DECL_ARTIFICIAL (decl))
+  if (TREE_CODE (decl) == FUNCTION_DECL
+      && DECL_DECLARED_INLINE_P (decl)
+      && !DECL_INITIAL (decl)
+      && !DECL_ARTIFICIAL (decl)
+      && !DECL_PURE_VIRTUAL_P (decl))
     /* Remember it, so we can check it was defined.  */
     note_vague_linkage_fn (decl);
 
index b10c2e057690eee014b2555ee2f0e6b8003f807d..eb6108b3a3ede25ecbcd74fefb60d93f266e996e 100644 (file)
@@ -1,6 +1,11 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92695
+       * g++.dg/warn/inline3.C: New test.
+
        2019-11-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/91944
diff --git a/gcc/testsuite/g++.dg/warn/inline3.C b/gcc/testsuite/g++.dg/warn/inline3.C
new file mode 100644 (file)
index 0000000..0d4dc8f
--- /dev/null
@@ -0,0 +1,20 @@
+struct S {
+  inline virtual void foo () = 0;      // { dg-bogus "used but never defined" }
+#if __cplusplus > 201703L
+  constexpr virtual void bar () = 0;   // { dg-bogus "used but never defined" "" { target c++2a } }
+#else
+  inline virtual void bar () = 0;      // { dg-bogus "used but never defined" "" { target c++17_down }  }
+#endif
+  S () {}
+};
+struct T : public S {
+  inline virtual void foo () {}
+#if __cplusplus > 201703L
+  constexpr virtual void bar () {}
+#else
+  inline virtual void bar () {}
+#endif
+  T () {}
+};
+T t;
+void foo (S *s) { s->foo (); s->bar (); }