#include "rust-compile-item.h"
#include "rust-compile-implitem.h"
-#include "rust-compile-expr.h"
#include "rust-compile-extern.h"
-#include "rust-constexpr.h"
namespace Rust {
namespace Compile {
= ctx->get_backend ()->global_variable (name, asm_name, type, is_external,
is_hidden, in_unique_section,
var.get_locus ());
- ctx->get_backend ()->global_variable_set_init (static_global, value);
+
+ tree init = value == error_mark_node ? error_mark_node : DECL_INITIAL (value);
+ ctx->get_backend ()->global_variable_set_init (static_global, init);
ctx->insert_var_decl (var.get_mappings ().get_hirid (), static_global);
ctx->push_var (static_global);
--- /dev/null
+// { dg-output "hello world: gccrs\n" }
+// { dg-additional-options "-w" }
+static TEST_1: &str = "gccrs";
+static TEST_2: i32 = 123;
+
+struct Foo(i32, bool);
+static TEST_3: Foo = Foo(123, false);
+
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+fn main() -> i32 {
+ unsafe {
+ let a1 = "hello world: %s\n";
+ let b1 = a1 as *const str;
+ let c1 = b1 as *const i8;
+
+ let a2 = TEST_1;
+ let b2 = a2 as *const str;
+ let c2 = b2 as *const i8;
+
+ printf(c1, c2);
+ }
+ 0
+}