Index: libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc
===================================================================
--- libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc	(revision 475331)
+++ libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc	(revision 475455)
@@ -22,6 +22,12 @@
 #include <algorithm>
 #include <testsuite_hooks.h>

+#ifdef __ia16__
+#define MAX 1650
+#else
+#define MAX 16500
+#endif
+
 // In the occasion of libstdc++/25482
 void test01()
 {
@@ -33,10 +39,10 @@ void test01()
   wifstream fbuf_ref("istream_unformatted-1.txt"),
             fbuf("istream_unformatted-1.txt");

-  wchar_t buffer_ref[16500],
-          buffer[16500];
+  wchar_t buffer_ref[MAX],
+          buffer[MAX];

-  fbuf_ref.read(buffer_ref, 16500);
+  fbuf_ref.read(buffer_ref, MAX);

   in_iterator_type beg(fbuf);
   in_iterator_type end;
@@ -45,7 +51,7 @@ void test01()
   VERIFY( fbuf_ref.good() );
   VERIFY( fbuf.good() );

-  VERIFY( !wmemcmp(buffer, buffer_ref, 16500) );
+  VERIFY( !wmemcmp(buffer, buffer_ref, MAX) );
 }

 int main()
Index: libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc
===================================================================
--- libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc	(revision 475331)
+++ libstdc++-v3/testsuite/25_algorithms/random_shuffle/moveable.cc	(revision 475455)
@@ -34,7 +34,11 @@ using __gnu_test::rvalstruct;

 typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;

+#ifdef __ia16__
+const unsigned int N = 1000;
+#else
 const unsigned int N = 10000;
+#endif
 int A[N]; // This is made global because we don't want it on the stack

 void fill_ascending()
Index: libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc
===================================================================
--- libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc	(revision 475331)
+++ libstdc++-v3/testsuite/25_algorithms/nth_element/58800.cc	(revision 475455)
@@ -18,20 +18,22 @@
 // 25.3.2 [lib.alg.nth.element]

 // { dg-options "-std=gnu++11" }
+// { dg-require-effective-target stdint_types }

 #include <algorithm>
 #include <vector>
 #include <testsuite_hooks.h>
 #include <testsuite_iterators.h>
+#include <stdint.h>

 using __gnu_test::test_container;
 using __gnu_test::random_access_iterator_wrapper;

-typedef test_container<int, random_access_iterator_wrapper> Container;
+typedef test_container<int_least32_t, random_access_iterator_wrapper> Container;

 void test01()
 {
-  std::vector<int> v = {
+  std::vector<int_least32_t> v = {
     207089,
     202585,
     180067,
Index: libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc
===================================================================
--- libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc	(revision 475331)
+++ libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc	(revision 475455)
@@ -1,5 +1,6 @@
 // { dg-options "-std=gnu++11" }
 // { dg-add-options ieee }
+// { dg-require-effective-target stdint_types }

 // 2010-02-25  Ed Smith-Rowland

@@ -25,6 +26,7 @@
 #include <limits>
 #include <cmath>
 #include <testsuite_hooks.h>
+#include <stdint.h>

 void
 test01()
@@ -57,12 +59,12 @@ test01()
 			      * 643 / 2136);
   VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 );

-  const int d_max_digits10 = (2 + std::numeric_limits<double>::digits
-			      * 643 / 2136);
+  const int_least32_t d_max_digits10 = (2 + std::numeric_limits<double>::digits
+			      * 643L / 2136);
   VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 );

-  const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
-			       * 643 / 2136);
+  const int_least32_t ld_max_digits10 = (2 + std::numeric_limits<long double>::digits
+			       * 643L / 2136);
   VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 );
 }

Index: libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/requirements/typedefs.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/requirements/typedefs.cc	(revision 475331)
+++ libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/requirements/typedefs.cc	(revision 475455)
@@ -31,7 +31,7 @@ test01()

   typedef discard_block
     <
-    subtract_with_carry<long, (1 << 24), 10, 24>,
+    subtract_with_carry<long, (1L << 24), 10, 24>,
     389, 24
     > test_type;

Index: libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/equal.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/equal.cc	(revision 475331)
+++ libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/equal.cc	(revision 475455)
@@ -31,7 +31,7 @@ test01()

   discard_block
     <
