diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-08-11 00:14:57 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-08-11 00:14:57 +0000 |
commit | 7d08196ddacfca13bcb185f4baa2df67faffee1d (patch) | |
tree | 211499ffeca0d57aab0add389d0ca9d79c073969 | |
parent | 05641ad8b6a3ebcbf8520a5201d7095f63badb40 (diff) | |
download | gcc-7d08196ddacfca13bcb185f4baa2df67faffee1d.tar.gz |
PR libstdc++/81808 skip test if reading directory doesn't fail
PR libstdc++/81808
* testsuite/27_io/basic_fstream/53984.cc: Adjust test for targets
that allow opening a directory as a FILE and reading from it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251041 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | libstdc++-v3/ChangeLog | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc | 25 |
2 files changed, 31 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8ebe21c9c11..fd9a6afbc3c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2017-08-11 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/81808 + * testsuite/27_io/basic_fstream/53984.cc: Adjust test for targets + that allow opening a directory as a FILE and reading from it. + 2017-08-09 Jonathan Wakely <jwakely@redhat.com> * include/std/type_traits (_GLIBCXX_NO_BUILTIN_HAS_UNIQ_OBJ_REP): diff --git a/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc b/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc index e49d2b1ad1f..a319aff1c62 100644 --- a/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc +++ b/libstdc++-v3/testsuite/27_io/basic_fstream/53984.cc @@ -17,6 +17,8 @@ // { dg-require-fileio "" } +// PR libstdc++/53984 + #include <fstream> #include <testsuite_hooks.h> @@ -26,9 +28,32 @@ test01() std::ifstream in("."); if (in) { + char c; + if (in.get(c)) + { + // Reading a directory doesn't produce an error on this target + // so the formatted input functions below wouldn't fail anyway + // (see PR libstdc++/81808). + return; + } int x; + in.clear(); + // Formatted input function should set badbit, but not throw: in >> x; VERIFY( in.bad() ); + + in.clear(); + in.exceptions(std::ios::badbit); + try + { + // Formatted input function should set badbit, and throw: + in >> x; + VERIFY( false ); + } + catch (const std::exception&) + { + VERIFY( in.bad() ); + } } } |