]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/79433 no #error for including headers with wrong -std
authorJonathan Wakely <jwakely@redhat.com>
Tue, 12 Sep 2017 14:02:59 +0000 (15:02 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 12 Sep 2017 14:02:59 +0000 (15:02 +0100)
PR libstdc++/79433
* doc/xml/manual/status_cxx2017.xml: Update feature-test macros.
* doc/html/*: Regenerate.
* include/Makefile.am: Remove <bits/c++17_warning.h>.
* include/Makefile.in: Regenerate.
* include/bits/c++17_warning.h: Remove.
* include/bits/string_view.tcc: Do not include <bits/c++17_warning.h>
for pre-C++17 modes.
* include/std/any: Likewise.
(__cpp_lib_any): Define.
* include/std/mutex (__cpp_lib_scoped_lock): Adjust value as per new
SD-6 draft.
* include/std/numeric (__cpp_lib_gcd_lcm): Define as per new SD-6
draft.
* include/std/optional: Do not include <bits/c++17_warning.h>.
(__cpp_lib_optional): Define.
* include/std/shared_mutex: Do not include <bits/c++14_warning.h>.
* include/std/string_view: Do not include <bits/c++17_warning.h>.
(__cpp_lib_string_view): Define.
* include/std/variant: Do not include <bits/c++17_warning.h>.
(__cpp_lib_variant): Define.
* testsuite/20_util/optional/cons/value_neg.cc: Adjust dg-error line
numbers.
* testsuite/26_numerics/gcd/1.cc: Test for __cpp_lib_gcd_lcm.
* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line
numbers.
* testsuite/26_numerics/lcm/1.cc: Test for __cpp_lib_gcd_lcm.
* testsuite/26_numerics/lcm/lcm_neg.cc: Adjust dg-error line
numbers.
* testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Adjust
expected value of __cpp_lib_scoped_lock.

From-SVN: r252018

19 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/doc/xml/manual/status_cxx2017.xml
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/bits/c++17_warning.h [deleted file]
libstdc++-v3/include/bits/string_view.tcc
libstdc++-v3/include/std/any
libstdc++-v3/include/std/mutex
libstdc++-v3/include/std/numeric
libstdc++-v3/include/std/optional
libstdc++-v3/include/std/shared_mutex
libstdc++-v3/include/std/string_view
libstdc++-v3/include/std/variant
libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc
libstdc++-v3/testsuite/26_numerics/gcd/1.cc
libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
libstdc++-v3/testsuite/26_numerics/lcm/1.cc
libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
libstdc++-v3/testsuite/30_threads/scoped_lock/requirements/typedefs.cc

index 5bae0dc7c91dd022430dd37b0ea721d01c4afdef..f7ffb08da0df828fb3ba1a87de5a332c4580f6f7 100644 (file)
@@ -1,5 +1,37 @@
 2017-09-12  Jonathan Wakely  <jwakely@redhat.com>
 
+       PR libstdc++/79433
+       * doc/xml/manual/status_cxx2017.xml: Update feature-test macros.
+       * doc/html/*: Regenerate.
+       * include/Makefile.am: Remove <bits/c++17_warning.h>.
+       * include/Makefile.in: Regenerate.
+       * include/bits/c++17_warning.h: Remove.
+       * include/bits/string_view.tcc: Do not include <bits/c++17_warning.h>
+       for pre-C++17 modes.
+       * include/std/any: Likewise.
+       (__cpp_lib_any): Define.
+       * include/std/mutex (__cpp_lib_scoped_lock): Adjust value as per new
+       SD-6 draft.
+       * include/std/numeric (__cpp_lib_gcd_lcm): Define as per new SD-6
+       draft.
+       * include/std/optional: Do not include <bits/c++17_warning.h>.
+       (__cpp_lib_optional): Define.
+       * include/std/shared_mutex: Do not include <bits/c++14_warning.h>.
+       * include/std/string_view: Do not include <bits/c++17_warning.h>.
+       (__cpp_lib_string_view): Define.
+       * include/std/variant: Do not include <bits/c++17_warning.h>.
+       (__cpp_lib_variant): Define.
+       * testsuite/20_util/optional/cons/value_neg.cc: Adjust dg-error line
+       numbers.
+       * testsuite/26_numerics/gcd/1.cc: Test for __cpp_lib_gcd_lcm.
+       * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line
+       numbers.
+       * testsuite/26_numerics/lcm/1.cc: Test for __cpp_lib_gcd_lcm.
+       * testsuite/26_numerics/lcm/lcm_neg.cc: Adjust dg-error line
+       numbers.
+       * testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Adjust
+       expected value of __cpp_lib_scoped_lock.
+
        PR libstdc++/70483
        * include/experimental/bits/string_view.tcc (basic_string_view::find)
        (basic_string_view::rfind, basic_string_view::find_first_of)
index 85e193daffa1a5a67ee7254541ad438e0f5b089a..fd66ac503a82d880ffc59d0a60a0f7d08b205be8 100644 (file)
@@ -98,7 +98,9 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> 7 </entry>
-      <entry> <code>__has_include(&lt;variant&gt;)</code> </entry>
+      <entry> <code>__has_include(&lt;variant&gt;)</code>,
+              <code>__cpp_lib_variant >= 201603</code>
+      </entry>
     </row>
 
     <row>
@@ -109,7 +111,9 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> 7 </entry>
-      <entry> <code>__has_include(&lt;optional&gt;)</code> </entry>
+      <entry> <code>__has_include(&lt;optional&gt;)</code>,
+              <code>__cpp_lib_optional >= 201603</code>
+      </entry>
     </row>
 
     <row>
@@ -120,7 +124,9 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> 7 </entry>
-      <entry> <code>__has_include(&lt;any&gt;)</code> </entry>
+      <entry> <code>__has_include(&lt;any&gt;)</code>,
+              <code>__cpp_lib_any >= 201603</code>
+      </entry>
     </row>
 
     <row>
@@ -131,7 +137,9 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> 7 </entry>
-      <entry> <code>__has_include(&lt;string_view&gt;)</code> </entry>
+      <entry> <code>__has_include(&lt;string_view&gt;)</code>,
+              <code>__cpp_lib_string_view >= 201603</code>
+      </entry>
     </row>
 
     <row>
@@ -143,7 +151,9 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> No </entry>
-      <entry> <code>__has_include(&lt;memory_resource&gt;)</code> </entry>
+      <entry> <code>__has_include(&lt;memory_resource&gt;)</code>,
+              <code>__cpp_lib_memory_resource >= 201603</code>
+      </entry>
     </row>
 
     <row>
@@ -616,7 +626,9 @@ Feature-testing recommendations for C++</link>.
       </entry>
       <entry align="center"> No </entry>
       <entry><code> __has_include(&lt;execution&gt;) </code>,
-            <code> __cpp_lib_parallel_algorithm >= 201603 </code></entry>
+            <code> __cpp_lib_execution >= 201603 </code>,
+            <code> __cpp_lib_parallel_algorithm >= 201603 </code>
+      </entry>
     </row>
 
     <row>
@@ -638,9 +650,7 @@ Feature-testing recommendations for C++</link>.
        </link>
       </entry>
       <entry align="center"> 7 </entry>
-      <entry><code> __cpp_lib_gcd >= 201606 </code>,
-            <code> __cpp_lib_lcm >= 201606 </code>
-      </entry>
+      <entry><code> __cpp_lib_gcd_lcm >= 201606 </code></entry>
     </row>
 
     <row>
index a65173658271bb67d85bc4ae79caca04164dd820..6395f1e6ae08e03a88e66a53ecc3a775534b0595 100644 (file)
@@ -96,7 +96,6 @@ bits_headers = \
        ${bits_srcdir}/boost_concept_check.h \
        ${bits_srcdir}/c++0x_warning.h \
        ${bits_srcdir}/c++14_warning.h \
-       ${bits_srcdir}/c++17_warning.h \
        ${bits_srcdir}/char_traits.h \
        ${bits_srcdir}/codecvt.h \
        ${bits_srcdir}/concept_check.h \
index 783c647087fb5b2c049d336e94ecf15f622afe94..745a8495da5fe9b64e0ced4caade902fd2de5b4e 100644 (file)
@@ -389,7 +389,6 @@ bits_headers = \
        ${bits_srcdir}/boost_concept_check.h \
        ${bits_srcdir}/c++0x_warning.h \
        ${bits_srcdir}/c++14_warning.h \
-       ${bits_srcdir}/c++17_warning.h \
        ${bits_srcdir}/char_traits.h \
        ${bits_srcdir}/codecvt.h \
        ${bits_srcdir}/concept_check.h \
diff --git a/libstdc++-v3/include/bits/c++17_warning.h b/libstdc++-v3/include/bits/c++17_warning.h
deleted file mode 100644 (file)
index 759fdc9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2016-2017 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// Under Section 7 of GPL version 3, you are granted additional
-// permissions described in the GCC Runtime Library Exception, version
-// 3.1, as published by the Free Software Foundation.
-
-// You should have received a copy of the GNU General Public License and
-// a copy of the GCC Runtime Library Exception along with this program;
-// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
-// <http://www.gnu.org/licenses/>.
-
-/** @file bits/c++17_warning.h
- *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{iosfwd}
- */
-
-#ifndef _CXX17_WARNING_H
-#define _CXX17_WARNING_H 1
-
-#if __cplusplus <= 201402L
-#error This file requires compiler and library support \
-for the ISO C++ 2017 standard. This support must be enabled \
-with the -std=c++17 or -std=gnu++17 compiler options.
-#endif
-
-#endif
index b8ab78cedf1781c2184fcf53bc1429c204ffa078..4d98f8668a0077ce9e070719367b1c526eb74b23 100644 (file)
@@ -36,9 +36,7 @@
 
 #pragma GCC system_header
 
-#if __cplusplus <= 201402L
-# include <bits/c++17_warning.h>
-#else
+#if __cplusplus >= 201703L
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
index 1e84302f0c04b49d41e0b8e6ad237f724501c846..eef510535d7420999c57a03694d3c423803758f4 100644 (file)
@@ -31,9 +31,7 @@
 
 #pragma GCC system_header
 
-#if __cplusplus <= 201402L
-# include <bits/c++17_warning.h>
-#else
+#if __cplusplus >= 201703L
 
 #include <typeinfo>
 #include <new>
@@ -68,6 +66,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
   }
 