-    subtract_with_carry<long, (1 << 24), 10, 24>,
+    subtract_with_carry<long, (1L << 24), 10, 24>,
     389, 24
     > u, v;

Index: libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/not_equal.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/not_equal.cc	(revision 475331)
+++ libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/not_equal.cc	(revision 475455)
@@ -31,13 +31,13 @@ test01()

   discard_block
     <
-    subtract_with_carry<long, (1 << 24), 10, 24>,
+    subtract_with_carry<long, (1L << 24), 10, 24>,
     389, 24
     > u(1);

   discard_block
     <
-    subtract_with_carry<long, (1 << 24), 10, 24>,
+    subtract_with_carry<long, (1L << 24), 10, 24>,
     389, 24
     > v(2);

Index: libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/serialize.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/serialize.cc	(revision 475331)
+++ libstdc++-v3/testsuite/tr1/5_numerical_facilities/random/discard_block/operators/serialize.cc	(revision 475455)
@@ -34,7 +34,7 @@ test01()
   std::stringstream str;
   discard_block
     <
-    subtract_with_carry<long, (1 << 24), 10, 24>,
+    subtract_with_carry<long, (1L << 24), 10, 24>,
     389, 24
     > u, v;

Index: libstdc++-v3/testsuite/tr1/4_metaprogramming/extent/value.cc
===================================================================
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/extent/value.cc	(revision 475331)
+++ libstdc++-v3/testsuite/tr1/4_metaprogramming/extent/value.cc	(revision 475455)
@@ -37,7 +37,7 @@ void test01()
   VERIFY( (extent<int[2], 1>::value == 0) );
   VERIFY( (extent<int[2][4], 1>::value == 4) );
   VERIFY( (extent<int[][4], 1>::value == 4) );
-  VERIFY( (extent<int[10][4][6][8][12][2], 4>::value == 12) );
+  VERIFY( (extent<int[3][4][6][8][12][2], 4>::value == 12) );
   VERIFY( (test_property<extent, ClassType, 0>(0)) );
   VERIFY( (test_property<extent, ClassType[2], 0>(2)) );
   VERIFY( (test_property<extent, ClassType[2][4], 0>(2)) );
@@ -46,7 +46,7 @@ void test01()
   VERIFY( (extent<ClassType[2], 1>::value == 0) );
   VERIFY( (extent<ClassType[2][4], 1>::value == 4) );
   VERIFY( (extent<ClassType[][4], 1>::value == 4) );
-  VERIFY( (extent<ClassType[10][4][6][8][12][2], 4>::value == 12) );
+  VERIFY( (extent<ClassType[3][4][6][8][12][2], 4>::value == 12) );
 }

 int main()
Index: libstdc++-v3/testsuite/lib/prune.exp
===================================================================
--- libstdc++-v3/testsuite/lib/prune.exp	(revision 475331)
+++ libstdc++-v3/testsuite/lib/prune.exp	(revision 475455)
@@ -33,6 +33,8 @@ proc libstdc++-dg-prune { system text }

 #    send_user "Before:$text\n"

+    regsub -all "(^|\n)\[^\n\]*: warning: target system does not support debug output\[^\n\]*" $text "" text
+
     # Ignore caret diagnostics. Unfortunately dejaGNU trims leading
     # spaces, so one cannot rely on them being present.
     regsub -all "(^|\n)\[^\n\]+\n *\\^\n" $text "\n" text
Index: libstdc++-v3/testsuite/lib/libstdc++.exp
===================================================================
--- libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 475331)
+++ libstdc++-v3/testsuite/lib/libstdc++.exp	(revision 475455)
@@ -503,6 +503,8 @@ proc v3_target_compile { source dest typ
     lappend options "timeout=[timeout_value]"

     set comp_output [target_compile $source $dest $type $options]
+    regsub -all "(^|\n)\[^\n\]*: warning: target system does not support debug output\[^\n\]*" $comp_output "" comp_output
+    set comp_output [string trim $comp_output]

     return $comp_output
 }
