]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 years agoparser: Allow parsing multiple reference types
Arthur Cohen [Wed, 1 Feb 2023 10:40:13 +0000 (11:40 +0100)] 
parser: Allow parsing multiple reference types

The parser now recursively tries to parse a reference type after seeing
a `&` or `&&` token.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_type): Handle double ampersan
properly
(Parser::parse_reference_type): Call into `parse_reference_type_inner`
and wrap double reference types in another `AST::ReferenceType` node
(Parser::parse_reference_type_inner): Add parsing implementation
which does not care about the leading token (& or  &&)
(Parser::parse_type_no_bounds): Handle double ampersand properly
* parse/rust-parse.h: Declare `parse_reference_type_inner`

gcc/testsuite/ChangeLog:

* rust/compile/multi_reference_type.rs: New test.

2 years agoMerge #1777
bors[bot] [Mon, 30 Jan 2023 09:06:03 +0000 (09:06 +0000)] 
Merge #1777

1777: Rename file rust-ast-full-test.cc to rust-ast.cc r=CohenArthur a=Parthib314

* Fixes issue  #1765

**Rename the `rust-ast-full-test.cc` to `rust-ast.cc` and also update it on `Make-lang.in`**

Co-authored-by: Parthib <parthibdutta02@gmail.com>
2 years agoRename file rust-ast-full-test.cc to rust-ast.cc
Parthib [Sat, 28 Jan 2023 16:37:45 +0000 (22:07 +0530)] 
Rename file rust-ast-full-test.cc to rust-ast.cc

2 years agoMerge #1759
bors[bot] [Fri, 27 Jan 2023 16:10:43 +0000 (16:10 +0000)] 
Merge #1759

1759: Revert 10-second timeout for each test r=philberty a=Parthib314

* Fixes issue #1747

**Remove the 10-second timeout for each compile case**

Co-authored-by: vagrant <vagrant@vagrant.vm>
2 years agoMerge #1772
bors[bot] [Fri, 27 Jan 2023 15:25:48 +0000 (15:25 +0000)] 
Merge #1772

1772: Added missing GroupedPattern visitors for code generation r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Implements some missing visitor methods for GroupedPattern compilation.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdded missing GroupedPattern visitors for code generation
Owen Avery [Wed, 11 Jan 2023 16:57:28 +0000 (11:57 -0500)] 
Added missing GroupedPattern visitors for code generation

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1771
bors[bot] [Thu, 26 Jan 2023 15:28:46 +0000 (15:28 +0000)] 
Merge #1771

1771: Add type resolution for grouped patterns r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Adds type resolution for GroupedPattern.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd type resolution for grouped patterns
Owen Avery [Wed, 11 Jan 2023 16:56:05 +0000 (11:56 -0500)] 
Add type resolution for grouped patterns

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd get_item method for HIR::GroupedPattern
Owen Avery [Wed, 25 Jan 2023 18:00:38 +0000 (13:00 -0500)] 
Add get_item method for HIR::GroupedPattern

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1769
bors[bot] [Wed, 25 Jan 2023 09:49:08 +0000 (09:49 +0000)] 
Merge #1769

1769: Add HIR lowering for GroupedPattern r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Implements HIR lowering for grouped patterns.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoAdd HIR lowering for GroupedPattern
Owen Avery [Wed, 11 Jan 2023 16:54:54 +0000 (11:54 -0500)] 
Add HIR lowering for GroupedPattern

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1763
bors[bot] [Tue, 24 Jan 2023 16:39:54 +0000 (16:39 +0000)] 
Merge #1763

1763: Do not crash on empty macros expand. Fixes #1712 r=philberty a=teromene

This PR fixes a compiler crash when expanding an empty macro into an existing AST.
(I ran clang-format but it marked a few other files as dirty, and I therefore did not touch them)

Signed-off-by: Lyra Karenai <teromene@teromene.fr>
Co-authored-by: Lyra <teromene@teromene.fr>
2 years agoMerge #1760
bors[bot] [Tue, 24 Jan 2023 15:52:01 +0000 (15:52 +0000)] 
Merge #1760

1760: Support GroupedPattern during name resolution r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
Adds support for GroupedPattern during name resolution.

Addresses #1136

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoDo not crash on empty macros expand. Fixes #1712
Lyra [Tue, 24 Jan 2023 13:15:42 +0000 (14:15 +0100)] 
Do not crash on empty macros expand. Fixes #1712

This commit fixes a compiler crash when expanding an empty macro into an existing AST.

Signed-off-by: Lyra Karenai <teromene@teromene.fr>
2 years agoSupport GroupedPattern during name resolution
Owen Avery [Wed, 11 Jan 2023 16:53:51 +0000 (11:53 -0500)] 
Support GroupedPattern during name resolution

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoRevert 10-second timeout for each test
vagrant [Sat, 21 Jan 2023 18:33:07 +0000 (18:33 +0000)] 
Revert 10-second timeout for each test

2 years agoMerge #1732
bors[bot] [Fri, 20 Jan 2023 08:36:23 +0000 (08:36 +0000)] 
Merge #1732

1732: testsuite: Handle Windows carriage returns properly r=CohenArthur a=CohenArthur

In dg-output, check for \r* carriage returns to make sure execution tests pass on windows platforms

gcc/testsuite/ChangeLog:

* rust/execute/torture/builtin_macro_cfg.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_concat.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_env.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_include_bytes.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_include_str.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macro_line.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macros1.rs: Handle carriage returns properly
* rust/execute/torture/builtin_macros3.rs: Handle carriage returns properly
* rust/execute/torture/cfg1.rs: Handle carriage returns properly
* rust/execute/torture/cfg2.rs: Handle carriage returns properly
* rust/execute/torture/cfg3.rs: Handle carriage returns properly
* rust/execute/torture/cfg4.rs: Handle carriage returns properly
* rust/execute/torture/coercion1.rs: Handle carriage returns properly
* rust/execute/torture/coercion2.rs: Handle carriage returns properly
* rust/execute/torture/extern_mod4.rs: Handle carriage returns properly
* rust/execute/torture/helloworld1.rs: Handle carriage returns properly
* rust/execute/torture/helloworld2.rs: Handle carriage returns properly
* rust/execute/torture/issue-1198.rs: Handle carriage returns properly
* rust/execute/torture/issue-1231.rs: Handle carriage returns properly
* rust/execute/torture/issue-1232.rs: Handle carriage returns properly
* rust/execute/torture/issue-1249.rs: Handle carriage returns properly
* rust/execute/torture/issue-1436.rs: Handle carriage returns properly
* rust/execute/torture/issue-1496.rs: Handle carriage returns properly
* rust/execute/torture/issue-647.rs: Handle carriage returns properly
* rust/execute/torture/issue-845.rs: Handle carriage returns properly
* rust/execute/torture/issue-851.rs: Handle carriage returns properly
* rust/execute/torture/issue-858.rs: Handle carriage returns properly
* rust/execute/torture/issue-976.rs: Handle carriage returns properly
* rust/execute/torture/macros10.rs: Handle carriage returns properly
* rust/execute/torture/macros11.rs: Handle carriage returns properly
* rust/execute/torture/macros12.rs: Handle carriage returns properly
* rust/execute/torture/macros13.rs: Handle carriage returns properly
* rust/execute/torture/macros14.rs: Handle carriage returns properly
* rust/execute/torture/macros2.rs: Handle carriage returns properly
* rust/execute/torture/macros22.rs: Handle carriage returns properly
* rust/execute/torture/macros29.rs: Handle carriage returns properly
* rust/execute/torture/macros3.rs: Handle carriage returns properly
* rust/execute/torture/macros30.rs: Handle carriage returns properly
* rust/execute/torture/macros31.rs: Handle carriage returns properly
* rust/execute/torture/macros7.rs: Handle carriage returns properly
* rust/execute/torture/macros8.rs: Handle carriage returns properly
* rust/execute/torture/macros9.rs: Handle carriage returns properly
* rust/execute/torture/match1.rs: Handle carriage returns properly
* rust/execute/torture/match2.rs: Handle carriage returns properly
* rust/execute/torture/match3.rs: Handle carriage returns properly
* rust/execute/torture/match_bool1.rs: Handle carriage returns properly
* rust/execute/torture/match_byte1.rs: Handle carriage returns properly
* rust/execute/torture/match_char1.rs: Handle carriage returns properly
* rust/execute/torture/match_int1.rs: Handle carriage returns properly
* rust/execute/torture/match_loop1.rs: Handle carriage returns properly
* rust/execute/torture/match_range1.rs: Handle carriage returns properly
* rust/execute/torture/match_range2.rs: Handle carriage returns properly
* rust/execute/torture/match_tuple1.rs: Handle carriage returns properly
* rust/execute/torture/method1.rs: Handle carriage returns properly
* rust/execute/torture/method2.rs: Handle carriage returns properly
* rust/execute/torture/method3.rs: Handle carriage returns properly
* rust/execute/torture/method4.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_1.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_10.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_11.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_12.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_2.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_4.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_5.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_6.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_7.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_8.rs: Handle carriage returns properly
* rust/execute/torture/operator_overload_9.rs: Handle carriage returns properly
* rust/execute/torture/str-layout1.rs: Handle carriage returns properly
* rust/execute/torture/str-zero.rs: Handle carriage returns properly
* rust/execute/torture/trait1.rs: Handle carriage returns properly
* rust/execute/torture/trait10.rs: Handle carriage returns properly
* rust/execute/torture/trait11.rs: Handle carriage returns properly
* rust/execute/torture/trait12.rs: Handle carriage returns properly
* rust/execute/torture/trait13.rs: Handle carriage returns properly
* rust/execute/torture/trait2.rs: Handle carriage returns properly
* rust/execute/torture/trait3.rs: Handle carriage returns properly
* rust/execute/torture/trait4.rs: Handle carriage returns properly
* rust/execute/torture/trait5.rs: Handle carriage returns properly
* rust/execute/torture/trait6.rs: Handle carriage returns properly
* rust/execute/torture/trait7.rs: Handle carriage returns properly
* rust/execute/torture/trait8.rs: Handle carriage returns properly
* rust/execute/torture/trait9.rs: Handle carriage returns properly

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agotestsuite: Handle Windows carriage returns properly
Arthur Cohen [Wed, 11 Jan 2023 10:36:11 +0000 (11:36 +0100)] 
testsuite: Handle Windows carriage returns properly

