public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] libstdc++: contracts uint_least32_t lineno
@ 2022-10-21  1:23 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2022-10-21  1:23 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

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

commit fcce3a45f0c6625dcc45dc7d83fdb1b836016bbe
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Oct 18 13:04:09 2022 -0400

    libstdc++: contracts uint_least32_t lineno
    
    As specified in N4820.
    
    libstdc++-v3/ChangeLog:
    
            * include/experimental/contract: line_number() returns
            uint_least32_t.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/contracts/contracts14.C: Cast line_number to int.
            * g++.dg/contracts/contracts15.C
            * g++.dg/contracts/contracts16.C: Likewise.

Diff:
---
 gcc/testsuite/g++.dg/contracts/contracts14.C | 2 +-
 gcc/testsuite/g++.dg/contracts/contracts15.C | 2 +-
 gcc/testsuite/g++.dg/contracts/contracts16.C | 2 +-
 libstdc++-v3/include/experimental/contract   | 5 +++--
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/g++.dg/contracts/contracts14.C b/gcc/testsuite/g++.dg/contracts/contracts14.C
index bda392a1f9d..cca1e79964f 100644
--- a/gcc/testsuite/g++.dg/contracts/contracts14.C
+++ b/gcc/testsuite/g++.dg/contracts/contracts14.C
@@ -20,7 +20,7 @@ void handle_contract_violation(const std::contract_violation &violation) {
     << " " << violation.line_number()
     << " " << violation.file_name()
     << std::endl;
-  throw -violation.line_number();
+  throw -(int)violation.line_number();
 }
 
 int fun() {
diff --git a/gcc/testsuite/g++.dg/contracts/contracts15.C b/gcc/testsuite/g++.dg/contracts/contracts15.C
index 8110876286c..fefafdfa66e 100644
--- a/gcc/testsuite/g++.dg/contracts/contracts15.C
+++ b/gcc/testsuite/g++.dg/contracts/contracts15.C
@@ -20,7 +20,7 @@ void handle_contract_violation(const std::contract_violation &violation) {
     << " " << violation.line_number()
     << " " << violation.file_name()
     << std::endl;
-  throw -violation.line_number();
+  throw -(int)violation.line_number();
 }
 
 int fun() noexcept {
diff --git a/gcc/testsuite/g++.dg/contracts/contracts16.C b/gcc/testsuite/g++.dg/contracts/contracts16.C
index 26172281767..d80cda46501 100644
--- a/gcc/testsuite/g++.dg/contracts/contracts16.C
+++ b/gcc/testsuite/g++.dg/contracts/contracts16.C
@@ -10,7 +10,7 @@ void handle_contract_violation(const std::contract_violation &violation) {
     << " " << violation.line_number()
     << " " << violation.file_name()
     << std::endl;
-  throw -violation.line_number();
+  throw -(int)violation.line_number();
 }
 
 int fun() {
diff --git a/libstdc++-v3/include/experimental/contract b/libstdc++-v3/include/experimental/contract
index 611d9c6db82..8d49bf751da 100644
--- a/libstdc++-v3/include/experimental/contract
+++ b/libstdc++-v3/include/experimental/contract
@@ -39,6 +39,7 @@
 
 #include <bits/c++config.h>
 #include <string_view>
+#include <cstdint>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -49,7 +50,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
   class contract_violation {
-    int _M_line; // FIXME uint_least32_t
+    uint_least32_t _M_line;
     const char* _M_file;
     const char* _M_function;
     const char* _M_comment;
@@ -62,7 +63,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                         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; }
+    uint_least32_t 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; }

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

only message in thread, other threads:[~2022-10-21  1:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21  1:23 [gcc/devel/c++-contracts] libstdc++: contracts uint_least32_t lineno 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).