diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2016-07-15 19:51:51 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2016-07-15 19:51:51 +0100 |
commit | 479d0ed5900b8e87634cd92383c11a5571cc43d9 (patch) | |
tree | 84b1ce031651f5ab9047b20512bc2cacadc0912f /gcc | |
parent | de54de93fa4bf4740638e58f9aaab1e50026bacb (diff) | |
download | gcc-479d0ed5900b8e87634cd92383c11a5571cc43d9.zip gcc-479d0ed5900b8e87634cd92383c11a5571cc43d9.tar.gz gcc-479d0ed5900b8e87634cd92383c11a5571cc43d9.tar.bz2 |
c++/58796 Make nullptr match exception handlers of pointer type
libstdc++-v3:
PR c++/58796
* libsupc++/pbase_type_info.cc (__pbase_type_info::__do_catch): Make
nullptr match handlers of pointer type.
gcc/testsuite:
PR c++/58796
* g++.dg/cpp0x/nullptr21.C: Remove void* handlers.
* g++.dg/cpp0x/nullptr35.C: New test.
From-SVN: r238396
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nullptr21.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nullptr35.C | 52 |
3 files changed, 58 insertions, 4 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8a03901..305f96a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-07-15 Jonathan Wakely <jwakely@redhat.com> + + PR c++/58796 + * g++.dg/cpp0x/nullptr21.C: Remove void* handlers. + * g++.dg/cpp0x/nullptr35.C: New test. + 2016-07-15 Bin Cheng <bin.cheng@arm.com> * gcc.dg/tree-ssa/scev-8.c: Update test string. diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr21.C b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C index 89884b9..c6f560e 100644 --- a/gcc/testsuite/g++.dg/cpp0x/nullptr21.C +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr21.C @@ -18,8 +18,6 @@ int main() { try { throw nullptr; - } catch (void*) { - foo (0, 1); } catch (bool) { foo (0, 2); } catch (int) { @@ -35,8 +33,6 @@ int main() nullptr_t mynull = 0; try { throw mynull; - } catch (void*) { - foo (1, 1); } catch (bool) { foo (1, 2); } catch (int) { diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr35.C b/gcc/testsuite/g++.dg/cpp0x/nullptr35.C new file mode 100644 index 0000000..2f93ce1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/nullptr35.C @@ -0,0 +1,52 @@ +// { dg-do run { target c++11 } } + +// Test catching as pointer and pointer to member types, [except.handle] p3. + +extern "C" void abort (void); + +typedef decltype(nullptr) nullptr_t; + +int result = 0; + +void __attribute__((noinline)) +caught(int bit) +{ + result &= bit; +} + +struct A { }; + +int main() +{ + try { + try { + try { + try { + try { + throw nullptr; + } catch (void* p) { + if (p == nullptr) + caught(1); + throw; + } + } catch (void(*pf)()) { + if (pf == nullptr) + caught(2); + throw; + } + } catch (int A::*pm) { + if (pm == nullptr) + caught(4); + throw; + } + } catch (int (A::*pmf)()) { // FIXME: currently unsupported + if (pmf == nullptr) + caught(8); + throw; + } + } catch (nullptr_t) { + } + + if (result != 7) // should be 15 + abort (); +} |