In dg-output, check for \r* carriage returns to make sure execution
tests pass on windows platforms

gcc/testsuite/ChangeLog:

* rust/execute/torture/builtin_macro_cfg.rs: Handle carriage returns
properly.
* rust/execute/torture/builtin_macro_concat.rs: Likewise.
* rust/execute/torture/builtin_macro_env.rs: Likewise.
* rust/execute/torture/builtin_macro_include_bytes.rs: Likewise.
* rust/execute/torture/builtin_macro_include_str.rs: Likewise.
* rust/execute/torture/builtin_macro_line.rs: Likewise.
* rust/execute/torture/builtin_macros1.rs: Likewise.
* rust/execute/torture/builtin_macros3.rs: Likewise.
* rust/execute/torture/cfg1.rs: Likewise.
* rust/execute/torture/cfg2.rs: Likewise.
* rust/execute/torture/cfg3.rs: Likewise.
* rust/execute/torture/cfg4.rs: Likewise.
* rust/execute/torture/coercion1.rs: Likewise.
* rust/execute/torture/coercion2.rs: Likewise.
* rust/execute/torture/extern_mod4.rs: Likewise.
* rust/execute/torture/helloworld1.rs: Likewise.
* rust/execute/torture/helloworld2.rs: Likewise.
* rust/execute/torture/issue-1198.rs: Likewise.
* rust/execute/torture/issue-1231.rs: Likewise.
* rust/execute/torture/issue-1232.rs: Likewise.
* rust/execute/torture/issue-1249.rs: Likewise.
* rust/execute/torture/issue-1436.rs: Likewise.
* rust/execute/torture/issue-1496.rs: Likewise.
* rust/execute/torture/issue-647.rs: Likewise.
* rust/execute/torture/issue-845.rs: Likewise.
* rust/execute/torture/issue-851.rs: Likewise.
* rust/execute/torture/issue-858.rs: Likewise.
* rust/execute/torture/issue-976.rs: Likewise.
* rust/execute/torture/macros10.rs: Likewise.
* rust/execute/torture/macros11.rs: Likewise.
* rust/execute/torture/macros12.rs: Likewise.
* rust/execute/torture/macros13.rs: Likewise.
* rust/execute/torture/macros14.rs: Likewise.
* rust/execute/torture/macros2.rs: Likewise.
* rust/execute/torture/macros22.rs: Likewise.
* rust/execute/torture/macros29.rs: Likewise.
* rust/execute/torture/macros3.rs: Likewise.
* rust/execute/torture/macros30.rs: Likewise.
* rust/execute/torture/macros31.rs: Likewise.
* rust/execute/torture/macros7.rs: Likewise.
* rust/execute/torture/macros8.rs: Likewise.
* rust/execute/torture/macros9.rs: Likewise.
* rust/execute/torture/match1.rs: Likewise.
* rust/execute/torture/match2.rs: Likewise.
* rust/execute/torture/match3.rs: Likewise.
* rust/execute/torture/match_bool1.rs: Likewise.
* rust/execute/torture/match_byte1.rs: Likewise.
* rust/execute/torture/match_char1.rs: Likewise.
* rust/execute/torture/match_int1.rs: Likewise.
* rust/execute/torture/match_loop1.rs: Likewise.
* rust/execute/torture/match_range1.rs: Likewise.
* rust/execute/torture/match_range2.rs: Likewise.
* rust/execute/torture/match_tuple1.rs: Likewise.
* rust/execute/torture/method1.rs: Likewise.
* rust/execute/torture/method2.rs: Likewise.
* rust/execute/torture/method3.rs: Likewise.
* rust/execute/torture/method4.rs: Likewise.
* rust/execute/torture/operator_overload_1.rs: Likewise.
* rust/execute/torture/operator_overload_10.rs: Likewise.
* rust/execute/torture/operator_overload_11.rs: Likewise.
* rust/execute/torture/operator_overload_12.rs: Likewise.
* rust/execute/torture/operator_overload_2.rs: Likewise.
* rust/execute/torture/operator_overload_4.rs: Likewise.
* rust/execute/torture/operator_overload_5.rs: Likewise.
* rust/execute/torture/operator_overload_6.rs: Likewise.
* rust/execute/torture/operator_overload_7.rs: Likewise.
* rust/execute/torture/operator_overload_8.rs: Likewise.
* rust/execute/torture/operator_overload_9.rs: Likewise.
* rust/execute/torture/str-layout1.rs: Likewise.
* rust/execute/torture/str-zero.rs: Likewise.
* rust/execute/torture/trait1.rs: Likewise.
* rust/execute/torture/trait10.rs: Likewise.
* rust/execute/torture/trait11.rs: Likewise.
* rust/execute/torture/trait12.rs: Likewise.
* rust/execute/torture/trait13.rs: Likewise.
* rust/execute/torture/trait2.rs: Likewise.
* rust/execute/torture/trait3.rs: Likewise.
* rust/execute/torture/trait4.rs: Likewise.
* rust/execute/torture/trait5.rs: Likewise.
* rust/execute/torture/trait6.rs: Likewise.
* rust/execute/torture/trait7.rs: Likewise.
* rust/execute/torture/trait8.rs: Likewise.
* rust/execute/torture/trait9.rs: Likewise.
* rust/execute/torture/closure2.rs: Likewise.
* rust/execute/torture/closure3.rs: Likewise.
* rust/execute/torture/loop-condition-eval.rs: Likewise.
* rust/execute/torture/operator_overload_3.rs: Likewise.

2 years agoMerge #1751
bors[bot] [Tue, 17 Jan 2023 16:32:09 +0000 (16:32 +0000)] 
Merge #1751

1751: README.md: Added experimental flag & updated gccrs path r=CohenArthur a=DrMahad

(1) There is a need of the flag "-frust-incomplete-and-experimental-compiler-do-not-use" because the rust1 compiler didn't work without this.

(2) The gccrs was not present in the $HOME/gccrs-install/, so updated the path to $HOME/gccrs-install/bin

Signed-off-by: MAHAD <mahadtxt@gmail.com>
Co-authored-by: MAHAD <mahadtxt@gmail.com>
2 years agoREADME.md: Added experimental flag & updated gccrs path
MAHAD [Tue, 17 Jan 2023 15:47:26 +0000 (20:47 +0500)] 
README.md: Added experimental flag & updated gccrs path

(1) There is a need of the flag "-frust-incomplete-and-experimental-compiler-do-not-use" because the rust1 compiler didn't work without this.

(2) The gccrs was not present in the $HOME/gccrs-install/, so updated the path to $HOME/gccrs-install/bin

Signed-off-by: MAHAD <mahadtxt@gmail.com>
2 years agoMerge #1736
bors[bot] [Sat, 14 Jan 2023 22:35:55 +0000 (22:35 +0000)] 
Merge #1736

1736: Change how CompileVarDecl outputs Bvariable's r=philberty a=powerboat9

This allows patterns to declare multiple/no variables

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoChange how CompileVarDecl outputs Bvariable's
Owen Avery [Wed, 11 Jan 2023 17:05:39 +0000 (12:05 -0500)] 
Change how CompileVarDecl outputs Bvariable's

This allows patterns to declare multiple/no variables

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1733
bors[bot] [Thu, 12 Jan 2023 13:54:04 +0000 (13:54 +0000)] 
Merge #1733

1733: diagnostics: Add underline for tokens in diagnostics. r=CohenArthur a=TuringKi

Currently, the diagnostics only point to the corresponding token's start position by carets, and lack of underlines for full token.  This commit add support for such underlines in diagnostics by encoding range information in location_t.

the results like this:

