diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-11-28 09:06:09 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-11-28 09:06:09 +0100 |
commit | 99150b053e1840ffc47704a9188e26c889d07517 (patch) | |
tree | 64b302d67363d6fb266d2bdb9a8715e1f4145928 /gcc | |
parent | f160cd13fb44be3f63a2f43d68befa76f797578f (diff) | |
download | gcc-99150b053e1840ffc47704a9188e26c889d07517.zip gcc-99150b053e1840ffc47704a9188e26c889d07517.tar.gz gcc-99150b053e1840ffc47704a9188e26c889d07517.tar.bz2 |
re PR c++/92695 (P1064R0 - virtual constexpr fails if object taken from array)
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: r278802
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/inline3.C | 20 |
4 files changed, 36 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ec37f5e..8b71f02 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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-16 Jason Merrill <jason@redhat.com> Implement P1814R0, CTAD for alias templates. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index f164494..46cc582 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -5596,8 +5596,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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4f97f4c..0bcac2a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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 rtl-optimization/92510 diff --git a/gcc/testsuite/g++.dg/warn/inline3.C b/gcc/testsuite/g++.dg/warn/inline3.C new file mode 100644 index 0000000..0d4dc8f --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/inline3.C @@ -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 (); } |