Index: libstdc++-v3/testsuite/special_functions/15_hermite/check_value.cc
===================================================================
--- libstdc++-v3/testsuite/special_functions/15_hermite/check_value.cc	(revision 475331)
+++ libstdc++-v3/testsuite/special_functions/15_hermite/check_value.cc	(revision 475455)
@@ -1,4 +1,5 @@
 // { dg-options "-D__STDCPP_WANT_MATH_SPEC_FUNCS__" }
+// { dg-skip-if "Does not fit in 64kB" { "ia16-*-*" } }
 //
 // Copyright (C) 2016 Free Software Foundation, Inc.
 //
Index: libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc	(revision 475455)
@@ -75,6 +75,6 @@ case_labels(bitmask_type b)
     case ~__INT_MAX__:
       break;
     }
-  static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t<bitmask_type>) >= sizeof(int),
       "underlying type has same range of values as int");
 }
Index: libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc	(revision 475455)
@@ -51,6 +51,6 @@ case_labels(bitmask_type b)
     case ~__INT_MAX__:
       break;
     }
-  static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t<bitmask_type>) >= sizeof(int),
       "underlying type has same range of values as int");
 }
Index: libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc	(revision 475455)
@@ -47,6 +47,6 @@ case_labels(bitmask_type b)
     case ~__INT_MAX__:
       break;
     }
-  static_assert( sizeof(std::underlying_type_t<bitmask_type>) == sizeof(int),
+  static_assert( sizeof(std::underlying_type_t<bitmask_type>) >= sizeof(int),
       "underlying type has same range of values as int");
 }
Index: libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/basic_stringbuf/setbuf/wchar_t/4.cc	(revision 475455)
@@ -19,7 +19,7 @@

 // 27.8.1.4 Overridden virtual functions

-// { dg-options "-DMAX_SIZE=4096" { target simulator } }
+// { dg-options "-DMAX_SIZE=4096" { target { simulator || ia16-*-* } } }

 #ifndef MAX_SIZE
 #define MAX_SIZE (1 << 18)