```
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:5:14: error: invalid cast 'bool' to 'f32' [E0054]
    5 |   let fone = t as f32;   // { dg-error "invalid cast" }
      |              ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:6:15: error: invalid cast 'bool' to 'f64' [E0054]
    6 |   let fzero = f as f64;  // { dg-error "invalid cast" }
      |               ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:8:12: error: invalid cast 'u8' to 'bool' [E0054]
    8 |   let nb = 0u8 as bool;  // { dg-error "invalid cast .u8. to .bool. \\\[E0054\\\]" }
      |            ^~~    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:9:12: error: invalid cast 'bool' to 'char' [E0054]
    9 |   let nc = true as char; // { dg-error "invalid cast" }
      |            ^~~~    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:13:12: error: invalid cast 'char' to 'f32' [E0054]
   13 |   let fa = a as f32;     // { dg-error "invalid cast" }
      |            ^    ~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:14:12: error: invalid cast 'char' to 'bool' [E0054]
   14 |   let bb = b as bool;    // { dg-error "invalid cast .char. to .bool. \\\[E0054\\\]" }
      |            ^    ~~~~
../gcc/testsuite/rust/compile/bad_as_bool_char.rs:17:12: error: invalid cast 'u32' to 'char' [E0054]
   17 |   let ab = t32 as char;  // { dg-error "invalid cast" }
      |            ^~~    ~~~~

```

This commit is split from pr #1718.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agodiagnostics: Add underline for tokens in diagnostics.
mxlol233 [Wed, 11 Jan 2023 12:36:13 +0000 (20:36 +0800)] 
diagnostics: Add underline for tokens in diagnostics.

Currently, the diagnostics only point to the corresponding token's start position by carets, and lack of underlines for full token.  This commit add support for such underlines in diagnostics by encoding range information in location_t.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoMerge #1734
bors[bot] [Wed, 11 Jan 2023 16:45:18 +0000 (16:45 +0000)] 
Merge #1734

1734: Add get_locus function for abstract class MetaItemInner. r=CohenArthur a=TuringKi

This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print  diagnostics on some sub-classes of MetaItemInner.

This commit is split from pr https://github.com/Rust-GCC/gccrs/pull/1718.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agoAdd get_locus function for abstract class MetaItemInner.
mxlol233 [Wed, 11 Jan 2023 15:24:07 +0000 (23:24 +0800)] 
Add get_locus function for abstract class MetaItemInner.

This commit adds virtual function get_locus to base class MetaItemInner, which is helpful when we need to print  diagnostics on some sub-classes of MetaItemInner.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoMerge #1730
bors[bot] [Wed, 11 Jan 2023 11:39:37 +0000 (11:39 +0000)] 
Merge #1730

1730: Improve type checking on let statements r=philberty a=powerboat9

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---

Improves the typechecking of patterns in let statements.

Co-authored-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoReuse TypeCheckPattern on LetStmt's
Owen Avery [Tue, 10 Jan 2023 00:54:55 +0000 (19:54 -0500)] 
Reuse TypeCheckPattern on LetStmt's

Update Rust type-checking to reuse TypeCheckPattern on HIR::LetStmt's.
This will unify the paths and improve error handling.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 years agoMerge #1724
bors[bot] [Tue, 10 Jan 2023 22:39:41 +0000 (22:39 +0000)] 
Merge #1724

1724: Add support for generics associated type binding r=philberty a=philberty

This patch set adds support to specify the associated type via the argument
binding syntax. We are still missing general bounds checking so in order to
properly add more test cases for bad types we need to implement that first.
I have also changed a test case to -fsyntax-only as at the time I always get
confused between Generic arguments of foo=i32 and bar: baz only specifies
the associated type and the latter adds a bound. Currently we are lacking a
way to represent adding a bound in the AST and HIR within generic arguments
so I have raised: #1725 and #1726

Fixes #1720

Co-authored-by: Philip Herron <herron.philip@googlemail.com>
2 years agoSupport associated type bound arguments
Philip Herron [Sat, 7 Jan 2023 14:41:12 +0000 (14:41 +0000)] 
Support associated type bound arguments

This patch adds support for the GenercArgsBinding type, where you can
specify the associated types of a trait bound using `<Foo=i32>` style
syntax. Note that the type-resolution relys on the i32 impl for Add
as type resolution will resolve the `a+a` to the core::ops::Add method
so code generation will require this to exist.

I have ameded testsuite/rust/compile/bounds.rs as this code is wrongly
creating an HIR::GenericArgs with a trait-object type and causing issues.
the parsing is still correct but we dont have the mechanism to represent
this in AST and HIR properly. I think we will need a new HIR::GenericArgs
AssociatedTypeBindingBound or something similar. We are still lacking
bounds checking during are type coercions and unifications so running this
example using an f32 will wrongly pass type checking, this will need
addressed next.

Fixes #1720

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* hir/tree/rust-hir-path.h:
* typecheck/rust-hir-path-probe.h:
* typecheck/rust-hir-trait-resolve.cc:
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound):
(TypeBoundPredicate::TypeBoundPredicate):
(TypeBoundPredicate::operator=):
(TypeBoundPredicate::apply_generic_arguments):
(TypeBoundPredicateItem::get_tyty_for_receiver):
(TypeBoundPredicate::get_num_associated_bindings):
(TypeBoundPredicate::lookup_associated_type):
(TypeBoundPredicate::get_associated_type_items):
* typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args):
(SubstitutionRef::infer_substitions):
(SubstitutionRef::solve_missing_mappings_from_this):
* typecheck/rust-tyty.h:

gcc/testsuite/ChangeLog:

* rust/compile/bounds.rs: change to use -fsyntax-only
* rust/execute/torture/issue-1720.rs: New test.

2 years agoAdd name resolution to generic argument associated item bindings
Philip Herron [Sat, 7 Jan 2023 17:15:23 +0000 (17:15 +0000)] 
Add name resolution to generic argument associated item bindings

When specifying generic arguments to Traits we can also specify the
associated types using `<BindingName=i32>` syntax we need to add
name resolution to the type argument here and rely on the type
resolution pass to ensure the associated type exists and to setup the
associated types accordingly.

Addresses #1720

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveGenericArgs::go):

2 years agoMerge #1708
bors[bot] [Mon, 9 Jan 2023 15:48:12 +0000 (15:48 +0000)] 
Merge #1708

1708: Parse declarative macro (decl_macro 2.0) r=CohenArthur a=tamaroning

This PR is currentry wip.
Opinions and advices are welcome!

Co-authored-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agoImplement declarative macro 2.0 parser
Raiki Tamura [Sun, 18 Dec 2022 16:48:54 +0000 (01:48 +0900)] 
Implement declarative macro 2.0 parser
Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agoMerge #1707 #1717
bors[bot] [Thu, 5 Jan 2023 15:59:10 +0000 (15:59 +0000)] 
Merge #1707 #1717

1707: Fix frust very long typo r=CohenArthur a=CohenArthur

Missing space character

1717: format: Fix git whitespace errors r=CohenArthur a=CohenArthur

Addresses #1680
Fixes #1680

Probably does not need a changelog since I assume this commit will just be dropped when we merge

Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
2 years agoMerge #1711
bors[bot] [Thu, 5 Jan 2023 15:17:27 +0000 (15:17 +0000)] 
Merge #1711

1711: unsafe: check use of `target_feature` attribute r=CohenArthur a=snprajwal

The `target_feature` attribute is for conditional compilation and may or may not compile on all platforms. Using it requires an unsafe function or block.

Addresses #1411

Co-authored-by: Prajwal S N <prajwalnadig21@gmail.com>
2 years agoMerge #1709
bors[bot] [Thu, 5 Jan 2023 08:36:42 +0000 (08:36 +0000)] 
Merge #1709

1709: Check const functions for mutable references r=CohenArthur a=dme2

Fixes #1552

Co-authored-by: Dave <dme2223@gmail.com>
2 years agoMerge #1716
bors[bot] [Wed, 4 Jan 2023 20:12:07 +0000 (20:12 +0000)] 
Merge #1716

1716: rust: add bound parsing in parse_generic_arg. r=philberty a=TuringKi

This patch adds parsing for generic parameters like: <F: Foo<Bar: Foo>>. In current version, this pattern  leads to endless loop.

Co-authored-by: mxlol233 <mxlol233@outlook.com>
2 years agoformat: Fix git whitespace errors
Arthur Cohen [Sat, 10 Dec 2022 07:58:58 +0000 (08:58 +0100)] 
format: Fix git whitespace errors

2 years agorust: add bound parsing in parse_generic_arg.
mxlol233 [Wed, 4 Jan 2023 13:21:59 +0000 (21:21 +0800)] 
rust: add bound parsing in parse_generic_arg.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
2 years agoCheck for mutable references in const functions
Dave [Mon, 19 Dec 2022 16:59:00 +0000 (10:59 -0600)] 
Check for mutable references in const functions

Use StackedContext instead. Fix error string

Signed-off-by: Dave Evans <dave@dmetwo.org>
(Squashed commits) Check for mutable references in const functions using StackedContext

Signed-off-by: Dave Evans <dave@dmetwo.org>
2 years agounsafe: check use of `target_feature` attribute
Prajwal S N [Sat, 31 Dec 2022 07:19:02 +0000 (12:49 +0530)] 
unsafe: check use of `target_feature` attribute

The `target_feature` attribute is for conditional compilation and may or
may not compile on all platforms. Using it requires an unsafe function
or block.

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
2 years agoMerge #1706
bors[bot] [Fri, 16 Dec 2022 12:46:03 +0000 (12:46 +0000)] 
Merge #1706

1706: Add math intrinsics r=CohenArthur a=tamaroning

Addresses https://github.com/Rust-GCC/gccrs/issues/658
Added math intrinsic functions.

Co-authored-by: Raiki Tamura <tamaron1203@gmail.com>
2 years agofatal_error_flag: Fix typo in error message
Arthur Cohen [Fri, 16 Dec 2022 12:38:36 +0000 (13:38 +0100)] 
fatal_error_flag: Fix typo in error message

2 years agoadd math intrinsics
Raiki Tamura [Thu, 15 Dec 2022 17:27:59 +0000 (02:27 +0900)] 
add math intrinsics

2 years agoMerge #1700
bors[bot] [Thu, 15 Dec 2022 14:13:33 +0000 (14:13 +0000)] 
Merge #1700

1700: Merge upstream, last commit before GCC/Rust upstreaming r=CohenArthur a=tschwinge

Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
Co-authored-by: Richard Biener <rguenther@suse.de>
Co-authored-by: Patrick Palka <ppalka@redhat.com>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Harald Anlauf <anlauf@gmx.de>
Co-authored-by: Ian Lance Taylor <iant@golang.org>
Co-authored-by: GCC Administrator <gccadmin@gcc.gnu.org>
Co-authored-by: David Malcolm <dmalcolm@redhat.com>
Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
Co-authored-by: Alexandre Oliva <oliva@adacore.com>
Co-authored-by: Paul-Antoine Arras <pa@codesourcery.com>
Co-authored-by: Tobias Burnus <tobias@codesourcery.com>
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Co-authored-by: Martin Liska <mliska@suse.cz>
Co-authored-by: Iskander Shakirzyanov <iskander@ispras.ru>
Co-authored-by: Iain Buclaw <ibuclaw@gdcproject.org>
Co-authored-by: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Co-authored-by: John David Anglin <danglin@gcc.gnu.org>
2 years agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Thu, 15 Dec 2022 13:52:24 +0000 (14:52 +0100)] 
Adjust '.github/bors_log_expected_warnings'

2 years agoMerge #1704
bors[bot] [Thu, 15 Dec 2022 09:06:54 +0000 (09:06 +0000)] 
Merge #1704

1704: rust: fix link serialization [PR108113] r=CohenArthur a=dkm

The Make-lang.in was missing the link serialization support.

    PR rust/108113