+#define __cpp_lib_any 201603
+
   /**
    *  @brief A type-safe container of any type.
    * 
index fadb9f60481ac19f9c5702695d3cedf9818ad1d6..8c692a88ffdcdfc9544755ee9bfa5426808abe36 100644 (file)
@@ -556,8 +556,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         }
     }
 
-#if __cplusplus > 201402L
-#define __cpp_lib_scoped_lock 201707
+#if __cplusplus >= 201703L
+#define __cpp_lib_scoped_lock 201703
   /** @brief A scoped lock type for multiple lockable objects.
    *
    * A scoped_lock controls mutex ownership within a scope, releasing
index 17d629db81d89e6d9280b357914e82794980e8e2..2b804199c7e999053850965cdb591a99a0179e90 100644 (file)
@@ -121,7 +121,11 @@ namespace __detail
 
 #if __cplusplus > 201402L
 
+#define __cpp_lib_gcd_lcm 201606
+// These were used in drafts of SD-6:
 #define __cpp_lib_gcd 201606
+#define __cpp_lib_lcm 201606
+
   /// Greatest common divisor
   template<typename _Mn, typename _Nn>
     constexpr common_type_t<_Mn, _Nn>
@@ -134,7 +138,6 @@ namespace __detail
       return __detail::__gcd(__m, __n);
     }
 
-#define __cpp_lib_lcm 201606
   /// Least common multiple
   template<typename _Mn, typename _Nn>
     constexpr common_type_t<_Mn, _Nn>
index c697c1682a60f7539010a1a3321803ad3b21c8cf..2743ef963b4daf2667103adddf16642cf20c6d1e 100644 (file)
@@ -29,9 +29,9 @@
 #ifndef _GLIBCXX_OPTIONAL
 #define _GLIBCXX_OPTIONAL 1
 
-#if __cplusplus <= 201402L
-# include <bits/c++17_warning.h>
-#else
+#pragma GCC system_header
+
+#if __cplusplus >= 201703L
 
 #include <utility>
 #include <type_traits>
@@ -51,6 +51,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @{
    */
 
