public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] session-manager: Do not go through with compilation on privacy/unsafe errors
@ 2022-07-27 13:20 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-07-27 13:20 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6b14b560bc25465f2e8465c087ecd9684fb5fb65

commit 6b14b560bc25465f2e8465c087ecd9684fb5fb65
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Mon Jul 25 10:56:23 2022 +0200

    session-manager: Do not go through with compilation on privacy/unsafe
    errors

Diff:
---
 gcc/rust/rust-session-manager.cc      | 5 +++++
 gcc/testsuite/rust/compile/unsafe5.rs | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index e533706168c..6a2c1b6dd62 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -792,7 +792,12 @@ Session::parse_file (const char *filename)
 
   // Various HIR error passes. The privacy pass happens before the unsafe checks
   Privacy::Resolver::resolve (hir);
+  if (saw_errors ())
+    return;
+
   HIR::UnsafeChecker ().go (hir);
+  if (saw_errors ())
+    return;
 
   // do compile to gcc generic
   Compile::Context ctx (backend);
diff --git a/gcc/testsuite/rust/compile/unsafe5.rs b/gcc/testsuite/rust/compile/unsafe5.rs
new file mode 100644
index 00000000000..35990f6ee9f
--- /dev/null
+++ b/gcc/testsuite/rust/compile/unsafe5.rs
@@ -0,0 +1,4 @@
+fn main() {
+    let b = 15;
+    let c = *(&b as *const i32); // { dg-error "dereference of raw pointer" }
+}


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

only message in thread, other threads:[~2022-07-27 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-27 13:20 [gcc/devel/rust/master] session-manager: Do not go through with compilation on privacy/unsafe errors Thomas Schwinge

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).