From: Yap Zhi Heng <[email protected]>
This is replaced with -frust-compat-version=<1.64 instead.
gcc/rust/ChangeLog:
* lang.opt: Remove frust-c-style-string-literals option.
* rust-session-manager.h (Session): New should_support_cstr_parsing
function.
* parse/rust-parse-impl-expr.hxx
(Parser<ManagedTokenSource>::parse_literal_expr):
Replace old flag_c_style_string_literals check with
should_support_cstr_parsing.
(Parser<ManagedTokenSource>::null_denotation_not_path): Likewise.
* parse/rust-parse.h: Import rust-session-manager.h to access Session
class.
gcc/testsuite/ChangeLog:
* rust/compile/c_string_null_byte_check.rs: Remove
frust-c-style-string-literals
from compilation options.
* rust/execute/torture/c_string_ensure_null_term.rs: Likewise.
* rust/execute/torture/c_string.rs: Likewise.
Signed-off-by: Yap Zhi Heng <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/69b7ef1a5d9a9cdec93df313259c37b16f3251eb
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4925
gcc/rust/lang.opt | 4 ----
gcc/rust/parse/rust-parse-impl-expr.hxx | 8 ++++----
gcc/rust/parse/rust-parse.h | 1 +
gcc/rust/rust-session-manager.h | 5 +++++
gcc/testsuite/rust/compile/c_string_null_byte_check.rs | 2 +-
gcc/testsuite/rust/execute/torture/c_string.rs | 2 +-
.../rust/execute/torture/c_string_ensure_null_term.rs | 2 +-
7 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt
index f996ec0f0..a94fd0f89 100644
--- a/gcc/rust/lang.opt
+++ b/gcc/rust/lang.opt
@@ -237,8 +237,4 @@ frust-unused-check-2.0
Rust Var(flag_unused_check_2_0)
Use the new unused variable check implementation.
-frust-c-style-string-literals
-Rust Var(flag_c_style_string_literals)
-Enable parsing and compilation of C-styled string literals.
-
; This comment is to ensure we retain the blank line above.
diff --git a/gcc/rust/parse/rust-parse-impl-expr.hxx
b/gcc/rust/parse/rust-parse-impl-expr.hxx
index 127b2c7a2..f42bf9a13 100644
--- a/gcc/rust/parse/rust-parse-impl-expr.hxx
+++ b/gcc/rust/parse/rust-parse-impl-expr.hxx
@@ -344,7 +344,7 @@ Parser<ManagedTokenSource>::parse_literal_expr
(AST::AttrVec outer_attrs)
break;
case C_STRING_LITERAL:
{
- if (flag_c_style_string_literals)
+ if (Session::get_instance ().should_support_cstr_parsing ())
{
type = AST::Literal::C_STRING;
literal_value = t->get_str ();
@@ -356,7 +356,7 @@ Parser<ManagedTokenSource>::parse_literal_expr
(AST::AttrVec outer_attrs)
Error (t->get_locus (),
"unexpected token %qs when parsing literal expression - "
"C-style string literals require "
- "%<-frust-c-style-string-literals%> to be enabled",
+ "%<-frust-compat-version%> to be set to least 1.64",
t->get_token_description ()));
return tl::unexpected<Parse::Error::Node> (
Parse::Error::Node::MALFORMED);
@@ -2134,7 +2134,7 @@ Parser<ManagedTokenSource>::null_denotation_not_path (
new AST::LiteralExpr (tok->get_str (), AST::Literal::RAW_STRING,
tok->get_type_hint (), {}, tok->get_locus ()));
case C_STRING_LITERAL:
- if (flag_c_style_string_literals)
+ if (Session::get_instance ().should_support_cstr_parsing ())
{
return std::unique_ptr<AST::LiteralExpr> (
new AST::LiteralExpr (tok->get_str (), AST::Literal::C_STRING,
@@ -2145,7 +2145,7 @@ Parser<ManagedTokenSource>::null_denotation_not_path (
{
Error error (tok->get_locus (),
"C-style string literals require "
- "%<-frust-c-style-string-literals%> to be enabled");
+ "%<-frust-compat-version%> to be set to least 1.64");
add_error (std::move (error));
return tl::unexpected<Parse::Error::Expr> (
Parse::Error::Expr::MALFORMED);
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index 7b0da58c5..4b389a827 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "rust-parse-utils.h"
#include "rust-feature.h"
#include "rust-feature-store.h"
+#include "rust-session-manager.h"
#include "expected.h"
#include "options.h"
diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h
index 9f0209b90..6a0acda7c 100644
--- a/gcc/rust/rust-session-manager.h
+++ b/gcc/rust/rust-session-manager.h
@@ -507,6 +507,11 @@ public:
int get_compat_version () const { return options.get_compat_version (); }
+ bool should_support_cstr_parsing () const
+ {
+ return get_compat_version () >= 64;
+ }
+
bool should_support_offset_of () const { return get_compat_version () >= 71;
}
bool should_support_cfg_select () const
diff --git a/gcc/testsuite/rust/compile/c_string_null_byte_check.rs
b/gcc/testsuite/rust/compile/c_string_null_byte_check.rs
index 57dfe8623..2b4f4bdd1 100644
--- a/gcc/testsuite/rust/compile/c_string_null_byte_check.rs
+++ b/gcc/testsuite/rust/compile/c_string_null_byte_check.rs
@@ -1,4 +1,4 @@
-// { dg-additional-options "-frust-c-style-string-literals
-frust-compat-version=1.90" }
+// { dg-additional-options "-frust-compat-version=1.90" }
#![feature(no_core, lang_items)]
#![no_core]
diff --git a/gcc/testsuite/rust/execute/torture/c_string.rs
b/gcc/testsuite/rust/execute/torture/c_string.rs
index be90e4e1c..b8d60cac8 100644
--- a/gcc/testsuite/rust/execute/torture/c_string.rs
+++ b/gcc/testsuite/rust/execute/torture/c_string.rs
@@ -1,4 +1,4 @@
-// { dg-additional-options "-frust-c-style-string-literals
-frust-compat-version=1.90" }
+// { dg-additional-options "-frust-compat-version=1.90" }
// { dg-output "gccrs" }
#![feature(no_core, lang_items)]
#![no_core]
diff --git a/gcc/testsuite/rust/execute/torture/c_string_ensure_null_term.rs
b/gcc/testsuite/rust/execute/torture/c_string_ensure_null_term.rs
index 488d9fdcd..2ba0d06ef 100644
--- a/gcc/testsuite/rust/execute/torture/c_string_ensure_null_term.rs
+++ b/gcc/testsuite/rust/execute/torture/c_string_ensure_null_term.rs
@@ -1,4 +1,4 @@
-// { dg-additional-options "-frust-c-style-string-literals
-frust-compat-version=1.90" }
+// { dg-additional-options "-frust-compat-version=1.90" }
#![feature(no_core, intrinsics, staged_api, lang_items)]
#![no_core]
base-commit: e0a7a91b661fe9361410739c230b7391e104fde0
--
2.55.0