diff options
author | Jason Merrill <jason@redhat.com> | 2020-05-11 14:05:46 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-05-11 15:10:05 -0400 |
commit | aa2c978400f3b3ca6e9f2d18598a379589e77ba0 (patch) | |
tree | 01a5cdae070da6abcbd646a94b31be0ab26d8761 /gcc/testsuite/g++.dg/abi | |
parent | e5ccab839a24a9c5ac1ddbb6e0ad1c339df3165e (diff) | |
download | gcc-aa2c978400f3b3ca6e9f2d18598a379589e77ba0.zip gcc-aa2c978400f3b3ca6e9f2d18598a379589e77ba0.tar.gz gcc-aa2c978400f3b3ca6e9f2d18598a379589e77ba0.tar.bz2 |
c++: Make references to __cxa_pure_virtual weak.
If a program has no other dependencies on libstdc++, we shouldn't require it
just for __cxa_pure_virtual, which is only there to give a prettier
diagnostic before crashing the program; resolving the reference to NULL will
also crash, just without the diagnostic.
gcc/cp/ChangeLog
2020-05-11 Jason Merrill <jason@redhat.com>
* decl.c (cxx_init_decl_processing): Call declare_weak for
__cxa_pure_virtual.
Diffstat (limited to 'gcc/testsuite/g++.dg/abi')
-rw-r--r-- | gcc/testsuite/g++.dg/abi/pure-virtual1.C | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/abi/pure-virtual1.C b/gcc/testsuite/g++.dg/abi/pure-virtual1.C new file mode 100644 index 0000000..823328e --- /dev/null +++ b/gcc/testsuite/g++.dg/abi/pure-virtual1.C @@ -0,0 +1,21 @@ +// Test that we don't need libsupc++ just for __cxa_pure_virtual. +// { dg-do link } +// { dg-require-weak } +// { dg-additional-options "-fno-rtti -nodefaultlibs -lc" } + +struct A +{ + int i; + virtual void f() = 0; + A(): i(0) {} +}; + +struct B: A +{ + virtual void f() {} +}; + +int main() +{ + B b; +} |