Skip to content

segfault DefaultHIRVisitor, macros #4187

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
macro x(
    $macro_name:ident,
    $macro2_name:ident,
    $type_name:ident,
    $field_name:ident,
    $const_name:ident
) {
    pub struct $type_name {}

    pub const $const_name: $type_name = $type_name {};

    #[x]
    macro_rules! $macro_name {
        () => {};
    }

    pub macro $type_name {
                (Copy $e:expr) => {},
                () => {;},

            }
}

x!(test_fields, test_fields2, x, field, MY_CONST);

pub fn check_fields_local() {
    test_fields!(check_fields);
}

original:

macro x(
    $macro_name:ident,
    $macro2_name:ident,
    $type_name:ident,
    $field_name:ident,
    $const_name:ident
) {
    pub struct $type_name {}

    pub const $const_name: $type_name = $type_name {};

    #[x]
    macro_rules! $macro_name {
        (check_fields) => {{
            assert_eq!($const_name.field, Field::MacroCtxt);
        }};
    }

    pub macro $type_name {
            (Copy $e:expr) => {},
            (check_fields) => {test_fields!(check_fields);},

        }
}

x!(test_fields, test_fields2, x, field, MY_CONST);

pub fn check_fields_local() {
    test_fields!(check_fields);
    test_fields2!(check_fields);
}

Version information:

5a762b9

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

/tmp/icemaker_global_tempdir.CmTzlVK6SkSa/rustc_testrunner_tmpdir_reporting.EhADlG9zJYJK/mvce.rs:12:7: error: macro not found
   12 |     #[x]
      |       ^
crab1: internal compiler error: Segmentation fault
0x301f909 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:786
0x199fb9f crash_signal
	../../gcc/toplev.cc:323
0x0 Rust::HIR::DefaultHIRVisitor::visit(Rust::HIR::TupleType&)
	../../gcc/rust/hir/tree/rust-hir-visitor.h:333
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions