[gcc r15-8519] gccrs: add test case to show issue is fixed
https://gcc.gnu.org/g:ead44a5df4e1b20cd2b2dbd73a431a27d7d80cfa commit r15-8519-gead44a5df4e1b20cd2b2dbd73a431a27d7d80cfa Author: Philip Herron Date: Wed Nov 6 11:08:27 2024 + gccrs: add test case to show issue is fixed The original test case 1773 has been moved to a new issue 3242 which is still open and test-case is skipped. The original issue in 1773 is fixed so this will close out that issue Fixes Rust-Gcc#1773 gcc/testsuite/ChangeLog: * rust/compile/issue-1773.rs: new test case * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3242.rs: old test ranamed to match issue. Signed-off-by: Philip Herron Diff: --- gcc/testsuite/rust/compile/issue-1773.rs | 23 +++ gcc/testsuite/rust/compile/issue-3242.rs | 24 gcc/testsuite/rust/compile/nr2/exclude | 1 + 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/gcc/testsuite/rust/compile/issue-1773.rs b/gcc/testsuite/rust/compile/issue-1773.rs index 468497a4792e..41c82f01b6dd 100644 --- a/gcc/testsuite/rust/compile/issue-1773.rs +++ b/gcc/testsuite/rust/compile/issue-1773.rs @@ -1,8 +1,4 @@ -#[lang = "sized"] -// { dg-skip-if "" { *-*-* } } -pub trait Sized {} - -trait Foo { +trait Foo { type A; fn test(a: Self::A) -> Self::A { @@ -10,9 +6,14 @@ trait Foo { } } -struct Bar(T); -impl Foo for Bar { -type A = T; +struct Bar(i32); +impl Foo for Bar { +type A = i32; +} + +struct Baz(f32); +impl Foo for Baz { +type A = f32; } fn main() { @@ -21,4 +22,10 @@ fn main() { let b; b = Bar::test(a.0); + +let c; +c = Baz(123f32); + +let d; +d = Baz::test(c.0); } diff --git a/gcc/testsuite/rust/compile/issue-3242.rs b/gcc/testsuite/rust/compile/issue-3242.rs new file mode 100644 index ..468497a4792e --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3242.rs @@ -0,0 +1,24 @@ +#[lang = "sized"] +// { dg-skip-if "" { *-*-* } } +pub trait Sized {} + +trait Foo { +type A; + +fn test(a: Self::A) -> Self::A { +a +} +} + +struct Bar(T); +impl Foo for Bar { +type A = T; +} + +fn main() { +let a; +a = Bar(123); + +let b; +b = Bar::test(a.0); +} diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 6f8187264aae..efee0fd1e2dd 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -216,4 +216,5 @@ issue-3009.rs issue-2323.rs issue-2953-1.rs issue-2953-2.rs +issue-1773.rs # please don't delete the trailing newline
[gcc r15-8571] gccrs: lang-item: Remove unused NodeId from LangItemPath
https://gcc.gnu.org/g:eacbbac93a49e144859d2c6510ed231e428d3ba4 commit r15-8571-geacbbac93a49e144859d2c6510ed231e428d3ba4 Author: Arthur Cohen Date: Fri Nov 29 13:44:59 2024 +0100 gccrs: lang-item: Remove unused NodeId from LangItemPath gcc/rust/ChangeLog: * ast/rust-path.h: Adapt children of Path to fix some NodeId issues. Diff: --- gcc/rust/ast/rust-path.h | 76 +++- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index bece60f95edd..563ad52a9d6d 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -599,9 +599,6 @@ public: return Pattern::Kind::Path; } - location_t get_locus () const override { return locus; } - NodeId get_node_id () const override { return node_id; } - std::unique_ptr clone_path () { return std::unique_ptr (clone_path_impl ()); @@ -613,22 +610,19 @@ public: } protected: - location_t locus; - NodeId node_id; - - Path (location_t locus, NodeId node_id) : locus (locus), node_id (node_id) {} - virtual Path *clone_path_impl () const = 0; }; class RegularPath : public Path { std::vector segments; + NodeId node_id; + location_t locus; public: explicit RegularPath (std::vector &&segments, location_t locus, NodeId node_id) -: Path (locus, node_id), segments (std::move (segments)) +: segments (std::move (segments)), node_id (node_id), locus (locus) {} std::string as_string () const override; @@ -657,17 +651,25 @@ public: return new RegularPath (std::vector (segments), locus, node_id); } + + NodeId get_node_id () const override { return node_id; } + location_t get_locus () const override { return locus; } }; class LangItemPath : public Path { - NodeId lang_item; - LangItem::Kind kind; + NodeId node_id; + location_t locus; + + LangItemPath (LangItem::Kind kind, NodeId node_id, location_t locus) +: kind (kind), node_id (node_id), locus (locus) + {} public: explicit LangItemPath (LangItem::Kind kind, location_t locus) -: Path (locus, Analysis::Mappings::get ().get_next_node_id ()), kind (kind) +: kind (kind), node_id (Analysis::Mappings::get ().get_next_node_id ()), + locus (locus) {} Path::Kind get_path_kind () const override { return Path::Kind::LangItem; } @@ -676,12 +678,15 @@ public: Path *clone_path_impl () const override { -return new LangItemPath (kind, locus); +return new LangItemPath (kind, node_id, locus); } std::string as_string () const override; LangItem::Kind get_lang_item_kind () { return kind; } + + NodeId get_node_id () const override { return node_id; } + location_t get_locus () const override { return locus; } }; /* AST node representing a path-in-expression pattern (path that allows @@ -739,11 +744,10 @@ public: // Returns whether path in expression is in an error state. bool is_error () const { -// FIXME: Cleanup if (path->get_path_kind () == Path::Kind::Regular) return !static_cast (*path).has_segments (); -return false; +rust_unreachable (); } /* Converts PathInExpression to SimplePath if possible (i.e. no generic @@ -822,7 +826,7 @@ public: if (path->get_path_kind () == Path::Kind::Regular) return static_cast (*path).get_segments ().size () == 1; -return false; +rust_unreachable (); } Pattern::Kind get_pattern_kind () override { return Pattern::Kind::Path; } @@ -1201,17 +1205,13 @@ public: } }; -// Path used inside types class TypePath : public TypeNoBounds, public Path { bool has_opening_scope_resolution; std::vector > segments; + location_t locus; protected: - Kind get_path_kind () const override { return Kind::Type; } - - Path *clone_path_impl () const override { return new TypePath (*this); } - /* Use covariance to implement clone function as returning this object * rather than base */ TypePath *clone_type_no_bounds_impl () const override @@ -1234,23 +1234,23 @@ public: static TypePath create_error () { return TypePath (std::vector > (), -UNKNOWN_LOCATION); +UNDEF_LOCATION); } // Constructor TypePath (std::vector > segments, location_t locus, bool has_opening_scope_resolution = false) : TypeNoBounds (), - Path (locus, Analysis::Mappings::get ().get_next_node_id ()), has_opening_scope_resolution (has_opening_scope_resolution), - segments (std::move (segments)) + segments (std::move (segments)), locus (locus) {} // Copy constructor with vector clone TypePath (TypePath const &other) -: Path (other.locus, other.Path::get_node_id ()), - has_opening_scope_resolution (other.has_opening_scope_resolution) +: has_opening_scope_resolution (other.has_opening_scope_resolution), + locus (o
[gcc r15-8532] gccrs: Refactor optional initializers
https://gcc.gnu.org/g:45d4f73b81dcd26df03e5e210a1f50803d1d4733 commit r15-8532-g45d4f73b81dcd26df03e5e210a1f50803d1d4733 Author: Pierre-Emmanuel Patry Date: Tue Nov 19 17:24:59 2024 +0100 gccrs: Refactor optional initializers Refactor some optional initializer in the lowering stage to make them more readable. gcc/rust/ChangeLog: * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Change the ternary expression with a more readable if. Signed-off-by: Pierre-Emmanuel Patry Diff: --- gcc/rust/hir/rust-ast-lower-stmt.cc | 20 +++- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower-stmt.cc b/gcc/rust/hir/rust-ast-lower-stmt.cc index 5a825fd11390..8244e8ae2ba4 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.cc +++ b/gcc/rust/hir/rust-ast-lower-stmt.cc @@ -70,15 +70,17 @@ ASTLoweringStmt::visit (AST::LetStmt &stmt) HIR::Pattern *variables = ASTLoweringPattern::translate (stmt.get_pattern (), true); - auto type -= stmt.has_type () ? tl::optional> ( - std::unique_ptr (ASTLoweringType::translate (stmt.get_type ( - : tl::nullopt; - auto init_expression -= stmt.has_init_expr () - ? tl::optional> (std::unique_ptr ( - ASTLoweringExpr::translate (stmt.get_init_expr ( - : tl::nullopt; + tl::optional> type = tl::nullopt; + + if (stmt.has_type ()) +type + = std::unique_ptr (ASTLoweringType::translate (stmt.get_type ())); + + tl::optional> init_expression = tl::nullopt; + + if (stmt.has_init_expr ()) +init_expression = std::unique_ptr ( + ASTLoweringExpr::translate (stmt.get_init_expr ())); auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (),
[gcc r15-8607] gccrs: improve mutability checks
https://gcc.gnu.org/g:770ca551cf9c591ba195e6c12c8a24948d5b289b commit r15-8607-g770ca551cf9c591ba195e6c12c8a24948d5b289b Author: Philip Herron Date: Mon Dec 16 14:51:17 2024 + gccrs: improve mutability checks This ensures that we handle var decls readonly checks much better Addresses: Rust-GCC#807 Rust-GCC#3287 gcc/rust/ChangeLog: * checks/errors/rust-readonly-check.cc (check_decl): improve mut check (emit_error): helper (check_modify_expr): likewise (readonly_walk_fn): reuse helper (ReadonlyCheck::Lint): cleanup context each run gcc/testsuite/ChangeLog: * rust/execute/torture/builtin_macro_include_bytes.rs: needs mut * rust/compile/mutability_checks1.rs: New test. Signed-off-by: Philip Herron Diff: --- gcc/rust/checks/errors/rust-readonly-check.cc | 54 ++ gcc/testsuite/rust/compile/mutability_checks1.rs | 15 ++ .../execute/torture/builtin_macro_include_bytes.rs | 2 +- 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/gcc/rust/checks/errors/rust-readonly-check.cc b/gcc/rust/checks/errors/rust-readonly-check.cc index b8998985d89c..c12893321169 100644 --- a/gcc/rust/checks/errors/rust-readonly-check.cc +++ b/gcc/rust/checks/errors/rust-readonly-check.cc @@ -19,10 +19,13 @@ #include "rust-readonly-check.h" #include "rust-tree.h" #include "rust-gcc.h" +#include "print-tree.h" namespace Rust { namespace Analysis { +static std::map assignment_map = {}; + // ported over from c-family/c-warn.cc void readonly_error (location_t loc, tree arg, enum lvalue_use use) @@ -106,37 +109,68 @@ readonly_error (location_t loc, tree arg, enum lvalue_use use) } static void -check_decl (tree *t) +emit_error (tree *t, tree lhs, enum lvalue_use use) { - if (TREE_CODE (*t) == MODIFY_EXPR) + readonly_error (EXPR_LOCATION (*t), lhs, use); + TREE_OPERAND (*t, 0) = error_mark_node; +} + +static void +check_modify_expr (tree *t) +{ + tree lhs = TREE_OPERAND (*t, 0); + if (TREE_CODE (lhs) == ARRAY_REF || TREE_CODE (lhs) == COMPONENT_REF) +lhs = TREE_OPERAND (lhs, 0); + + tree lhs_type = TREE_TYPE (lhs); + if (TYPE_READONLY (lhs_type) || TREE_READONLY (lhs) || TREE_CONSTANT (lhs)) { - tree lhs = TREE_OPERAND (*t, 0); - if (TREE_READONLY (lhs) || TREE_CONSTANT (lhs)) + if (TREE_CODE (lhs) != VAR_DECL) + emit_error (t, lhs, lv_assign); + else if (!DECL_ARTIFICIAL (lhs)) { - readonly_error (EXPR_LOCATION (*t), lhs, lv_assign); - TREE_OPERAND (*t, 0) = error_mark_node; + if (DECL_INITIAL (lhs) != NULL) + emit_error (t, lhs, lv_assign); + else + { + if (assignment_map.find (lhs) == assignment_map.end ()) + { + assignment_map.insert ({lhs, 0}); + } + assignment_map[lhs]++; + + if (assignment_map[lhs] > 1) + emit_error (t, lhs, lv_assign); + } } } } -static tree -readonly_walk_fn (tree *t, int *, void *) +static void +check_decl (tree *t) { switch (TREE_CODE (*t)) { case MODIFY_EXPR: - check_decl (t); + check_modify_expr (t); break; default: break; } +} + +static tree +readonly_walk_fn (tree *t, int *, void *) +{ + check_decl (t); return NULL_TREE; } void ReadonlyCheck::Lint (Compile::Context &ctx) { + assignment_map.clear (); for (auto &fndecl : ctx.get_func_decls ()) { for (tree p = DECL_ARGUMENTS (fndecl); p != NULL_TREE; p = DECL_CHAIN (p)) @@ -148,12 +182,14 @@ ReadonlyCheck::Lint (Compile::Context &ctx) &readonly_walk_fn, &ctx); } + assignment_map.clear (); for (auto &var : ctx.get_var_decls ()) { tree decl = var->get_decl (); check_decl (&decl); } + assignment_map.clear (); for (auto &const_decl : ctx.get_const_decls ()) { check_decl (&const_decl); diff --git a/gcc/testsuite/rust/compile/mutability_checks1.rs b/gcc/testsuite/rust/compile/mutability_checks1.rs new file mode 100644 index ..4affae030534 --- /dev/null +++ b/gcc/testsuite/rust/compile/mutability_checks1.rs @@ -0,0 +1,15 @@ +pub fn test() { +let a; +a = 1; +a = 2 + 1; +// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } + +struct Foo(i32); +let a = Foo(1); +a.0 = 2; +// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } + +let a = [1, 2, 3, 4]; +a[0] = 1 + 2; +// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } +} diff --git a/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs b/gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs index 6aec417e94f1..c8a2daeccd9b 100644 --- a/gcc/testsuite/rust/execute/torture/builtin_macro_inc
[gcc r15-8665] libphobos: Add module declaration to rt.invariant
https://gcc.gnu.org/g:499c58f443e97198c30776f54bc57ea2af48245d commit r15-8665-g499c58f443e97198c30776f54bc57ea2af48245d Author: Iain Buclaw Date: Sat Mar 22 10:26:47 2025 +0100 libphobos: Add module declaration to rt.invariant This prevents conflicts with a user-provided `invariant.d' module. gcc/d/ChangeLog: * runtime.def (INVARIANT): Update signature of run-time function. libphobos/ChangeLog: * libdruntime/Makefile.am (DRUNTIME_DSOURCES): Rename rt/invariant.d to rt/invariant_.d. * libdruntime/Makefile.in: Regenerate. * libdruntime/rt/invariant.d: Move to... * libdruntime/rt/invariant_.d: ...here. Diff: --- gcc/d/runtime.def | 4 ++-- libphobos/libdruntime/Makefile.am | 2 +- libphobos/libdruntime/Makefile.in | 6 +++--- libphobos/libdruntime/rt/{invariant.d => invariant_.d} | 9 ++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/gcc/d/runtime.def b/gcc/d/runtime.def index e4261946e00b..4aff0a6e16a5 100644 --- a/gcc/d/runtime.def +++ b/gcc/d/runtime.def @@ -142,8 +142,8 @@ DEF_D_RUNTIME (CXA_END_CATCH, "__cxa_end_catch", RT(VOID), P0(), 0) /* When invariant() contracts are turned on, used after testing whether a class != null for validating the state of a class. */ -DEF_D_RUNTIME (INVARIANT, "_D9invariant12_d_invariantFC6ObjectZv", RT(VOID), - P1(OBJECT), 0) +DEF_D_RUNTIME (INVARIANT, "_D2rt10invariant_12_d_invariantFC6ObjectZv", + RT(VOID), P1(OBJECT), 0) #undef P0 #undef P1 diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am index 595e3f974c0c..252c6a3eebbc 100644 --- a/libphobos/libdruntime/Makefile.am +++ b/libphobos/libdruntime/Makefile.am @@ -222,7 +222,7 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \ gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \ rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arraycat.d rt/cast_.d \ rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \ - rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ + rt/invariant_.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \ rt/util/utility.d diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in index 4832fd15c408..52b0c377241e 100644 --- a/libphobos/libdruntime/Makefile.in +++ b/libphobos/libdruntime/Makefile.in @@ -248,7 +248,7 @@ am__objects_1 = core/atomic.lo core/attribute.lo core/bitop.lo \ gcc/unwind/generic.lo gcc/unwind/package.lo gcc/unwind/pe.lo \ object.lo rt/aApply.lo rt/aApplyR.lo rt/aaA.lo rt/adi.lo \ rt/arraycat.lo rt/cast_.lo rt/config.lo rt/critical_.lo \ - rt/deh.lo rt/dmain2.lo rt/ehalloc.lo rt/invariant.lo \ + rt/deh.lo rt/dmain2.lo rt/ehalloc.lo rt/invariant_.lo \ rt/lifetime.lo rt/memory.lo rt/minfo.lo rt/monitor_.lo \ rt/profilegc.lo rt/sections.lo rt/tlsgc.lo rt/util/typeinfo.lo \ rt/util/utility.lo @@ -903,7 +903,7 @@ DRUNTIME_DSOURCES = core/atomic.d core/attribute.d core/bitop.d \ gcc/unwind/generic.d gcc/unwind/package.d gcc/unwind/pe.d object.d \ rt/aApply.d rt/aApplyR.d rt/aaA.d rt/adi.d rt/arraycat.d rt/cast_.d \ rt/config.d rt/critical_.d rt/deh.d rt/dmain2.d rt/ehalloc.d \ - rt/invariant.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ + rt/invariant_.d rt/lifetime.d rt/memory.d rt/minfo.d rt/monitor_.d \ rt/profilegc.d rt/sections.d rt/tlsgc.d rt/util/typeinfo.d \ rt/util/utility.d @@ -1413,7 +1413,7 @@ rt/critical_.lo: rt/$(am__dirstamp) rt/deh.lo: rt/$(am__dirstamp) rt/dmain2.lo: rt/$(am__dirstamp) rt/ehalloc.lo: rt/$(am__dirstamp) -rt/invariant.lo: rt/$(am__dirstamp) +rt/invariant_.lo: rt/$(am__dirstamp) rt/lifetime.lo: rt/$(am__dirstamp) rt/memory.lo: rt/$(am__dirstamp) rt/minfo.lo: rt/$(am__dirstamp) diff --git a/libphobos/libdruntime/rt/invariant.d b/libphobos/libdruntime/rt/invariant_.d similarity index 70% rename from libphobos/libdruntime/rt/invariant.d rename to libphobos/libdruntime/rt/invariant_.d index e536196e8c8f..2a64dc89da6c 100644 --- a/libphobos/libdruntime/rt/invariant.d +++ b/libphobos/libdruntime/rt/invariant_.d @@ -4,15 +4,10 @@ * Copyright: Copyright Digital Mars 2007 - 2010. * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). * Authors: Walter Bright - * Source: $(DRUNTIMESRC rt/_invariant.d) - */ - -/* Copyright Digital Mars 2007 - 2010. - * Distributed under the Boost Software License, Version 1.0. - *(See accompanying file LICENSE or copy at - * http://www.boost.org/LICENSE_1_0.txt) + * Source: $(DRUNTIMESRC rt/_invariant_.d) */ +module rt.invariant_; /** *
[gcc r15-8668] d: Improve UFCS/property error message
https://gcc.gnu.org/g:33a428f966d6583d47524a5274f519d4490d0e01 commit r15-8668-g33a428f966d6583d47524a5274f519d4490d0e01 Author: Iain Buclaw Date: Sat Mar 22 10:49:06 2025 +0100 d: Improve UFCS/property error message Improves on the speller suggestions for UFCS by using the location of the suggested symbol, and considering that local functions aren't eligible for UFCS instead of making a nonsensical suggestion, such as "no property foo, did you mean foo?". gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 9d2f034398. Reviewed-on: https://github.com/dlang/dmd/pull/21046 Diff: --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/typesem.d | 14 +++-- gcc/testsuite/gdc.test/fail_compilation/fail347.d | 4 +-- gcc/testsuite/gdc.test/fail_compilation/ufcs.d| 36 ++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 9982d0dd83ef..0b554f126a6d 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -94950cae582d89f5ba2720786522f669f620f9d1 +9d2f034398c33be1a28d8c60721014a6ab34d652 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/typesem.d b/gcc/d/dmd/typesem.d index 65bad387ef80..c5a3b83379a9 100644 --- a/gcc/d/dmd/typesem.d +++ b/gcc/d/dmd/typesem.d @@ -3444,8 +3444,16 @@ Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int fla auto s2 = scope_.search_correct(ident); // UFCS if (s2 && s2.isFuncDeclaration) -errorSupplemental(loc, "did you mean %s `%s`?", -s2.kind(), s2.toChars()); +{ +if (s2.ident == ident) +{ +errorSupplemental(s2.loc, "cannot call %s `%s` with UFCS because it is not declared at module scope", +s2.kind(), s2.toChars()); +} +else +errorSupplemental(s2.loc, "did you mean %s `%s`?", +s2.kind(), s2.toChars()); +} else if (src.type.ty == Tpointer) { // structPtr.field @@ -3454,7 +3462,7 @@ Expression getProperty(Type t, Scope* scope_, Loc loc, Identifier ident, int fla { if (auto s3 = as.search_correct(ident)) { -errorSupplemental(loc, "did you mean %s `%s`?", +errorSupplemental(s3.loc, "did you mean %s `%s`?", s3.kind(), s3.toChars()); } } diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail347.d b/gcc/testsuite/gdc.test/fail_compilation/fail347.d index e495ba257e35..c56acf5642cd 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/fail347.d +++ b/gcc/testsuite/gdc.test/fail_compilation/fail347.d @@ -5,10 +5,10 @@ TEST_OUTPUT: fail_compilation/fail347.d(26): Error: undefined identifier `bbr`, did you mean variable `bar`? fail_compilation/fail347.d(27): Error: no property `ofo` for type `S`, did you mean `fail347.S.foo`? fail_compilation/fail347.d(29): Error: no property `fool` for `sp` of type `fail347.S*` -fail_compilation/fail347.d(29):did you mean variable `foo`? +fail_compilation/fail347.d(20):did you mean variable `foo`? fail_compilation/fail347.d(30): Error: undefined identifier `strlenx`, did you mean function `strlen`? fail_compilation/fail347.d(31): Error: no property `strlenx` for `"hello"` of type `string` -fail_compilation/fail347.d(31):did you mean function `strlen`? +fail_compilation/imports/fail347a.d(3):did you mean function `strlen`? --- */ diff --git a/gcc/testsuite/gdc.test/fail_compilation/ufcs.d b/gcc/testsuite/gdc.test/fail_compilation/ufcs.d index 3a92a691e2f4..87efbcf65c9e 100644 --- a/gcc/testsuite/gdc.test/fail_compilation/ufcs.d +++ b/gcc/testsuite/gdc.test/fail_compilation/ufcs.d @@ -1,23 +1,28 @@ /* TEST_OUTPUT: --- -fail_compilation/ufcs.d(26): Error: no property `regularF` for `s` of type `S` -fail_compilation/ufcs.d(26):the following error occured while looking for a UFCS match -fail_compilation/ufcs.d(26): Error: function `regularF` is not callable using argument types `(S)` -fail_compilation/ufcs.d(26):expected 0 argument(s), not 1 -fail_compilation/ufcs.d(31):`ufcs.regularF()` declared here -fail_compilation/ufcs.d(27): Error: no property `templateF` for `s` of type `S` -fail_compilation/ufcs.d(27):the following error occured while looking for a UFCS match -fail_compilation/ufcs.d(27): Error: template `templateF` is not callable using argument types `!()(S)` -fail_compilation/ufcs.d(32):
[gcc r15-8664] libphobos: Fix IEEE typo in std.numeric link
https://gcc.gnu.org/g:e6ff1dc191f2dc6fd96d755fdc18fcbaade56e12 commit r15-8664-ge6ff1dc191f2dc6fd96d755fdc18fcbaade56e12 Author: Iain Buclaw Date: Sat Mar 22 10:15:09 2025 +0100 libphobos: Fix IEEE typo in std.numeric link libphobos/ChangeLog: * src/MERGE: Merge upstream phobos d4c9efef1. Reviewed-on: https://github.com/dlang/phobos/pull/10700 Diff: --- libphobos/src/MERGE | 2 +- libphobos/src/std/numeric.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE index a4888fc96180..7eb4c35ff842 100644 --- a/libphobos/src/MERGE +++ b/libphobos/src/MERGE @@ -1,4 +1,4 @@ -79cbde1ab69bae9372f310d663edfc43166095e3 +d4c9efef156385204d382cd941dc58bb750d7141 The first line of this file holds the git revision number of the last merge done from the dlang/phobos repository. diff --git a/libphobos/src/std/numeric.d b/libphobos/src/std/numeric.d index 9966b1ce77fc..918984fd52ee 100644 --- a/libphobos/src/std/numeric.d +++ b/libphobos/src/std/numeric.d @@ -37,7 +37,7 @@ public enum CustomFloatFlags * Store values in normalized form by default. The actual precision of the * significand is extended by 1 bit by assuming an implicit leading bit of 1 * instead of 0. i.e. `1.` instead of `0.`. - * True for all $(LINK2 https://en.wikipedia.org/wiki/IEEE_floating_point, IEE754) types + * True for all $(LINK2 https://en.wikipedia.org/wiki/IEEE_floating_point, IEEE754) types */ storeNormalized = 2,
[gcc r15-8669] d: Bump front-end language version to v2.111.0-rc.1.
https://gcc.gnu.org/g:a6cb7e917b1f7aa1c3ab44a62bcb7f5d81fc79e4 commit r15-8669-ga6cb7e917b1f7aa1c3ab44a62bcb7f5d81fc79e4 Author: Iain Buclaw Date: Sat Mar 22 10:54:10 2025 +0100 d: Bump front-end language version to v2.111.0-rc.1. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 032e24446b. * dmd/VERSION: Bump version to v2.111.0-rc.1. Diff: --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/VERSION | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 0b554f126a6d..116074932aed 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -9d2f034398c33be1a28d8c60721014a6ab34d652 +032e24446b3d8c6cfe3043d62534d5ce6d004c34 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/VERSION b/gcc/d/dmd/VERSION index 2f668e5056b6..0172d7d7add4 100644 --- a/gcc/d/dmd/VERSION +++ b/gcc/d/dmd/VERSION @@ -1 +1 @@ -v2.111.0-beta.1 +v2.111.0-rc.1
[gcc r15-8666] d: Indexing a cast(AA) yields no lvalue anymore
https://gcc.gnu.org/g:76df0e069f6c8ba5aa93ae10606ba61fa990883c commit r15-8666-g76df0e069f6c8ba5aa93ae10606ba61fa990883c Author: Iain Buclaw Date: Sat Mar 22 10:33:24 2025 +0100 d: Indexing a cast(AA) yields no lvalue anymore gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 8db14cf846. Reviewed-on: https://github.com/dlang/dmd/pull/21029 Diff: --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/expression.d | 1 + gcc/testsuite/gdc.test/runnable/test21020.d | 11 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 1be4da416f45..f274580f2d60 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -fde0f8c40a1b8eb78c3485cb0e940035bfe6fb00 +8db14cf8467ca25256904d51169b176c9c89afb1 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/expression.d b/gcc/d/dmd/expression.d index ef5c0b09eb45..4bf1f9f25f86 100644 --- a/gcc/d/dmd/expression.d +++ b/gcc/d/dmd/expression.d @@ -3632,6 +3632,7 @@ extern (C++) final class CastExp : UnaExp if (rvalue || !e1.isLvalue()) return false; return (to.ty == Tsarray && (e1.type.ty == Tvector || e1.type.ty == Tsarray)) || +(to.ty == Taarray && e1.type.ty == Taarray) || e1.type.mutableOf.unSharedOf().equals(to.mutableOf().unSharedOf()); } diff --git a/gcc/testsuite/gdc.test/runnable/test21020.d b/gcc/testsuite/gdc.test/runnable/test21020.d new file mode 100644 index ..484db30a56cd --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/test21020.d @@ -0,0 +1,11 @@ +// https://github.com/dlang/dmd/issues/21020 + +shared struct Queue { +int[int] map; +} + +void main() { +auto queue = Queue(); +(cast(int[int]) queue.map)[1] = 2; +assert(queue.map[1] == 2); +}
[gcc r15-8563] gccrs: Fix ForeverStack::find_starting_point output parameter
https://gcc.gnu.org/g:588ded8766e16fe2e9c2a657935cde519dad454e commit r15-8563-g588ded8766e16fe2e9c2a657935cde519dad454e Author: Owen Avery Date: Mon Nov 11 16:04:58 2024 -0500 gccrs: Fix ForeverStack::find_starting_point output parameter gcc/rust/ChangeLog: * resolve/rust-forever-stack.h (ForeverStack::find_starting_point): Use type 'std::reference_wrapper &' instead of 'Node &' for parameter starting_point. * resolve/rust-forever-stack.hxx (ForeverStack::find_starting_point): Likewise. (ForeverStack::resolve_path): Handle change to ForeverStack::find_starting_point. Signed-off-by: Owen Avery Diff: --- gcc/rust/resolve/rust-forever-stack.h | 3 ++- gcc/rust/resolve/rust-forever-stack.hxx | 13 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gcc/rust/resolve/rust-forever-stack.h b/gcc/rust/resolve/rust-forever-stack.h index c548eeae0879..064d1ab2bb3a 100644 --- a/gcc/rust/resolve/rust-forever-stack.h +++ b/gcc/rust/resolve/rust-forever-stack.h @@ -614,7 +614,8 @@ private: template tl::optional> - find_starting_point (const std::vector &segments, Node &starting_point); + find_starting_point (const std::vector &segments, + std::reference_wrapper &starting_point); template tl::optional resolve_segments (Node &starting_point, diff --git a/gcc/rust/resolve/rust-forever-stack.hxx b/gcc/rust/resolve/rust-forever-stack.hxx index 58164a4d3285..d3d78894671a 100644 --- a/gcc/rust/resolve/rust-forever-stack.hxx +++ b/gcc/rust/resolve/rust-forever-stack.hxx @@ -374,8 +374,8 @@ check_leading_kw_at_start (const S &segment, bool condition) template template tl::optional::const_iterator> -ForeverStack::find_starting_point (const std::vector &segments, - Node &starting_point) +ForeverStack::find_starting_point ( + const std::vector &segments, std::reference_wrapper &starting_point) { auto iterator = segments.begin (); @@ -412,14 +412,15 @@ ForeverStack::find_starting_point (const std::vector &segments, } if (seg.is_super_path_seg ()) { - if (starting_point.is_root ()) + if (starting_point.get ().is_root ()) { rust_error_at (seg.get_locus (), ErrorCode::E0433, "too many leading % keywords"); return tl::nullopt; } - starting_point = find_closest_module (starting_point.parent.value ()); + starting_point + = find_closest_module (starting_point.get ().parent.value ()); continue; } @@ -494,12 +495,12 @@ ForeverStack::resolve_path (const std::vector &segments) if (segments.size () == 1) return get (segments.back ().as_string ()); - auto starting_point = cursor (); + std::reference_wrapper starting_point = cursor (); return find_starting_point (segments, starting_point) .and_then ([this, &segments, &starting_point] ( typename std::vector::const_iterator iterator) { - return resolve_segments (starting_point, segments, iterator); + return resolve_segments (starting_point.get (), segments, iterator); }) .and_then ([&segments] (Node final_node) { return final_node.rib.get (segments.back ().as_string ());
[gcc r15-8671] c++: structural equality and partially inst typedef [PR119379]
https://gcc.gnu.org/g:df5fa3a3d0d7f2413c832548c88f76dfe67802fd commit r15-8671-gdf5fa3a3d0d7f2413c832548c88f76dfe67802fd Author: Patrick Palka Date: Sat Mar 22 10:15:52 2025 -0400 c++: structural equality and partially inst typedef [PR119379] Complex alias templates (and their dependent specializations) always use structural equality because we need to treat them as transparent in some contexts but not others. Structural-ness however wasn't being preserved during partial instantiation, which for the below testcase leads to the checking ICE same canonical type node for different types 'S::P' and 'pair' when comparing those two types with comparing_dependent_aliases set (from alias_ctad_tweaks). This patch fixes this by making us preserve structural-ness for partially instantiated typedefs in general. PR c++/119379 gcc/cp/ChangeLog: * pt.cc (tsubst_decl) : Preserve structural-ness of a partially instantiated typedef. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias24.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/cp/pt.cc | 5 + gcc/testsuite/g++.dg/cpp2a/class-deduction-alias24.C | 16 2 files changed, 21 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 538ff220d745..39c0ee610bbd 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -15920,6 +15920,11 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain, if (TYPE_USER_ALIGN (TREE_TYPE (t))) TREE_TYPE (r) = build_aligned_type (TREE_TYPE (r), TYPE_ALIGN (TREE_TYPE (t))); + + /* Preserve structural-ness of a partially instantiated typedef. */ + if (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (t)) + && dependent_type_p (TREE_TYPE (r))) + SET_TYPE_STRUCTURAL_EQUALITY (TREE_TYPE (r)); } layout_decl (r, 0); diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias24.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias24.C new file mode 100644 index ..cceddac0359f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias24.C @@ -0,0 +1,16 @@ +// PR c++/119379 +// { dg-do compile { target c++20 } } + +template +struct pair { + pair(T, U); +}; + +template +struct S { + template requires true + using P = pair; +}; + +using type = decltype(S::P(1, 2)); +using type = S::P;
[gcc r15-8594] gccrs: fix ICE during HIR dump
https://gcc.gnu.org/g:b0563bb8a5279719360027e3ca0305fde730e5e0 commit r15-8594-gb0563bb8a5279719360027e3ca0305fde730e5e0 Author: Philip Herron Date: Mon Jan 6 11:02:51 2025 + gccrs: fix ICE during HIR dump These hir nodes have optional expressions which need guarded gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::do_qualifiedpathtype): add guard (Dump::do_traitfunctiondecl): likewise (Dump::visit): likewise Signed-off-by: Philip Herron Diff: --- gcc/rust/hir/rust-hir-dump.cc | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 2590eed19ae8..5acf53e9296f 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -404,7 +404,8 @@ Dump::do_qualifiedpathtype (QualifiedPathType &e) do_mappings (e.get_mappings ()); visit_field ("type", e.get_type ()); - visit_field ("trait", e.get_trait ()); + if (e.has_as_clause ()) +visit_field ("trait", e.get_trait ()); } void @@ -521,7 +522,8 @@ Dump::do_traitfunctiondecl (TraitFunctionDecl &e) else put_field ("function_params", "empty"); - visit_field ("return_type", e.get_return_type ()); + if (e.has_return_type ()) +visit_field ("return_type", e.get_return_type ()); if (e.has_where_clause ()) put_field ("where_clause", e.get_where_clause ().as_string ()); @@ -1295,7 +1297,8 @@ Dump::visit (BreakExpr &e) else put_field ("label", "none"); - visit_field ("break_expr ", e.get_expr ()); + if (e.has_break_expr ()) +visit_field ("break_expr ", e.get_expr ()); end ("BreakExpr"); }
[gcc r15-8677] AVR: Use "avr-peep2-after-fuse-move" for the 2nd run of peephole2.
https://gcc.gnu.org/g:a54bd1c8995ad9dab27b09feb4bdbeba169d5419 commit r15-8677-ga54bd1c8995ad9dab27b09feb4bdbeba169d5419 Author: Georg-Johann Lay Date: Sat Mar 22 19:10:39 2025 +0100 AVR: Use "avr-peep2-after-fuse-move" for the 2nd run of peephole2. This patch uses a name for the dump file that makes it clear where in the pass chain the 2nd run of peephole2 is located. gcc/ * config/avr/avr.cc (avr_option_override): Use "avr-peep2-after-fuse-move" as dump name instead of "peephole2". Diff: --- gcc/config/avr/avr.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index d94df84037c6..b192a12671f0 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -567,6 +567,7 @@ avr_option_override (void) { opt_pass *extra_peephole2 = g->get_passes ()->get_pass_peephole2 ()->clone (); +extra_peephole2->name = "avr-peep2-after-fuse-move"; register_pass_info peep2_2_info = { extra_peephole2, "avr-fuse-move", 1, PASS_POS_INSERT_AFTER };
[gcc r15-8676] libgfortran/intrinsics: Fix build for targets with int32_t=long int
https://gcc.gnu.org/g:45d54c70ec54af88905397626f6912c512ab commit r15-8676-g45d54c70ec54af88905397626f6912c512ab Author: Hans-Peter Nilsson Date: Sat Mar 22 18:27:10 2025 +0100 libgfortran/intrinsics: Fix build for targets with int32_t=long int Without this, after r15-8650-g94fa9f4d27bac5, you'll see, for targets where GFC_INTEGER_4 alias int32_t is a typedef of long int (beware of artificially broken lines): /x/gcc/libgfortran/intrinsics/reduce.c:269:1: error: conflicting types for 'reduce_scalar_c'; have 'void(void *, index_type, parray *, void (*)(void *, void *, void *), int *, gfc_array_l4 *, void *, void *, index_type, index_type)' {aka 'void(void *, long int, parray *, void (*)(void *, void *, void *), int *, gfc_array_l4 *, void *, void *, long int, long int)'} 269 | reduce_scalar_c (void *res, | ^~~ [...] excessive error message verbiage deleted /x/gcc/libgfortran/intrinsics/reduce.c: In function 'reduce_scalar_c': /x/gcc/libgfortran/intrinsics/reduce.c:283:35: error: passing argument 4 of 'reduce' from incompatible pointer type [-Wincompatible-pointer-types] 283 | reduce (&ret, array, operation, dim, mask, identity, ordered); | ^~~ | | | int * /x/gcc/libgfortran/intrinsics/reduce.c:41:24: note: expected 'GFC_INTEGER_4 *' {aka 'long int *'} but argument is of type 'int *' 41 | GFC_INTEGER_4 *dim, | ~~~^~~ make[3]: *** [Makefile:4678: intrinsics/reduce.lo] Error 1 libgfortran: * intrinsics/reduce.c (reduce_scalar_c): Correct type of parameter DIM. Diff: --- libgfortran/intrinsics/reduce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgfortran/intrinsics/reduce.c b/libgfortran/intrinsics/reduce.c index 63997d874baa..c8950e41fd01 100644 --- a/libgfortran/intrinsics/reduce.c +++ b/libgfortran/intrinsics/reduce.c @@ -270,7 +270,7 @@ reduce_scalar_c (void *res, index_type res_strlen __attribute__ ((unused)), parray *array, void (*operation) (void *, void *, void *), -int *dim, +GFC_INTEGER_4 *dim, gfc_array_l4 *mask, void *identity, void *ordered,
[gcc r14-11436] c: minor fixes related to arrays of unspecified size
https://gcc.gnu.org/g:432f918f111498e0c3bfee5f9b2ddd8205370163 commit r14-11436-g432f918f111498e0c3bfee5f9b2ddd8205370163 Author: Martin Uecker Date: Sat Mar 22 17:05:51 2025 +0100 c: minor fixes related to arrays of unspecified size The patch for PR117145 and PR117245 also fixed PR100420 and PR116284 which are bugs related to arrays of unspecified size. Those are now represented as variable size arrays with size (0, 0). There are still some loose ends, which are resolved here by 1. adding a testcase for PR116284, 2. moving code related to creation and detection of arrays of unspecified sizes in their own functions, 3. preferring a specified size over an unspecified size when forming a composite type as required by C99 (PR118391) 4. removing useless code in comptypes_internal and composite_type_internal. PR c/116284 PR c/117391 gcc/c/ChangeLog: * c-tree.h (c_type_unspecified_p): New inline function. * c-typeck.cc (c_build_array_type_unspecified): New function. (comptypes_interal): Remove useless code. (composite_type_internal): Update. * c-decl.cc (grokdeclarator): Revise. gcc/testsuite/ChangeLog: * gcc.dg/pr116284.c: New test. * gcc.dg/pr117391.c: New test. (cherry picked from commit 114abf075c1e28358173756042049c9992ae6572) Diff: --- gcc/c/c-decl.cc | 9 - gcc/c/c-tree.h | 16 --- gcc/c/c-typeck.cc | 43 ++--- gcc/testsuite/gcc.dg/pr116284.c | 14 ++ gcc/testsuite/gcc.dg/pr117391.c | 14 ++ 5 files changed, 72 insertions(+), 24 deletions(-) diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc index ab21ee3e5bd1..70f3faf6d688 100644 --- a/gcc/c/c-decl.cc +++ b/gcc/c/c-decl.cc @@ -7434,10 +7434,6 @@ grokdeclarator (const struct c_declarator *declarator, /* C99 6.7.5.2p4 */ if (decl_context == TYPENAME) warning (0, "%<[*]%> not in a declaration"); - /* Array of unspecified size. */ - tree upper = build2 (COMPOUND_EXPR, TREE_TYPE (size_zero_node), -integer_zero_node, size_zero_node); - itype = build_index_type (upper); size_varies = true; } @@ -7473,7 +7469,10 @@ grokdeclarator (const struct c_declarator *declarator, if (!ADDR_SPACE_GENERIC_P (as) && as != TYPE_ADDR_SPACE (type)) type = c_build_qualified_type (type, ENCODE_QUAL_ADDR_SPACE (as)); - type = c_build_array_type (type, itype); + if (array_parm_vla_unspec_p) + type = c_build_array_type_unspecified (type); + else + type = c_build_array_type (type, itype); } if (type != error_mark_node) diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 0f5b4246d0fe..8b9a4610877b 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -748,12 +748,22 @@ extern struct c_switch *c_switch_stack; extern bool null_pointer_constant_p (const_tree); -inline -bool c_type_variably_modified_p (tree t) +inline bool +c_type_variably_modified_p (tree t) { return error_mark_node != t && C_TYPE_VARIABLY_MODIFIED (t); } +inline bool +c_type_unspecified_p (tree t) +{ + return error_mark_node != t +&& C_TYPE_VARIABLE_SIZE (t) && TREE_CODE (t) == ARRAY_TYPE +&& TYPE_DOMAIN (t) && TYPE_MAX_VALUE (TYPE_DOMAIN (t)) +&& TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == COMPOUND_EXPR +&& integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0)) +&& integer_zerop (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 1)); +} extern bool char_type_p (tree); extern tree c_objc_common_truthvalue_conversion (location_t, tree, @@ -852,10 +862,10 @@ extern tree c_reconstruct_complex_type (tree, tree); extern tree c_build_type_attribute_variant (tree ntype, tree attrs); extern tree c_build_pointer_type (tree type); extern tree c_build_array_type (tree type, tree domain); +extern tree c_build_array_type_unspecified (tree type); extern tree c_build_function_type (tree type, tree args, bool no = false); extern tree c_build_pointer_type_for_mode (tree type, machine_mode mode, bool m); - /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 401a55932787..24cc4faa55fa 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -357,7 +357,7 @@ qualify_type (tree type, tree like) } -/* Check consistency of type TYP.E For derived types, we test that +/* Check consistency of type TYPE. For derived types, we test that C_TYPE_VARIABLE_SIZE and C_TY
[gcc r15-8675] avr.opt.urls += -muse-nonzero-bits
https://gcc.gnu.org/g:6d75bb5fe8057ab627a59d122420b996674760e4 commit r15-8675-g6d75bb5fe8057ab627a59d122420b996674760e4 Author: Georg-Johann Lay Date: Sat Mar 22 18:20:10 2025 +0100 avr.opt.urls += -muse-nonzero-bits gcc/ * config/avr/avr.opt.urls: Add -muse-nonzero-bits. Diff: --- gcc/config/avr/avr.opt.urls | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/config/avr/avr.opt.urls b/gcc/config/avr/avr.opt.urls index 64cf0600a36b..662fdee38fd4 100644 --- a/gcc/config/avr/avr.opt.urls +++ b/gcc/config/avr/avr.opt.urls @@ -26,6 +26,9 @@ UrlSuffix(gcc/AVR-Options.html#index-mskip-bug) mrmw UrlSuffix(gcc/AVR-Options.html#index-mrmw) +muse-nonzero-bits +UrlSuffix(gcc/AVR-Options.html#index-muse-nonzero-bits) + mshort-calls UrlSuffix(gcc/AVR-Options.html#index-mshort-calls)
[gcc r15-8667] d: Add C++23 to CppStdRevision enum
https://gcc.gnu.org/g:1f42269ee49240ac68a877c29a26306fcc246c2d commit r15-8667-g1f42269ee49240ac68a877c29a26306fcc246c2d Author: Iain Buclaw Date: Sat Mar 22 10:42:21 2025 +0100 d: Add C++23 to CppStdRevision enum D front-end changes: - The compiler now accepts `-fextern-std=c++23' gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 94950cae58. * d-lang.cc (d_handle_option): Add case for CppStdRevisionCpp23. * gdc.texi: Document -fextern-std=c++23. * lang.opt (fextern-std=): Add c++23. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime 94950cae58. Reviewed-on: https://github.com/dlang/dmd/pull/21043 Diff: --- gcc/d/d-lang.cc | 1 + gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/globals.d | 1 + gcc/d/dmd/globals.h | 3 ++- gcc/d/gdc.texi | 2 ++ gcc/d/lang.opt | 3 +++ libphobos/libdruntime/MERGE | 2 +- libphobos/libdruntime/core/stdcpp/xutility.d | 1 + 8 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index 21f46ffb6aa8..b3786be3c905 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -510,6 +510,7 @@ d_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, case CppStdRevisionCpp14: case CppStdRevisionCpp17: case CppStdRevisionCpp20: + case CppStdRevisionCpp23: global.params.cplusplus = (CppStdRevision) value; break; diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index f274580f2d60..9982d0dd83ef 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -8db14cf8467ca25256904d51169b176c9c89afb1 +94950cae582d89f5ba2720786522f669f620f9d1 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/gcc/d/dmd/globals.d b/gcc/d/dmd/globals.d index 4a637b519c9a..900c554e5f45 100644 --- a/gcc/d/dmd/globals.d +++ b/gcc/d/dmd/globals.d @@ -62,6 +62,7 @@ enum CppStdRevision : uint cpp14 = 2014_02, cpp17 = 2017_03, cpp20 = 2020_02, +cpp23 = 2023_02, } /// Trivalent boolean to represent the state of a `revert`able change diff --git a/gcc/d/dmd/globals.h b/gcc/d/dmd/globals.h index cdb0663b18d1..69fe709f4b0a 100644 --- a/gcc/d/dmd/globals.h +++ b/gcc/d/dmd/globals.h @@ -73,7 +73,8 @@ enum CppStdRevision CppStdRevisionCpp11 = 201103, CppStdRevisionCpp14 = 201402, CppStdRevisionCpp17 = 201703, -CppStdRevisionCpp20 = 202002 +CppStdRevisionCpp20 = 202002, +CppStdRevisionCpp23 = 202302, }; /// Trivalent boolean to represent the state of a `revert`able change diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi index 1a84d6dc4517..2cb0c4a62676 100644 --- a/gcc/d/gdc.texi +++ b/gcc/d/gdc.texi @@ -273,6 +273,8 @@ Sets @code{__traits(getTargetInfo, "cppStd")} to @code{201703}. This is the default. @item c++20 Sets @code{__traits(getTargetInfo, "cppStd")} to @code{202002}. +@item c++23 +Sets @code{__traits(getTargetInfo, "cppStd")} to @code{202302}. @end table @opindex finvariants diff --git a/gcc/d/lang.opt b/gcc/d/lang.opt index f769a71aee81..50c6f2f4da4d 100644 --- a/gcc/d/lang.opt +++ b/gcc/d/lang.opt @@ -320,6 +320,9 @@ Enum(extern_stdcpp) String(c++17) Value(201703) EnumValue Enum(extern_stdcpp) String(c++20) Value(202002) +EnumValue +Enum(extern_stdcpp) String(c++23) Value(202302) + fignore-unknown-pragmas D Ignore unsupported pragmas. diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE index 18c9d1190ced..9982d0dd83ef 100644 --- a/libphobos/libdruntime/MERGE +++ b/libphobos/libdruntime/MERGE @@ -1,4 +1,4 @@ -d2ee11364c25ca8865eb0acb9596a6147532ef41 +94950cae582d89f5ba2720786522f669f620f9d1 The first line of this file holds the git revision number of the last merge done from the dlang/dmd repository. diff --git a/libphobos/libdruntime/core/stdcpp/xutility.d b/libphobos/libdruntime/core/stdcpp/xutility.d index 5e2e711ba67b..f93df68debaf 100644 --- a/libphobos/libdruntime/core/stdcpp/xutility.d +++ b/libphobos/libdruntime/core/stdcpp/xutility.d @@ -35,6 +35,7 @@ enum CppStdRevision : uint cpp14 = 201402, cpp17 = 201703, cpp20 = 202002, +cpp23 = 202302, } /**
[gcc r15-8672] AVR: Add attribute "used" for code in .initN and .initN sections.
https://gcc.gnu.org/g:f529f3d0ecde48e785ed792b24ae2fce635c5b55 commit r15-8672-gf529f3d0ecde48e785ed792b24ae2fce635c5b55 Author: Georg-Johann Lay Date: Fri Mar 21 14:29:13 2025 +0100 AVR: Add attribute "used" for code in .initN and .initN sections. Code in .initN and .initN sections is never called since these sections are special and part of the startup resp. shutdown code. This patch adds attribute "used" so they won't be optimized out. gcc/ * config/avr/avr.cc (avr_attrs_section_name): New function. (avr_insert_attributes): Add "used" attribute to functions in .initN and .finiN. Diff: --- gcc/config/avr/avr.cc | 45 ++--- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 71c03b421489..0ce06a1e580a 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -11736,6 +11736,23 @@ avr_handle_isr_attribute (tree node, tree *attrs, const char *name) } +/* Helper for `avr_insert_attributes'. + Return the section name from attribute "section" in attribute list ATTRS. + When no "section" attribute is present, then return nullptr. */ + +static const char * +avr_attrs_section_name (tree attrs) +{ + if (tree a_sec = lookup_attribute ("section", attrs)) +if (TREE_VALUE (a_sec)) + if (tree t_section_name = TREE_VALUE (TREE_VALUE (a_sec))) + if (TREE_CODE (t_section_name) == STRING_CST) + return TREE_STRING_POINTER (t_section_name); + + return nullptr; +} + + /* Implement `TARGET_INSERT_ATTRIBUTES'. */ static void @@ -11768,25 +11785,31 @@ avr_insert_attributes (tree node, tree *attributes) NULL, *attributes); } + const char *section_name = avr_attrs_section_name (*attributes); + + // When the function is in an .initN or .finiN section, then add "used" + // since such functions are never called. + if (section_name + && strlen (section_name) == strlen (".init*") + && IN_RANGE (section_name[5], '0', '9') + && (startswith (section_name, ".init") + || startswith (section_name, ".fini")) + && !lookup_attribute ("used", *attributes)) +{ + *attributes = tree_cons (get_identifier ("used"), NULL, *attributes); +} + #if defined WITH_AVRLIBC if (avropt_call_main == 0 && TREE_CODE (node) == FUNCTION_DECL && MAIN_NAME_P (DECL_NAME (node))) { - const char *s_section_name = nullptr; - - if (tree a_sec = lookup_attribute ("section", *attributes)) - if (TREE_VALUE (a_sec)) - if (tree t_section_name = TREE_VALUE (TREE_VALUE (a_sec))) - if (TREE_CODE (t_section_name) == STRING_CST) - s_section_name = TREE_STRING_POINTER (t_section_name); - - bool in_init9_p = s_section_name && !strcmp (s_section_name, ".init9"); + bool in_init9_p = section_name && !strcmp (section_name, ".init9"); - if (s_section_name && !in_init9_p) + if (section_name && !in_init9_p) { warning (OPT_Wattributes, "% attribute on main" - " function inhibits %<-mno-call-main%>", s_section_name); + " function inhibits %<-mno-call-main%>", section_name); } else {
[gcc r15-8673] AVR: libgcc: Properly exclude object files for AVRrc.
https://gcc.gnu.org/g:8736edca77a59157a3dae5b3aa5ca59f4fe4b4a4 commit r15-8673-g8736edca77a59157a3dae5b3aa5ca59f4fe4b4a4 Author: Georg-Johann Lay Date: Sat Mar 22 15:19:39 2025 +0100 AVR: libgcc: Properly exclude object files for AVRrc. There are many objects / functions that are not available on AVRrc, the reduced core. The old way to exclude some objects for AVRrc did not work properly since it tested for MULTIFLAGS. This does not work for, say MULTIFLAGS = "-mmcu=avrtiny -mdouble=64". This patch uses $(findstring avrtiny,$(MULTIDIR)) in the condition. libgcc/ * config/avr/t-avr (LIB1ASMFUNCS, LIB2FUNCS_EXCLUDE): Properly handle avrtiny. libgcc/config/avr/libf7/ * t-libf7 (libgcc-objects): Only add objects when building for non-AVRrc. Diff: --- libgcc/config/avr/libf7/t-libf7 | 4 libgcc/config/avr/t-avr | 23 +-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libgcc/config/avr/libf7/t-libf7 b/libgcc/config/avr/libf7/t-libf7 index f17e67e8523a..9ec70d84ae88 100644 --- a/libgcc/config/avr/libf7/t-libf7 +++ b/libgcc/config/avr/libf7/t-libf7 @@ -127,7 +127,9 @@ iter-labels := $(f7_parts) -include $(patsubst %,$(libf7)/libf7-c-object.mk,$(iter-items)) +ifeq (,$(findstring avrtiny,$(MULTIDIR))) libgcc-objects += $(patsubst %,f7_c_%$(objext),$(F7_C_PARTS)) +endif # Build the libf7 ASM objects and add them to libgcc.a. @@ -138,7 +140,9 @@ iter-labels := $(f7_parts) -include $(patsubst %,$(libf7)/libf7-asm-object.mk,$(iter-items)) +ifeq (,$(findstring avrtiny,$(MULTIDIR))) libgcc-objects += $(patsubst %,f7_asm_%$(objext),$(F7_ASM_PARTS)) +endif .PHONY: clean-f7 diff --git a/libgcc/config/avr/t-avr b/libgcc/config/avr/t-avr index f98d48fc013e..b10542c8945e 100644 --- a/libgcc/config/avr/t-avr +++ b/libgcc/config/avr/t-avr @@ -33,8 +33,7 @@ LIB1ASMFUNCS = \ _popcountsi2 \ _popcountqi2 \ _bswapsi2 \ - _fmul _fmuls _fmulsu \ - _strlen_memx + _fmul _fmuls _fmulsu # The below functions either use registers that are not present # in tiny core, or use a different register convention (don't save @@ -45,16 +44,15 @@ LIB1ASMFUNCS = \ # _load, __fload and _xload variations - expect lpm and elpm support # _movmemx and _movmemf - expect elpm/lpm -ifneq ($(MULTIFLAGS),-mmcu=avrtiny) -LIB1ASMFUNCS += \ -_mulsqipsi3 \ +FUNCS_notiny = \ + _mulsqipsi3 \ _mulhisi3 \ _umulhisi3 \ _usmulhisi3 \ _muluhisi3 \ _mulshisi3 \ -_muldi3 _muldi3_6 \ -_mulsidi3 _umulsidi3 \ + _muldi3 _muldi3_6 \ + _mulsidi3 _umulsidi3 \ _divdi3 _udivdi3 \ _udivmod64 \ _negdi2 \ @@ -64,6 +62,7 @@ LIB1ASMFUNCS += \ _xload_1 _xload_2 _xload_3 _xload_4 \ _fload_1 _fload_2 _fload_3 _fload_4 \ _movmemx _movmemf \ + _strlen_memx \ _clzdi2 \ _paritydi2 \ _popcountdi2 \ @@ -72,11 +71,9 @@ LIB1ASMFUNCS += \ _adddi3 _adddi3_s8 _subdi3 \ _cmpdi2 _cmpdi2_s8 \ _powif -endif # Fixed point routines in avr/lib1funcs-fixed.S -ifneq ($(MULTIFLAGS),-mmcu=avrtiny) -LIB1ASMFUNCS += \ +FUNCS_notiny += \ _fractqqsf _fractuqqsf \ _fracthqsf _fractuhqsf _fracthasf _fractuhasf \ _fractsasf _fractusasf _fractsqsf _fractusqsf \ @@ -107,6 +104,9 @@ LIB1ASMFUNCS += \ _rounddq3 _roundudq3 \ _roundda3 _rounduda3 \ _roundta3 _rounduta3 + +ifeq (,$(findstring avrtiny,$(MULTIDIR))) +LIB1ASMFUNCS += $(FUNCS_notiny) endif LIB2FUNCS_EXCLUDE = \ @@ -115,6 +115,9 @@ LIB2FUNCS_EXCLUDE = \ _clrsbdi2 \ _powisf2 +ifneq (,$(findstring avrtiny,$(MULTIDIR))) +LIB2FUNCS_EXCLUDE += $(FUNCS_notiny) +endif ifeq ($(long_double_type_size),32) # We do not have the DFtype.
[gcc r15-8674] AVR: target/119421 Better optimize some bit operations.
https://gcc.gnu.org/g:94355acc2debe03eb3b0a85229e340675a1ff6bd commit r15-8674-g94355acc2debe03eb3b0a85229e340675a1ff6bd Author: Georg-Johann Lay Date: Sat Mar 15 20:53:52 2025 +0100 AVR: target/119421 Better optimize some bit operations. There are occasions where knowledge about nonzero bits makes some optimizations possible. For example, Rd |= Rn << Off can be implemented as SBRC Rn, 0 ORI Rd, 1 << Off when Rn in { 0, 1 }, i.e. nonzero_bits (Rn) == 1. This patch adds some patterns that exploit nonzero_bits() in some combiner patterns. As insn conditions are not supposed to contain nonzero_bits(), the patch splits such insns right after pass insn combine. PR target/119421 gcc/ * config/avr/avr.opt (-muse-nonzero-bits): New option. * config/avr/avr-protos.h (avr_nonzero_bits_lsr_operands_p): New. (make_avr_pass_split_nzb): New. * config/avr/avr.cc (avr_nonzero_bits_lsr_operands_p): New function. (avr_rtx_costs_1): Return costs for the new insns. * config/avr/avr.md (nzb): New insn attribute. (*nzb=1): New insns to better support some bit operations for in AND, IOR, XOR. * config/avr/avr-passes.def (avr_pass_split_nzb): Insert pass atfer combine. * config/avr/avr-passes.cc (avr_pass_data_split_nzb). New pass data. (avr_pass_split_nzb): New pass. (make_avr_pass_split_nzb): New function. * common/config/avr/avr-common.cc (avr_option_optimization_table): Enable -muse-nonzero-bits for -O2 and higher. * doc/invoke.texi (AVR Options): Document -muse-nonzero-bits. gcc/testsuite/ * gcc.target/avr/torture/pr119421-sreg.c: New test. Diff: --- gcc/common/config/avr/avr-common.cc| 1 + gcc/config/avr/avr-passes.cc | 71 + gcc/config/avr/avr-passes.def | 12 + gcc/config/avr/avr-protos.h| 2 + gcc/config/avr/avr.cc | 106 gcc/config/avr/avr.md | 215 +++ gcc/config/avr/avr.opt | 4 + gcc/doc/invoke.texi| 9 +- .../gcc.target/avr/torture/pr119421-sreg.c | 301 + 9 files changed, 719 insertions(+), 2 deletions(-) diff --git a/gcc/common/config/avr/avr-common.cc b/gcc/common/config/avr/avr-common.cc index 06c6cc856d3c..203a96528186 100644 --- a/gcc/common/config/avr/avr-common.cc +++ b/gcc/common/config/avr/avr-common.cc @@ -42,6 +42,7 @@ static const struct default_options avr_option_optimization_table[] = { OPT_LEVELS_2_PLUS, OPT_mfuse_move_, NULL, 23 }, { OPT_LEVELS_2_PLUS, OPT_msplit_bit_shift, NULL, 1 }, { OPT_LEVELS_2_PLUS, OPT_msplit_ldst, NULL, 1 }, +{ OPT_LEVELS_2_PLUS, OPT_muse_nonzero_bits, NULL, 1 }, // Stick to the "old" placement of the subreg lowering pass. { OPT_LEVELS_1_PLUS, OPT_fsplit_wide_types_early, NULL, 1 }, /* Allow optimizer to introduce store data races. This used to be the diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc index 184619af6cb4..2c21e7be7aba 100644 --- a/gcc/config/avr/avr-passes.cc +++ b/gcc/config/avr/avr-passes.cc @@ -29,6 +29,7 @@ #include "target.h" #include "rtl.h" #include "tree.h" +#include "diagnostic-core.h" #include "cfghooks.h" #include "cfganal.h" #include "df.h" @@ -4846,6 +4847,70 @@ avr_pass_fuse_add::execute1 (function *func) } + +// +// Split insns with nonzero_bits() after combine. + +static const pass_data avr_pass_data_split_nzb = +{ + RTL_PASS,// type + "", // name (will be patched) + OPTGROUP_NONE,// optinfo_flags + TV_DF_SCAN, // tv_id + 0, // properties_required + 0, // properties_provided + 0, // properties_destroyed + 0, // todo_flags_start + 0// todo_flags_finish +}; + +class avr_pass_split_nzb : public rtl_opt_pass +{ +public: + avr_pass_split_nzb (gcc::context *ctxt, const char *name) +: rtl_opt_pass (avr_pass_data_split_nzb, ctxt) + { +this->name = name; + } + + unsigned int execute (function *) final override + { +if (avropt_use_nonzero_bits) + split_nzb_insns (); +return 0; + } + + void split_nzb_insns (); + +}; // avr_pass_split_nzb + + +void +avr_pass_split_nzb::split_nzb_insns () +{ + rtx_insn *next; + + for (rtx_insn *insn = get_insns (); insn; insn = next) +{ + next = NEXT_INSN (insn); + + if (INSN_P (insn) + && single_set (insn) + && get_attr_nzb (insn) == NZB_YES) + { + rtx_insn *last = try_split (PATTERN (insn), insn, 1 /*last*/); + +
[gcc r15-8627] gccrs: lang-items: Mark Clone trait as a lang item in testsuite
https://gcc.gnu.org/g:8f65a00131a53804b4cdd7fc15107c6b35bcf6f9 commit r15-8627-g8f65a00131a53804b4cdd7fc15107c6b35bcf6f9 Author: Arthur Cohen Date: Fri Jan 3 15:46:33 2025 + gccrs: lang-items: Mark Clone trait as a lang item in testsuite gcc/testsuite/ChangeLog: * rust/compile/derive_macro1.rs: Add #[lang = "clone"] to Clone trait. * rust/compile/derive_macro3.rs: Likewise. * rust/compile/derive_macro6.rs: Likewise. * rust/execute/torture/derive_macro3.rs: Likewise. Diff: --- gcc/testsuite/rust/compile/derive_macro1.rs | 1 + gcc/testsuite/rust/compile/derive_macro3.rs | 1 + gcc/testsuite/rust/compile/derive_macro6.rs | 7 +++ gcc/testsuite/rust/execute/torture/derive_macro3.rs | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/rust/compile/derive_macro1.rs b/gcc/testsuite/rust/compile/derive_macro1.rs index 779aad78e11d..bc10d601bb8d 100644 --- a/gcc/testsuite/rust/compile/derive_macro1.rs +++ b/gcc/testsuite/rust/compile/derive_macro1.rs @@ -1,6 +1,7 @@ #[lang = "sized"] pub trait Sized {} +#[lang = "clone"] pub trait Clone { fn clone(&self) -> Self; } diff --git a/gcc/testsuite/rust/compile/derive_macro3.rs b/gcc/testsuite/rust/compile/derive_macro3.rs index 1c7d4737bfe9..ad40cae94b51 100644 --- a/gcc/testsuite/rust/compile/derive_macro3.rs +++ b/gcc/testsuite/rust/compile/derive_macro3.rs @@ -1,6 +1,7 @@ #[lang = "sized"] pub trait Sized {} +#[lang = "clone"] pub trait Clone { fn clone(&self) -> Self; } diff --git a/gcc/testsuite/rust/compile/derive_macro6.rs b/gcc/testsuite/rust/compile/derive_macro6.rs index b7bf7a78acd1..35327c03b54c 100644 --- a/gcc/testsuite/rust/compile/derive_macro6.rs +++ b/gcc/testsuite/rust/compile/derive_macro6.rs @@ -2,6 +2,9 @@ pub trait Sized {} pub trait Copy {} + + +#[lang = "clone"] pub trait Clone { fn clone(&self) -> Self; } @@ -9,10 +12,6 @@ pub trait Clone { #[lang = "phantom_data"] pub struct PhantomData; -pub struct AssertParamIsCopy { -pub _field: PhantomData, -} - impl Copy for i32 {} impl Copy for i64 {} impl Copy for U {} diff --git a/gcc/testsuite/rust/execute/torture/derive_macro3.rs b/gcc/testsuite/rust/execute/torture/derive_macro3.rs index 7b3a089d7514..4138a5bf7e4c 100644 --- a/gcc/testsuite/rust/execute/torture/derive_macro3.rs +++ b/gcc/testsuite/rust/execute/torture/derive_macro3.rs @@ -1,6 +1,7 @@ #[lang = "sized"] pub trait Sized {} +#[lang = "clone"] pub trait Clone { fn clone(&self) -> Self; }
[gcc r14-11437] c: Set attributes for fields when forming a composite type [PR117806]
https://gcc.gnu.org/g:a3989d8158705975ab72c9167469905cbe7d11cf commit r14-11437-ga3989d8158705975ab72c9167469905cbe7d11cf Author: Martin Uecker Date: Sat Mar 22 17:35:58 2025 +0100 c: Set attributes for fields when forming a composite type [PR117806] We need to call decl_attributes when creating the fields for a composite type. PR c/117806 gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal): Call decl_attributes. gcc/testsuite/ChangeLog: * gcc.dg/pr117806.c: New test. (cherry picked from commit 1539bcd19c5928d8359722c532dfcc7a26a16dda) Diff: --- gcc/c/c-typeck.cc | 2 ++ gcc/testsuite/gcc.dg/pr117806.c | 13 + 2 files changed, 15 insertions(+) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 24cc4faa55fa..57d5ca586608 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -773,6 +773,8 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache) DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a); C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t); + decl_attributes (&f, DECL_ATTRIBUTES (f), 0); + finish_decl (f, input_location, NULL, NULL, NULL); if (DECL_C_BIT_FIELD (a)) diff --git a/gcc/testsuite/gcc.dg/pr117806.c b/gcc/testsuite/gcc.dg/pr117806.c new file mode 100644 index ..bc2c8c665e73 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr117806.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +struct Test { + double D __attribute__((packed,aligned(4))); +} x; +struct Test { + double D __attribute__((packed,aligned(4))); +} x; +struct Test { + double D __attribute__((packed,aligned(4))); +} x; +
[gcc r15-8662] Fix up some further cases of missing or extraneous spaces in diagnostics
https://gcc.gnu.org/g:20360e4b6b5a63bc65d1855a7ecf22eb7148a452 commit r15-8662-g20360e4b6b5a63bc65d1855a7ecf22eb7148a452 Author: Jakub Jelinek Date: Sat Mar 22 08:39:38 2025 +0100 Fix up some further cases of missing or extraneous spaces in diagnostics Given the recent PR119406 I've tried to grep for concatenated string literals without space at the end of one line and at the start of next line, unless it was obviously intentional. Furthermore, I've then looked through gcc.pot looking for 2 adjacent spaces and looking back if that wasn't the case of "something " " with spaces at both sides". Here is the result from that. I think just the c.opt change needs an explanation, the "" in the description is simply eaten up somewhere during the option processing and gcc -v --help before this patch was displaying -Wdeprecated-literal-operator Warn about deprecated space between and suffix in a user-defined literal operator. 2025-03-22 Jakub Jelinek gcc/ * gimplify.cc (warn_switch_unreachable_and_auto_init_r): Add missing space in the middle of diagnostics. * tree-vect-stmts.cc (vectorizable_load): Add missing space in the middle of debug dump message. * sym-exec/sym-exec-state.cc (state::check_args_compatibility): Likewise. gcc/c-family/ * c.opt (Wdeprecated-literal-operator): Use \"\" rather than "" in option description. gcc/fortran/ * resolve.cc (resolve_procedure_expression): Remove extraneous space from the middle of diagnostics. Diff: --- gcc/c-family/c.opt | 2 +- gcc/fortran/resolve.cc | 2 +- gcc/gimplify.cc| 2 +- gcc/sym-exec/sym-exec-state.cc | 2 +- gcc/tree-vect-stmts.cc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 6c6922ab2018..ad216983126e 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -666,7 +666,7 @@ type and the other is of a floating-point type. Wdeprecated-literal-operator C++ ObjC++ Var(warn_deprecated_literal_operator) Warning -Warn about deprecated space between "" and suffix in a user-defined literal operator. +Warn about deprecated space between \"\" and suffix in a user-defined literal operator. Wdeprecated-non-prototype C ObjC Var(warn_deprecated_non_prototype) Init(-1) Warning diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index e016865a6bb4..cf9318ff763c 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -1986,7 +1986,7 @@ resolve_procedure_expression (gfc_expr* expr) if (is_illegal_recursion (sym, gfc_current_ns)) { if (sym->attr.use_assoc && expr->symtree->name[0] == '@') - gfc_warning (0, "Non-RECURSIVE procedure %qs from module %qs is " + gfc_warning (0, "Non-RECURSIVE procedure %qs from module %qs is" " possibly calling itself recursively in procedure %qs. " " Declare it RECURSIVE or use %<-frecursive%>", sym->name, sym->module, gfc_current_ns->proc_name->name); diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 244c4ba4b637..354c3d663e7e 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -2395,7 +2395,7 @@ warn_switch_unreachable_and_auto_init_r (gimple_stmt_iterator *gsi_p, const char *var_name_str = TREE_STRING_POINTER (var_name); warning_at (gimple_location (stmt), OPT_Wtrivial_auto_var_init, - "%qs cannot be initialized with" + "%qs cannot be initialized with " "%<-ftrivial-auto-var_init%>", var_name_str); break; diff --git a/gcc/sym-exec/sym-exec-state.cc b/gcc/sym-exec/sym-exec-state.cc index fb7495a2c56b..d5cbb73694b0 100644 --- a/gcc/sym-exec/sym-exec-state.cc +++ b/gcc/sym-exec/sym-exec-state.cc @@ -265,7 +265,7 @@ state::check_args_compatibility (tree arg1, tree arg2, tree dest) || TREE_CODE (arg2) == INTEGER_CST)) { if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "Sym-Exec: Incompatible destination" + fprintf (dump_file, "Sym-Exec: Incompatible destination " "and argument sizes.\n"); return false; diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 17e3b1db894a..813b2b779511 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -12576,7 +12576,7 @@ vectorizable_load (vec_info *vinfo, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, -"vect_model_load_cost:" +"vect_model_load_cost: " "strided group_size = %d .\n", group_size); }
[gcc r15-8540] gccrs: Clean up some system includes
https://gcc.gnu.org/g:066cd2e1f817bc0009fe634983abd06d1d295d89 commit r15-8540-g066cd2e1f817bc0009fe634983abd06d1d295d89 Author: Pierre-Emmanuel Patry Date: Fri Nov 22 12:20:09 2024 +0100 gccrs: Clean up some system includes System includes shall use rust-system header instead. gcc/rust/ChangeLog: * ast/rust-stmt.h: Remove stdlib include and use rust-system instead. * backend/rust-compile-expr.cc: Likewise. * backend/rust-mangle-legacy.cc: Likewise. * backend/rust-mangle-v0.cc: Likewise. * hir/rust-hir-dump.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * typecheck/rust-tyty.h: Likewise. * util/rust-common.h: Likewise. * util/rust-token-converter.cc: Likewise. * util/rust-token-converter.h: Likewise. Signed-off-by: Pierre-Emmanuel Patry Diff: --- gcc/rust/ast/rust-stmt.h | 2 +- gcc/rust/backend/rust-compile-expr.cc | 1 - gcc/rust/backend/rust-mangle-legacy.cc | 1 - gcc/rust/backend/rust-mangle-v0.cc | 1 - gcc/rust/hir/rust-hir-dump.cc | 2 +- gcc/rust/typecheck/rust-hir-type-check-type.cc | 2 +- gcc/rust/typecheck/rust-tyty.cc| 2 +- gcc/rust/typecheck/rust-tyty.h | 2 -- gcc/rust/util/rust-common.h| 1 - gcc/rust/util/rust-token-converter.cc | 3 +-- gcc/rust/util/rust-token-converter.h | 2 +- 11 files changed, 6 insertions(+), 13 deletions(-) diff --git a/gcc/rust/ast/rust-stmt.h b/gcc/rust/ast/rust-stmt.h index e8aec34d47eb..6cbecaffd033 100644 --- a/gcc/rust/ast/rust-stmt.h +++ b/gcc/rust/ast/rust-stmt.h @@ -22,7 +22,7 @@ #include "rust-ast.h" #include "rust-path.h" #include "rust-expr.h" -#include +#include "rust-system.h" namespace Rust { namespace AST { diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 05c52261cf78..7ea2a6755221 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -31,7 +31,6 @@ #include "convert.h" #include "print-tree.h" #include "rust-system.h" -#include namespace Rust { namespace Compile { diff --git a/gcc/rust/backend/rust-mangle-legacy.cc b/gcc/rust/backend/rust-mangle-legacy.cc index 2c0ddd92df03..7671982da3f9 100644 --- a/gcc/rust/backend/rust-mangle-legacy.cc +++ b/gcc/rust/backend/rust-mangle-legacy.cc @@ -21,7 +21,6 @@ #include "rust-unicode.h" #include "rust-diagnostics.h" #include "rust-system.h" -#include namespace Rust { namespace Compile { diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc index 67d7e4d1885a..d0df4aba27c3 100644 --- a/gcc/rust/backend/rust-mangle-v0.cc +++ b/gcc/rust/backend/rust-mangle-v0.cc @@ -25,7 +25,6 @@ #include "rust-unicode.h" #include "rust-punycode.h" #include "rust-compile-type.h" -#include namespace Rust { namespace Compile { diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 5d2a09db3483..81cb881268f8 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -22,9 +22,9 @@ #include "rust-hir-path.h" #include "rust-hir-type.h" #include "rust-hir.h" -#include #include "rust-attribute-values.h" #include "tree/rust-hir-expr.h" +#include "rust-system.h" namespace Rust { namespace HIR { diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 4ebbaf6d8366..0360c5504b78 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -27,7 +27,7 @@ #include "rust-mapping-common.h" #include "rust-substitution-mapper.h" #include "rust-type-util.h" -#include +#include "rust-system.h" namespace Rust { namespace Resolver { diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 1073dfa6adc9..f0c967e09490 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -32,7 +32,7 @@ #include "rust-hir-type-bounds.h" #include "options.h" -#include +#include "rust-system.h" namespace Rust { namespace TyTy { diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 49cd00c91742..a41837e35afa 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -30,8 +30,6 @@ #include "rust-system.h" #include "rust-hir.h" -#include - namespace Rust { namespace Resolver { diff --git a/gcc/rust/util/rust-common.h b/gcc/rust/util/rust-common.h index 2033694156e9..71637cee68e5 100644 --- a/gcc/rust/util/rust-common.h +++ b/gcc/rust/util/rust-common.h @@ -21,7 +21,6 @@ #ifndef RUST_COMMON #define RUST_COMMON #include "rust-system.h" -#include namespace Rust { diff --git a/gcc/rust/util/rust-token-converter.cc b/gcc/rust/util/rust-token-
[gcc/devel/omp/gcc-14] c++: constexpr ref template arg [PR119194]
https://gcc.gnu.org/g:a8f53501ef8ebbb0dbef431e0275806eafd2e41f commit a8f53501ef8ebbb0dbef431e0275806eafd2e41f Author: Jason Merrill Date: Tue Mar 18 14:44:08 2025 -0400 c++: constexpr ref template arg [PR119194] Here we were assuming that a constant variable appearing in a template argument is used for its value. We also need to handle seeing its address taken. PR c++/119194 gcc/cp/ChangeLog: * decl2.cc (min_vis_expr_r) [ADDR_EXPR]: New case. gcc/testsuite/ChangeLog: * g++.dg/template/linkage7.C: New test. (cherry picked from commit 145c90720640ec6711ed3e5aa4152bbe1ee21751) Diff: --- gcc/cp/decl2.cc | 22 +- gcc/testsuite/g++.dg/template/linkage7.C | 17 + 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index c1e4a4e148fa..56b222412b86 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -2713,6 +2713,14 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void *data) tpvis = type_visibility (TREE_TYPE (t)); break; +case ADDR_EXPR: + t = TREE_OPERAND (t, 0); + if (VAR_P (t)) + /* If a variable has its address taken, the lvalue-rvalue conversion is + not applied, so skip that case. */ + goto addressable; + break; + case TEMPLATE_DECL: if (DECL_ALIAS_TEMPLATE_P (t) || standard_concept_p (t)) /* FIXME: We don't maintain TREE_PUBLIC / DECL_VISIBILITY for @@ -2726,11 +2734,15 @@ min_vis_expr_r (tree *tp, int */*walk_subtrees*/, void *data) if (decl_constant_var_p (t)) /* The ODR allows definitions in different TUs to refer to distinct constant variables with internal or no linkage, so such a reference - shouldn't affect visibility (PR110323). FIXME but only if the - lvalue-rvalue conversion is applied. We still want to restrict - visibility according to the type of the declaration however. */ - tpvis = type_visibility (TREE_TYPE (t)); - else if (! TREE_PUBLIC (t)) + shouldn't affect visibility if the lvalue-rvalue conversion is + applied (PR110323). We still want to restrict visibility according + to the type of the declaration however. */ + { + tpvis = type_visibility (TREE_TYPE (t)); + break; + } +addressable: + if (! TREE_PUBLIC (t)) tpvis = VISIBILITY_ANON; else tpvis = DECL_VISIBILITY (t); diff --git a/gcc/testsuite/g++.dg/template/linkage7.C b/gcc/testsuite/g++.dg/template/linkage7.C new file mode 100644 index ..6686a0e5e511 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/linkage7.C @@ -0,0 +1,17 @@ +// PR c++/119194 +// { dg-do compile { target c++11 } } + +template +[[gnu::noipa]] +int get_length() { +return Str; +} +static constexpr int s{ 3}; +int main() { + if (get_length() != s) + __builtin_abort(); +return 0; +} + +// { dg-final { scan-assembler {_Z10get_lengthIL_ZL5sEEiv} } } +// { dg-final { scan-assembler-not {(weak|glob)[^\n]*_Z10get_lengthIL_Z5sEEiv} } }
[gcc r14-11434] c++: ICE w/ dependently scoped template friend [PR119378]
https://gcc.gnu.org/g:d025b6880cde2cb2063b4d34546cdd70e5526e74 commit r14-11434-gd025b6880cde2cb2063b4d34546cdd70e5526e74 Author: Patrick Palka Date: Sat Mar 22 10:18:07 2025 -0400 c++: ICE w/ dependently scoped template friend [PR119378] Here we ICE during instantiation of the dependently scoped template friend template struct friend class A::B; ultimately because processing_template_decl isn't set during substitution into the A scope. Since it's naturally a partial substitution, we need to make sure the flag is set. For GCC 15, this is already fixed similarly by r15-123. PR c++/119378 gcc/cp/ChangeLog: * pt.cc (tsubst) : Set processing_template_decl when substituting the context. gcc/testsuite/ChangeLog: * g++.dg/template/friend85.C: New test. Reviewed-by: Jason Merrill Diff: --- gcc/cp/pt.cc | 2 ++ gcc/testsuite/g++.dg/template/friend85.C | 16 2 files changed, 18 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ca34ed75d659..2efc7eb19e87 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -16946,8 +16946,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) case UNBOUND_CLASS_TEMPLATE: { + ++processing_template_decl; tree ctx = tsubst_aggr_type (TYPE_CONTEXT (t), args, complain, in_decl, /*entering_scope=*/1); + --processing_template_decl; tree name = TYPE_IDENTIFIER (t); tree parm_list = DECL_TEMPLATE_PARMS (TYPE_NAME (t)); diff --git a/gcc/testsuite/g++.dg/template/friend85.C b/gcc/testsuite/g++.dg/template/friend85.C new file mode 100644 index ..5cf839111931 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/friend85.C @@ -0,0 +1,16 @@ +// PR c++/119378 + +template +struct A { + template + struct B; +}; + +template +struct C { + template + template + friend class A::B; +}; + +template struct C;
[gcc r15-8679] cobol: Make CXXFLAGS_FOR_TARGET available to the libgcobol build.
https://gcc.gnu.org/g:438e82b8aa3cf14e08c70ea8a7f669621a897eae commit r15-8679-g438e82b8aa3cf14e08c70ea8a7f669621a897eae Author: Bob Dubner Date: Fri Mar 21 17:22:31 2025 -0400 cobol: Make CXXFLAGS_FOR_TARGET available to the libgcobol build. By setting "CXXFLAGS_FOR_TARGET=-ggdb -O0", a debuggable version of libgcobol.so is created. libgcobol * Makefile.am: Incorporate AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET). * Makefile.in: Regenerated. Diff: --- libgcobol/Makefile.am | 2 ++ libgcobol/Makefile.in | 1 + 2 files changed, 3 insertions(+) diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am index 888cbf2b0b04..cafb733dde1d 100644 --- a/libgcobol/Makefile.am +++ b/libgcobol/Makefile.am @@ -52,6 +52,8 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \ WARN_CFLAGS = -W -Wall -Wwrite-strings +AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET) + # not defined: DEFS, MAX_ERRORS, LTLDFLAGS ALL_CXXFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS) \ $(XCFLAGS) $(AM_CXXFLAGS) $(WARN_CFLAGS) $(MAX_ERRORS) \ diff --git a/libgcobol/Makefile.in b/libgcobol/Makefile.in index 1a1e2ee39eb0..c4a562a80585 100644 --- a/libgcobol/Makefile.in +++ b/libgcobol/Makefile.in @@ -431,6 +431,7 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \ $(LTLDFLAGS) $(LTLIBICONV) WARN_CFLAGS = -W -Wall -Wwrite-strings +AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET) # not defined: DEFS, MAX_ERRORS, LTLDFLAGS ALL_CXXFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS) \