-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gccrs: [E0124] field x is already declared in struct
Refactored error message for more than one duplicate fields. gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc (struct_field_name_exists): called error function. gcc/testsuite/ChangeLog: * rust/compile/bad_pub_enumitems.rs: changed comment to pass test cases. * rust/compile/dup_fields.rs: likewise. * rust/execute/same_field_name.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
- Loading branch information
1 parent
5d124d1
commit 1827610
Showing
4 changed files
with
16 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
struct S { a: i32, b: i32, c: u8, a: i128 } | ||
// { dg-error "duplicate field" "" { target *-*-* } .-1 } | ||
// { dg-error "field .a. is already declared" "" { target *-*-* } .-1 } | ||
|
||
union U | ||
{ | ||
a: i32, | ||
b: i32, | ||
c: u8, | ||
b: char // { dg-error "duplicate field" "" { target *-*-* } } | ||
b: char // { dg-error "field .b. is already declared" "" { target *-*-* } } | ||
} | ||
|
||
fn main () | ||
{ | ||
struct SS { alpha: i32, beta: i32, gamma: u8, gamma: i128 } | ||
// { dg-error "duplicate field" "" { target *-*-* } .-1 } | ||
// { dg-error "field .gamma. is already declared" "" { target *-*-* } .-1 } | ||
|
||
union UU | ||
{ | ||
alpha: i32, beta: i32, | ||
gamma: u8, beta: char | ||
// { dg-error "duplicate field" "" { target *-*-* } .-1 } | ||
// { dg-error "field .beta. is already declared" "" { target *-*-* } .-1 } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// https://doc.rust-lang.org/error_codes/E0124.html | ||
fn main() { | ||
struct Foo { | ||
field1: i32, // { dg-error "field .field1. is already declared" } | ||
field1: i32, // { dg-error "field .field1. is already declared" } | ||
field1: i32, // { dg-error "field .field1. is already declared" } | ||
} | ||
} |