+#define __cpp_lib_optional 201603
+
   template<typename _Tp>
     class optional;
 
index ff116c0e30d2c9e5f9682285bfa0ef05c623a0bb..295fdc7118c9ca8bea8573f1f96557bb9234f116 100644 (file)
@@ -31,9 +31,7 @@
 
 #pragma GCC system_header
 
-#if __cplusplus <= 201103L
-# include <bits/c++14_warning.h>
-#else
+#if __cplusplus >= 201402L
 
 #include <bits/c++config.h>
 #include <condition_variable>
@@ -51,7 +49,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 #ifdef _GLIBCXX_HAS_GTHREADS
 
-#if __cplusplus > 201402L
+#if __cplusplus >= 201703L
 #define __cpp_lib_shared_mutex 201505
   class shared_mutex;
 #endif
index d766b75f9a73e4bcc9f2fdc10694e56ab11e0259..97316ef49ab92f754150ef3ce5a3de69ff1a6e8e 100644 (file)
@@ -35,9 +35,7 @@
 
 #pragma GCC system_header
 
-#if __cplusplus <= 201402L
-# include <bits/c++17_warning.h>
-#else
+#if __cplusplus >= 201703L
 
 #include <limits>
 #include <iosfwd>
@@ -49,6 +47,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#define __cpp_lib_string_view 201603
+
   /**
    *  @class basic_string_view <string_view>
    *  @brief  A non-owning reference to a string.
index d0c22e35d0f2d3a3e21055c809b62b40a2f67124..ee2571b78577c55e0a9a95b696bfdd76c62fef70 100644 (file)
@@ -31,9 +31,7 @@
 
 #pragma GCC system_header
 
-#if __cplusplus <= 201402L
-# include <bits/c++17_warning.h>
-#else
+#if __cplusplus >= 201703L
 
 #include <type_traits>
 #include <utility>
@@ -70,6 +68,8 @@ namespace __variant
 } // namespace __variant
 } // namespace __detail
 
+#define __cpp_lib_variant 201603
+
   template<typename... _Types> class tuple;
   template<typename... _Types> class variant;
   template <typename> struct hash;
index 524e302fec10b250cd52a47040d405a3c95c6003..98964eadbde9a3a9e534ce6046be416f78784af1 100644 (file)
@@ -37,8 +37,8 @@ int main()
     std::optional<std::unique_ptr<int>> oup2 = new int;  // { dg-error "conversion" }
     struct U { explicit U(std::in_place_t); };
     std::optional<U> ou(std::in_place); // { dg-error "no matching" }
-    // { dg-error "no type" "" { target { *-*-* } } 493 }
-    // { dg-error "no type" "" { target { *-*-* } } 503 }
-    // { dg-error "no type" "" { target { *-*-* } } 560 }
+    // { dg-error "no type" "" { target { *-*-* } } 495 }
+    // { dg-error "no type" "" { target { *-*-* } } 505 }
+    // { dg-error "no type" "" { target { *-*-* } } 562 }
   }
 }
index 17e97a7e0ae50466ed23662a8437c87f910dd293..0f0b7b85b4e0d234c9d27cf02c84e1d80979a545 100644 (file)
@@ -20,9 +20,9 @@
 
 #include <numeric>
 
-#ifndef __cpp_lib_gcd
+#ifndef __cpp_lib_gcd_lcm
 # error "Feature-test macro for gcd missing"
-#elif __cpp_lib_gcd != 201606
+#elif __cpp_lib_gcd_lcm != 201606
 # error "Feature-test macro for gcd has wrong value"
 #endif
 
index 8c3494d70418793fcad35840a58ebc232b6c4cca..d88f145d75452ecec938c44c0a9579aff058f8de 100644 (file)
@@ -31,9 +31,9 @@ test01()
   std::gcd(0.1, 0.1);   // { dg-error "from here" }
 }
 
-// { dg-error "integers" "" { target *-*-* } 130 }
-// { dg-error "integers" "" { target *-*-* } 131 }
-// { dg-error "not bools" "" { target *-*-* } 132 }
-// { dg-error "not bools" "" { target *-*-* } 133 }
+// { dg-error "integers" "" { target *-*-* } 134 }
+// { dg-error "integers" "" { target *-*-* } 135 }
+// { dg-error "not bools" "" { target *-*-* } 136 }
+// { dg-error "not bools" "" { target *-*-* } 137 }
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "invalid operands" }
index 81cb91437ba290ff1c2723ed318d572d140e0849..367f0a3e0e3f6de205568877c8f68e27252ca5a9 100644 (file)
@@ -20,9 +20,9 @@
 
 #include <numeric>
 
-#ifndef __cpp_lib_lcm
+#ifndef __cpp_lib_gcd_lcm
 # error "Feature-test macro for lcm missing"
-#elif __cpp_lib_lcm != 201606
+#elif __cpp_lib_gcd_lcm != 201606
 # error "Feature-test macro for lcm has wrong value"
 #endif
 
index abcac4f18c1f6e2b4fbce8820e1fac22d016ed27..7a908a4568ff885bf6729d54b6d33e733a01295b 100644 (file)
@@ -31,9 +31,9 @@ test01()
   std::lcm(0.1, 0.1);   // { dg-error "from here" }
 }
 
-// { dg-error "integers" "" { target *-*-* } 143 }
-// { dg-error "integers" "" { target *-*-* } 144 }
-// { dg-error "not bools" "" { target *-*-* } 145 }
-// { dg-error "not bools" "" { target *-*-* } 146 }
+// { dg-error "integers" "" { target *-*-* } 146 }
+// { dg-error "integers" "" { target *-*-* } 147 }
+// { dg-error "not bools" "" { target *-*-* } 148 }
+// { dg-error "not bools" "" { target *-*-* } 149 }
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "invalid operands" }
index 0a8903ebaab4683f5b62769eb01d3a93d1ac313e..b8a09042094a150718cbc84f6e0e1b982c7cf9d5 100644 (file)
@@ -27,7 +27,7 @@
 
 #ifndef __cpp_lib_scoped_lock
 # error "Feature-test macro for scoped_lock missing"
-#elif __cpp_lib_scoped_lock != 201707
+#elif __cpp_lib_scoped_lock != 201703
 # error "Feature-test macro for scoped_lock has wrong value"
 #endif