gcc/rust
* Make-lang.in (rust.serial): New variable.
(rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
2 years agorust: fix link serialization [PR108113]
Marc Poulhiès [Wed, 14 Dec 2022 20:29:13 +0000 (21:29 +0100)] 
rust: fix link serialization [PR108113]

The Make-lang.in was missing the link serialization support.

    PR rust/108113

gcc/rust
* Make-lang.in (rust.serial): New variable.
(rust1$(exeext)): Depend on $(rust.prev). Call LINK_PROGRESS.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2 years agoAdjust for "Make Warray-bounds alias to Warray-bounds= [PR107787]"
Thomas Schwinge [Wed, 14 Dec 2022 09:33:24 +0000 (10:33 +0100)] 
Adjust for "Make Warray-bounds alias to Warray-bounds= [PR107787]"

See GCC upstream commit 7c01d029fca669263b9c2dcb8837c42f7ae3a77f
"Make Warray-bounds alias to Warray-bounds= [PR107787]".

2 years agoMerge commit '3b89428c0d5710c8093055b3d92c543888759f93' into HEAD
Thomas Schwinge [Wed, 14 Dec 2022 16:30:07 +0000 (17:30 +0100)] 
Merge commit '3b89428c0d5710c8093055b3d92c543888759f93' into HEAD

2 years agoMerge commit '3d6dbb6fc5d1d14bf36a879b6f4a00ae91090a63' into HEAD
Thomas Schwinge [Wed, 14 Dec 2022 16:27:01 +0000 (17:27 +0100)] 
Merge commit '3d6dbb6fc5d1d14bf36a879b6f4a00ae91090a63' into HEAD

2 years agoMerge #1703
bors[bot] [Wed, 14 Dec 2022 14:46:30 +0000 (14:46 +0000)] 
Merge #1703

1703: Backport "c++: Quash -Wdangling-reference for member operator* [PR107488]" r=tschwinge a=tschwinge

As had also been reported in <https://gcc.gnu.org/PR107633> "Bootstrap failure due to -Werror=unused-parameter and -Werror=dangling-reference", GCC `--enable-bootstrap` build is currently broken:

    [...]/gcc/rust/backend/rust-compile-expr.cc: In member function â€˜tree_node* Rust::Compile::CompileExpr::resolve_method_address(Rust::TyTy::FnType*, Rust::HirId, Rust::TyTy::BaseType*, Rust::HIR::PathIdentSegment&, Rust::Analysis::NodeMapping, Location)’:
    [...]/gcc/rust/backend/rust-compile-expr.cc:2019:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     2019 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/backend/rust-compile-expr.cc:2019:44: note: the temporary was destroyed at the end of the full expression â€˜candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
     2019 |       auto &candidate = *candidates.begin ();
          |                                            ^
    [...]/gcc/rust/backend/rust-compile-expr.cc: In member function â€˜tree_node* Rust::Compile::CompileExpr::generate_closure_fntype(Rust::HIR::ClosureExpr&, const Rust::TyTy::ClosureType&, tree, Rust::TyTy::FnType**)’:
    [...]/gcc/rust/backend/rust-compile-expr.cc:3034:35: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
     3034 |   const TyTy::TypeBoundPredicate &predicate
          |                                   ^~~~~~~~~
    [...]/gcc/rust/backend/rust-compile-expr.cc:3035:52: note: the temporary was destroyed at the end of the full expression â€˜(&(& closure_tyty)->Rust::TyTy::ClosureType::<anonymous>.Rust::TyTy::BaseType::<anonymous>.Rust::TyTy::TypeBoundsMappings::get_specified_bounds())->std::vector<Rust::TyTy::TypeBoundPredicate>::begin().__gnu_cxx::__normal_iterator<const Rust::TyTy::TypeBoundPredicate*, std::vector<Rust::TyTy::TypeBoundPredicate> >::operator*()’
     3035 |     = *closure_tyty.get_specified_bounds ().begin ();
          |                                                    ^

    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc: In member function â€˜void Rust::Resolver::TypeCheckExpr::resolve_segments(Rust::NodeId, std::vector<Rust::HIR::PathExprSegment>&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’:
    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
      340 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/typecheck/rust-hir-type-check-path.cc:340:44: note: the temporary was destroyed at the end of the full expression â€˜candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
      340 |       auto &candidate = *candidates.begin ();
          |                                            ^

    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc: In member function â€˜Rust::TyTy::BaseType* Rust::Resolver::TypeCheckType::resolve_segments(Rust::NodeId, Rust::HirId, std::vector<std::unique_ptr<Rust::HIR::TypePathSegment> >&, size_t, Rust::TyTy::BaseType*, const Rust::Analysis::NodeMapping&, Location)’:
    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:13: error: possibly dangling reference to a temporary [-Werror=dangling-reference]
      465 |       auto &candidate = *candidates.begin ();
          |             ^~~~~~~~~
    [...]/gcc/rust/typecheck/rust-hir-type-check-type.cc:465:44: note: the temporary was destroyed at the end of the full expression â€˜candidates.std::set<Rust::Resolver::PathProbeCandidate>::begin().std::_Rb_tree_const_iterator<Rust::Resolver::PathProbeCandidate>::operator*()’
      465 |       auto &candidate = *candidates.begin ();
          |                                            ^

I understand this code has been changed in the GCC/Rust upstream submission; but in order to make progress with #1700, I'd like to first individually backport "c++: Quash -Wdangling-reference for member operator* [PR107488]", to resolve this issue here.

Co-authored-by: Marek Polacek <polacek@redhat.com>
2 years agoc++: Quash -Wdangling-reference for member operator* [PR107488]
Marek Polacek [Tue, 1 Nov 2022 21:05:52 +0000 (17:05 -0400)] 
c++: Quash -Wdangling-reference for member operator* [PR107488]

-Wdangling-reference complains here:

  std::vector<int> v = ...;
  std::vector<int>::const_iterator it = v.begin();
  while (it != v.end()) {
    const int &r = *it++; // warning
  }

because it sees a call to
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator*
which returns a reference and its argument is a TARGET_EXPR representing
the result of
__gnu_cxx::__normal_iterator<const int*, std::vector<int> >::operator++
But 'r' above refers to one of the int elements of the vector 'v', not
to a temporary object.  Therefore the warning is a false positive.

I suppose code like the above is relatively common (the warning broke
cppunit-1.15.1 and a few other projects), so presumably it makes sense
to suppress the warning when it comes to member operator*.  In this case
it's defined as

      reference
      operator*() const _GLIBCXX_NOEXCEPT
      { return *_M_current; }

and I'm guessing a lot of member operator* are like that, at least when
it comes to iterators.  I've looked at _Fwd_list_iterator,
_Fwd_list_const_iterator, __shared_ptr_access, _Deque_iterator,
istream_iterator, etc, and they're all like that, so adding #pragmas
would be quite tedious.  :/

PR c++/107488

gcc/cp/ChangeLog:

* call.cc (do_warn_dangling_reference): Quash -Wdangling-reference
for member operator*.

gcc/testsuite/ChangeLog:

* g++.dg/warn/Wdangling-reference5.C: New test.

(cherry picked from commit 32a06ce38a38bf37db468f0e6c83520fcc221534)

2 years agoMerge #1701
bors[bot] [Wed, 14 Dec 2022 11:51:46 +0000 (11:51 +0000)] 
Merge #1701

1701: Standardize warning flags r=tschwinge a=tschwinge

Bring in #1670, revert #1623 and parts of #1585.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2 years agoReally fix up '.github/bors_log_expected_warnings'
Thomas Schwinge [Wed, 14 Dec 2022 10:25:45 +0000 (11:25 +0100)] 
Really fix up '.github/bors_log_expected_warnings'

2 years agoRevert "bors: Fix warning list"
Thomas Schwinge [Wed, 14 Dec 2022 09:14:55 +0000 (10:14 +0100)] 
Revert "bors: Fix warning list"

This reverts #1585 commit 94d11161c1abe8927f571aedbf39871f21ccf73a.

Conflicts:
.github/bors_log_expected_warnings
... manually resolved and adjusted; let's see...

2 years agoRevert "ci: Apply warnings in CI"
Thomas Schwinge [Wed, 14 Dec 2022 08:45:58 +0000 (09:45 +0100)] 
Revert "ci: Apply warnings in CI"

As discussed in
<https://inbox.sourceware.org/gcc-patches/871qpjtmd8.fsf@euler.schwinge.homeip.net>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror' [for '--enable-bootstrap' builds].
> ([...])
> (Maybe that isn't active for '--disable-bootstrap' builds, but that's
> "OK".)

For '--disable-bootstrap' builds, we still have '-Woverloaded-virtual', and any
new such diagnostics will be caught by the #1026 "check for new warnings"
machinery, so effectively that does implement '-Werror', too.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1585 commit a32ef7aa18c45e7047f539b11cd572f0f9502b6d.

2 years agoRevert "ci: Use same CXXFLAGS in bootstrap workflow"
Thomas Schwinge [Wed, 14 Dec 2022 08:39:44 +0000 (09:39 +0100)] 
Revert "ci: Use same CXXFLAGS in bootstrap workflow"

As discussed in
<https://inbox.sourceware.org/gcc-patches/871qpjtmd8.fsf@euler.schwinge.homeip.net>:

> '-Werror=overloaded-virtual' is implied as by default, we have
> '-Woverloaded-virtual' and '-Werror'.

> '-Wno-unused-parameter' [did] move into
> 'rust-warn'

This reverts #1623 commit b3222881f443f2b09e2dd72699def43d5ae928ba.

2 years ago'rust-warn += -Wno-unused-parameter'
Thomas Schwinge [Sun, 20 Nov 2022 23:01:20 +0000 (00:01 +0100)] 
'rust-warn += -Wno-unused-parameter'

(cherry picked from #1670 commit 7ceb5e29c80c1fc91e208ae6955a22b0b73a2e6b)

2 years agoMerge commit 'b4fddbe9592e9feb37ce567d90af822b75995531' into HEAD
Thomas Schwinge [Tue, 13 Dec 2022 21:44:33 +0000 (22:44 +0100)] 
Merge commit 'b4fddbe9592e9feb37ce567d90af822b75995531' into HEAD

2 years agotree-optimization/108076 - if-conversion and forced labels
Richard Biener [Mon, 12 Dec 2022 16:52:46 +0000 (17:52 +0100)] 
tree-optimization/108076 - if-conversion and forced labels

When doing if-conversion we simply throw away labels without checking
whether they are possibly targets of non-local gotos or have their
address taken.  The following rectifies this and refuses to if-convert
such loops.

PR tree-optimization/108076
* tree-if-conv.cc (if_convertible_loop_p_1): Reject blocks
with non-local or forced labels that we later remove
labels from.

* gcc.dg/torture/pr108076.c: New testcase.

2 years agolibsanitizer: Fix up libbacktrace build after r13-4547 [PR108072]
Jakub Jelinek [Tue, 13 Dec 2022 09:30:36 +0000 (10:30 +0100)] 
libsanitizer: Fix up libbacktrace build after r13-4547 [PR108072]

The r13-4547 commit added new non-static function to libbacktrace:
backtrace_uncompress_zstd but for the libsanitizer use we need to
rename it, so that it is in __asan_* namespace and doesn't clash
with other copies of libbacktrace.

2022-12-13  Jakub Jelinek  <jakub@redhat.com>

libsanitizer/
PR sanitizer/108072
* libbacktrace/backtrace-rename.h (backtrace_uncompress_zstd): Define.

2 years agors6000: enable cbranchcc4
Haochen Gui [Tue, 13 Dec 2022 08:45:10 +0000 (16:45 +0800)] 
rs6000: enable cbranchcc4

This patch enables "have_cbranchcc4" on rs6000 by defining a
"cbranchcc4" expander. "have_cbrnachcc4" is a flag in ifcvt.cc to
indicate if branching by CC bits is valid or not. With this flag
enabled, some branches can be optimized to conditional moves.

2022-12-07  Haochen Gui <guihaoc@linux.ibm.com>

gcc/
* config/rs6000/rs6000.md (cbranchcc4): New expander.

gcc/testsuite
* gcc.target/powerpc/cbranchcc4-1.c: New.
* gcc.target/powerpc/cbranchcc4-2.c: New.

2 years agooptabs: make prepare_cmp_insn goto fail when cbranchcc4 checks unsatisfied
Haochen Gui [Thu, 8 Dec 2022 05:22:29 +0000 (13:22 +0800)] 
optabs: make prepare_cmp_insn goto fail when cbranchcc4 checks unsatisfied

prepare_cmp_insn is a help function to generate comparison rtx.
It should not assume that cbranchcc4 exists and all sub-CC modes
are supported on a target.  When the check fails, it could go to
fail and return a NULL rtx as its callers check the return value
for CCmode.

The test case (gcc.target/powerpc/cbranchcc4-1.c) which covers
failure path will be committed with an rs6000 specific patch.

2022-12-05  Haochen Gui <guihaoc@linux.ibm.com>

gcc/
* optabs.cc (prepare_cmp_insn): Return a NULL rtx other than
assertion failure when targets don't have cbranch optab or
predicate check fails.

2 years agoDaily bump.
GCC Administrator [Tue, 13 Dec 2022 00:18:07 +0000 (00:18 +0000)] 
Daily bump.

2 years agoRevert "c++: build initializer_list<string> in a loop [PR105838]"
Jason Merrill [Mon, 12 Dec 2022 22:41:39 +0000 (17:41 -0500)] 
Revert "c++: build initializer_list<string> in a loop [PR105838]"

This patch broke a couple of different patterns; reverting while I work on a
fix.

PR c++/108701

This reverts commit bd0485f20f4794f9787237706a6308473a8e9415.

2 years agolibgo: bump major version
Ian Lance Taylor [Mon, 12 Dec 2022 20:46:40 +0000 (12:46 -0800)] 
libgo: bump major version

PR go/108057

The current version is the same as for the previous GCC release,
but there have been minor changes like new type descriptors that
make it impossible to run Go programs built with the previous GCC
release with the current libgo.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/456976

2 years agoFortran: improve checking of assumed-size array spec [PR102180]
Harald Anlauf [Sun, 11 Dec 2022 22:24:03 +0000 (23:24 +0100)] 
Fortran: improve checking of assumed-size array spec [PR102180]

gcc/fortran/ChangeLog:

PR fortran/102180
* array.cc (match_array_element_spec): Add check for bad
assumed-implied-spec.
(gfc_match_array_spec): Reorder logic so that the first bad array
element spec may trigger an error.

gcc/testsuite/ChangeLog:

PR fortran/102180
* gfortran.dg/pr102180.f90: New test.

2 years agod: Fix undefined reference to nested lambda in template (PR108055)
Iain Buclaw [Sat, 10 Dec 2022 21:11:41 +0000 (22:11 +0100)] 
d: Fix undefined reference to nested lambda in template (PR108055)

Sometimes, nested lambdas of templated functions get no code generation
due to them being marked as instantianted outside of all modules being
compiled in the current compilation unit.  This despite enclosing
template instances being marked as instantiated inside the current
compilation unit.  To fix, all enclosing templates are now checked in
`function_defined_in_root_p'.

Because of this change, `function_needs_inline_definition_p' has also
been fixed up to only check whether the regular function definition
itself is to be emitted in the current compilation unit.

PR d/108055

gcc/d/ChangeLog:

* decl.cc (function_defined_in_root_p): Check all enclosing template
instances for definition in a root module.
(function_needs_inline_definition_p): Replace call to
function_defined_in_root_p with test for outer module `isRoot'.

gcc/testsuite/ChangeLog:

* gdc.dg/torture/imports/pr108055conv.d: New.
* gdc.dg/torture/imports/pr108055spec.d: New.
* gdc.dg/torture/imports/pr108055write.d: New.
* gdc.dg/torture/pr108055.d: New test.

2 years agoAArch64: Enable TARGET_CONST_ANCHOR
Wilco Dijkstra [Mon, 12 Dec 2022 15:44:03 +0000 (15:44 +0000)] 
AArch64: Enable TARGET_CONST_ANCHOR

Enable TARGET_CONST_ANCHOR to allow complex constants to be created via
immediate add/sub.  Use a 24-bit range as that enables a 3 or 4-instruction
immediate to be replaced by 2 add/sub instructions.  Fix the costing of
add/sub to support 24-bit and 12-bit shifted immediates.
The generated code for the testcase is now the same or better than LLVM.
It also results in a small codesize reduction on SPEC.

gcc/
* config/aarch64/aarch64.cc (aarch64_rtx_costs): Add correct costs
for 24-bit and 12-bit shifted immediate add/sub.
(TARGET_CONST_ANCHOR): Define.
* config/aarch64/predicates.md (aarch64_pluslong_immediate):
Fix range check.

gcc/testsuite/
* gcc.target/aarch64/movk_3.c: New test.

2 years agomiddle-end: simplify complex if expressions where comparisons are inverse of one...
Tamar Christina [Mon, 12 Dec 2022 15:21:39 +0000 (15:21 +0000)] 
middle-end: simplify complex if expressions where comparisons are inverse of one another.

This optimizes the following sequence

  ((a < b) & c) | ((a >= b) & d)

into

  (a < b ? c : d) & 1

for scalar and on vector we can omit the & 1.

Also recognizes

  (-(a < b) & c) | (-(a >= b) & d)

into

  a < b ? c : d

This changes the code generation from

zoo2:
cmp     w0, w1
cset    w0, lt
cset    w1, ge
and     w0, w0, w2
and     w1, w1, w3
orr     w0, w0, w1
ret

into

cmp w0, w1
csel w0, w2, w3, lt
and w0, w0, 1
ret

and significantly reduces the number of selects we have to do in the vector
code.

gcc/ChangeLog:

* match.pd: Add new rule.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/if-compare_1.c: New test.
* gcc.target/aarch64/if-compare_2.c: New test.

2 years agoAArch64: Fix vector re-interpretation between partial SIMD modes
Tamar Christina [Mon, 12 Dec 2022 15:20:30 +0000 (15:20 +0000)] 
AArch64: Fix vector re-interpretation between partial SIMD modes

While writing a patch series I started getting incorrect codegen out from
VEC_PERM on partial struct types.

It turns out that this was happening because the TARGET_CAN_CHANGE_MODE_CLASS
implementation has a slight bug in it.  The hook only checked for SIMD to
Partial but never Partial to SIMD.   This resulted in incorrect subregs to be
generated from the fallback code in VEC_PERM_EXPR expansions.

I have unfortunately not been able to trigger it using a standalone testcase as
the mid-end optimizes away the permute every time I try to describe a permute
that would result in the bug.

The patch now rejects any conversion of partial SIMD struct types, unless they
are both partial structures of the same number of registers or one is a SIMD
type who's size is less than 8 bytes.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_can_change_mode_class): Restrict
conversions between partial struct types properly.

2 years agoAArch64: Support new tbranch optab.
Tamar Christina [Mon, 12 Dec 2022 15:18:56 +0000 (15:18 +0000)] 
AArch64: Support new tbranch optab.

This implements the new tbranch optab for AArch64.

we cannot emit one big RTL for the final instruction immediately.
The reason that all comparisons in the AArch64 backend expand to separate CC
compares, and separate testing of the operands is for ifcvt.

The separate CC compare is needed so ifcvt can produce csel, cset etc from the
compares.  Unlike say combine, ifcvt can not do recog on a parallel with a
clobber.  Should we emit the instruction directly then ifcvt will not be able
to say, make a csel, because we have no patterns which handle zero_extract and
compare. (unlike combine ifcvt cannot transform the extract into an AND).

While you could provide various patterns for this (and I did try) you end up
with broken patterns because you can't add the clobber to the CC register.  If
you do, ifcvt recog fails.

i.e.

int
f1 (int x)
{
  if (x & 1)
    return 1;
  return x;
}

We lose csel here.

Secondly the reason the compare with an explicit CC mode is needed is so that
ifcvt can transform the operation into a version that doesn't require the flags
to be set.  But it only does so if it know the explicit usage of the CC reg.

For instance

int
foo (int a, int b)
{
  return ((a & (1 << 25)) ? 5 : 4);
}

Doesn't require a comparison, the optimal form is:

foo(int, int):
        ubfx    x0, x0, 25, 1
        add     w0, w0, 4
        ret

and no compare is actually needed.  If you represent the instruction using an
ANDS instead of a zero_extract then you get close, but you end up with an ands
followed by an add, which is a slower operation.

gcc/ChangeLog:

* config/aarch64/aarch64.md (*tb<optab><mode>1): Rename to...
(*tb<optab><ALLI:mode><GPI:mode>1): ... this.
(tbranch_<code><mode>4): New.
* config/aarch64/iterators.md(ZEROM, zerom): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/tbz_1.c: New test.

2 years agomiddle-end: Add new tbranch optab to add support for bit-test-and-branch operations
Tamar Christina [Mon, 12 Dec 2022 15:16:50 +0000 (15:16 +0000)] 
middle-end: Add new tbranch optab to add support for bit-test-and-branch operations

This adds a new test-and-branch optab that can be used to do a conditional test
of a bit and branch.   This is similar to the cbranch optab but instead can
test any arbitrary bit inside the register.

This patch recognizes boolean comparisons and single bit mask tests.

gcc/ChangeLog:

* dojump.cc (do_jump): Pass along value.
(do_jump_by_parts_greater_rtx): Likewise.
(do_jump_by_parts_zero_rtx): Likewise.
(do_jump_by_parts_equality_rtx): Likewise.
(do_compare_rtx_and_jump): Likewise.
(do_compare_and_jump): Likewise.
* dojump.h (do_compare_rtx_and_jump): New.
* optabs.cc (emit_cmp_and_jump_insn_1): Refactor to take optab to check.
(validate_test_and_branch): New.
(emit_cmp_and_jump_insns): Optiobally take a value, and when value is
supplied then check if it's suitable for tbranch.
* optabs.def (tbranch_eq$a4, tbranch_ne$a4): New.
* doc/md.texi (tbranch_@var{op}@var{mode}4): Document it.
* optabs.h (emit_cmp_and_jump_insns): New.
* tree.h (tree_zero_one_valued_p): New.

2 years agoaarch64: Make existing V2HF be usable.
Tamar Christina [Mon, 12 Dec 2022 15:15:07 +0000 (15:15 +0000)] 
aarch64: Make existing V2HF be usable.

The backend has an existing V2HFmode that is used by pairwise operations.
This mode was however never made fully functional.  Amongst other things it was
never declared as a vector type which made it unusable from the mid-end.

It's also lacking an implementation for load/stores so reload ICEs if this mode
is every used.  This finishes the implementation by providing the above.

Note that I have created a new iterator VHSDF_P instead of extending VHSDF
because the previous iterator is used in far more things than just load/stores.

It's also used for instance in intrinsics and extending this would force me to
provide support for mangling the type while we never expose it through
intrinsics.

gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (*aarch64_simd_movv2hf): New.
(mov<mode>, movmisalign<mode>, aarch64_dup_lane<mode>,
aarch64_store_lane0<mode>, aarch64_simd_vec_set<mode>,
@aarch64_simd_vec_copy_lane<mode>, vec_set<mode>,
reduc_<optab>_scal_<mode>, reduc_<fmaxmin>_scal_<mode>,
aarch64_reduc_<optab>_internal<mode>, aarch64_get_lane<mode>,
vec_init<mode><Vel>, vec_extract<mode><Vel>): Support V2HF.
(aarch64_simd_dupv2hf): New.
* config/aarch64/aarch64.cc (aarch64_classify_vector_mode):
Add E_V2HFmode.
* config/aarch64/iterators.md (VHSDF_P): New.
(V2F, VMOVE, nunits, Vtype, Vmtype, Vetype, stype, VEL,
Vel, q, vp): Add V2HF.
* config/arm/types.md (neon_fp_reduc_add_h): New.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/slp_1.c: Update testcase.

2 years agolibstdc++: Add a test checking for chrono::duration overflows
Jonathan Wakely [Mon, 12 Dec 2022 12:51:49 +0000 (12:51 +0000)] 
libstdc++: Add a test checking for chrono::duration overflows

This test fails if chrono::days::rep or chrono::years::rep is a 32-bit
type, because a large days or years value silently overflows a 32-bit
integer when converted to seconds. It would be conforming to implement
chrono::days as chrono::duration<int32_t, ratio<86400>>, but would make
this overflow case more likely. Similarly for chrono::years,
chrono::months and chrono::weeks. This test is here to remind us not to
make that change lightly.

libstdc++-v3/ChangeLog:

* testsuite/20_util/duration/arithmetic/overflow_c++20.cc: New
test.

2 years agolibstdc++: Fix constraint on std::basic_format_string [PR108024]
Jonathan Wakely [Mon, 12 Dec 2022 11:40:07 +0000 (11:40 +0000)] 
libstdc++: Fix constraint on std::basic_format_string [PR108024]

Also remove some redundant std::move calls for return statements.

libstdc++-v3/ChangeLog:

PR libstdc++/108024
* include/std/format (basic_format_string): Fix constraint.
* testsuite/std/format/format_string.cc: New test.

2 years agolibstdc++: Change names that clash with Win32 or Clang
Jonathan Wakely [Mon, 12 Dec 2022 11:22:45 +0000 (11:22 +0000)] 
libstdc++: Change names that clash with Win32 or Clang

Clang now defines an __is_unsigned built-in, and Windows defines an
_Out_ macro. Replace uses of those as identifiers.

There might also be a problem with __is_signed, which we use in several
places.

libstdc++-v3/ChangeLog:

* include/std/chrono (hh_mm_ss): Rename __is_unsigned member to
_S_is_unsigned.
* include/std/format (basic_format_context): Rename _Out_
template parameter to _Out2.
* testsuite/17_intro/names.cc: Add Windows SAL annotation
macros.

2 years agolibstdc++: Define atomic lock-free type aliases for C++20 [PR98034]
Jonathan Wakely [Mon, 12 Dec 2022 12:49:40 +0000 (12:49 +0000)] 
libstdc++: Define atomic lock-free type aliases for C++20 [PR98034]

libstdc++-v3/ChangeLog:

PR libstdc++/98034
* include/std/atomic (__cpp_lib_atomic_lock_free_type_aliases):
Define macro.
(atomic_signed_lock_free, atomic_unsigned_lock_free): Define
aliases.
* include/std/version (__cpp_lib_atomic_lock_free_type_aliases):
Define macro.
* testsuite/29_atomics/atomic/lock_free_aliases.cc: New test.

2 years agolibstdc++: Make operator<< for stacktraces less templated (LWG 3515)
Jonathan Wakely [Fri, 9 Dec 2022 14:59:01 +0000 (14:59 +0000)] 
libstdc++: Make operator<< for stacktraces less templated (LWG 3515)

This change was approved for C++23 last month.

libstdc++-v3/ChangeLog:

* include/std/stacktrace (operator<<): Only output to narrow
ostreams (LWG 3515).
* testsuite/19_diagnostics/stacktrace/synopsis.cc:

2 years agomklog: do not parse binary file for PR entry
Martin Liska [Mon, 12 Dec 2022 12:24:25 +0000 (13:24 +0100)] 
mklog: do not parse binary file for PR entry

contrib/ChangeLog:

* mklog.py: Do not search PR entry in a file that is binary.

2 years agoaarch64: Add __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI ACLE defines
Kyrylo Tkachov [Mon, 12 Dec 2022 11:07:45 +0000 (11:07 +0000)] 
aarch64: Add __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI ACLE defines

Recent ACLE additions specified the __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI macros [1] that the compiler
should define when the pointer authentication and BTI instructions are available (and don't act as NOPs).
We've received requests to enable them in GCC for aarch64, similar to clang [2].
It's a fairly simple patch and should be non-intrusive at this stage.
Pointer authentication has its own "pauth" feature flag, whereas BTI depends on an architecture level
of Armv8.5-a or later.

Bootstrapped and tested on aarch64-none-linux-gnu.

[1] https://github.com/ARM-software/acle/blob/main/main/acle.md#pointer-authentication
[2] https://reviews.llvm.org/rG7d40baa82b1f272f68de63f3c4f68d970bdcd6ed

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Define
__ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI when appropriate.
* config/aarch64/aarch64.h (TARGET_BTI): Define.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/bti_def.c: New test.
* gcc.target/aarch64/acle/pauth_def.c: New test.

2 years agoRevert parts of ADDR_EXPR/CONSTRUCTOR treatment change in match.pd
Richard Biener [Mon, 12 Dec 2022 07:56:41 +0000 (08:56 +0100)] 
Revert parts of ADDR_EXPR/CONSTRUCTOR treatment change in match.pd

This reverts the part that substitutes from the definition of an
SSA name to the capture, thus ADDR_EXPR@0 eventually yielding
&y_1->a[i_2] instead of _3.  That's because I didn't think of
how to deal with substituting @0 in the result pattern.  So
the following re-instantiates the SSA def CONSTRUCTOR handling
and in the ADDR_EXPR helpers used by match.pd handles SSA names
defined to ADDR_EXPRs transparently.

* genmatch.cc (dt_simplify::gen): Revert last change.
* match.pd: Revert simplification of CONSTUCTOR leaf handling.
(&x cmp SSA_NAME): Handle ADDR_EXPR in SSA defs.
* fold-const.cc (split_address_to_core_and_offset): Handle
ADDR_EXPRs in SSA defs.
(address_compare): Likewise.

2 years agotree-optimization/89317 - another pattern for &p->x != p + 4
Richard Biener [Mon, 12 Dec 2022 07:13:33 +0000 (08:13 +0100)] 
tree-optimization/89317 - another pattern for &p->x != p + 4

As seen in the original testcase for PR89317 we are missing
comparison simplification patterns for &p->x != p + 4.  Fixed
by making an existing one apply.  To make the pattern apply
during CCP we need to simplify ccp_fold to not use GENERIC
folding of conditions but also use GIMPLE folding.

PR tree-optimization/89317
* tree-ssa-ccp.cc (ccp_fold): Handle GIMPLE_COND via
gimple_fold_stmt_to_constant_1.
* match.pd (&a != &a + c): Apply to pointer_plus with non-ADDR_EXPR
base as well.

* gcc.dg/tree-ssa/pr89317.c: Amend.

2 years agoDaily bump.
GCC Administrator [Mon, 12 Dec 2022 00:22:21 +0000 (00:22 +0000)] 
Daily bump.

2 years agoFortran: fix ICE on bad use of statement function [PR107995]
Steve Kargl [Sat, 10 Dec 2022 21:17:15 +0000 (22:17 +0100)] 
Fortran: fix ICE on bad use of statement function [PR107995]

gcc/fortran/ChangeLog:

PR fortran/107995
* interface.cc (gfc_check_dummy_characteristics): Reject statement
function dummy arguments.

gcc/testsuite/ChangeLog:

PR fortran/107995
* gfortran.dg/pr107995.f90: New test.

2 years agod: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)
Iain Buclaw [Sat, 10 Dec 2022 18:12:43 +0000 (19:12 +0100)] 
d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)

The visitor for lowering IMPORTED_DECLs did not have an override for
dealing with importing OverloadSet symbols.  This has now been
implemented in the code generator.

PR d/108050

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl
returning a TREE_LIST.
* imports.cc (ImportVisitor::visit (OverloadSet *)): New override.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr108050/mod1.d: New.
* gdc.dg/imports/pr108050/mod2.d: New.
* gdc.dg/imports/pr108050/package.d: New.
* gdc.dg/pr108050.d: New test.

2 years agounidiff: use newline='\n' argument
Martin Liska [Sun, 11 Dec 2022 16:18:12 +0000 (17:18 +0100)] 
unidiff: use newline='\n' argument

In order to support CR on a line, we need to open files
with newline='\n' as our line endings supposed to be of UNIX style.

contrib/ChangeLog:

* check_GNU_style.py: Use newline=\n.
* check_GNU_style_lib.py: Simplify.
* gcc-changelog/git_commit.py: Fix issues seen
Rust patchset.
* gcc-changelog/git_email.py: Use newline argument.
* gcc-changelog/test_email.py: New test.
* gcc-changelog/test_patches.txt: New test.
* mklog.py: Use newline argument.

2 years agod: Merge upstream dmd, druntime c8ae4adb2e, phobos 792c8b7c1.
Iain Buclaw [Fri, 9 Dec 2022 17:59:38 +0000 (18:59 +0100)] 
d: Merge upstream dmd, druntime c8ae4adb2e, phobos 792c8b7c1.

D front-end changes:

- Import dmd v2.101.0.
- Deprecate the ability to call `__traits(getAttributes)' on
  overload sets.
- Deprecate non-empty `for' statement increment clause with no
  effect.
- Array literals assigned to `scope' array variables can now be
  allocated on the stack.

D runtime changes:

- Import druntime v2.101.0.

Phobos changes:

- Import phobos v2.101.0.

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd c8ae4adb2e.
* typeinfo.cc (check_typeinfo_type): Update for new front-end
interface.
(TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Remove warning
that toHash() must be declared 'nothrow @safe`.

libphobos/ChangeLog:

* libdruntime/MERGE: Merge upstream druntime c8ae4adb2e.
* src/MERGE: Merge upstream phobos 792c8b7c1.

2 years agod: Expand bsr intrinsic as `clz(arg) ^ (argsize - 1)'
Iain Buclaw [Sat, 10 Dec 2022 16:17:35 +0000 (17:17 +0100)] 
d: Expand bsr intrinsic as `clz(arg) ^ (argsize - 1)'

As well as removing unnecessary casts, this results in less temporaries
being generated during the initial gimple lowering pass.  Otherwise the
code generated is identical to the former intrinsic expansion.

gcc/d/ChangeLog:

* intrinsics.cc (expand_intrinsic_bsf): Fix comment.
(expand_intrinsic_bsr): Use BIT_XOR_EXPR instead of MINUS_EXPR.

2 years agotree-optimization/89317 - missed folding of (p + 4) - &p->d
Richard Biener [Sun, 11 Dec 2022 13:07:34 +0000 (14:07 +0100)] 
tree-optimization/89317 - missed folding of (p + 4) - &p->d

The PR notices we fail to simplify

  a_4 = &x_3(D)->data;
  b_5 = x_3(D) + 16;
  _1 = b_5 - a_4;

together with the enabler handling ADDR_EXPR leafs in separate
stmts in match.pd the suggested patterns work.

PR tree-optimization/89317
* match.pd ((p + b) - &p->c -> b - offsetof(c)): New patterns.

* gcc.dg/tree-ssa/pr89317.c: New testcase.

2 years agoTreat ADDR_EXPR and CONSTRUCTOR as GIMPLE/GENERIC magically
Richard Biener [Sun, 11 Dec 2022 11:32:49 +0000 (12:32 +0100)] 
Treat ADDR_EXPR and CONSTRUCTOR as GIMPLE/GENERIC magically

The following allows to match ADDR_EXPR for both the invariant
&a.b case as well as the &p->d case in a separate definition
transparently.  This also allows to remove the hack we employ
for CONSTRUCTOR which we handle for example with

 (match vec_same_elem_p
  CONSTRUCTOR@0
  (if (TREE_CODE (@0) == SSA_NAME
       && uniform_vector_p (gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0))))))

Note CONSTUCTORs always appear as separate definition in GIMPLE,
but I continue to play safe and ADDR_EXPRs are now matched in
both places where previously ADDR_EXPR@0 would have missed
the &p->x case.

This is a prerequesite for the PR89317 fix.

* genmatch.cc (dt_node::gen_kids): Handle ADDR_EXPR in both
the GENERIC and GIMPLE op position.
(dt_simplify::gen): Capture both GENERIC and GIMPLE op
position for ADDR_EXPR and CONSTRUCTOR.
* match.pd: Simplify CONSTRUCTOR leaf handling.

* gcc.dg/tree-ssa/forwprop-3.c: Adjust.
* g++.dg/tree-ssa/pr31146-2.C: Likewise.

2 years agotree-optimization/106904 - bogus -Wstringopt-overflow with vectors
Richard Biener [Wed, 7 Dec 2022 13:42:24 +0000 (14:42 +0100)] 
tree-optimization/106904 - bogus -Wstringopt-overflow with vectors

The following avoids CSE of &ps->wp to &ps->wp.hwnd confusing
-Wstringopt-overflow by making sure to produce addresses to the
biggest container from vectorization.  For this I introduce
strip_zero_offset_components which turns &ps->wp.hwnd into
&(*ps) and use that to base the vector data references on.
That will also work for addresses with variable components,
alternatively emitting pointer arithmetic via calling
get_inner_reference and gimplifying that would be possible
but likely more intrusive.

This is by no means a complete fix for all of those issues
(avoiding ADDR_EXPRs in favor of pointer arithmetic might be).
Other passes will have similar issues.

In theory that might now cause false negatives.

PR tree-optimization/106904
* tree.h (strip_zero_offset_components): Declare.
* tree.cc (strip_zero_offset_components): Define.
* tree-vect-data-refs.cc (vect_create_addr_base_for_vector_ref):
Strip zero offset components before building the address.

* gcc.dg/Wstringop-overflow-pr106904.c: New testcase.

2 years agofortran/openmp.cc: Remove 's' that slipped in during %<..%> replacement
Tobias Burnus [Sun, 11 Dec 2022 10:47:55 +0000 (11:47 +0100)] 
fortran/openmp.cc: Remove 's' that slipped in during %<..%> replacement

Seemingly, 's' (in VI that's the 's'ubstitute command) appeared verbatim in
a gfc_error message when to doing the '...' to %<...%> replacements in commit
r13-4590-g84f6f8a2a97f88be01e223c9c9dbab801a4f501f

gcc/fortran/
* openmp.cc (gfc_match_omp_context_selector_specification):
Remove spurious 's' in an error message.

2 years agoDaily bump.
GCC Administrator [Sun, 11 Dec 2022 00:17:43 +0000 (00:17 +0000)] 
Daily bump.

2 years agoFortran: reject bad SIZE argument while simplifying ISHFTC [PR106911]
Harald Anlauf [Sat, 10 Dec 2022 21:05:15 +0000 (22:05 +0100)] 
Fortran: reject bad SIZE argument while simplifying ISHFTC [PR106911]

gcc/fortran/ChangeLog:

PR fortran/106911
* simplify.cc (gfc_simplify_ishftc): If the SIZE argument is known
to be outside the allowed range, terminate simplification.

gcc/testsuite/ChangeLog:

PR fortran/106911
* gfortran.dg/pr106911.f90: New test.

2 years agoivopts: Fix IP_END handling for asm goto [PR107997]
Jakub Jelinek [Sat, 10 Dec 2022 15:50:39 +0000 (16:50 +0100)] 
ivopts: Fix IP_END handling for asm goto [PR107997]

The following testcase ICEs, because the latch bb ends with
asm goto which has both fallthrough to the header and one or more labels
in the header too.  In that case there is just a single edge out of the
latch block, but still the asm goto is stmt_ends_bb_p statement, yet
ivopts decides to emit an IV bump at the IP_END position and inserts
it into the same bb as the asm goto after it, which then fails verification
(control flow in the middle of bb).

The following patch fixes it by splitting the latch -> header edge in that
case and inserting into the newly created bb, where split_edge ->
redirect_edge_and_branch is able to deal with this case correctly.

2022-12-10  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/107997
* tree-ssa-loop-ivopts.cc: Include cfganal.h.
(create_new_iv) <case IP_END>: If ip_end_pos bb is non-empty and ends
with a stmt which ends bb, instead of adding iv update after it split
the latch edge and insert iterator into the new latch bb.

* gcc.c-torture/compile/pr107997.c: New test.

2 years agolibgomp: Handle OpenMP's reverse offloads
Tobias Burnus [Sat, 10 Dec 2022 12:42:08 +0000 (13:42 +0100)] 
libgomp: Handle OpenMP's reverse offloads

This commit enabled reverse offload for nvptx such that gomp_target_rev
actually gets called.  And it fills the latter function to do all of
the following: finding the host function to the device func ptr and
copying the arguments to the host, processing the mapping/firstprivate,
calling the host function, copying back the data and freeing as needed.

The data handling is made easier by assuming that all host variables
either existed before (and are in the mapping) or that those are
devices variables not yet available on the host. Thus, the reverse
mapping can do without refcounts etc. Note that the spec disallows
inside a target region device-affecting constructs other than target
plus ancestor device-modifier and it also limits the clauses permitted
on this construct.

For the function addresses, an additional splay tree is used; for
the lookup of mapped variables, the existing splay-tree is used.
Unfortunately, its data structure requires a full walk of the tree;
Additionally, the just mapped variables are recorded in a separate
data structure an extra lookup. While the lookup is slow, assuming
that only few variables get mapped in each reverse offload construct
and that reverse offload is the exception and not performance critical,
this seems to be acceptable.

libgomp/ChangeLog:

* libgomp.h (struct target_mem_desc): Predeclare; move
below after 'reverse_splay_tree_node' and add rev_array
member.
(struct reverse_splay_tree_key_s, reverse_splay_compare): New.
(reverse_splay_tree_node, reverse_splay_tree,
reverse_splay_tree_key): New typedef.
(struct gomp_device_descr): Add mem_map_rev member.
* oacc-host.c (host_dispatch): NULL init .mem_map_rev.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_num_devices): Claim
support for GOMP_REQUIRES_REVERSE_OFFLOAD.
* splay-tree.h (splay_tree_callback_stop): New typedef; like
splay_tree_callback but returning int not void.
(splay_tree_foreach_lazy): Define; like splay_tree_foreach but
taking splay_tree_callback_stop as argument.
* splay-tree.c (splay_tree_foreach_internal_lazy,
splay_tree_foreach_lazy): New; but early exit if callback returns
nonzero.
* target.c: Instatiate splay_tree_c with splay_tree_prefix 'reverse'.
(gomp_map_lookup_rev): New.
(gomp_load_image_to_device): Handle reverse-offload function
lookup table.
(gomp_unload_image_from_device): Free devicep->mem_map_rev.
(struct gomp_splay_tree_rev_lookup_data, gomp_splay_tree_rev_lookup,
gomp_map_rev_lookup, struct cpy_data, gomp_map_cdata_lookup_int,
gomp_map_cdata_lookup): New auxiliary structs and functions for
gomp_target_rev.
(gomp_target_rev): Implement reverse offloading and its mapping.
(gomp_target_init): Init current_device.mem_map_rev.root.
* testsuite/libgomp.fortran/reverse-offload-2.f90: New test.
* testsuite/libgomp.fortran/reverse-offload-3.f90: New test.
* testsuite/libgomp.fortran/reverse-offload-4.f90: New test.
* testsuite/libgomp.fortran/reverse-offload-5.f90: New test.
* testsuite/libgomp.fortran/reverse-offload-5a.f90: New test without
mapping of on-device allocated variables.

2 years agoAdd initial ChangeLogs for modula2.
Gaius Mulley [Sat, 10 Dec 2022 09:10:29 +0000 (09:10 +0000)] 
Add initial ChangeLogs for modula2.

Add initial ChangeLog file in libgm2 and gcc/m2.

ChangeLog:

* libgm2: (New directory).
* libgm2/ChangeLog: (New file).

gcc/ChangeLog:

* m2: (New directory).
* m2/ChangeLog: (New file).

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2 years agoAdd stub 'gcc/rust/ChangeLog'
Thomas Schwinge [Sat, 10 Dec 2022 07:33:22 +0000 (08:33 +0100)] 
Add stub 'gcc/rust/ChangeLog'