Index: libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/basic_istream/getline/wchar_t/5.cc	(revision 475455)
@@ -50,7 +50,11 @@ check(wistream& stream, const wstring& s
 {
   bool test __attribute__((unused)) = true;

+#ifdef __ia16__
+  static wchar_t buf[1000];
+#else
   static wchar_t buf[1000000];
+#endif
   wstring::size_type index = 0, index_new = 0;
   unsigned n = 0;

Index: libstdc++-v3/testsuite/27_io/headers/cstdio/functions_std.cc
===================================================================
--- libstdc++-v3/testsuite/27_io/headers/cstdio/functions_std.cc	(revision 475331)
+++ libstdc++-v3/testsuite/27_io/headers/cstdio/functions_std.cc	(revision 475455)
@@ -34,7 +34,9 @@ namespace gnu
   using std::fseek;
   using std::perror;
   using std::rewind;
+#if _GLIBCXX_USE_TMPNAM
   using std::tmpnam;
+#endif
   using std::feof;
   using std::fprintf;
   using std::fsetpos;
Index: libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc
===================================================================
--- libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc	(revision 475331)
+++ libstdc++-v3/testsuite/19_diagnostics/headers/system_error/errc_std_c++0x.cc	(revision 475455)
@@ -104,7 +104,10 @@ void test01()

   TEST_ERRC(not_connected);
   TEST_ERRC(not_enough_memory);
+
+#ifdef _GLIBCXX_HAVE_ENOTSUP
   TEST_ERRC(not_supported);
+#endif

 #ifdef _GLIBCXX_HAVE_ECANCELED
   TEST_ERRC(operation_canceled);
Index: libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc
===================================================================
--- libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc	(revision 475331)
+++ libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc	(revision 475455)
@@ -24,6 +24,6 @@
 void test01()
 {
   std::error_code ec;
-  if (ec == std::errc::not_supported)
+  if (ec == std::errc::not_enough_memory)
     { }
 }
Index: libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc
===================================================================
--- libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc	(revision 475331)
+++ libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_functions.cc	(revision 475455)
@@ -1,4 +1,4 @@
-// { dg-do compile }
+// { dg-do compile { target { stdint_types } } }
 // { dg-options "-std=gnu++11" }

 // Copyright (C) 2010-2016 Free Software Foundation, Inc.
@@ -20,6 +20,7 @@

 #include <random>
 #include <testsuite_common_types.h>
+#include <stdint.h>

 namespace __gnu_test
 {
@@ -49,7 +50,7 @@ namespace __gnu_test
 int main()
 {
   __gnu_test::constexpr_member_functions test;
-  typedef std::linear_congruential_engine<unsigned int, 41, 0, 2147483647> type;
+  typedef std::linear_congruential_engine<uint_least32_t, 41, 0, 2147483647> type;
   test.operator()<type>();
   return 0;
 }
Index: libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc
===================================================================
--- libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc	(revision 475331)
+++ libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/requirements/constexpr_data.cc	(revision 475455)
@@ -1,4 +1,4 @@
-// { dg-do compile }
+// { dg-do compile { target { stdint_types } } }
 // { dg-options "-std=gnu++11" }

 // Copyright (C) 2010-2016 Free Software Foundation, Inc.
@@ -20,6 +20,7 @@

 #include <random>
 #include <testsuite_common_types.h>
+#include <stdint.h>

 namespace __gnu_test
 {
@@ -53,7 +54,7 @@ namespace __gnu_test
 int main()
 {
   __gnu_test::constexpr_member_data test;
-  typedef std::linear_congruential_engine<unsigned int, 41, 0, 2147483647> type;
+  typedef std::linear_congruential_engine<uint_least32_t, 41, 0, 2147483647> type;
   test.operator()<type>();
   return 0;
 }
Index: libstdc++-v3/testsuite/20_util/extent/value.cc
===================================================================
--- libstdc++-v3/testsuite/20_util/extent/value.cc	(revision 475331)
+++ libstdc++-v3/testsuite/20_util/extent/value.cc	(revision 475455)
@@ -34,7 +34,7 @@ void test01()
   static_assert(extent<int[2], 1>::value == 0, "");
   static_assert(extent<int[2][4], 1>::value == 4, "");
   static_assert(extent<int[][4], 1>::value == 4, "");
-  static_assert(extent<int[10][4][6][8][12][2], 4>::value == 12, "");
+  static_assert(extent<int[3][4][6][8][12][2], 4>::value == 12, "");
   static_assert(test_property<extent, ClassType, 0>(0), "");
   static_assert(test_property<extent, ClassType[2], 0>(2), "");
   static_assert(test_property<extent, ClassType[2][4], 0>(2), "");
@@ -43,5 +43,5 @@ void test01()
   static_assert(extent<ClassType[2], 1>::value == 0, "");
   static_assert(extent<ClassType[2][4], 1>::value == 4, "");
   static_assert(extent<ClassType[][4], 1>::value == 4, "");
-  static_assert(extent<ClassType[10][4][6][8][12][2], 4>::value == 12, "");
+  static_assert(extent<ClassType[3][4][6][8][12][2], 4>::value == 12, "");
 }
Index: libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc
===================================================================
--- libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc	(revision 475331)
+++ libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc	(revision 475455)
@@ -1,4 +1,4 @@
-// { dg-do compile }
+// { dg-do compile { target { stdint_types } } }
 // { dg-options "-std=gnu++11" }

 // Copyright (C) 2011-2016 Free Software Foundation, Inc.
@@ -24,6 +24,7 @@
 // changes this test may begin to fail.

 #include <tuple>
+#include <stdint.h>

 bool test __attribute__((unused)) = true;

@@ -60,9 +61,9 @@ test_forward_as_tuple()
   {
     static int i(22);
     static float f(22.222);
-    static int ii(77799);
+    static int_least32_t ii(77799);

-    typedef std::tuple<int&, float&, int&&> tuple_type;
+    typedef std::tuple<int&, float&, int_least32_t&&> tuple_type;
     constexpr tuple_type p1 __attribute__((unused))
       = std::forward_as_tuple(i, f, std::move(ii));
   }
@@ -83,9 +84,9 @@ test_tie()
   {
     static int i(22);
     static float f(22.222);
-    static const int ii(77799);
+    static const int_least32_t ii(77799);

-    typedef std::tuple<int&, float&, const int&> tuple_type;
+    typedef std::tuple<int&, float&, const int_least32_t&> tuple_type;
     constexpr tuple_type p1 __attribute__((unused))
       = std::tie(i, f, ii);
   }


