]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Do not allow contract26.cc to build without -fcontracts
authorJonathan Wakely <jwakely@redhat.com>
Wed, 28 Jan 2026 12:17:14 +0000 (12:17 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 28 Jan 2026 12:19:08 +0000 (12:19 +0000)
It seems prefereable to get a hard error if this file is built
incorrectly, rather than failing to define any symbols.

libstdc++-v3/ChangeLog:

* src/experimental/contract26.cc: Use #error if built without
contracts support enabled.
* include/std/source_location: Remove stray whitespace.

libstdc++-v3/include/std/source_location
libstdc++-v3/src/experimental/contract26.cc

index 3a631c31c1e31f4b70f2b55188b0c32c52ac1862..170753fdde2a55dacd64b55a888152d868565907 100644 (file)
@@ -94,7 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     constexpr source_location (const void *__t)
       : _M_impl (static_cast <const __impl*>(__t)) {}
-      
+
 #ifdef __cpp_lib_contracts
     /* To enable use of the source __impl*.  */
     friend class std::contracts::contract_violation;
index d32a2ca13e2fbc323bb05527d8fde68df4e256f5..007a9fcbf5865995ab941e2161d660c05485bd78 100644 (file)
 
 #include <contracts>
 
-#ifdef __cpp_lib_contracts
+#ifndef __cpp_lib_contracts
+# error "This file requires C++26 contracts support to be enabled"
+#endif
+
 #if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE
 # include <iostream>
 # include <cxxabi.h>
@@ -154,4 +157,3 @@ _Z41invoke_default_contract_violation_handlerRKNSt9contracts18contract_violation
 { invoke_default_contract_violation_handler(violation); }
 
 #endif
-#endif // __cpp_lib_contracts