public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] libstdc++: contracts support changes
@ 2021-07-06 20:44 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-07-06 20:44 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:a70e678aec8900fff80602afff5eb223c993aa50

commit a70e678aec8900fff80602afff5eb223c993aa50
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jul 2 15:27:52 2021 -0400

    libstdc++: contracts support changes
    
    libstdc++-v3/ChangeLog:
    
            * src/c++17/contract.cc: Remove member functions.
            * config/abi/pre/gnu.ver: Remove their symbols, move to latest
            version.
            * include/std/contract: Make them inline.
            Change string_view data members to const char *.
            Use libstdc++ naming pattern.

Diff:
---
 libstdc++-v3/src/c++17/contract.cc  | 68 -------------------------------------
 libstdc++-v3/config/abi/pre/gnu.ver | 16 +++------
 libstdc++-v3/include/std/contract   | 40 +++++++++++++---------
 3 files changed, 28 insertions(+), 96 deletions(-)

diff --git a/libstdc++-v3/src/c++17/contract.cc b/libstdc++-v3/src/c++17/contract.cc
index 56ee9c8e841..769e6d3b722 100644
--- a/libstdc++-v3/src/c++17/contract.cc
+++ b/libstdc++-v3/src/c++17/contract.cc
@@ -23,75 +23,8 @@
 // <http://www.gnu.org/licenses/>.
 
 #include <contract>
-#include <exception>
 #include <iostream>
 #include <cstdlib>
-#include <cstdio>
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-contract_violation::contract_violation (int line_number,
-  string_view file_name,
-  string_view function_name,
-  string_view comment,
-  string_view assertion_level,
-  string_view assertion_role,
-  contract_violation_continuation_mode continuation_mode)
-  : line_number_(line_number),
-    file_name_(file_name),
-    function_name_(function_name),
-    comment_(comment),
-    assertion_level_(assertion_level),
-    assertion_role_(assertion_role),
-    continuation_mode_(continuation_mode)
-  { }
-
-int
-contract_violation::line_number () const noexcept
-{
-  return this->line_number_;
-}
-
-string_view
-contract_violation::file_name () const noexcept
-{
-  return this->file_name_;
-}
-
-string_view
-contract_violation::function_name () const noexcept
-{
-  return this->function_name_;
-}
-
-string_view
-contract_violation::comment () const noexcept
-{
-  return this->comment_;
-}
-
-string_view
-contract_violation::assertion_level () const noexcept
-{
-  return this->assertion_level_;
-}
-
-string_view
-contract_violation::assertion_role () const noexcept
-{
-  return this->assertion_role_;
-}
-
-contract_violation_continuation_mode
-contract_violation::continuation_mode () const noexcept
-{
-  return this->continuation_mode_;
-}
-
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace std
-
 
 __attribute__ ((weak)) void
 handle_contract_violation (const std::contract_violation &violation)
@@ -133,4 +66,3 @@ __on_contract_violation (bool continue_,
 
   return 0;
 }
-
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index e4235847b13..94a3e4769b5 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -2282,18 +2282,6 @@ GLIBCXX_3.4.26 {
     _ZNSt7codecvtID[is]Du*;
     _ZT[ISV]St7codecvtID[is]Du*E;
 
-    # std::contract_violation::contract_violation (int, std::string_view, std::string_view, std::string_view, std::string_view, std::string_view, std::contract_violation_continuation_mode)
-    _ZNSt18contract_violationC1EiSt17basic_string_viewIcSt11char_traitsIcEES3_S3_S3_S3_St36contract_violation_continuation_mode;
-    _ZNKSt18contract_violation11line_numberEv;
-    _ZNKSt18contract_violation13function_nameEv;
-    _ZNKSt18contract_violation15assertion_levelEv;
-    _ZNKSt18contract_violation14assertion_roleEv;
-    _ZNKSt18contract_violation7commentEv;
-    _ZNKSt18contract_violation9file_nameEv;
-    _ZNKSt18contract_violation17continuation_modeEv;
-
-    _Z25handle_contract_violationRKSt18contract_violation;
-    _Z23__on_contract_violationbiPKcS0_S0_S0_S0_i;
 } GLIBCXX_3.4.25;
 
 GLIBCXX_3.4.27 {
@@ -2407,6 +2395,10 @@ GLIBCXX_3.4.29 {
     # std::to_chars(char*, char*, [float|double|long double], chars_format, int)
     _ZSt8to_charsPcS_[def]St12chars_formati;
 
+    # experimental contracts support
+    _Z25handle_contract_violationRKSt18contract_violation;
+    _Z23__on_contract_violationbiPKcS0_S0_S0_S0_i;
+
 } GLIBCXX_3.4.28;
 
 # Symbols in the support library (libsupc++) have their own tag.
diff --git a/libstdc++-v3/include/std/contract b/libstdc++-v3/include/std/contract
index 039a8e24a12..2eabb3190cd 100644
--- a/libstdc++-v3/include/std/contract
+++ b/libstdc++-v3/include/std/contract
@@ -23,6 +23,10 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
+// FIXME experimental
+// FIXME string_view vs. freestanding
+// FIXME remove on_contract_violation?
+
 /** @file contract
  *  This is a Standard C++ Library header.
  */
@@ -46,23 +50,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
   class contract_violation {
-    int line_number_;
-    string_view file_name_;
-    string_view function_name_;
-    string_view comment_;
-    string_view assertion_level_;
-    string_view assertion_role_;
-    contract_violation_continuation_mode continuation_mode_;
+    int _M_line; // FIXME uint_least32_t
+    const char* _M_file;
+    const char* _M_function;
+    const char* _M_comment;
+    const char* _M_level;
+    const char* _M_role;
+    contract_violation_continuation_mode _M_continue;
   public:
-    contract_violation (int, string_view, string_view, string_view, string_view,
-                        string_view, contract_violation_continuation_mode);
-    int line_number() const noexcept;
-    string_view file_name() const noexcept;
-    string_view function_name() const noexcept;
-    string_view comment() const noexcept;
-    string_view assertion_level() const noexcept;
-    string_view assertion_role() const noexcept;
-    contract_violation_continuation_mode continuation_mode() const noexcept;
+    contract_violation (int __l, const char* __f, const char* __fn,
+			const char* __c, const char* __lv, const char *__r,
+                        contract_violation_continuation_mode __m)
+      : _M_line(__l), _M_file(__f), _M_function(__fn), _M_comment(__c),
+	_M_level(__lv), _M_role(__r), _M_continue(__m) { }
+    int line_number() const noexcept { return _M_line; }
+    string_view file_name() const noexcept { return _M_file; }
+    string_view function_name() const noexcept { return _M_function; }
+    string_view comment() const noexcept { return _M_comment; }
+    string_view assertion_level() const noexcept { return _M_level; }
+    string_view assertion_role() const noexcept { return _M_role; }
+    contract_violation_continuation_mode continuation_mode() const noexcept
+    { return _M_continue; }
   };
 
   //void handle_contract_violation (const contract_violation &);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-06 20:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 20:44 [gcc/devel/c++-contracts] libstdc++: contracts support changes Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).