[gcc(refs/users/meissner/heads/work167-tar)] Update ChangeLog.*
https://gcc.gnu.org/g:baa082e5aa0ab8bc2aa347ed0234eeb795367a43 commit baa082e5aa0ab8bc2aa347ed0234eeb795367a43 Author: Michael Meissner Date: Fri May 24 23:19:22 2024 -0400 Update ChangeLog.* Diff: --- gcc/ChangeLog.tar | 20 1 file changed, 20 insertions(+) diff --git a/gcc/ChangeLog.tar b/gcc/ChangeLog.tar index 8141a355c54..5dde9431641 100644 --- a/gcc/ChangeLog.tar +++ b/gcc/ChangeLog.tar @@ -1,3 +1,23 @@ + Branch work167-tar, patch #204 + +Add -mccspr and -mfpspr + +2024-05-24 Michael Meissner + + * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Add + support for -mccspr and -mfpspr debug switches + * config/rs6000/rs6000.md (movcc_): Add spr support back in. + (movsf_hardfloat): Likewise. + (movsd_hardfloat): Likewise. + (mov_softfloat): Likewise. + (mov_softfloat32): Likewise. + (ov_hardfloat64): Likewise. + (mov_softfloat64): Likewise. + (indirect_jump): Add TAR register support. + (@indirect_jump_nospec): Likewise. + * config/rs6000/rs6000.opt (-mccspr): New switch. + (-mfpspr): Likewise. + Branch work167-tar, patch #203 Add -mintspr.
[gcc(refs/users/meissner/heads/work167-tar)] Add -mccspr and -mfpspr
https://gcc.gnu.org/g:d5fdd314b266f9830ab28db14db7d0aa3f59f424 commit d5fdd314b266f9830ab28db14db7d0aa3f59f424 Author: Michael Meissner Date: Fri May 24 23:15:34 2024 -0400 Add -mccspr and -mfpspr 2024-05-24 Michael Meissner * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Add support for -mccspr and -mfpspr debug switches * config/rs6000/rs6000.md (movcc_): Add spr support back in. (movsf_hardfloat): Likewise. (movsd_hardfloat): Likewise. (mov_softfloat): Likewise. (mov_softfloat32): Likewise. (ov_hardfloat64): Likewise. (mov_softfloat64): Likewise. (indirect_jump): Add TAR register support. (@indirect_jump_nospec): Likewise. * config/rs6000/rs6000.opt (-mccspr): New switch. (-mfpspr): Likewise. Diff: --- gcc/config/rs6000/rs6000.cc | 31 gcc/config/rs6000/rs6000.md | 118 ++- gcc/config/rs6000/rs6000.opt | 8 +++ 3 files changed, 101 insertions(+), 56 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index fa330c2a4b1..c6fb978977c 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1943,20 +1943,33 @@ rs6000_hard_regno_mode_ok_uncached (int regno, machine_mode mode) SPR. */ switch (regno) { - /* 32-bit registers. */ case VRSAVE_REGNO: case VSCR_REGNO: - return (!orig_complex_p && mode == SImode); - - /* Registers that hold addresses. */ case LR_REGNO: case CTR_REGNO: case TAR_REGNO: - return (!orig_complex_p - && (mode == Pmode - || (TARGET_INTSPR - && SCALAR_INT_MODE_P (mode) - && GET_MODE_SIZE (mode) <= UNITS_PER_WORD))); + { + unsigned reg_size = ((regno == VRSAVE_REGNO || regno == VSCR_REGNO) +? 4 +: UNITS_PER_WORD); + + if (orig_complex_p || GET_MODE_SIZE (mode) > reg_size) + return false; + + if (GET_MODE_CLASS (mode) == MODE_CC) + return TARGET_CCSPR != 0; + + if (SCALAR_FLOAT_MODE_P (mode)) + return TARGET_FPSPR != 0; + + if (!SCALAR_INT_MODE_P (mode)) + return false; + + if (TARGET_INTSPR) + return true; + + return GET_MODE_SIZE (mode) == reg_size; + } default: break; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index b5dc0719a88..28f8ebee738 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -8120,9 +8120,9 @@ (define_insn "*movcc_" [(set (match_operand:CC_any 0 "nonimmediate_operand" - "=y,x,?y,y,r,r,r,r,r,m") + "=y,x,?y,y,r,r,r,r, r,*c*l,r,m") (match_operand:CC_any 1 "general_operand" - " y,r, r,O,x,y,r,I,m,r"))] + " y,r, r,O,x,y,r,I,*h, r,m,r"))] "register_operand (operands[0], mode) || register_operand (operands[1], mode)" "@ @@ -8134,6 +8134,8 @@ mfcr %0%Q1\;rlwinm %0,%0,%f1,0xf000 mr %0,%1 li %0,%1 + mf%1 %0 + mt%0 %1 lwz%U1%X1 %0,%1 stw%U0%X0 %1,%0" [(set_attr_alternative "type" @@ -8147,9 +8149,11 @@ (const_string "mfcrf") (const_string "mfcr")) (const_string "integer") (const_string "integer") + (const_string "mfjmpr") + (const_string "mtjmpr") (const_string "load") (const_string "store")]) - (set_attr "length" "*,*,12,*,*,8,*,*,*,*")]) + (set_attr "length" "*,*,12,*,*,8,*,*,*,*,*,*")]) ;; For floating-point, we normally deal with the floating-point registers ;; unless -msoft-float is used. The sole exception is that parameter passing @@ -8200,17 +8204,17 @@ ;; ;; LWZ LFSLXSSP LXSSPX STFS STXSSP ;; STXSSPX STWXXLXOR LI FMRXSCPSGNDP -;; MR XXSPLTIDP +;; MR MT MF NOPXXSPLTIDP (define_insn "movsf_hardfloat" [(set (match_operand:SF 0 "nonimmediate_operand" "=!r, f, v, wa,m, wY, Z, m, wa, !r,f, wa, - !r,wa") + !r,*c*l, !r, *h,wa") (match_operand:SF 1 "input_operand" "m, m, wY, Z, f, v, wa,r, j, j, f, wa, - r, eP"))] + r, r, *h, 0, eP"))] "(register_operand (operands[0], SFmode) || register_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT @@ -8230,29 +8234,32 @@ fmr %0,%1 xscpsgndp %x0,%x1,%x1 mr %0,%1 + mt%0 %1 + mf%1 %0 + nop
[gcc r15-830] c++/modules: Improve diagnostic when redeclaring builtin in module [PR102345]
https://gcc.gnu.org/g:28b508233a12c13295f960a2cb8a4864879acfb4 commit r15-830-g28b508233a12c13295f960a2cb8a4864879acfb4 Author: Nathaniel Shead Date: Sat May 25 01:03:54 2024 +1000 c++/modules: Improve diagnostic when redeclaring builtin in module [PR102345] If a user mistakenly includes a standard library header within the module purview, they currently get a confusing "declaration conflicts with builtin" error. This patch updates the message to include "in module", to help guide the user towards the likely cause. PR c++/102345 gcc/cp/ChangeLog: * module.cc (module_may_redeclare): Update error message. gcc/testsuite/ChangeLog: * g++.dg/modules/enum-12.C: Test for updated error. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/module.cc | 8 +++- gcc/testsuite/g++.dg/modules/enum-12.C | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 6cd7d9e0b93..3f8f84bb9fd 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -19140,7 +19140,13 @@ module_may_redeclare (tree olddecl, tree newdecl) decl = newdecl ? newdecl : olddecl; location_t loc = newdecl ? DECL_SOURCE_LOCATION (newdecl) : input_location; if (DECL_IS_UNDECLARED_BUILTIN (olddecl)) -error_at (loc, "declaration %qD conflicts with builtin", decl); +{ + if (newdecl_attached_p) + error_at (loc, "declaring %qD in module %qs conflicts with builtin " + "in global module", decl, new_mod->get_flatname ()); + else + error_at (loc, "declaration %qD conflicts with builtin", decl); +} else if (DECL_LANG_SPECIFIC (old_inner) && DECL_MODULE_IMPORT_P (old_inner)) { auto_diagnostic_group d; diff --git a/gcc/testsuite/g++.dg/modules/enum-12.C b/gcc/testsuite/g++.dg/modules/enum-12.C index 064f220dedf..cf8f445e076 100644 --- a/gcc/testsuite/g++.dg/modules/enum-12.C +++ b/gcc/testsuite/g++.dg/modules/enum-12.C @@ -4,7 +4,7 @@ export module foo; namespace std { - enum class align_val_t : decltype(sizeof(int)) {}; // { dg-error "conflicts with builtin" } + enum class align_val_t : decltype(sizeof(int)) {}; // { dg-error "in module .foo. conflicts with builtin" } } // { dg-prune-output "not writing module" }
gcc-wwwdocs branch master updated. 77993a3798b638d2518dcb11ac939b581ea3cea8
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gcc-wwwdocs". The branch, master has been updated via 77993a3798b638d2518dcb11ac939b581ea3cea8 (commit) from b20402b74f21724e2772d48ec8f12043ca785503 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit 77993a3798b638d2518dcb11ac939b581ea3cea8 Author: Gerald Pfeifer Date: Sat May 25 00:33:59 2024 +0200 gcc-13: Run time instead of runtime diff --git a/htdocs/gcc-13/changes.html b/htdocs/gcc-13/changes.html index d431c768..2702170d 100644 --- a/htdocs/gcc-13/changes.html +++ b/htdocs/gcc-13/changes.html @@ -62,9 +62,9 @@ You may also want to check out our includes the iostream header. This change improves the start-up performance of C++ programs, but it means that code compiled with GCC 13.1 will crash if the correct version of - libstdc++.so is not used at runtime. See the + libstdc++.so is not used at run time. See the https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.dynamic;>documentation - about using the right libstdc++.so at runtime. + about using the right libstdc++.so at run time. Future GCC releases will mitigate the problem so that the program cannot be run at all with an older libstdc++.so. --- Summary of changes: htdocs/gcc-13/changes.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- gcc-wwwdocs
[gcc r15-828] Fortran: improve attribute conflict checking [PR93635]
https://gcc.gnu.org/g:9561cf550a66a89e7c8d31202a03c4fddf82a3f2 commit r15-828-g9561cf550a66a89e7c8d31202a03c4fddf82a3f2 Author: Harald Anlauf Date: Thu May 23 21:13:00 2024 +0200 Fortran: improve attribute conflict checking [PR93635] gcc/fortran/ChangeLog: PR fortran/93635 * symbol.cc (conflict_std): Helper function for reporting attribute conflicts depending on the Fortran standard version. (conf_std): Helper macro for checking standard-dependent conflicts. (gfc_check_conflict): Use it. gcc/testsuite/ChangeLog: PR fortran/93635 * gfortran.dg/c-interop/c1255-2.f90: Adjust pattern. * gfortran.dg/pr87907.f90: Likewise. * gfortran.dg/pr93635.f90: New test. Co-authored-by: Steven G. Kargl Diff: --- gcc/fortran/symbol.cc | 63 +++-- gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 | 4 +- gcc/testsuite/gfortran.dg/pr87907.f90 | 8 ++-- gcc/testsuite/gfortran.dg/pr93635.f90 | 19 4 files changed, 54 insertions(+), 40 deletions(-) diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 0a1646def67..5db3c887127 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -407,18 +407,36 @@ gfc_check_function_type (gfc_namespace *ns) / Symbol attribute stuff */ +/* Older standards produced conflicts for some attributes that are allowed + in newer standards. Check for the conflict and issue an error depending + on the standard in play. */ + +static bool +conflict_std (int standard, const char *a1, const char *a2, const char *name, + locus *where) +{ + if (name == NULL) +{ + return gfc_notify_std (standard, "%s attribute conflicts " +"with %s attribute at %L", a1, a2, +where); +} + else +{ + return gfc_notify_std (standard, "%s attribute conflicts " +"with %s attribute in %qs at %L", +a1, a2, name, where); +} +} + /* This is a generic conflict-checker. We do this to avoid having a single conflict in two places. */ #define conf(a, b) if (attr->a && attr->b) { a1 = a; a2 = b; goto conflict; } #define conf2(a) if (attr->a) { a2 = a; goto conflict; } -#define conf_std(a, b, std) if (attr->a && attr->b)\ - {\ -a1 = a;\ -a2 = b;\ -standard = std;\ -goto conflict_std;\ - } +#define conf_std(a, b, std) if (attr->a && attr->b \ + && !conflict_std (std, a, b, name, where)) \ + return false; bool gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) @@ -451,7 +469,6 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) "OACC DECLARE DEVICE_RESIDENT"; const char *a1, *a2; - int standard; if (attr->artificial) return true; @@ -460,20 +477,10 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) where = _current_locus; if (attr->pointer && attr->intent != INTENT_UNKNOWN) -{ - a1 = pointer; - a2 = intent; - standard = GFC_STD_F2003; - goto conflict_std; -} +conf_std (pointer, intent, GFC_STD_F2003); - if (attr->in_namelist && (attr->allocatable || attr->pointer)) -{ - a1 = in_namelist; - a2 = attr->allocatable ? allocatable : pointer; - standard = GFC_STD_F2003; - goto conflict_std; -} + conf_std (in_namelist, allocatable, GFC_STD_F2003); + conf_std (in_namelist, pointer, GFC_STD_F2003); /* Check for attributes not allowed in a BLOCK DATA. */ if (gfc_current_state () == COMP_BLOCK_DATA) @@ -922,20 +929,6 @@ conflict: a1, a2, name, where); return false; - -conflict_std: - if (name == NULL) -{ - return gfc_notify_std (standard, "%s attribute conflicts " - "with %s attribute at %L", a1, a2, - where); -} - else -{ - return gfc_notify_std (standard, "%s attribute conflicts " -"with %s attribute in %qs at %L", - a1, a2, name, where); -} } #undef conf diff --git a/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 b/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 index 0e5505a0183..feed2e7645f 100644 --- a/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 +++ b/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 @@ -92,12 +92,12 @@ module m2 end function ! function result is a type that is not interoperable -function g (x) bind (c) ! { dg-error
[gcc r15-827] Fortran: fix bounds check for assignment, class component [PR86100]
https://gcc.gnu.org/g:93765736815a049e14d985b758a213cfe60c1e1c commit r15-827-g93765736815a049e14d985b758a213cfe60c1e1c Author: Harald Anlauf Date: Mon May 13 22:06:33 2024 +0200 Fortran: fix bounds check for assignment, class component [PR86100] gcc/fortran/ChangeLog: PR fortran/86100 * trans-array.cc (gfc_conv_ss_startstride): Use abridged_ref_name to generate a more user-friendly name for bounds-check messages. * trans-expr.cc (gfc_copy_class_to_class): Fix bounds check for rank>1 by looping over the dimensions. gcc/testsuite/ChangeLog: PR fortran/86100 * gfortran.dg/bounds_check_25.f90: New test. Diff: --- gcc/fortran/trans-array.cc| 7 - gcc/fortran/trans-expr.cc | 40 +++ gcc/testsuite/gfortran.dg/bounds_check_25.f90 | 32 + 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index c5b56f4e273..eec62c296ff 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -4911,6 +4911,7 @@ done: gfc_expr *expr; locus *expr_loc; const char *expr_name; + char *ref_name = NULL; ss_info = ss->info; if (ss_info->type != GFC_SS_SECTION) @@ -4922,7 +4923,10 @@ done: expr = ss_info->expr; expr_loc = >where; - expr_name = expr->symtree->name; + if (expr->ref) + expr_name = ref_name = abridged_ref_name (expr, NULL); + else + expr_name = expr->symtree->name; gfc_start_block (); @@ -5134,6 +5138,7 @@ done: gfc_add_expr_to_block (, tmp); + free (ref_name); } tmp = gfc_finish_block (); diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index e315e2d3370..dfc5b8e9b4a 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -1520,7 +1520,6 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems, bool unlimited) stmtblock_t body; stmtblock_t ifbody; gfc_loopinfo loop; - tree orig_nelems = nelems; /* Needed for bounds check. */ gfc_init_block (); tmp = fold_build2_loc (input_location, MINUS_EXPR, @@ -1552,27 +1551,32 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems, bool unlimited) /* Add bounds check. */ if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS) > 0 && is_from_desc) { - char *msg; const char *name = "<>"; - tree from_len; + int dim, rank; if (DECL_P (to)) - name = (const char *)(DECL_NAME (to)->identifier.id.str); - - from_len = gfc_conv_descriptor_size (from_data, 1); - from_len = fold_convert (TREE_TYPE (orig_nelems), from_len); - tmp = fold_build2_loc (input_location, NE_EXPR, - logical_type_node, from_len, orig_nelems); - msg = xasprintf ("Array bound mismatch for dimension %d " - "of array '%s' (%%ld/%%ld)", - 1, name); - - gfc_trans_runtime_check (true, false, tmp, , - _current_locus, msg, -fold_convert (long_integer_type_node, orig_nelems), - fold_convert (long_integer_type_node, from_len)); + name = IDENTIFIER_POINTER (DECL_NAME (to)); - free (msg); + rank = GFC_TYPE_ARRAY_RANK (TREE_TYPE (from_data)); + for (dim = 1; dim <= rank; dim++) + { + tree from_len, to_len, cond; + char *msg; + + from_len = gfc_conv_descriptor_size (from_data, dim); + from_len = fold_convert (long_integer_type_node, from_len); + to_len = gfc_conv_descriptor_size (to_data, dim); + to_len = fold_convert (long_integer_type_node, to_len); + msg = xasprintf ("Array bound mismatch for dimension %d " + "of array '%s' (%%ld/%%ld)", + dim, name); + cond = fold_build2_loc (input_location, NE_EXPR, + logical_type_node, from_len, to_len); + gfc_trans_runtime_check (true, false, cond, , + _current_locus, msg, + to_len, from_len); + free (msg); + } } tmp = build_call_vec (fcn_type, fcn, args); diff --git a/gcc/testsuite/gfortran.dg/bounds_check_25.f90 b/gcc/testsuite/gfortran.dg/bounds_check_25.f90 new file mode 100644 index 000..cc2247597f9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_25.f90 @@ -0,0 +1,32 @@ +! { dg-do run } +! { dg-additional-options "-fcheck=bounds -fdump-tree-original" } +! +! PR fortran/86100 - bogus bounds
[gcc r11-11448] c++: unroll pragma in templates [PR111529]
https://gcc.gnu.org/g:a644775c363979bc25951532819ffa0f244b82f4 commit r11-11448-ga644775c363979bc25951532819ffa0f244b82f4 Author: Jason Merrill Date: Fri Sep 22 12:10:11 2023 +0100 c++: unroll pragma in templates [PR111529] We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading to problems with substitution of any wrapped expressions. Let's also not tell users that lambda templates are available in C++14. PR c++/111529 gcc/cp/ChangeLog: * parser.c (cp_parser_lambda_declarator_opt): Don't suggest -std=c++14 for lambda templates. * pt.c (tsubst_expr): Move ANNOTATE_EXPR handling... (tsubst_copy_and_build): ...here. gcc/testsuite/ChangeLog: * g++.dg/ext/unroll-4.C: New test. (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8) Diff: --- gcc/cp/parser.c | 2 +- gcc/cp/pt.c | 14 +++--- gcc/testsuite/g++.dg/ext/unroll-4.C | 16 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 0619b834cf4..4f75f19ac50 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -11310,7 +11310,7 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) if (cxx_dialect < cxx14) pedwarn (parser->lexer->next_token->location, 0, "lambda templates are only available with " -"%<-std=c++14%> or %<-std=gnu++14%>"); +"%<-std=c++20%> or %<-std=gnu++20%>"); else if (cxx_dialect < cxx20) pedwarn (parser->lexer->next_token->location, OPT_Wpedantic, "lambda templates are only available with " diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 07515f63d29..8d39473de9e 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19367,13 +19367,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, RECUR (TREE_OPERAND (t, 1)), complain)); -case ANNOTATE_EXPR: - tmp = RECUR (TREE_OPERAND (t, 0)); - RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, - TREE_TYPE (tmp), tmp, - RECUR (TREE_OPERAND (t, 1)), - RECUR (TREE_OPERAND (t, 2; - case PREDICT_EXPR: RETURN (add_stmt (copy_node (t))); @@ -21123,6 +21116,13 @@ tsubst_copy_and_build (tree t, with constant operands. */ RETURN (t); +case ANNOTATE_EXPR: + op1 = RECUR (TREE_OPERAND (t, 0)); + RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, + TREE_TYPE (op1), op1, + RECUR (TREE_OPERAND (t, 1)), + RECUR (TREE_OPERAND (t, 2; + case NON_LVALUE_EXPR: case VIEW_CONVERT_EXPR: if (location_wrapper_p (t)) diff --git a/gcc/testsuite/g++.dg/ext/unroll-4.C b/gcc/testsuite/g++.dg/ext/unroll-4.C new file mode 100644 index 000..1d1643a6bd9 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/unroll-4.C @@ -0,0 +1,16 @@ +// PR c++/111529 +// { dg-do compile { target c++11 } } +// { dg-additional-options -w } + +template +void f() { + []() { +#pragma GCC unroll 9 +for (int i = 1; i; --i) { +} + }; +} + +int main() { + f<0>(); +}
[gcc r11-11449] c++: array of PMF [PR113598]
https://gcc.gnu.org/g:38de942670ad39c60ba4feae893d11843e0aebe8 commit r11-11449-g38de942670ad39c60ba4feae893d11843e0aebe8 Author: Jason Merrill Date: Thu Jan 25 12:02:07 2024 -0500 c++: array of PMF [PR113598] Here AGGREGATE_TYPE_P includes pointers to member functions, which is not what we want. Instead we should use class||array, as elsewhere in the function. PR c++/113598 gcc/cp/ChangeLog: * init.c (build_vec_init): Don't use {} for PMF. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-pmf2.C: New test. (cherry picked from commit 136a828754ff65079a83482b49d54bd5bc64) Diff: --- gcc/cp/init.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C | 12 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 08b26ba9a17..b6e63ee8f28 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -4479,7 +4479,9 @@ build_vec_init (tree base, tree maxindex, tree init, But for non-classes, that's the same as value-initialization. */ if (empty_list) { - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + if (cxx_dialect >= cxx11 + && (CLASS_TYPE_P (type) + || TREE_CODE (type) == ARRAY_TYPE)) { init = build_constructor (init_list_type_node, NULL); } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C new file mode 100644 index 000..59c3698a9f8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C @@ -0,0 +1,12 @@ +// PR c++/113598 +// { dg-additional-options -w } + +struct Cpu +{ + int op_nop(); +}; +typedef int(Cpu::*OpCode)(); +void f() +{ + new OpCode[256]{::op_nop}; +}
[gcc r11-11447] c++: __is_constructible ref binding [PR100667]
https://gcc.gnu.org/g:16046a075cb54c90609825e30b2ab45a03395ca1 commit r11-11447-g16046a075cb54c90609825e30b2ab45a03395ca1 Author: Jason Merrill Date: Wed Mar 27 16:14:01 2024 -0400 c++: __is_constructible ref binding [PR100667] The requirement that a type argument be complete is excessive in the case of direct reference binding to the same type, which does not rely on any properties of the type. This is LWG 2939. PR c++/100667 gcc/cp/ChangeLog: * semantics.c (same_type_ref_bind_p): New. (finish_trait_expr): Use it. gcc/testsuite/ChangeLog: * g++.dg/ext/is_constructible8.C: New test. (cherry picked from commit 8bb3ef3f6e335e8794590fb712a2661d11d21973) Diff: --- gcc/cp/semantics.c | 41 ++-- gcc/testsuite/g++.dg/ext/is_constructible8.C | 16 +++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 385e108a1c8..57e71ec3a3c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10570,6 +10570,38 @@ check_trait_type (tree type) return !!complete_type_or_else (strip_array_types (type), NULL_TREE); } +/* True iff the conversion (if any) would be a direct reference + binding, not requiring complete types. This is LWG2939. */ + +static bool +same_type_ref_bind_p (cp_trait_kind kind, tree type1, tree type2) +{ + tree from, to; + switch (kind) +{ + /* These put the target type first. */ +case CPTK_IS_CONSTRUCTIBLE: +case CPTK_IS_NOTHROW_CONSTRUCTIBLE: +case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: + to = type1; + from = type2; + break; + +default: + gcc_unreachable (); +} + + if (TREE_CODE (to) != REFERENCE_TYPE || !from) +return false; + if (TREE_CODE (from) == TREE_VEC && TREE_VEC_LENGTH (from) == 1) +from = TREE_VEC_ELT (from, 0); + else if (TREE_CODE (from) == TREE_LIST && !TREE_CHAIN (from)) +from = TREE_VALUE (from); + return (TYPE_P (from) + && (same_type_ignoring_top_level_qualifiers_p + (non_reference (to), non_reference (from; +} + /* Process a trait expression. */ tree @@ -10619,10 +10651,15 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CONSTRUCTIBLE: break; -case CPTK_IS_TRIVIALLY_ASSIGNABLE: case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: -case CPTK_IS_NOTHROW_ASSIGNABLE: case CPTK_IS_NOTHROW_CONSTRUCTIBLE: + /* Don't check completeness for direct reference binding. */; + if (same_type_ref_bind_p (kind, type1, type2)) + break; + gcc_fallthrough (); + +case CPTK_IS_NOTHROW_ASSIGNABLE: +case CPTK_IS_TRIVIALLY_ASSIGNABLE: if (!check_trait_type (type1) || !check_trait_type (type2)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/ext/is_constructible8.C b/gcc/testsuite/g++.dg/ext/is_constructible8.C new file mode 100644 index 000..4b8204c0768 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_constructible8.C @@ -0,0 +1,16 @@ +// PR c++/100667 +// { dg-do compile { target c++11 } } + +struct T; + +#define SA(X) static_assert ((X), #X); + +SA (__is_constructible(T&&, T)); +SA (__is_constructible(const T&, T)); +SA (!__is_constructible(T&, T)); +SA (__is_nothrow_constructible(T&&, T)); +SA (__is_nothrow_constructible(const T&, T)); +SA (!__is_nothrow_constructible(T&, T)); +SA (__is_trivially_constructible(T&&, T)); +SA (__is_trivially_constructible(const T&, T)); +SA (!__is_trivially_constructible(T&, T));
[gcc] Deleted branch 'mikael/heads/pr93635-v2_Harald' in namespace 'refs/users'
The branch 'mikael/heads/pr93635-v2_Harald' in namespace 'refs/users' was deleted. It previously pointed to: 1ea6d9d7f54... Fortran: improve attribute conflict checking [PR93635] Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- 1ea6d9d... Fortran: improve attribute conflict checking [PR93635]
[gcc r15-826] Small enhancement to implementation of -fdump-ada-spec
https://gcc.gnu.org/g:73eef7a04453d01147cbf4642fe6626350dded75 commit r15-826-g73eef7a04453d01147cbf4642fe6626350dded75 Author: Eric Botcazou Date: Fri May 24 19:48:18 2024 +0200 Small enhancement to implementation of -fdump-ada-spec This lets it recognize more preprocessing floating constants. gcc/c-family/ * c-ada-spec.cc (is_cpp_float): New predicate. (dump_number): Deal with more preprocessing floating constants. (dump_ada_macros) : Use is_cpp_float. Diff: --- gcc/c-family/c-ada-spec.cc | 70 -- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc index 8f0849bd427..0bea923220b 100644 --- a/gcc/c-family/c-ada-spec.cc +++ b/gcc/c-family/c-ada-spec.cc @@ -113,6 +113,26 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len, (*buffer_len)++; } +/* Return true if NUMBER is a preprocessing floating-point number. */ + +static bool +is_cpp_float (unsigned char *number) +{ + /* In C, a floating constant need not have a point. */ + while (*number != '\0') +{ + if (*number == '.') + return true; + else if ((*number == 'e' || *number == 'E') + && (*(number + 1) == '+' || *(number + 1) == '-')) + return true; + else + number++; +} + + return false; +} + /* Dump all digits/hex chars from NUMBER to BUFFER and return a pointer to the character after the last character written. If FLOAT_P is true, this is a floating-point number. */ @@ -120,12 +140,45 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len, static unsigned char * dump_number (unsigned char *number, unsigned char *buffer, bool float_p) { - while (*number != '\0' -&& *number != (float_p ? 'F' : 'U') -&& *number != (float_p ? 'f' : 'u') -&& *number != 'l' -&& *number != 'L') -*buffer++ = *number++; + /* In Ada, a real literal is a numeric literal that includes a point. */ + if (float_p) +{ + bool point_seen = false; + + while (*number != '\0') + { + if (ISDIGIT (*number)) + *buffer++ = *number++; + else if (*number == '.') + { + *buffer++ = *number++; + point_seen = true; + } + else if ((*number == 'e' || *number == 'E') + && (*(number + 1) == '+' || *(number + 1) == '-')) + { + if (!point_seen) + { + *buffer++ = '.'; + *buffer++ = '0'; + point_seen = true; + } + *buffer++ = *number++; + *buffer++ = *number++; + } + else + break; + } +} + + /* An integer literal is a numeric literal without a point. */ + else +while (*number != '\0' + && *number != 'U' + && *number != 'u' + && *number != 'l' + && *number != 'L') + *buffer++ = *number++; return buffer; } @@ -450,7 +503,7 @@ dump_ada_macros (pretty_printer *pp, const char* file) default: /* Dump floating-point constant unmodified. */ - if (strchr ((const char *)tmp, '.')) + if (is_cpp_float (tmp)) buffer = dump_number (tmp, buffer, true); else { @@ -480,8 +533,7 @@ dump_ada_macros (pretty_printer *pp, const char* file) default: buffer - = dump_number (tmp, buffer, - strchr ((const char *)tmp, '.')); + = dump_number (tmp, buffer, is_cpp_float (tmp)); break; } break;
[gcc(refs/users/meissner/heads/work167-tar)] Update ChangeLog.*
https://gcc.gnu.org/g:eb61a824e1d8ee0c86fca797c67fe2c55cec5c33 commit eb61a824e1d8ee0c86fca797c67fe2c55cec5c33 Author: Michael Meissner Date: Fri May 24 13:21:52 2024 -0400 Update ChangeLog.* Diff: --- gcc/ChangeLog.tar | 12 1 file changed, 12 insertions(+) diff --git a/gcc/ChangeLog.tar b/gcc/ChangeLog.tar index fab703bc7a4..8141a355c54 100644 --- a/gcc/ChangeLog.tar +++ b/gcc/ChangeLog.tar @@ -1,3 +1,15 @@ + Branch work167-tar, patch #203 + +Add -mintspr. + +2024-05-24 Michael Meissner + + * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Add + support for -mintspr. + * config/rs6000/rs6000.md (mov_internal): Add support for moving + QI/HImode to/from SPRs back. + * config/rs6000/rs6000.opt (-mintspr): New switch. + Branch work167-tar, patch #202 Add -mtar.
[gcc(refs/users/meissner/heads/work167-tar)] Add -mintspr.
https://gcc.gnu.org/g:819056304acea25b44313f402a5d9d51bf49d4cf commit 819056304acea25b44313f402a5d9d51bf49d4cf Author: Michael Meissner Date: Fri May 24 13:20:47 2024 -0400 Add -mintspr. 2024-05-24 Michael Meissner * config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached): Add support for -mintspr. * config/rs6000/rs6000.md (mov_internal): Add support for moving QI/HImode to/from SPRs back. * config/rs6000/rs6000.opt (-mintspr): New switch. Diff: --- gcc/config/rs6000/rs6000.cc | 6 +- gcc/config/rs6000/rs6000.md | 17 ++--- gcc/config/rs6000/rs6000.opt | 4 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index f72c62f4e5f..fa330c2a4b1 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -1952,7 +1952,11 @@ rs6000_hard_regno_mode_ok_uncached (int regno, machine_mode mode) case LR_REGNO: case CTR_REGNO: case TAR_REGNO: - return (!orig_complex_p && mode == Pmode); + return (!orig_complex_p + && (mode == Pmode + || (TARGET_INTSPR + && SCALAR_INT_MODE_P (mode) + && GET_MODE_SIZE (mode) <= UNITS_PER_WORD))); default: break; diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index d1ab06998c7..b5dc0719a88 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -8064,16 +8064,16 @@ ;; MR LHZ/LBZLXSI*ZXSTH/STBSTXSI*XLI ;; XXLOR load 0 load -1VSPLTI*# MFVSRWZ -;; MTVSRWZ +;; MTVSRWZ MF%1 MT%1 NOP (define_insn "*mov_internal" [(set (match_operand:QHI 0 "nonimmediate_operand" "=r,r, wa,m, ?Z,r, wa,wa,wa,v, ?v,r, -wa") +wa,r, *c*l, *h") (match_operand:QHI 1 "input_operand" "r, m, ?Z,r, wa,i, wa,O, wM,wB,wS,wa, -r"))] +r, *h,r, 0"))] "gpc_reg_operand (operands[0], mode) || gpc_reg_operand (operands[1], mode)" "@ @@ -8089,19 +8089,22 @@ vspltis %0,%1 # mfvsrwz %0,%x1 - mtvsrwz %x0,%1" + mtvsrwz %x0,%1 + mf%1 %0 + mt%0 %1 + nop" [(set_attr "type" "*, load, fpload,store, fpstore, *, vecsimple, vecperm, vecperm, vecperm, vecperm, mfvsr, -mtvsr") +mtvsr, mfjmpr,mtjmpr,*") (set_attr "length" "*, *, *, *, *, *, *, *, *, *, 8, *, -*") +*, *, *, *") (set_attr "isa" "*, *, p9v, *, p9v, *, p9v, p9v, p9v, p9v, p9v, p9v, -p9v")]) +p9v, *, *, *")]) ;; Here is how to move condition codes around. When we store CC data in diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt index 7f7a283bc99..bac74695f64 100644 --- a/gcc/config/rs6000/rs6000.opt +++ b/gcc/config/rs6000/rs6000.opt @@ -634,6 +634,10 @@ mtar Target Undocumented Mask(TAR) Var(rs6000_isa_flags) Allow (do not allow) use the TAR register. +mintspr +Target Undocumented Var(TARGET_INTSPR) Init(0) Save +Allow (do not allow) small integers in SPR registers. + ; Documented parameters -param=rs6000-vect-unroll-limit=
[gcc r12-10470] c++: __is_constructible ref binding [PR100667]
https://gcc.gnu.org/g:ba57a52dbf6a64ba66f72c20064c5c0e8cc9dbbb commit r12-10470-gba57a52dbf6a64ba66f72c20064c5c0e8cc9dbbb Author: Jason Merrill Date: Wed Mar 27 16:14:01 2024 -0400 c++: __is_constructible ref binding [PR100667] The requirement that a type argument be complete is excessive in the case of direct reference binding to the same type, which does not rely on any properties of the type. This is LWG 2939. PR c++/100667 gcc/cp/ChangeLog: * semantics.cc (same_type_ref_bind_p): New. (finish_trait_expr): Use it. gcc/testsuite/ChangeLog: * g++.dg/ext/is_constructible8.C: New test. (cherry picked from commit 8bb3ef3f6e335e8794590fb712a2661d11d21973) Diff: --- gcc/cp/semantics.cc | 41 ++-- gcc/testsuite/g++.dg/ext/is_constructible8.C | 16 +++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index e5db5189f33..0672d6c5b68 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -12034,6 +12034,38 @@ check_trait_type (tree type) return !!complete_type_or_else (strip_array_types (type), NULL_TREE); } +/* True iff the conversion (if any) would be a direct reference + binding, not requiring complete types. This is LWG2939. */ + +static bool +same_type_ref_bind_p (cp_trait_kind kind, tree type1, tree type2) +{ + tree from, to; + switch (kind) +{ + /* These put the target type first. */ +case CPTK_IS_CONSTRUCTIBLE: +case CPTK_IS_NOTHROW_CONSTRUCTIBLE: +case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: + to = type1; + from = type2; + break; + +default: + gcc_unreachable (); +} + + if (TREE_CODE (to) != REFERENCE_TYPE || !from) +return false; + if (TREE_CODE (from) == TREE_VEC && TREE_VEC_LENGTH (from) == 1) +from = TREE_VEC_ELT (from, 0); + else if (TREE_CODE (from) == TREE_LIST && !TREE_CHAIN (from)) +from = TREE_VALUE (from); + return (TYPE_P (from) + && (same_type_ignoring_top_level_qualifiers_p + (non_reference (to), non_reference (from; +} + /* Process a trait expression. */ tree @@ -12083,10 +12115,15 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_CONSTRUCTIBLE: break; -case CPTK_IS_TRIVIALLY_ASSIGNABLE: case CPTK_IS_TRIVIALLY_CONSTRUCTIBLE: -case CPTK_IS_NOTHROW_ASSIGNABLE: case CPTK_IS_NOTHROW_CONSTRUCTIBLE: + /* Don't check completeness for direct reference binding. */; + if (same_type_ref_bind_p (kind, type1, type2)) + break; + gcc_fallthrough (); + +case CPTK_IS_NOTHROW_ASSIGNABLE: +case CPTK_IS_TRIVIALLY_ASSIGNABLE: if (!check_trait_type (type1) || !check_trait_type (type2)) return error_mark_node; diff --git a/gcc/testsuite/g++.dg/ext/is_constructible8.C b/gcc/testsuite/g++.dg/ext/is_constructible8.C new file mode 100644 index 000..4b8204c0768 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/is_constructible8.C @@ -0,0 +1,16 @@ +// PR c++/100667 +// { dg-do compile { target c++11 } } + +struct T; + +#define SA(X) static_assert ((X), #X); + +SA (__is_constructible(T&&, T)); +SA (__is_constructible(const T&, T)); +SA (!__is_constructible(T&, T)); +SA (__is_nothrow_constructible(T&&, T)); +SA (__is_nothrow_constructible(const T&, T)); +SA (!__is_nothrow_constructible(T&, T)); +SA (__is_trivially_constructible(T&&, T)); +SA (__is_trivially_constructible(const T&, T)); +SA (!__is_trivially_constructible(T&, T));
[gcc r12-10469] c++: fix PR111529 backport
https://gcc.gnu.org/g:6a5dcdb7ae6bbd9c5a273ceadc7f7c7cd8a6c8ec commit r12-10469-g6a5dcdb7ae6bbd9c5a273ceadc7f7c7cd8a6c8ec Author: Jason Merrill Date: Fri May 24 11:19:29 2024 -0400 c++: fix PR111529 backport r12-10468-g19827831516023 added the ANNOTATE_EXPR in the wrong place, leading to ICEs on several testcases. gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build): Move ANNOTATE_EXPR out of fallthrough path. Diff: --- gcc/cp/pt.cc | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 1dcdaad571a..d6cdab5ad80 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -21535,6 +21535,13 @@ tsubst_copy_and_build (tree t, with constant operands. */ RETURN (t); +case ANNOTATE_EXPR: + op1 = RECUR (TREE_OPERAND (t, 0)); + RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, + TREE_TYPE (op1), op1, + RECUR (TREE_OPERAND (t, 1)), + RECUR (TREE_OPERAND (t, 2; + case NON_LVALUE_EXPR: case VIEW_CONVERT_EXPR: if (location_wrapper_p (t)) @@ -21544,13 +21551,6 @@ tsubst_copy_and_build (tree t, EXPR_LOCATION (t))); /* fallthrough. */ -case ANNOTATE_EXPR: - op1 = RECUR (TREE_OPERAND (t, 0)); - RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, - TREE_TYPE (op1), op1, - RECUR (TREE_OPERAND (t, 1)), - RECUR (TREE_OPERAND (t, 2; - default: /* Handle Objective-C++ constructs, if appropriate. */ {
[gcc r14-10242] c++: deleting array temporary [PR115187]
https://gcc.gnu.org/g:9031c027827bff44e1b55c366fc7034c43501b4c commit r14-10242-g9031c027827bff44e1b55c366fc7034c43501b4c Author: Jason Merrill Date: Wed May 22 18:41:27 2024 -0400 c++: deleting array temporary [PR115187] Decaying the array temporary to a pointer and then deleting that crashes in verify_gimple_stmt, because the TARGET_EXPR is first evaluated inside the TRY_FINALLY_EXPR, but the cleanup point is outside. Fixed by using get_target_expr instead of save_expr. I also adjust the stabilize_expr comment to prevent me from again thinking it's a suitable replacement. PR c++/115187 gcc/cp/ChangeLog: * init.cc (build_delete): Use get_target_expr instead of save_expr. * tree.cc (stabilize_expr): Update comment. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/array-prvalue3.C: New test. Diff: --- gcc/cp/init.cc | 9 - gcc/cp/tree.cc | 6 +- gcc/testsuite/g++.dg/cpp1z/array-prvalue3.C | 8 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index e758a8c8568..c5ba82c8664 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -5222,9 +5222,13 @@ build_delete (location_t loc, tree otype, tree addr, addr = convert_force (build_pointer_type (type), addr, 0, complain); } + tree addr_expr = NULL_TREE; if (deleting) /* We will use ADDR multiple times so we must save it. */ -addr = save_expr (addr); +{ + addr_expr = get_target_expr (addr); + addr = TARGET_EXPR_SLOT (addr_expr); +} bool virtual_p = false; if (type_build_dtor_call (type)) @@ -5343,6 +5347,9 @@ build_delete (location_t loc, tree otype, tree addr, if (!integer_nonzerop (ifexp)) expr = build3 (COND_EXPR, void_type_node, ifexp, expr, void_node); + if (addr_expr) +expr = cp_build_compound_expr (addr_expr, expr, tf_none); + protected_set_expr_location (expr, loc); return expr; } diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 9d37d255d8d..41fdf67f757 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -5952,7 +5952,11 @@ decl_storage_duration (tree decl) *INITP) an expression that will perform the pre-evaluation. The value returned by this function is a side-effect free expression equivalent to the pre-evaluated expression. Callers must ensure - that *INITP is evaluated before EXP. */ + that *INITP is evaluated before EXP. + + Note that if EXPR is a glvalue, the return value is a glvalue denoting the + same address; this function does not guard against modification of the + stored value like save_expr or get_target_expr do. */ tree stabilize_expr (tree exp, tree* initp) diff --git a/gcc/testsuite/g++.dg/cpp1z/array-prvalue3.C b/gcc/testsuite/g++.dg/cpp1z/array-prvalue3.C new file mode 100644 index 000..f264e46084a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/array-prvalue3.C @@ -0,0 +1,8 @@ +// PR c++/115187 +// { dg-do compile { target c++17 } } + +void f() { + using T = int[2]; + delete T{}; // { dg-warning "deleting array" } + // { dg-warning "unallocated object" "" { target *-*-* } .-1 } +}
[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] [to-be-committed, v2, RISC-V] Use bclri in constant synthesis
https://gcc.gnu.org/g:a08b5d4d5c6d679a9d65797eaea93aa381ece172 commit a08b5d4d5c6d679a9d65797eaea93aa381ece172 Author: Jeff Law Date: Fri May 24 07:27:00 2024 -0600 [to-be-committed,v2,RISC-V] Use bclri in constant synthesis Testing with Zbs enabled by default showed a minor logic error. After the loop clearing things with bclri, we can only use the sequence if we were able to clear all the necessary bits. If any bits are still on, then the bclr sequence turned out to not be profitable. -- So this is conceptually similar to how we handled direct generation of bseti for constant synthesis, but this time for bclr. In the bclr case, we already have an expander for AND. So we just needed to adjust the predicate to accept another class of constant operands (those with a single bit clear). With that in place constant synthesis is adjusted so that it counts the number of bits clear in the high 33 bits of a 64bit word. If that number is small relative to the current best cost, then we try to generate the constant with a lui based sequence for the low half which implicitly sets the upper 32 bits as well. Then we bclri one or more of those upper 33 bits. So as an example, this code goes from 4 instructions down to 3: > unsigned long foo_0xfffbf7ff(void) { return 0xfffbf7ffUL; } Note the use of 33 bits above. That's meant to capture cases like this: > unsigned long foo_0xfffd77ff(void) { return 0xfffd77ffUL; } We can use lui+addi+bclri+bclri to synthesize that in 4 instructions instead of 5. I'm including a handful of cases covering the two basic ideas above that were found by the testing code. And, no, we're not done yet. I see at least one more notable idiom missing before exploring zbkb's potential to improve things. Tested in my tester and waiting on Rivos CI system before moving forward. gcc/ * config/riscv/predicates.md (arith_operand_or_mode_mask): Renamed to.. (arith_or_mode_mask_or_zbs_operand): New predicate. * config/riscv/riscv.md (and3): Update predicate for operand 2. * config/riscv/riscv.cc (riscv_build_integer_1): Use bclri to clear bits, particularly bits 31..63 when profitable to do so. gcc/testsuite/ * gcc.target/riscv/synthesis-6.c: New test. (cherry picked from commit 401994d60ab38ffa9e63f368f0456eb7b08599be) Diff: --- gcc/config/riscv/predicates.md | 14 ++-- gcc/config/riscv/riscv.cc| 34 ++ gcc/config/riscv/riscv.md| 2 +- gcc/testsuite/gcc.target/riscv/synthesis-6.c | 95 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md index 8948fbfc363..0fb5729fdcf 100644 --- a/gcc/config/riscv/predicates.md +++ b/gcc/config/riscv/predicates.md @@ -27,12 +27,6 @@ (ior (match_operand 0 "const_arith_operand") (match_operand 0 "register_operand"))) -(define_predicate "arith_operand_or_mode_mask" - (ior (match_operand 0 "arith_operand") - (and (match_code "const_int") -(match_test "UINTVAL (op) == GET_MODE_MASK (HImode) -|| UINTVAL (op) == GET_MODE_MASK (SImode)" - (define_predicate "lui_operand" (and (match_code "const_int") (match_test "LUI_OPERAND (INTVAL (op))"))) @@ -398,6 +392,14 @@ (and (match_code "const_int") (match_test "SINGLE_BIT_MASK_OPERAND (~UINTVAL (op))"))) +(define_predicate "arith_or_mode_mask_or_zbs_operand" + (ior (match_operand 0 "arith_operand") + (and (match_test "TARGET_ZBS") + (match_operand 0 "not_single_bit_mask_operand")) + (and (match_code "const_int") + (match_test "UINTVAL (op) == GET_MODE_MASK (HImode) +|| UINTVAL (op) == GET_MODE_MASK (SImode)" + (define_predicate "const_si_mask_operand" (and (match_code "const_int") (match_test "(INTVAL (op) & (GET_MODE_BITSIZE (SImode) - 1)) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 85df5b7ab49..92935275aaa 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -893,6 +893,40 @@ riscv_build_integer_1 (struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS], codes[1].use_uw = false; cost = 2; } + + /* If LUI/ADDI are going to set bits 32..63 and we need a small +number of them cleared, we might be able to use bclri profitably. + +Note we may allow clearing of bit 31 using bclri. There's a class +of constants with that bit clear where this helps. */ + else if (TARGET_64BIT + && TARGET_ZBS + && (32 - popcount_hwi (value & HOST_WIDE_INT_C
[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] RISC-V: Enable vectorization for vect-early-break_124-pr114403.c
https://gcc.gnu.org/g:4e981cccad14ea3add39f92378da41d203814a60 commit 4e981cccad14ea3add39f92378da41d203814a60 Author: xuli Date: Mon May 20 01:56:47 2024 + RISC-V: Enable vectorization for vect-early-break_124-pr114403.c Because "targetm.slow_unaligned_access" is set to true by default (aka -mtune=rocket) for RISC-V, it causes the __builtin_memcpy with 8 bytes failed to folded into int64 assignment during ccp1. So adding "-mtune=generic-ooo" to the RISC-V target can vectorize vect-early-break_124-pr114403.c. gcc/testsuite/ChangeLog: * gcc.dg/vect/vect-early-break_124-pr114403.c: Enable vectrization for RISC-V target. (cherry picked from commit ffab721f3c9ecbb9831844d844ad257b69a77993) Diff: --- gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c index 101ae1e0eaa..610b951b262 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_124-pr114403.c @@ -1,8 +1,9 @@ /* { dg-add-options vect_early_break } */ /* { dg-require-effective-target vect_early_break_hw } */ /* { dg-require-effective-target vect_long_long } */ +/* { dg-additional-options "-mtune=generic-ooo" { target riscv*-*-* } } */ -/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail riscv*-*-* } } } */ +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ #include "tree-vect.h" @@ -74,4 +75,3 @@ int main () return 0; } -
[gcc r15-825] c: Fix for some variably modified types not being recognized [PR114831]
https://gcc.gnu.org/g:9f1798c1a93257526196a3c19828e40fb28ac551 commit r15-825-g9f1798c1a93257526196a3c19828e40fb28ac551 Author: Martin Uecker Date: Sat May 18 14:40:02 2024 +0200 c: Fix for some variably modified types not being recognized [PR114831] We did not evaluate expressions with variably modified types correctly in typeof and did not produce warnings when jumping over declarations using typeof. After addressof or array-to-pointer decay we construct new pointer types that have to be marked variably modified if the pointer target is variably modified. 2024-05-18 Martin Uecker PR c/114831 gcc/c/ * c-typeck.cc (array_to_pointer_conversion, build_unary_op): Propagate flag to pointer target. gcc/testsuite/ * gcc.dg/pr114831-1.c: New test. * gcc.dg/pr114831-2.c: New test. * gcc.dg/gnu23-varmod-1.c: New test. * gcc.dg/gnu23-varmod-2.c: New test. Diff: --- gcc/c/c-typeck.cc | 9 + gcc/testsuite/gcc.dg/gnu23-varmod-1.c | 12 gcc/testsuite/gcc.dg/gnu23-varmod-2.c | 16 gcc/testsuite/gcc.dg/pr114831-1.c | 27 +++ gcc/testsuite/gcc.dg/pr114831-2.c | 16 5 files changed, 80 insertions(+) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 7ecca9f58c6..2d092357e0f 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -1891,8 +1891,12 @@ array_to_pointer_conversion (location_t loc, tree exp) copy_warning (exp, orig_exp); + bool varmod = C_TYPE_VARIABLY_MODIFIED (restype); + ptrtype = build_pointer_type (restype); + C_TYPE_VARIABLY_MODIFIED (ptrtype) = varmod; + if (INDIRECT_REF_P (exp)) return convert (ptrtype, TREE_OPERAND (exp, 0)); @@ -4630,6 +4634,7 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, tree eptype = NULL_TREE; const char *invalid_op_diag; bool int_operands; + bool varmod; int_operands = EXPR_INT_CONST_OPERANDS (xarg); if (int_operands) @@ -5113,8 +5118,12 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, gcc_assert (TREE_CODE (arg) != COMPONENT_REF || !DECL_C_BIT_FIELD (TREE_OPERAND (arg, 1))); + varmod = C_TYPE_VARIABLY_MODIFIED (argtype); + argtype = build_pointer_type (argtype); + C_TYPE_VARIABLY_MODIFIED (argtype) = varmod; + /* ??? Cope with user tricks that amount to offsetof. Delete this when we have proper support for integer constant expressions. */ val = get_base_address (arg); diff --git a/gcc/testsuite/gcc.dg/gnu23-varmod-1.c b/gcc/testsuite/gcc.dg/gnu23-varmod-1.c new file mode 100644 index 000..add10d13573 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-varmod-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } + * { dg-options "-std=gnu23" } */ + +int foo(int n) +{ + int (*a(void))[n] { return 0; }; + goto err; /* { dg-error "jump into scope" "variably modified" } */ + typeof((n++,a)) b2; +err: + return n; +} + diff --git a/gcc/testsuite/gcc.dg/gnu23-varmod-2.c b/gcc/testsuite/gcc.dg/gnu23-varmod-2.c new file mode 100644 index 000..c36af1d1647 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu23-varmod-2.c @@ -0,0 +1,16 @@ +/* { dg-do run } + * { dg-options "-std=gnu23" } */ + +int foo(int n) +{ + int (*a(void))[n] { return 0; }; + typeof((n++,a)) b2; + return n; +} + +int main() +{ + if (2 != foo(1)) + __builtin_abort(); +} + diff --git a/gcc/testsuite/gcc.dg/pr114831-1.c b/gcc/testsuite/gcc.dg/pr114831-1.c new file mode 100644 index 000..ed30a494b3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114831-1.c @@ -0,0 +1,27 @@ +/* { dg-do compile } + * { dg-options "-std=c23" } */ + +void f(int n) +{ + int a[n]; + goto foo; /* { dg-error "jump into scope" "variably modified" } */ + typeof(a) b1; +foo: +} + +void g(int n) +{ + int a2[1][n]; + goto foo; /* { dg-error "jump into scope" "variably modified" } */ + typeof((n++,a2)) b2; +foo: +} + +void h(int n) +{ + int a[n]; + typeof(a) b1; + goto foo; /* { dg-error "jump into scope" "variably modified" } */ + typeof() b; +foo: +} diff --git a/gcc/testsuite/gcc.dg/pr114831-2.c b/gcc/testsuite/gcc.dg/pr114831-2.c new file mode 100644 index 000..ecfd87988c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr114831-2.c @@ -0,0 +1,16 @@ +/* { dg-do run } + * { dg-options "-std=c23" } */ + +int foo(int n) +{ + int a[1][n]; + typeof((n++,a)) b2; + return n; +} + +int main() +{ + if (2 != foo(1)) + __builtin_abort(); +} +
[gcc r14-10241] c++: Propagate using decls from partitions [PR114868]
https://gcc.gnu.org/g:782ad2033ea0709a25ef3e899cbb9491406146d5 commit r14-10241-g782ad2033ea0709a25ef3e899cbb9491406146d5 Author: Nathaniel Shead Date: Tue Apr 9 21:49:58 2024 +1000 c++: Propagate using decls from partitions [PR114868] The modules code currently neglects to set OVL_USING_P on the dependency created for a using-decl, which causes it not to remember that the OVL_EXPORT_P flag had been set on it when emitted from the primary interface unit. This patch ensures that it occurs. PR c++/114868 gcc/cp/ChangeLog: * module.cc (depset::hash::add_binding_entity): Propagate OVL_USING_P for using-declarations. gcc/testsuite/ChangeLog: * g++.dg/modules/using-15_a.C: New test. * g++.dg/modules/using-15_b.C: New test. * g++.dg/modules/using-15_c.C: New test. Signed-off-by: Nathaniel Shead (cherry picked from commit 0d0215b10dbbe39d655ceda4af283f288ec7680c) Diff: --- gcc/cp/module.cc | 6 ++ gcc/testsuite/g++.dg/modules/using-15_a.C | 14 ++ gcc/testsuite/g++.dg/modules/using-15_b.C | 6 ++ gcc/testsuite/g++.dg/modules/using-15_c.C | 8 4 files changed, 34 insertions(+) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 85c410aaa4c..b610b808240 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -13151,10 +13151,14 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) /* Ignore NTTP objects. */ return false; + bool unscoped_enum_const_p = false; if (!(flags & WMB_Using) && CP_DECL_CONTEXT (decl) != data->ns) { /* A using that lost its wrapper or an unscoped enum constant. */ + /* FIXME: Ensure that unscoped enums are differentiated from +'using enum' declarations when PR c++/114683 is fixed. */ + unscoped_enum_const_p = (TREE_CODE (decl) == CONST_DECL); flags = WMB_Flags (flags | WMB_Using); if (DECL_MODULE_EXPORT_P (TREE_CODE (decl) == CONST_DECL ? TYPE_NAME (TREE_TYPE (decl)) @@ -13215,6 +13219,8 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags flags, void *data_) if (flags & WMB_Using) { decl = ovl_make (decl, NULL_TREE); + if (!unscoped_enum_const_p) + OVL_USING_P (decl) = true; if (flags & WMB_Export) OVL_EXPORT_P (decl) = true; } diff --git a/gcc/testsuite/g++.dg/modules/using-15_a.C b/gcc/testsuite/g++.dg/modules/using-15_a.C new file mode 100644 index 000..3f4bb6c5914 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_a.C @@ -0,0 +1,14 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts -Wno-global-module" } +// { dg-module-cmi M:a } + +module; +namespace foo { + void a(); +} +export module M:a; + +namespace bar { + // propagate usings from partitions + export using foo::a; +} diff --git a/gcc/testsuite/g++.dg/modules/using-15_b.C b/gcc/testsuite/g++.dg/modules/using-15_b.C new file mode 100644 index 000..4b0cb745157 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_b.C @@ -0,0 +1,6 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts" } +// { dg-module-cmi M } + +export module M; +export import :a; diff --git a/gcc/testsuite/g++.dg/modules/using-15_c.C b/gcc/testsuite/g++.dg/modules/using-15_c.C new file mode 100644 index 000..74dd10a5413 --- /dev/null +++ b/gcc/testsuite/g++.dg/modules/using-15_c.C @@ -0,0 +1,8 @@ +// PR c++/114868 +// { dg-additional-options "-fmodules-ts" } +import M; + +int main() { + bar::a(); + foo::a(); // { dg-error "not been declared" } +}
[gcc r14-10240] c++: Fix instantiation of imported temploid friends [PR114275]
https://gcc.gnu.org/g:fd6fd88b1a93f4fb38f095688255ab5c00122810 commit r14-10240-gfd6fd88b1a93f4fb38f095688255ab5c00122810 Author: Nathaniel Shead Date: Mon Apr 29 17:00:13 2024 +1000 c++: Fix instantiation of imported temploid friends [PR114275] This patch fixes a number of issues with the handling of temploid friend declarations. The primary issue is that instantiations of friend declarations should attach the declaration to the same module as the befriending class, by [module.unit] p7.1 and [temp.friend] p2; this could be a different module from the current TU, and so needs special handling. The other main issue here is that we can't assume that just because name lookup didn't find a definition for a hidden class template, that it doesn't exist at all: it could be a non-exported entity that we've nevertheless streamed in from an imported module. We need to ensure that when instantiating template friend classes that we return the same TEMPLATE_DECL that we got from our imports, otherwise we will get later issues with 'duplicate_decls' (rightfully) complaining that they're different when trying to merge. This doesn't appear necessary for function templates due to the existing name lookup handling already finding these hidden declarations. (cherry-picked from commits b5f6a56940e70838a07e885de03a92e2bd64674a and ec2365e07537e8b17745d75c28a2b45bf33be119) PR c++/105320 PR c++/114275 gcc/cp/ChangeLog: * cp-tree.h (propagate_defining_module): Declare. (remove_defining_module): Declare. (lookup_imported_hidden_friend): Declare. * decl.cc (duplicate_decls): Also check if hidden decls can be redeclared in this module. Call remove_defining_module on to-be-freed newdecl. * module.cc (imported_temploid_friends): New. (init_modules): Initialize it. (trees_out::decl_value): Write it; don't consider imported temploid friends as attached to a module. (trees_in::decl_value): Read it for non-discarded decls. (get_originating_module_decl): Follow the owning decl for an imported temploid friend. (propagate_defining_module): New. (remove_defining_module): New. * name-lookup.cc (get_mergeable_namespace_binding): New. (lookup_imported_hidden_friend): New. * pt.cc (tsubst_friend_function): Propagate defining module for new friend functions. (tsubst_friend_class): Lookup imported hidden friends. Check for valid module attachment of existing names. Propagate defining module for new classes. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-10_a.C: New test. * g++.dg/modules/tpl-friend-10_b.C: New test. * g++.dg/modules/tpl-friend-10_c.C: New test. * g++.dg/modules/tpl-friend-10_d.C: New test. * g++.dg/modules/tpl-friend-11_a.C: New test. * g++.dg/modules/tpl-friend-11_b.C: New test. * g++.dg/modules/tpl-friend-12_a.C: New test. * g++.dg/modules/tpl-friend-12_b.C: New test. * g++.dg/modules/tpl-friend-12_c.C: New test. * g++.dg/modules/tpl-friend-12_d.C: New test. * g++.dg/modules/tpl-friend-12_e.C: New test. * g++.dg/modules/tpl-friend-12_f.C: New test. * g++.dg/modules/tpl-friend-13_a.C: New test. * g++.dg/modules/tpl-friend-13_b.C: New test. * g++.dg/modules/tpl-friend-13_c.C: New test. * g++.dg/modules/tpl-friend-13_d.C: New test. * g++.dg/modules/tpl-friend-13_e.C: New test. * g++.dg/modules/tpl-friend-13_f.C: New test. * g++.dg/modules/tpl-friend-13_g.C: New test. * g++.dg/modules/tpl-friend-14_a.C: New test. * g++.dg/modules/tpl-friend-14_b.C: New test. * g++.dg/modules/tpl-friend-14_c.C: New test. * g++.dg/modules/tpl-friend-14_d.C: New test. * g++.dg/modules/tpl-friend-9.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Reviewed-by: Patrick Palka Diff: --- gcc/cp/cp-tree.h | 3 ++ gcc/cp/decl.cc | 41 -- gcc/cp/module.cc | 75 ++ gcc/cp/name-lookup.cc | 53 ++ gcc/cp/pt.cc | 32 ++- gcc/testsuite/g++.dg/modules/tpl-friend-10_a.C | 15 ++ gcc/testsuite/g++.dg/modules/tpl-friend-10_b.C | 5 ++ gcc/testsuite/g++.dg/modules/tpl-friend-10_c.C | 7 +++ gcc/testsuite/g++.dg/modules/tpl-friend-10_d.C | 8 +++ gcc/testsuite/g++.dg/modules/tpl-friend-11_a.C | 14 +
[gcc r14-10239] c++: Standardise errors for module_may_redeclare
https://gcc.gnu.org/g:557cddcc71c9025932b30f1f825dc600a82dfe03 commit r14-10239-g557cddcc71c9025932b30f1f825dc600a82dfe03 Author: Nathaniel Shead Date: Sun Apr 14 23:03:11 2024 +1000 c++: Standardise errors for module_may_redeclare Currently different places calling 'module_may_redeclare' all emit very similar but slightly different error messages, and handle different kinds of declarations differently. This patch makes the function perform its own error messages so that they're all in one place, and prepares it for use with temploid friends. gcc/cp/ChangeLog: * cp-tree.h (module_may_redeclare): Add default parameter. * decl.cc (duplicate_decls): Don't emit errors for failed module_may_redeclare. (xref_tag): Likewise. (start_enum): Likewise. * semantics.cc (begin_class_definition): Likewise. * module.cc (module_may_redeclare): Clean up logic. Emit error messages on failure. gcc/testsuite/ChangeLog: * g++.dg/modules/enum-12.C: Update error message. * g++.dg/modules/friend-5_b.C: Likewise. * g++.dg/modules/shadow-1_b.C: Likewise. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill (cherry picked from commit 2faf040335f9b49c33ba6d40cf317920f27ce431) Diff: --- gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.cc| 28 +-- gcc/cp/module.cc | 120 -- gcc/cp/semantics.cc | 6 +- gcc/testsuite/g++.dg/modules/enum-12.C| 2 +- gcc/testsuite/g++.dg/modules/friend-5_b.C | 2 +- gcc/testsuite/g++.dg/modules/shadow-1_b.C | 5 +- 7 files changed, 89 insertions(+), 76 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 64760a40215..d4a70807460 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7402,7 +7402,7 @@ inline bool module_exporting_p () extern module_state *get_module (tree name, module_state *parent = NULL, bool partition = false); -extern bool module_may_redeclare (tree decl); +extern bool module_may_redeclare (tree olddecl, tree newdecl = NULL); extern bool module_global_init_needed (); extern bool module_determine_import_inits (); diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index fea66e838ce..93f81e42127 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -2279,18 +2279,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) && TREE_CODE (olddecl) != NAMESPACE_DECL && !hiding) { - if (!module_may_redeclare (olddecl)) - { - if (DECL_ARTIFICIAL (olddecl)) - error ("declaration %qD conflicts with builtin", newdecl); - else - { - error ("declaration %qD conflicts with import", newdecl); - inform (olddecl_loc, "import declared %q#D here", olddecl); - } - - return error_mark_node; - } + if (!module_may_redeclare (olddecl, newdecl)) + return error_mark_node; tree not_tmpl = STRIP_TEMPLATE (olddecl); if (DECL_LANG_SPECIFIC (not_tmpl) @@ -16633,12 +16623,7 @@ xref_tag (enum tag_types tag_code, tree name, { tree decl = TYPE_NAME (t); if (!module_may_redeclare (decl)) - { - auto_diagnostic_group d; - error ("cannot declare %qD in a different module", decl); - inform (DECL_SOURCE_LOCATION (decl), "previously declared here"); - return error_mark_node; - } + return error_mark_node; tree not_tmpl = STRIP_TEMPLATE (decl); if (DECL_LANG_SPECIFIC (not_tmpl) @@ -16986,12 +16971,7 @@ start_enum (tree name, tree enumtype, tree underlying_type, { tree decl = TYPE_NAME (enumtype); if (!module_may_redeclare (decl)) - { - auto_diagnostic_group d; - error ("cannot declare %qD in different module", decl); - inform (DECL_SOURCE_LOCATION (decl), "previously declared here"); - enumtype = error_mark_node; - } + enumtype = error_mark_node; else set_instantiating_module (decl); } diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 3bf863e15d4..c2f077d6fd8 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -19003,11 +19003,15 @@ get_importing_module (tree decl, bool flexible) return module->mod; } -/* Is it permissible to redeclare DECL. */ +/* Is it permissible to redeclare OLDDECL with NEWDECL. + + If NEWDECL is NULL, assumes that OLDDECL will be redeclared using + the current scope's module and attachment. */ bool -module_may_redeclare (tree decl) +module_may_redeclare (tree olddecl, tree newdecl) { + tree decl = olddecl; for (;;) { tree ctx = CP_DECL_CONTEXT (decl);
[gcc r15-824] c++/modules: Improve errors for bad module-directives [PR115200]
https://gcc.gnu.org/g:dae606a11eb99814e452b49241fa76f7678f53b8 commit r15-824-gdae606a11eb99814e452b49241fa76f7678f53b8 Author: Nathaniel Shead Date: Fri May 24 00:08:57 2024 +1000 c++/modules: Improve errors for bad module-directives [PR115200] This fixes an ICE when a module directive is not given at global scope. Although not explicitly mentioned, it seems implied from [basic.link] p1 and [module.global.frag] that a module-declaration must appear at the global scope after preprocessing. Apart from this the patch also slightly improves the errors given when accidentally using a module control-line in other situations where it is not expected. PR c++/115200 gcc/cp/ChangeLog: * parser.cc (cp_parser_error_1): Special-case unexpected module directives for better diagnostics. (cp_parser_module_declaration): Check that the module declaration is at global scope. (cp_parser_import_declaration): Sync error message with that in cp_parser_error_1. gcc/testsuite/ChangeLog: * g++.dg/modules/mod-decl-1.C: Update error messages. * g++.dg/modules/mod-decl-6.C: New test. * g++.dg/modules/mod-decl-7.C: New test. * g++.dg/modules/mod-decl-8.C: New test. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/parser.cc | 26 +++--- gcc/testsuite/g++.dg/modules/mod-decl-1.C | 8 +--- gcc/testsuite/g++.dg/modules/mod-decl-6.C | 11 +++ gcc/testsuite/g++.dg/modules/mod-decl-7.C | 11 +++ gcc/testsuite/g++.dg/modules/mod-decl-8.C | 14 ++ 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 476ddc0d63a..779625144db 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -3230,6 +3230,19 @@ cp_parser_error_1 (cp_parser* parser, const char* gmsgid, return; } + if (cp_token_is_module_directive (token)) +{ + auto_diagnostic_group d; + error_at (token->location, "unexpected module directive"); + if (token->keyword != RID__EXPORT) + inform (token->location, "perhaps insert a line break after" + " %qs, or other disambiguation, to prevent this being" + " considered a module control-line", + (token->keyword == RID__MODULE) ? "module" : "import"); + cp_parser_skip_to_pragma_eol (parser, token); + return; +} + /* If this is actually a conflict marker, report it as such. */ if (token->type == CPP_LSHIFT || token->type == CPP_RSHIFT @@ -15135,12 +15148,19 @@ cp_parser_module_declaration (cp_parser *parser, module_parse mp_state, parser->lexer->in_pragma = true; cp_token *token = cp_lexer_consume_token (parser->lexer); + tree scope = current_scope (); if (flag_header_unit) { error_at (token->location, "module-declaration not permitted in header-unit"); goto skip_eol; } + else if (scope != global_namespace) +{ + error_at (token->location, "module-declaration must be at global scope"); + inform (DECL_SOURCE_LOCATION (scope), "scope opened here"); + goto skip_eol; +} else if (mp_state == MP_FIRST && !exporting && cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON)) { @@ -15217,9 +15237,9 @@ cp_parser_import_declaration (cp_parser *parser, module_parse mp_state, error_at (token->location, "post-module-declaration" " imports must be contiguous"); note_lexer: - inform (token->location, "perhaps insert a line break, or other" - " disambiguation, to prevent this being considered a" - " module control-line"); + inform (token->location, "perhaps insert a line break after" + " %, or other disambiguation, to prevent this" + " being considered a module control-line"); skip_eol: cp_parser_skip_to_pragma_eol (parser, token); } diff --git a/gcc/testsuite/g++.dg/modules/mod-decl-1.C b/gcc/testsuite/g++.dg/modules/mod-decl-1.C index 23d34483dd7..df398b3ef50 100644 --- a/gcc/testsuite/g++.dg/modules/mod-decl-1.C +++ b/gcc/testsuite/g++.dg/modules/mod-decl-1.C @@ -10,17 +10,19 @@ module foo.second; // { dg-error "only permitted as" } namespace Foo { -module third; // { dg-error "only permitted as" } +module third; // { dg-error "must be at global scope" } } struct Baz { - module forth; // { dg-error "expected" } + module forth; // { dg-error "unexpected module directive" } + // { dg-message "line break after .module." "" { target *-*-* } .-1 } }; void Bink () { - module fifth; // { dg-error "expected" } + module fifth; // { dg-error "unexpected module directive" } + // { dg-message "line break after .module." "" { target *-*-* } .-1 } } module a.; // { dg-error "only
[gcc r15-823] c++/modules: Remember that header units have CMIs
https://gcc.gnu.org/g:03531ec45f15aa187bbab7842a1eb6cf746a104b commit r15-823-g03531ec45f15aa187bbab7842a1eb6cf746a104b Author: Nathaniel Shead Date: Thu May 23 22:56:52 2024 +1000 c++/modules: Remember that header units have CMIs This appears to be an oversight in the definition of module_has_cmi_p. This change will allow us to use the function directly in more places that need to additional work only if generating a module CMI in the future, allowing us to do additional work only when we know we need it. gcc/cp/ChangeLog: * cp-tree.h (module_has_cmi_p): Also include header units. (module_maybe_has_cmi_p): Update comment. * module.cc (set_defining_module): Only need to track declarations for later exporting if the module may have a CMI. (set_defining_module_for_partial_spec): Likewise. * name-lookup.cc (pushdecl): Likewise. Signed-off-by: Nathaniel Shead Diff: --- gcc/cp/cp-tree.h | 7 +++ gcc/cp/module.cc | 4 ++-- gcc/cp/name-lookup.cc | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 7ae5b876735..655850a9ab6 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -7381,7 +7381,7 @@ inline bool module_interface_p () inline bool module_partition_p () { return module_kind & MK_PARTITION; } inline bool module_has_cmi_p () -{ return module_kind & (MK_INTERFACE | MK_PARTITION); } +{ return module_kind & (MK_INTERFACE | MK_PARTITION | MK_HEADER); } inline bool module_purview_p () { return module_kind & MK_PURVIEW; } @@ -7393,9 +7393,8 @@ inline bool named_module_purview_p () inline bool named_module_attach_p () { return named_module_p () && module_attach_p (); } -/* We don't know if this TU will have a CMI while parsing the GMF, - so tentatively assume that it might, for the purpose of determining - whether no-linkage decls could be used by an importer. */ +/* Like module_has_cmi_p, but tentatively assumes that this TU may have a + CMI if we haven't seen the module-declaration yet. */ inline bool module_maybe_has_cmi_p () { return module_has_cmi_p () || (named_module_p () && !module_purview_p ()); } diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 3ca963cb3e9..6cd7d9e0b93 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -19221,7 +19221,7 @@ set_defining_module (tree decl) gcc_checking_assert (!DECL_LANG_SPECIFIC (decl) || !DECL_MODULE_IMPORT_P (decl)); - if (module_p ()) + if (module_maybe_has_cmi_p ()) { /* We need to track all declarations within a module, not just those in the module purview, because we don't necessarily know yet if @@ -19261,7 +19261,7 @@ set_defining_module (tree decl) void set_defining_module_for_partial_spec (tree decl) { - if (module_p () + if (module_maybe_has_cmi_p () && DECL_IMPLICIT_TYPEDEF_P (decl) && CLASSTYPE_TEMPLATE_SPECIALIZATION (TREE_TYPE (decl))) vec_safe_push (partial_specializations, decl); diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc index 78f08acffaa..f1f8c19feb1 100644 --- a/gcc/cp/name-lookup.cc +++ b/gcc/cp/name-lookup.cc @@ -4103,7 +4103,7 @@ pushdecl (tree decl, bool hiding) if (level->kind == sk_namespace && TREE_PUBLIC (level->this_entity) - && module_p ()) + && module_maybe_has_cmi_p ()) maybe_record_mergeable_decl (slot, name, decl); } }
[gcc r15-822] c++/modules: Fix treatment of unnamed types
https://gcc.gnu.org/g:0173dcce92baa62a74929814a75edb75eeab1a54 commit r15-822-g0173dcce92baa62a74929814a75edb75eeab1a54 Author: Nathaniel Shead Date: Thu May 23 22:50:58 2024 +1000 c++/modules: Fix treatment of unnamed types In r14-9530 we relaxed "depending on type with no-linkage" errors for declarations that could actually be accessed from different TUs anyway. However, this also enabled it for unnamed types, which never work. In a normal module interface, an unnamed type is TU-local by [basic.link] p15.2, and so cannot be exposed or the program is ill-formed. We don't yet implement this checking but we should assume that we will later; currently supporting this actually causes ICEs when attempting to create the mangled name in some situations. For a header unit, by [module.import] p5.3 it is unspecified whether two TUs importing a header unit providing such a declaration are importing the same header unit. In this case, we would require name mangling changes to somehow allow the (anonymous) type exported by such a header unit to correspond across different TUs in the presence of other anonymous declarations, so for this patch just assume that this case would be an ODR violation instead. gcc/cp/ChangeLog: * tree.cc (no_linkage_check): Anonymous types can't be accessed in a different TU. gcc/testsuite/ChangeLog: * g++.dg/modules/linkage-1_a.C: Remove anonymous type test. * g++.dg/modules/linkage-1_b.C: Likewise. * g++.dg/modules/linkage-1_c.C: Likewise. * g++.dg/modules/linkage-2.C: Add note about anonymous types. Signed-off-by: Nathaniel Shead Reviewed-by: Jason Merrill Diff: --- gcc/cp/tree.cc | 10 +- gcc/testsuite/g++.dg/modules/linkage-1_a.C | 4 gcc/testsuite/g++.dg/modules/linkage-1_b.C | 1 - gcc/testsuite/g++.dg/modules/linkage-1_c.C | 1 - gcc/testsuite/g++.dg/modules/linkage-2.C | 6 ++ 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 0485a618c6c..fe3f034d000 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -2988,15 +2988,7 @@ no_linkage_check (tree t, bool relaxed_p) /* Only treat unnamed types as having no linkage if they're at namespace scope. This is core issue 966. */ if (TYPE_UNNAMED_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) - { - if (relaxed_p - && TREE_PUBLIC (CP_TYPE_CONTEXT (t)) - && module_maybe_has_cmi_p ()) - /* This type could possibly be accessed outside this TU. */ - return NULL_TREE; - else - return t; - } + return t; for (r = CP_TYPE_CONTEXT (t); ; ) { diff --git a/gcc/testsuite/g++.dg/modules/linkage-1_a.C b/gcc/testsuite/g++.dg/modules/linkage-1_a.C index 750e31ff347..1d81312e94f 100644 --- a/gcc/testsuite/g++.dg/modules/linkage-1_a.C +++ b/gcc/testsuite/g++.dg/modules/linkage-1_a.C @@ -9,7 +9,3 @@ auto f() { } decltype(f()) g(); // { dg-warning "used but not defined" "" { target c++17_down } } export auto x = g(); - -struct {} s; -decltype(s) h(); // { dg-warning "used but not defined" "" { target c++17_down } } -export auto y = h(); diff --git a/gcc/testsuite/g++.dg/modules/linkage-1_b.C b/gcc/testsuite/g++.dg/modules/linkage-1_b.C index f23962d76b7..5bc0d1b888d 100644 --- a/gcc/testsuite/g++.dg/modules/linkage-1_b.C +++ b/gcc/testsuite/g++.dg/modules/linkage-1_b.C @@ -3,4 +3,3 @@ module M; decltype(f()) g() { return {}; } -decltype(s) h() { return {}; } diff --git a/gcc/testsuite/g++.dg/modules/linkage-1_c.C b/gcc/testsuite/g++.dg/modules/linkage-1_c.C index f1406b99032..9ff1491b67e 100644 --- a/gcc/testsuite/g++.dg/modules/linkage-1_c.C +++ b/gcc/testsuite/g++.dg/modules/linkage-1_c.C @@ -5,5 +5,4 @@ import M; int main() { auto a = x; - auto b = y; } diff --git a/gcc/testsuite/g++.dg/modules/linkage-2.C b/gcc/testsuite/g++.dg/modules/linkage-2.C index eb4d7b051af..d913d6a30fc 100644 --- a/gcc/testsuite/g++.dg/modules/linkage-2.C +++ b/gcc/testsuite/g++.dg/modules/linkage-2.C @@ -23,4 +23,10 @@ export void use() { h(); } +// Additionally, unnamed types have no linkage but are also TU-local, and thus +// cannot be exposed in a module interface unit. The non-TU-local entity 's' +// here is an exposure of this type, so this should be an error; we don't yet +// implement this checking however. +struct {} s; // { dg-error "TU-local" "" { xfail *-*-* } } + // { dg-prune-output "not writing module" }
[gcc(refs/users/aoliva/heads/testme)] Introduce attribute sym_alias
https://gcc.gnu.org/g:3612317409b4c0ec201d7f536638015872ffbc8d commit 3612317409b4c0ec201d7f536638015872ffbc8d Author: Alexandre Oliva Date: Thu Dec 14 03:21:21 2023 -0300 Introduce attribute sym_alias This patch introduces an attribute to add extra asm names (aliases) for a decl when its definition is output. The main goal is to ease interfacing C++ with Ada, as C++ mangled names have to be named, and in some cases (e.g. when using stdint.h typedefs in function arguments) the symbol names may vary across platforms. The attribute is usable in C and C++, presumably in all C-family languages. It can be attached to global variables and functions, and also to local static variables. In C++, it can also be attached to class types, namespace-scoped variables and functions, static data members, member functions, explicit instantiations and specializations of template functions, members and classes. When applied to constructors or destructor, additional sym aliases with _Base and _Del suffixes are defined for variants other than complete-object ones. This changes the assumption that clones always carry the same attributes as their abstract declarations, so there is now a function to adjust them. C++ also had a bug in which attributes from local extern declarations failed to be propagated to a preexisting corresponding namespace-scoped decl. I've fixed that, and adjusted acc tests that distinguished between C and C++ in this regard. Applying the attribute to class types is only valid in C++, and the effect is to attach the alias to the RTTI object associated with the class type. for gcc/ChangeLog * attribs.cc: Include cgraph.h. (decl_attributes): Allow late introduction of sym_alias in types. (create_sym_alias_decl, create_sym_alias_decls): New. * attribs.h: Declare them. (FOR_EACH_SYM_ALIAS): New macro. * cgraph.cc (cgraph_node::create): Create sym_alias decls. * varpool.cc (varpool_node::get_create): Create sym_alias decls. * cgraph.h (symtab_node::remap_sym_alias_target): New. * symtab.cc (symtab_node::remap_sym_alias_target): Define. (symbol_table::insert_to_assembler_name_hash): Check for symbol name clashes. (symtab_node::noninterposable_alias): Drop sym_alias attributes. * cgraphunit.cc (cgraph_node::analyze): Create alias_target node if needed. (analyze_functions): Fixup visibility of implicit alias only after its node is analyzed. * doc/extend.texi (sym_alias): Document for variables, functions and types. for gcc/ada/ChangeLog * doc/gnat_rm/interfacing_to_other_languages.rst: Mention attribute sym_alias to give RTTI symbols mnemonic names. * doc/gnat_ugn/the_gnat_compilation_model.rst: Mention aliases. Fix incorrect ref to C1 ctor variant. for gcc/c-family/ChangeLog * c-ada-spec.cc (pp_asm_name): Use first sym_alias if available. * c-attribs.cc (handle_sym_alias_attribute): New. (c_common_attribute_table): Add sym_alias. (handle_copy_attribute): Do not copy sym_alias attribute. for gcc/c/ChangeLog * c-decl.cc (duplicate_decls): Remap sym_alias target. (finish_decl): Create varpool_node for local static variables. for gcc/cp/ChangeLog * class.cc (adjust_clone_attributes): New. (copy_fndecl_with_name, build_clone): Call it. * cp-tree.h (adjust_clone_attributes): Declare. (update_sym_alias_interface): Declare. (update_tinfo_sym_alias): Declare. * decl.cc (duplicate_decls): Remap sym_alias target. Adjust clone attributes. (grokfndecl): Tentatively create sym_alias decls after adding attributes in e.g. a template member function explicit instantiation. * decl2.cc (cplus_decl_attributes): Update tinfo sym_alias. (copy_interface, update_sym_alias_interface): New. (determine_visibility): Update sym_alias interface. (tentative_decl_linkage, import_export_decl): Likewise. * name-lookup.cc: Include target.h and cgraph.h. (push_local_extern_decl_alias): Merge attributes with namespace-scoped decl, and drop duplicate sym_alias. * optimize.cc (maybe_clone_body): Re-adjust attributes after cloning them. Update sym_alias interface. * rtti.cc: Include attribs.h and cgraph.h. (get_tinfo_decl): Copy sym_alias attributes from type to tinfo decl. Create sym_alias
[gcc/aoliva/heads/testme] (32 commits) Introduce attribute sym_alias
The branch 'aoliva/heads/testme' was updated to point to: 3612317409b... Introduce attribute sym_alias It previously pointed to: 8cc56a8291a... testsuite: adjust iteration count for ppc costmodel 76b Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- 8cc56a8... testsuite: adjust iteration count for ppc costmodel 76b 0c3019c... [testsuite] conditionalize dg-additional-sources on target Summary of changes (added commits): --- 3612317... Introduce attribute sym_alias 7acd5d7... testsuite: adjust iteration count for ppc costmodel 76b (*) 85e2ce1... Fix gcc.dg/vect/vect-gather-4.c for cascadelake (*) 5b9b3ba... tree-optimization/115144 - improve sinking destination choi (*) 51f4b47... Fix typo in the testcase. (*) 3e06763... Use simple_dce_from_worklist in phiprop (*) c71886f... Avoid splitting store dataref groups during SLP discovery (*) ee49210... Daily bump. (*) 7fa0ffa... c++/modules: Ensure all partial specialisations are tracked (*) 66d2a76... libstdc++: Implement ranges::concat_view from P2542R7 (*) 83bb9ad... Move condexpr_adjust into gimple-range-fold (*) fae5e6a... Make gori_map a shared component. (*) ac0bc89... Make GORI a range_query component. (*) 44db939... Gori_compute inherits from gimple_outgoing_range. (*) a049f08... Gori_compute no longer inherits from gori_map. (*) 7615363... Default gimple_outgoing_range to not process switches. (*) efc4255... Add inferred ranges for range-ops based statements. (*) 07441e4... Move infer_manager to a range_query oracle. (*) 6c64a85... Allow components to be shared among range-queries. (*) fca649d... Rename relation oracle and API. (*) 3be530f... Move to an always available relation oracle. (*) 67afcf2... Move all relation queries into relation_oracle. (*) ed63cd2... c++: deleting array temporary [PR115187] (*) 0b3b6a8... Another small fix to implementation of -fdump-ada-spec (*) dca3e6b... Match: Add overloaded types_match to avoid code dup [NFC] (*) 2b2476d... tree-optimization/115197 - fix ICE w/ constant in LC PHI an (*) f0a0246... tree-optimization/115199 - fix PTA constraint processing fo (*) 61f5b3c... tree-optimization/115138 - ptr-vs-ptr and FUNCTION_DECLs (*) 4efa7ec... missing require target has_arch_ppc64 for pr106550.c (*) fc5e109... testsuite: vect: Fix gcc.dg/vect/vect-pr111779.c on SPARC [ (*) 2ce9051... Fortran: Fix ICEs due to comp calls in initialization exprs (*) 57e0487... s390: Implement TARGET_NOCE_CONVERSION_PROFITABLE_P [PR1095 (*) (*) This commit already exists in another branch. Because the reference `refs/users/aoliva/heads/testme' matches your hooks.email-new-commits-only configuration, no separate email is sent for this commit.
[gcc/aoliva/heads/testbase] (31 commits) testsuite: adjust iteration count for ppc costmodel 76b
The branch 'aoliva/heads/testbase' was updated to point to: 7acd5d71547... testsuite: adjust iteration count for ppc costmodel 76b It previously pointed to: dbdddc92a3b... [testsuite] xfail pr79004 on longdouble64; drop long_double Diff: Summary of changes (added commits): --- 7acd5d7... testsuite: adjust iteration count for ppc costmodel 76b (*) 85e2ce1... Fix gcc.dg/vect/vect-gather-4.c for cascadelake (*) 5b9b3ba... tree-optimization/115144 - improve sinking destination choi (*) 51f4b47... Fix typo in the testcase. (*) 3e06763... Use simple_dce_from_worklist in phiprop (*) c71886f... Avoid splitting store dataref groups during SLP discovery (*) ee49210... Daily bump. (*) 7fa0ffa... c++/modules: Ensure all partial specialisations are tracked (*) 66d2a76... libstdc++: Implement ranges::concat_view from P2542R7 (*) 83bb9ad... Move condexpr_adjust into gimple-range-fold (*) fae5e6a... Make gori_map a shared component. (*) ac0bc89... Make GORI a range_query component. (*) 44db939... Gori_compute inherits from gimple_outgoing_range. (*) a049f08... Gori_compute no longer inherits from gori_map. (*) 7615363... Default gimple_outgoing_range to not process switches. (*) efc4255... Add inferred ranges for range-ops based statements. (*) 07441e4... Move infer_manager to a range_query oracle. (*) 6c64a85... Allow components to be shared among range-queries. (*) fca649d... Rename relation oracle and API. (*) 3be530f... Move to an always available relation oracle. (*) 67afcf2... Move all relation queries into relation_oracle. (*) ed63cd2... c++: deleting array temporary [PR115187] (*) 0b3b6a8... Another small fix to implementation of -fdump-ada-spec (*) dca3e6b... Match: Add overloaded types_match to avoid code dup [NFC] (*) 2b2476d... tree-optimization/115197 - fix ICE w/ constant in LC PHI an (*) f0a0246... tree-optimization/115199 - fix PTA constraint processing fo (*) 61f5b3c... tree-optimization/115138 - ptr-vs-ptr and FUNCTION_DECLs (*) 4efa7ec... missing require target has_arch_ppc64 for pr106550.c (*) fc5e109... testsuite: vect: Fix gcc.dg/vect/vect-pr111779.c on SPARC [ (*) 2ce9051... Fortran: Fix ICEs due to comp calls in initialization exprs (*) 57e0487... s390: Implement TARGET_NOCE_CONVERSION_PROFITABLE_P [PR1095 (*) (*) This commit already exists in another branch. Because the reference `refs/users/aoliva/heads/testbase' matches your hooks.email-new-commits-only configuration, no separate email is sent for this commit.
[gcc r15-821] [to-be-committed, v2, RISC-V] Use bclri in constant synthesis
https://gcc.gnu.org/g:401994d60ab38ffa9e63f368f0456eb7b08599be commit r15-821-g401994d60ab38ffa9e63f368f0456eb7b08599be Author: Jeff Law Date: Fri May 24 07:27:00 2024 -0600 [to-be-committed,v2,RISC-V] Use bclri in constant synthesis Testing with Zbs enabled by default showed a minor logic error. After the loop clearing things with bclri, we can only use the sequence if we were able to clear all the necessary bits. If any bits are still on, then the bclr sequence turned out to not be profitable. -- So this is conceptually similar to how we handled direct generation of bseti for constant synthesis, but this time for bclr. In the bclr case, we already have an expander for AND. So we just needed to adjust the predicate to accept another class of constant operands (those with a single bit clear). With that in place constant synthesis is adjusted so that it counts the number of bits clear in the high 33 bits of a 64bit word. If that number is small relative to the current best cost, then we try to generate the constant with a lui based sequence for the low half which implicitly sets the upper 32 bits as well. Then we bclri one or more of those upper 33 bits. So as an example, this code goes from 4 instructions down to 3: > unsigned long foo_0xfffbf7ff(void) { return 0xfffbf7ffUL; } Note the use of 33 bits above. That's meant to capture cases like this: > unsigned long foo_0xfffd77ff(void) { return 0xfffd77ffUL; } We can use lui+addi+bclri+bclri to synthesize that in 4 instructions instead of 5. I'm including a handful of cases covering the two basic ideas above that were found by the testing code. And, no, we're not done yet. I see at least one more notable idiom missing before exploring zbkb's potential to improve things. Tested in my tester and waiting on Rivos CI system before moving forward. gcc/ * config/riscv/predicates.md (arith_operand_or_mode_mask): Renamed to.. (arith_or_mode_mask_or_zbs_operand): New predicate. * config/riscv/riscv.md (and3): Update predicate for operand 2. * config/riscv/riscv.cc (riscv_build_integer_1): Use bclri to clear bits, particularly bits 31..63 when profitable to do so. gcc/testsuite/ * gcc.target/riscv/synthesis-6.c: New test. Diff: --- gcc/config/riscv/predicates.md | 14 ++-- gcc/config/riscv/riscv.cc| 34 ++ gcc/config/riscv/riscv.md| 2 +- gcc/testsuite/gcc.target/riscv/synthesis-6.c | 95 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md index 8948fbfc363..0fb5729fdcf 100644 --- a/gcc/config/riscv/predicates.md +++ b/gcc/config/riscv/predicates.md @@ -27,12 +27,6 @@ (ior (match_operand 0 "const_arith_operand") (match_operand 0 "register_operand"))) -(define_predicate "arith_operand_or_mode_mask" - (ior (match_operand 0 "arith_operand") - (and (match_code "const_int") -(match_test "UINTVAL (op) == GET_MODE_MASK (HImode) -|| UINTVAL (op) == GET_MODE_MASK (SImode)" - (define_predicate "lui_operand" (and (match_code "const_int") (match_test "LUI_OPERAND (INTVAL (op))"))) @@ -398,6 +392,14 @@ (and (match_code "const_int") (match_test "SINGLE_BIT_MASK_OPERAND (~UINTVAL (op))"))) +(define_predicate "arith_or_mode_mask_or_zbs_operand" + (ior (match_operand 0 "arith_operand") + (and (match_test "TARGET_ZBS") + (match_operand 0 "not_single_bit_mask_operand")) + (and (match_code "const_int") + (match_test "UINTVAL (op) == GET_MODE_MASK (HImode) +|| UINTVAL (op) == GET_MODE_MASK (SImode)" + (define_predicate "const_si_mask_operand" (and (match_code "const_int") (match_test "(INTVAL (op) & (GET_MODE_BITSIZE (SImode) - 1)) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 85df5b7ab49..92935275aaa 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -893,6 +893,40 @@ riscv_build_integer_1 (struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS], codes[1].use_uw = false; cost = 2; } + + /* If LUI/ADDI are going to set bits 32..63 and we need a small +number of them cleared, we might be able to use bclri profitably. + +Note we may allow clearing of bit 31 using bclri. There's a class +of constants with that bit clear where this helps. */ + else if (TARGET_64BIT + && TARGET_ZBS + && (32 - popcount_hwi (value & HOST_WIDE_INT_C (0x8000))) + 1 < cost) + { + /* Turn on all those upper
[gcc r11-11446] c++: binding reference to comma expr [PR114561]
https://gcc.gnu.org/g:b35afe75674ff9f79cf9685d099bc80f10442216 commit r11-11446-gb35afe75674ff9f79cf9685d099bc80f10442216 Author: Jason Merrill Date: Tue Apr 2 10:52:28 2024 -0400 c++: binding reference to comma expr [PR114561] We represent a reference binding where the referent type is more qualified by a ck_ref_bind around a ck_qual. We performed the ck_qual and then tried to undo it with STRIP_NOPS, but that doesn't work if the conversion is buried in COMPOUND_EXPR. So instead let's avoid performing that fake conversion in the first place. PR c++/114561 PR c++/114562 gcc/cp/ChangeLog: * call.c (convert_like_internal): Avoid adding qualification conversion in direct reference binding. gcc/testsuite/ChangeLog: * g++.dg/conversion/ref10.C: New test. * g++.dg/conversion/ref11.C: New test. (cherry picked from commit 5d7e9a35024f065b25f61747859c7cb7a770c92b) Diff: --- gcc/cp/call.c | 23 +-- gcc/testsuite/g++.dg/conversion/ref10.C | 5 + gcc/testsuite/g++.dg/conversion/ref11.C | 33 + 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7c3ce1693e1..fbe29f38384 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7816,7 +7816,15 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, break; }; - expr = convert_like (next_conversion (convs), expr, fn, argnum, + conversion *nc = next_conversion (convs); + if (convs->kind == ck_ref_bind && nc->kind == ck_qual + && !convs->need_temporary_p) +/* direct_reference_binding might have inserted a ck_qual under + this ck_ref_bind for the benefit of conversion sequence ranking. + Don't actually perform that conversion. */ +nc = next_conversion (nc); + + expr = convert_like (nc, expr, fn, argnum, convs->kind == ck_ref_bind ? issue_conversion_warnings : false, c_cast_p, complain & ~tf_no_cleanup); @@ -7897,19 +7905,6 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, { tree ref_type = totype; - /* direct_reference_binding might have inserted a ck_qual under - this ck_ref_bind for the benefit of conversion sequence ranking. - Ignore the conversion; we'll create our own below. */ - if (next_conversion (convs)->kind == ck_qual - && !convs->need_temporary_p) - { - gcc_assert (same_type_p (TREE_TYPE (expr), -next_conversion (convs)->type)); - /* Strip the cast created by the ck_qual; cp_build_addr_expr - below expects an lvalue. */ - STRIP_NOPS (expr); - } - if (convs->bad_p && !next_conversion (convs)->bad_p) { tree extype = TREE_TYPE (expr); diff --git a/gcc/testsuite/g++.dg/conversion/ref10.C b/gcc/testsuite/g++.dg/conversion/ref10.C new file mode 100644 index 000..1913f733a6b --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref10.C @@ -0,0 +1,5 @@ +// PR c++/114561 + +void create(void* u) { + const void* const& r = ( (void)0, u ); +} diff --git a/gcc/testsuite/g++.dg/conversion/ref11.C b/gcc/testsuite/g++.dg/conversion/ref11.C new file mode 100644 index 000..bb9b835034c --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref11.C @@ -0,0 +1,33 @@ +// PR c++/114562 +// { dg-do compile { target c++11 } } + +template +struct Optional { + Optional(T&&); +}; + +struct MyClass { + MyClass(Optional); +}; + +// const void* NONE = nullptr; // Correct Error +void* NONE = nullptr; // Crash + +void beforeParam(); + +template +struct Create { + template static T create(U &&) noexcept; +}; + + +template +template +T Create::create(U && u) noexcept { + return T( ( (beforeParam()), (u) ) ); // { dg-error "cannot bind rvalue reference" } + // return T( (u) ); // Correct Error +} + +void test_func() { + Create::create(NONE); +}
[gcc r12-10468] c++: unroll pragma in templates [PR111529]
https://gcc.gnu.org/g:19827831516023f2dff449af0b228b2d60190a28 commit r12-10468-g19827831516023f2dff449af0b228b2d60190a28 Author: Jason Merrill Date: Fri Sep 22 12:10:11 2023 +0100 c++: unroll pragma in templates [PR111529] We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading to problems with substitution of any wrapped expressions. Let's also not tell users that lambda templates are available in C++14. PR c++/111529 gcc/cp/ChangeLog: * parser.cc (cp_parser_lambda_declarator_opt): Don't suggest -std=c++14 for lambda templates. * pt.cc (tsubst_expr): Move ANNOTATE_EXPR handling... (tsubst_copy_and_build): ...here. gcc/testsuite/ChangeLog: * g++.dg/ext/unroll-4.C: New test. (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8) Diff: --- gcc/cp/parser.cc| 7 ++- gcc/cp/pt.cc| 14 +++--- gcc/testsuite/g++.dg/ext/unroll-4.C | 16 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 194f9b07d83..9c1bd32cff1 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -11513,11 +11513,8 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) an opening angle if present. */ if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) { - if (cxx_dialect < cxx14) - pedwarn (parser->lexer->next_token->location, OPT_Wc__14_extensions, -"lambda templates are only available with " -"%<-std=c++14%> or %<-std=gnu++14%>"); - else if (pedantic && cxx_dialect < cxx20) + if (cxx_dialect < cxx20 + && (pedantic || cxx_dialect < cxx14)) pedwarn (parser->lexer->next_token->location, OPT_Wc__20_extensions, "lambda templates are only available with " "%<-std=c++20%> or %<-std=gnu++20%>"); diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index ed4dbe06179..1dcdaad571a 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -19616,13 +19616,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, templated_operator_saved_lookups (t), complain)); -case ANNOTATE_EXPR: - tmp = RECUR (TREE_OPERAND (t, 0)); - RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, - TREE_TYPE (tmp), tmp, - RECUR (TREE_OPERAND (t, 1)), - RECUR (TREE_OPERAND (t, 2; - case PREDICT_EXPR: RETURN (add_stmt (copy_node (t))); @@ -21551,6 +21544,13 @@ tsubst_copy_and_build (tree t, EXPR_LOCATION (t))); /* fallthrough. */ +case ANNOTATE_EXPR: + op1 = RECUR (TREE_OPERAND (t, 0)); + RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, + TREE_TYPE (op1), op1, + RECUR (TREE_OPERAND (t, 1)), + RECUR (TREE_OPERAND (t, 2; + default: /* Handle Objective-C++ constructs, if appropriate. */ { diff --git a/gcc/testsuite/g++.dg/ext/unroll-4.C b/gcc/testsuite/g++.dg/ext/unroll-4.C new file mode 100644 index 000..d488aca974e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/unroll-4.C @@ -0,0 +1,16 @@ +// PR c++/111529 +// { dg-do compile { target c++11 } } +// { dg-additional-options -Wno-c++20-extensions } + +template +void f() { + []() { +#pragma GCC unroll 9 +for (int i = 1; i; --i) { +} + }; +} + +int main() { + f<0>(); +}
[gcc r12-10467] c++: array of PMF [PR113598]
https://gcc.gnu.org/g:419b5e17eace9b6b985b9853db0dc1a5478375b6 commit r12-10467-g419b5e17eace9b6b985b9853db0dc1a5478375b6 Author: Jason Merrill Date: Thu Jan 25 12:02:07 2024 -0500 c++: array of PMF [PR113598] Here AGGREGATE_TYPE_P includes pointers to member functions, which is not what we want. Instead we should use class||array, as elsewhere in the function. PR c++/113598 gcc/cp/ChangeLog: * init.cc (build_vec_init): Don't use {} for PMF. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-pmf2.C: New test. (cherry picked from commit 136a828754ff65079a83482b49d54bd5bc64) Diff: --- gcc/cp/init.cc | 4 +++- gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C | 12 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 36a5d7c4849..a0a28f2a002 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4760,7 +4760,9 @@ build_vec_init (tree base, tree maxindex, tree init, But for non-classes, that's the same as value-initialization. */ if (empty_list) { - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + if (cxx_dialect >= cxx11 + && (CLASS_TYPE_P (type) + || TREE_CODE (type) == ARRAY_TYPE)) { init = build_constructor (init_list_type_node, NULL); } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C new file mode 100644 index 000..0fac8333c75 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C @@ -0,0 +1,12 @@ +// PR c++/113598 +// { dg-additional-options -Wno-c++11-extensions } + +struct Cpu +{ + int op_nop(); +}; +typedef int(Cpu::*OpCode)(); +void f() +{ + new OpCode[256]{::op_nop}; +}
[gcc r12-10466] c++: binding reference to comma expr [PR114561]
https://gcc.gnu.org/g:7076c565e22281e193aeafafbf40676426a64b75 commit r12-10466-g7076c565e22281e193aeafafbf40676426a64b75 Author: Jason Merrill Date: Tue Apr 2 10:52:28 2024 -0400 c++: binding reference to comma expr [PR114561] We represent a reference binding where the referent type is more qualified by a ck_ref_bind around a ck_qual. We performed the ck_qual and then tried to undo it with STRIP_NOPS, but that doesn't work if the conversion is buried in COMPOUND_EXPR. So instead let's avoid performing that fake conversion in the first place. PR c++/114561 PR c++/114562 gcc/cp/ChangeLog: * call.cc (convert_like_internal): Avoid adding qualification conversion in direct reference binding. gcc/testsuite/ChangeLog: * g++.dg/conversion/ref10.C: New test. * g++.dg/conversion/ref11.C: New test. (cherry picked from commit 5d7e9a35024f065b25f61747859c7cb7a770c92b) Diff: --- gcc/cp/call.cc | 23 +-- gcc/testsuite/g++.dg/conversion/ref10.C | 5 + gcc/testsuite/g++.dg/conversion/ref11.C | 33 + 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index 4f4cee5b95c..6fd6da4b2dd 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -8135,7 +8135,15 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, break; }; - expr = convert_like (next_conversion (convs), expr, fn, argnum, + conversion *nc = next_conversion (convs); + if (convs->kind == ck_ref_bind && nc->kind == ck_qual + && !convs->need_temporary_p) +/* direct_reference_binding might have inserted a ck_qual under + this ck_ref_bind for the benefit of conversion sequence ranking. + Don't actually perform that conversion. */ +nc = next_conversion (nc); + + expr = convert_like (nc, expr, fn, argnum, convs->kind == ck_ref_bind ? issue_conversion_warnings : false, c_cast_p, complain & ~tf_no_cleanup); @@ -8216,19 +8224,6 @@ convert_like_internal (conversion *convs, tree expr, tree fn, int argnum, { tree ref_type = totype; - /* direct_reference_binding might have inserted a ck_qual under - this ck_ref_bind for the benefit of conversion sequence ranking. - Ignore the conversion; we'll create our own below. */ - if (next_conversion (convs)->kind == ck_qual - && !convs->need_temporary_p) - { - gcc_assert (same_type_p (TREE_TYPE (expr), -next_conversion (convs)->type)); - /* Strip the cast created by the ck_qual; cp_build_addr_expr - below expects an lvalue. */ - STRIP_NOPS (expr); - } - if (convs->bad_p && !next_conversion (convs)->bad_p) { tree extype = TREE_TYPE (expr); diff --git a/gcc/testsuite/g++.dg/conversion/ref10.C b/gcc/testsuite/g++.dg/conversion/ref10.C new file mode 100644 index 000..1913f733a6b --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref10.C @@ -0,0 +1,5 @@ +// PR c++/114561 + +void create(void* u) { + const void* const& r = ( (void)0, u ); +} diff --git a/gcc/testsuite/g++.dg/conversion/ref11.C b/gcc/testsuite/g++.dg/conversion/ref11.C new file mode 100644 index 000..bb9b835034c --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/ref11.C @@ -0,0 +1,33 @@ +// PR c++/114562 +// { dg-do compile { target c++11 } } + +template +struct Optional { + Optional(T&&); +}; + +struct MyClass { + MyClass(Optional); +}; + +// const void* NONE = nullptr; // Correct Error +void* NONE = nullptr; // Crash + +void beforeParam(); + +template +struct Create { + template static T create(U &&) noexcept; +}; + + +template +template +T Create::create(U && u) noexcept { + return T( ( (beforeParam()), (u) ) ); // { dg-error "cannot bind rvalue reference" } + // return T( (u) ); // Correct Error +} + +void test_func() { + Create::create(NONE); +}
[gcc r13-8799] c++: unroll pragma in templates [PR111529]
https://gcc.gnu.org/g:53cdaa755de57e57ba9e787f232adc3cfde88209 commit r13-8799-g53cdaa755de57e57ba9e787f232adc3cfde88209 Author: Jason Merrill Date: Fri Sep 22 12:10:11 2023 +0100 c++: unroll pragma in templates [PR111529] We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading to problems with substitution of any wrapped expressions. Let's also not tell users that lambda templates are available in C++14. PR c++/111529 gcc/cp/ChangeLog: * parser.cc (cp_parser_lambda_declarator_opt): Don't suggest -std=c++14 for lambda templates. * pt.cc (tsubst_expr): Move ANNOTATE_EXPR handling... (tsubst_copy_and_build): ...here. gcc/testsuite/ChangeLog: * g++.dg/ext/unroll-4.C: New test. (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8) Diff: --- gcc/cp/parser.cc| 7 ++- gcc/cp/pt.cc| 14 +++--- gcc/testsuite/g++.dg/ext/unroll-4.C | 16 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 4e67da6ff3a..a9241bd7e7a 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -11558,11 +11558,8 @@ cp_parser_lambda_declarator_opt (cp_parser* parser, tree lambda_expr) an opening angle if present. */ if (cp_lexer_next_token_is (parser->lexer, CPP_LESS)) { - if (cxx_dialect < cxx14) - pedwarn (parser->lexer->next_token->location, OPT_Wc__14_extensions, -"lambda templates are only available with " -"%<-std=c++14%> or %<-std=gnu++14%>"); - else if (pedantic && cxx_dialect < cxx20) + if (cxx_dialect < cxx20 + && (pedantic || cxx_dialect < cxx14)) pedwarn (parser->lexer->next_token->location, OPT_Wc__20_extensions, "lambda templates are only available with " "%<-std=c++20%> or %<-std=gnu++20%>"); diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 3af705c647a..5a6bf80c3d4 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -19926,13 +19926,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) templated_operator_saved_lookups (t), complain)); -case ANNOTATE_EXPR: - tmp = RECUR (TREE_OPERAND (t, 0)); - RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, - TREE_TYPE (tmp), tmp, - RECUR (TREE_OPERAND (t, 1)), - RECUR (TREE_OPERAND (t, 2; - case PREDICT_EXPR: RETURN (add_stmt (copy_node (t))); @@ -21862,6 +21855,13 @@ tsubst_copy_and_build (tree t, RETURN (op); } +case ANNOTATE_EXPR: + op1 = RECUR (TREE_OPERAND (t, 0)); + RETURN (build3_loc (EXPR_LOCATION (t), ANNOTATE_EXPR, + TREE_TYPE (op1), op1, + RECUR (TREE_OPERAND (t, 1)), + RECUR (TREE_OPERAND (t, 2; + default: /* Handle Objective-C++ constructs, if appropriate. */ { diff --git a/gcc/testsuite/g++.dg/ext/unroll-4.C b/gcc/testsuite/g++.dg/ext/unroll-4.C new file mode 100644 index 000..d488aca974e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/unroll-4.C @@ -0,0 +1,16 @@ +// PR c++/111529 +// { dg-do compile { target c++11 } } +// { dg-additional-options -Wno-c++20-extensions } + +template +void f() { + []() { +#pragma GCC unroll 9 +for (int i = 1; i; --i) { +} + }; +} + +int main() { + f<0>(); +}
[gcc r13-8798] c++: array of PMF [PR113598]
https://gcc.gnu.org/g:5f1457841abc2fd8657a52d1371c983ac010f1cc commit r13-8798-g5f1457841abc2fd8657a52d1371c983ac010f1cc Author: Jason Merrill Date: Thu Jan 25 12:02:07 2024 -0500 c++: array of PMF [PR113598] Here AGGREGATE_TYPE_P includes pointers to member functions, which is not what we want. Instead we should use class||array, as elsewhere in the function. PR c++/113598 gcc/cp/ChangeLog: * init.cc (build_vec_init): Don't use {} for PMF. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-pmf2.C: New test. (cherry picked from commit 136a828754ff65079a83482b49d54bd5bc64) Diff: --- gcc/cp/init.cc | 4 +++- gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C | 12 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 78e992af171..4977ce34398 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4859,7 +4859,9 @@ build_vec_init (tree base, tree maxindex, tree init, But for non-classes, that's the same as value-initialization. */ if (empty_list) { - if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type)) + if (cxx_dialect >= cxx11 + && (CLASS_TYPE_P (type) + || TREE_CODE (type) == ARRAY_TYPE)) { init = build_constructor (init_list_type_node, NULL); } diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C new file mode 100644 index 000..0fac8333c75 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-pmf2.C @@ -0,0 +1,12 @@ +// PR c++/113598 +// { dg-additional-options -Wno-c++11-extensions } + +struct Cpu +{ + int op_nop(); +}; +typedef int(Cpu::*OpCode)(); +void f() +{ + new OpCode[256]{::op_nop}; +}
[gcc r15-820] vect: Fix access size alignment assumption [PR115192]
https://gcc.gnu.org/g:a0fe4fb1c8d7804515845dd5d2a814b3c7a1ccba commit r15-820-ga0fe4fb1c8d7804515845dd5d2a814b3c7a1ccba Author: Richard Sandiford Date: Fri May 24 13:47:21 2024 +0100 vect: Fix access size alignment assumption [PR115192] create_intersect_range_checks checks whether two access ranges a and b are alias-free using something equivalent to: end_a <= start_b || end_b <= start_a It has two ways of doing this: a "vanilla" way that calculates the exact exclusive end pointers, and another way that uses the last inclusive aligned pointers (and changes the comparisons accordingly). The comment for the latter is: /* Calculate the minimum alignment shared by all four pointers, then arrange for this alignment to be subtracted from the exclusive maximum values to get inclusive maximum values. This "- min_align" is cumulative with a "+ access_size" in the calculation of the maximum values. In the best (and common) case, the two cancel each other out, leaving us with an inclusive bound based only on seg_len. In the worst case we're simply adding a smaller number than before. The problem is that the associated code implicitly assumed that the access size was a multiple of the pointer alignment, and so the alignment could be carried over to the exclusive end pointer. The testcase started failing after g:9fa5b473b5b8e289b6542 because that commit improved the alignment information for the accesses. gcc/ PR tree-optimization/115192 * tree-data-ref.cc (create_intersect_range_checks): Take the alignment of the access sizes into account. gcc/testsuite/ PR tree-optimization/115192 * gcc.dg/vect/pr115192.c: New test. Diff: --- gcc/testsuite/gcc.dg/vect/pr115192.c | 28 gcc/tree-data-ref.cc | 5 - 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/vect/pr115192.c b/gcc/testsuite/gcc.dg/vect/pr115192.c new file mode 100644 index 000..923d377c1bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr115192.c @@ -0,0 +1,28 @@ +#include "tree-vect.h" + +int data[4 * 16 * 16] __attribute__((aligned(16))); + +__attribute__((noipa)) void +foo (__SIZE_TYPE__ n) +{ + for (__SIZE_TYPE__ i = 1; i < n; ++i) +{ + data[i * n * 4] = data[(i - 1) * n * 4] + 1; + data[i * n * 4 + 1] = data[(i - 1) * n * 4 + 1] + 2; +} +} + +int +main () +{ + check_vect (); + + data[0] = 10; + data[1] = 20; + + foo (3); + + if (data[24] != 12 || data[25] != 24) +__builtin_abort (); + return 0; +} diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc index db15ddb43de..7c4049faf34 100644 --- a/gcc/tree-data-ref.cc +++ b/gcc/tree-data-ref.cc @@ -73,6 +73,7 @@ along with GCC; see the file COPYING3. If not see */ +#define INCLUDE_ALGORITHM #include "config.h" #include "system.h" #include "coretypes.h" @@ -2640,7 +2641,9 @@ create_intersect_range_checks (class loop *loop, tree *cond_expr, Because the maximum values are inclusive, there is an alias if the maximum value of one segment is equal to the minimum value of the other. */ - min_align = MIN (dr_a.align, dr_b.align); + min_align = std::min (dr_a.align, dr_b.align); + min_align = std::min (min_align, known_alignment (dr_a.access_size)); + min_align = std::min (min_align, known_alignment (dr_b.access_size)); cmp_code = LT_EXPR; }
[gcc r15-819] modula2: fix xref fourth parameter in documentation, change from gm2 to m2
https://gcc.gnu.org/g:5833e5b8ef40367764325f4f3c80cfa129fbe1da commit r15-819-g5833e5b8ef40367764325f4f3c80cfa129fbe1da Author: Gaius Mulley Date: Fri May 24 13:42:58 2024 +0100 modula2: fix xref fourth parameter in documentation, change from gm2 to m2 This patch corrects the gm2.texi xref for the modula-2 documentation. gcc/ChangeLog: * doc/gm2.texi: Replace all occurrences of xref {, , , gm2} with xref {, , , m2}. Signed-off-by: Gaius Mulley Diff: --- gcc/doc/gm2.texi | 26 +- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi index b38d6a15de0..7e580400fb9 100644 --- a/gcc/doc/gm2.texi +++ b/gcc/doc/gm2.texi @@ -291,7 +291,7 @@ This manual only documents the options specific to @command{gm2}. This section describes how to compile and link a simple hello world program. It provides a few examples of using the different options -mentioned in @pxref{Compiler options, , ,gm2}. Assuming that you have +mentioned in @pxref{Compiler options, , ,m2}. Assuming that you have a file called @file{hello.mod} in your current directory which contains: @@ -442,7 +442,7 @@ turn on ISO standard features. Currently this enables the ISO @code{SYSTEM} module and alters the default library search path so that the ISO libraries are searched before the PIM libraries. It also effects the behavior of @code{DIV} and @code{MOD} operators. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -flibs= modifies the default library search path. The libraries supplied are: @@ -558,30 +558,30 @@ turn on PIM standard features. Currently this enables the PIM @code{SYSTEM} module and determines which identifiers are pervasive (declared in the base module). If no other @samp{-fpim[234]} switch is used then division and modulus operators behave as defined in PIM4. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -fpim2 turn on PIM-2 standard features. Currently this removes @code{SIZE} from being a pervasive identifier (declared in the base module). It places @code{SIZE} in the @code{SYSTEM} module. It also effects the behavior of @code{DIV} and @code{MOD} operators. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -fpim3 turn on PIM-3 standard features. Currently this only effects the behavior of @code{DIV} and @code{MOD} operators. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -fpim4 turn on PIM-4 standard features. Currently this only effects the behavior of @code{DIV} and @code{MOD} operators. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -fpositive-mod-floor-div forces the @code{DIV} and @code{MOD} operators to behave as defined by PIM4. All modulus results are positive and the results from the division are rounded to the floor. -@xref{Dialect, , ,gm2}. +@xref{Dialect, , ,m2}. @item -fpthread link against the pthread library. By default this option is on. It @@ -876,8 +876,8 @@ LONGCOMPLEX complex long double Note that GNU Modula-2 also supports fixed sized data types which are exported from the @code{SYSTEM} module. -@xref{The PIM system module, , ,gm2}. -@xref{The ISO system module, , ,gm2}. +@xref{The PIM system module, , ,m2}. +@xref{The ISO system module, , ,m2}. @node Standard procedures, High procedure function, Elementary data types, Using @section Permanently accessible base procedures. @@ -1628,7 +1628,7 @@ This section introduces the GNU Modula-2 language extensions. The GNU Modula-2 compiler allows abstract data types to be any type, not just restricted to a pointer type providing the @samp{-fextended-opaque} option is supplied -@xref{Compiler options, , ,gm2}. +@xref{Compiler options, , ,m2}. Declarations can be made in any order, whether they are types, constants, procedures, nested modules or variables. @@ -1829,8 +1829,8 @@ program module. GNU Modula-2 also provides additional fixed sized data types which are all exported from the @code{SYSTEM} module. -@xref{The PIM system module, , ,gm2}. -@xref{The ISO system module, , ,gm2}. +@xref{The PIM system module, , ,m2}. +@xref{The ISO system module, , ,m2}. @node Type compatibility, Unbounded by reference, Extensions, Using @section Type compatibility @@ -2205,7 +2205,7 @@ $ python3 testnum.py 1234 x 2 = 2468 @end example -@xref{Producing a Python module, , ,gm2} for another example which +@xref{Producing a Python module, , ,m2} for another example which uses the @code{UNQUALIFIED} keyword to reduce the module name clutter from the viewport of Python3.
[gcc r15-818] MATCH: Look through VIEW_CONVERT when folding VEC_PERM_EXPRs.
https://gcc.gnu.org/g:6d6f324bda1ccb51cd43ff9d4d017eb71bb2d690 commit r15-818-g6d6f324bda1ccb51cd43ff9d4d017eb71bb2d690 Author: Manolis Tsamis Date: Wed Nov 1 12:27:28 2023 +0100 MATCH: Look through VIEW_CONVERT when folding VEC_PERM_EXPRs. The match.pd patterns to merge two vector permutes into one fail when a potentially no-op view convert expressions is between the two permutes. This change lifts this restriction. gcc/ChangeLog: * match.pd: Allow no-op view_convert between permutes. gcc/testsuite/ChangeLog: * gcc.dg/fold-perm-2.c: New test. Diff: --- gcc/match.pd | 14 -- gcc/testsuite/gcc.dg/fold-perm-2.c | 16 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 7081d76d56a..024e3350465 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -10082,19 +10082,21 @@ and, d = VEC_PERM_EXPR ; */ (simplify - (vec_perm (vec_perm@0 @1 @2 VECTOR_CST@3) @0 VECTOR_CST@4) + (vec_perm (view_convert?@0 (vec_perm@1 @2 @3 VECTOR_CST@4)) @0 VECTOR_CST@5) (if (TYPE_VECTOR_SUBPARTS (type).is_constant ()) (with { machine_mode result_mode = TYPE_MODE (type); - machine_mode op_mode = TYPE_MODE (TREE_TYPE (@1)); + machine_mode op_mode = TYPE_MODE (TREE_TYPE (@2)); int nelts = TYPE_VECTOR_SUBPARTS (type).to_constant (); vec_perm_builder builder0; vec_perm_builder builder1; vec_perm_builder builder2 (nelts, nelts, 1); } - (if (tree_to_vec_perm_builder (, @3) - && tree_to_vec_perm_builder (, @4)) + (if (tree_to_vec_perm_builder (, @4) + && tree_to_vec_perm_builder (, @5) + && TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0))) + == TYPE_SIZE (TREE_TYPE (TREE_TYPE (@1 (with { vec_perm_indices sel0 (builder0, 2, nelts); @@ -10116,10 +10118,10 @@ and, ? (!can_vec_perm_const_p (result_mode, op_mode, sel0, false) || !can_vec_perm_const_p (result_mode, op_mode, sel1, false)) : !can_vec_perm_const_p (result_mode, op_mode, sel1, false))) -op0 = vec_perm_indices_to_tree (TREE_TYPE (@4), sel2); +op0 = vec_perm_indices_to_tree (TREE_TYPE (@5), sel2); } (if (op0) - (vec_perm @1 @2 { op0; }))) + (view_convert (vec_perm @2 @3 { op0; } /* Merge c = VEC_PERM_EXPR ; diff --git a/gcc/testsuite/gcc.dg/fold-perm-2.c b/gcc/testsuite/gcc.dg/fold-perm-2.c new file mode 100644 index 000..1a4ab4065de --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-perm-2.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre1" } */ + +typedef int veci __attribute__ ((vector_size (4 * sizeof (int; +typedef unsigned int vecu __attribute__ ((vector_size (4 * sizeof (unsigned int; + +void fun (veci *a, veci *b, veci *c) +{ + veci r1 = __builtin_shufflevector (*a, *b, 0, 5, 2, 7); + vecu r2 = __builtin_convertvector (r1, vecu); + vecu r3 = __builtin_shufflevector (r2, r2, 2, 3, 1, 0); + *c = __builtin_convertvector (r3, veci); +} + +/* { dg-final { scan-tree-dump "VEC_PERM_EXPR.*{ 2, 7, 5, 0 }" "fre1" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "fre1" } } */
[gcc r15-817] testsuite: adjust iteration count for ppc costmodel 76b
https://gcc.gnu.org/g:7acd5d71547f74a2af35bab1b17a518197d25d23 commit r15-817-g7acd5d71547f74a2af35bab1b17a518197d25d23 Author: Alexandre Oliva Date: Fri May 24 08:32:04 2024 -0300 testsuite: adjust iteration count for ppc costmodel 76b For some hardware which doesn't support unaligned vector memory access, test case costmodel-vect-76b.c expects to see cost modeling would make the decision that it's not profitable for peeling, according to the commit history, test case comments and the way to check. For now, the existing loop bound 14 works well for Power7, but it does not for some targets on which the cost of operation vec_perm can be different from Power7, such as: Power6, it's 3 vs. 1. This difference further causes the difference (10 vs. 12) on the minimum iteration for profitability and cause the failure. To keep the original test point, this patch is to tweak the loop bound to ensure it's not profitable to be vectorized for !vect_no_align with peeling. Co-Authored-By: Kewen Lin for gcc/testsuite/ChangeLog * gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c (N): Tweak. Diff: --- gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c index cbbfbb24658..e48b0ab759e 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c +++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-vect-76b.c @@ -6,7 +6,7 @@ /* On Power7 without misalign vector support, this case is to check it's not profitable to perform vectorization by peeling to align the store. */ -#define N 14 +#define N 13 #define OFF 4 /* Check handling of accesses for which the "initial condition" -
[gcc r15-816] Fix gcc.dg/vect/vect-gather-4.c for cascadelake
https://gcc.gnu.org/g:85e2ce10f76aee93e43aab6558cf8e39cec911e4 commit r15-816-g85e2ce10f76aee93e43aab6558cf8e39cec911e4 Author: Richard Biener Date: Fri May 24 13:15:38 2024 +0200 Fix gcc.dg/vect/vect-gather-4.c for cascadelake There's not really a good way to test what the testcase wants to test, the following exchanges one dump scan for another (imperfect) one. * gcc.dg/vect/vect-gather-4.c: Scan for not vectorizing using SLP. Diff: --- gcc/testsuite/gcc.dg/vect/vect-gather-4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/vect/vect-gather-4.c b/gcc/testsuite/gcc.dg/vect/vect-gather-4.c index 1ce63e69199..d18094d6982 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-gather-4.c +++ b/gcc/testsuite/gcc.dg/vect/vect-gather-4.c @@ -45,4 +45,4 @@ f3 (int *restrict y, int *restrict x, int *restrict indices) } } -/* { dg-final { scan-tree-dump-not "Loop contains only SLP stmts" vect } } */ +/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" vect } } */
[gcc r15-815] tree-optimization/115144 - improve sinking destination choice
https://gcc.gnu.org/g:5b9b3bae33cae7fca2e3c3e3028be6b8bee9b698 commit r15-815-g5b9b3bae33cae7fca2e3c3e3028be6b8bee9b698 Author: Richard Biener Date: Wed May 22 09:16:51 2024 +0200 tree-optimization/115144 - improve sinking destination choice When sinking code closer to its uses we already try to minimize the distance we move by inserting at the start of the basic-block. The following makes sure to sink closest to the control dependence check of the region we want to sink to as well as make sure to ignore control dependences that are only guarding exceptional code. This restores somewhat the old profile check but without requiring nearly even probabilities. The patch also makes sure to not give up completely when the best sink location is one we do not want to sink to but possibly then choose the next best one. PR tree-optimization/115144 * tree-ssa-sink.cc (do_not_sink): New function, split out from ... (select_best_block): Here. First pick valid block to sink to. From that search for the best valid block, avoiding sinking across conditions to exceptional code. (sink_code_in_bb): When updating vuses of stores in paths we do not sink a store to make sure we didn't pick a dominating sink location. * gcc.dg/tree-ssa/ssa-sink-22.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-22.c | 14 gcc/tree-ssa-sink.cc| 106 +++- 2 files changed, 86 insertions(+), 34 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-22.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-22.c new file mode 100644 index 000..e35626d4070 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-sink-22.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-sink1-details" } */ + +extern void abort (void); + +int foo (int x, int y, int f) +{ + int tem = x / y; + if (f) +abort (); + return tem; +} + +/* { dg-final { scan-tree-dump-not "Sinking" "sink1" } } */ diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 2188b7523c7..b0fe871cf1e 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -172,6 +172,39 @@ nearest_common_dominator_of_uses (def_operand_p def_p, bool *debug_stmts) return commondom; } +/* Return whether sinking STMT from EARLY_BB to BEST_BB should be avoided. */ + +static bool +do_not_sink (gimple *stmt, basic_block early_bb, basic_block best_bb) +{ + /* Placing a statement before a setjmp-like function would be invalid + (it cannot be reevaluated when execution follows an abnormal edge). + If we selected a block with abnormal predecessors, just punt. */ + if (bb_has_abnormal_pred (best_bb)) +return true; + + /* If the latch block is empty, don't make it non-empty by sinking + something into it. */ + if (best_bb == early_bb->loop_father->latch + && empty_block_p (best_bb)) +return true; + + /* Avoid turning an unconditional read into a conditional one when we + still might want to perform vectorization. */ + if (best_bb->loop_father == early_bb->loop_father + && loop_outer (best_bb->loop_father) + && !best_bb->loop_father->inner + && gimple_vuse (stmt) + && !gimple_vdef (stmt) + && flag_tree_loop_vectorize + && !(cfun->curr_properties & PROP_loop_opts_done) + && dominated_by_p (CDI_DOMINATORS, best_bb->loop_father->latch, early_bb) + && !dominated_by_p (CDI_DOMINATORS, best_bb->loop_father->latch, best_bb)) +return true; + + return false; +} + /* Given EARLY_BB and LATE_BB, two blocks in a path through the dominator tree, return the best basic block between them (inclusive) to place statements. @@ -185,54 +218,57 @@ select_best_block (basic_block early_bb, basic_block late_bb, gimple *stmt) { + /* First pick a block we do not disqualify. */ + while (late_bb != early_bb +&& do_not_sink (stmt, early_bb, late_bb)) +late_bb = get_immediate_dominator (CDI_DOMINATORS, late_bb); + basic_block best_bb = late_bb; basic_block temp_bb = late_bb; - while (temp_bb != early_bb) { /* Walk up the dominator tree, hopefully we'll find a shallower loop nest. */ temp_bb = get_immediate_dominator (CDI_DOMINATORS, temp_bb); + /* Do not consider blocks we do not want to sink to. */ + if (temp_bb != early_bb && do_not_sink (stmt, early_bb, temp_bb)) + ; + /* If we've moved into a lower loop nest, then that becomes our best block. */ - if (bb_loop_depth (temp_bb) < bb_loop_depth (best_bb)) + else if (bb_loop_depth (temp_bb) < bb_loop_depth (best_bb)) best_bb = temp_bb; -} - /* Placing a statement before a setjmp-like function would be invalid - (it cannot be reevaluated when execution
gcc-wwwdocs branch master updated. b20402b74f21724e2772d48ec8f12043ca785503
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "gcc-wwwdocs". The branch, master has been updated via b20402b74f21724e2772d48ec8f12043ca785503 (commit) from c18141d3bac790885c68d2b7fa6e99559557460d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log - commit b20402b74f21724e2772d48ec8f12043ca785503 Author: Jakub Jelinek Date: Fri May 24 10:36:19 2024 +0200 Adjust 12.3.1 Status Report URL. diff --git a/htdocs/index.html b/htdocs/index.html index afc76800..0680ef30 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -189,7 +189,7 @@ More news? Let ger...@pfeifer.com know! Status: - https://gcc.gnu.org/pipermail/gcc/2023-May/241260.html;>2023-05-08 + https://gcc.gnu.org/pipermail/gcc/2024-May/243994.html;>2024-05-24 (regression fixes docs only). --- Summary of changes: htdocs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- gcc-wwwdocs
[gcc(refs/users/mikael/heads/pr93635-v2_Harald)] Fortran: improve attribute conflict checking [PR93635]
https://gcc.gnu.org/g:1ea6d9d7f541844106e9dbec0b3962cdd8695696 commit 1ea6d9d7f541844106e9dbec0b3962cdd8695696 Author: Harald Anlauf Date: Thu May 23 21:13:00 2024 +0200 Fortran: improve attribute conflict checking [PR93635] gcc/fortran/ChangeLog: PR fortran/93635 * symbol.cc (conflict_std): Helper function for reporting attribute conflicts depending on the Fortran standard version. (conf_std): Helper macro for checking standard-dependent conflicts. (gfc_check_conflict): Use it. gcc/testsuite/ChangeLog: PR fortran/93635 * gfortran.dg/c-interop/c1255-2.f90: Adjust pattern. * gfortran.dg/pr87907.f90: Likewise. * gfortran.dg/pr93635.f90: New test. Co-authored-by: Steven G. Kargl Diff: --- gcc/fortran/symbol.cc | 63 +++-- gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 | 4 +- gcc/testsuite/gfortran.dg/pr87907.f90 | 8 ++-- gcc/testsuite/gfortran.dg/pr93635.f90 | 19 4 files changed, 54 insertions(+), 40 deletions(-) diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index 0a1646def67..5db3c887127 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -407,18 +407,36 @@ gfc_check_function_type (gfc_namespace *ns) / Symbol attribute stuff */ +/* Older standards produced conflicts for some attributes that are allowed + in newer standards. Check for the conflict and issue an error depending + on the standard in play. */ + +static bool +conflict_std (int standard, const char *a1, const char *a2, const char *name, + locus *where) +{ + if (name == NULL) +{ + return gfc_notify_std (standard, "%s attribute conflicts " +"with %s attribute at %L", a1, a2, +where); +} + else +{ + return gfc_notify_std (standard, "%s attribute conflicts " +"with %s attribute in %qs at %L", +a1, a2, name, where); +} +} + /* This is a generic conflict-checker. We do this to avoid having a single conflict in two places. */ #define conf(a, b) if (attr->a && attr->b) { a1 = a; a2 = b; goto conflict; } #define conf2(a) if (attr->a) { a2 = a; goto conflict; } -#define conf_std(a, b, std) if (attr->a && attr->b)\ - {\ -a1 = a;\ -a2 = b;\ -standard = std;\ -goto conflict_std;\ - } +#define conf_std(a, b, std) if (attr->a && attr->b \ + && !conflict_std (std, a, b, name, where)) \ + return false; bool gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) @@ -451,7 +469,6 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) "OACC DECLARE DEVICE_RESIDENT"; const char *a1, *a2; - int standard; if (attr->artificial) return true; @@ -460,20 +477,10 @@ gfc_check_conflict (symbol_attribute *attr, const char *name, locus *where) where = _current_locus; if (attr->pointer && attr->intent != INTENT_UNKNOWN) -{ - a1 = pointer; - a2 = intent; - standard = GFC_STD_F2003; - goto conflict_std; -} +conf_std (pointer, intent, GFC_STD_F2003); - if (attr->in_namelist && (attr->allocatable || attr->pointer)) -{ - a1 = in_namelist; - a2 = attr->allocatable ? allocatable : pointer; - standard = GFC_STD_F2003; - goto conflict_std; -} + conf_std (in_namelist, allocatable, GFC_STD_F2003); + conf_std (in_namelist, pointer, GFC_STD_F2003); /* Check for attributes not allowed in a BLOCK DATA. */ if (gfc_current_state () == COMP_BLOCK_DATA) @@ -922,20 +929,6 @@ conflict: a1, a2, name, where); return false; - -conflict_std: - if (name == NULL) -{ - return gfc_notify_std (standard, "%s attribute conflicts " - "with %s attribute at %L", a1, a2, - where); -} - else -{ - return gfc_notify_std (standard, "%s attribute conflicts " -"with %s attribute in %qs at %L", - a1, a2, name, where); -} } #undef conf diff --git a/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 b/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 index 0e5505a0183..feed2e7645f 100644 --- a/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 +++ b/gcc/testsuite/gfortran.dg/c-interop/c1255-2.f90 @@ -92,12 +92,12 @@ module m2 end function ! function result is a type that is not interoperable -function g (x) bind (c) ! { dg-error "BIND\\(C\\)" }
[gcc] Created branch 'mikael/heads/pr93635-v2_Harald' in namespace 'refs/users'
The branch 'mikael/heads/pr93635-v2_Harald' was created in namespace 'refs/users' pointing to: 1ea6d9d7f54... Fortran: improve attribute conflict checking [PR93635]
[gcc] Deleted branch 'mikael/heads/pr99798_v32' in namespace 'refs/users'
The branch 'mikael/heads/pr99798_v32' in namespace 'refs/users' was deleted. It previously pointed to: e13178f7fbd... fortran: Assume there is no cyclic reference with submodule Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- e13178f... fortran: Assume there is no cyclic reference with submodule
[gcc r15-814] Fix typo in the testcase.
https://gcc.gnu.org/g:51f4b47c4f4f61fe31a7bd1fa80e08c2438d76a8 commit r15-814-g51f4b47c4f4f61fe31a7bd1fa80e08c2438d76a8 Author: liuhongt Date: Fri May 24 09:49:08 2024 +0800 Fix typo in the testcase. gcc/testsuite/ChangeLog: PR target/114148 * gcc.target/i386/pr106010-7b.c: Refine testcase. Diff: --- gcc/testsuite/gcc.target/i386/pr106010-7b.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/pr106010-7b.c b/gcc/testsuite/gcc.target/i386/pr106010-7b.c index 26482cc10f5..917e56e45f7 100644 --- a/gcc/testsuite/gcc.target/i386/pr106010-7b.c +++ b/gcc/testsuite/gcc.target/i386/pr106010-7b.c @@ -34,11 +34,11 @@ avx_test (void) p_init[i] = i % 2 + 3; memcpy (pd_src, p_init, 2 * N * sizeof (double)); - memcpy (ps_dst, p_init, 2 * N * sizeof (float)); - memcpy (epi64_dst, p_init, 2 * N * sizeof (long long)); - memcpy (epi32_dst, p_init, 2 * N * sizeof (int)); - memcpy (epi16_dst, p_init, 2 * N * sizeof (short)); - memcpy (epi8_dst, p_init, 2 * N * sizeof (char)); + memcpy (ps_src, p_init, 2 * N * sizeof (float)); + memcpy (epi64_src, p_init, 2 * N * sizeof (long long)); + memcpy (epi32_src, p_init, 2 * N * sizeof (int)); + memcpy (epi16_src, p_init, 2 * N * sizeof (short)); + memcpy (epi8_src, p_init, 2 * N * sizeof (char)); foo_pd (pd_dst, pd_src[0]); foo_ps (ps_dst, ps_src[0]);
[gcc r15-813] Use simple_dce_from_worklist in phiprop
https://gcc.gnu.org/g:3e06763a695d97aa46c9de71573ec6a43bb92449 commit r15-813-g3e06763a695d97aa46c9de71573ec6a43bb92449 Author: Andrew Pinski Date: Thu May 23 09:56:37 2024 -0700 Use simple_dce_from_worklist in phiprop I noticed that phiprop leaves around phi nodes which defines a ssa name which is unused. This just adds a bitmap to mark those ssa names and then calls simple_dce_from_worklist at the very end to remove those phi nodes and all of the dependencies if there was any. This might allow us to optimize something earlier due to the removal of the phi which was taking the address of the variables. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * tree-ssa-phiprop.cc (phiprop_insert_phi): Add dce_ssa_names argument. Add the phi's result to it. (propagate_with_phi): Add dce_ssa_names argument. Update call to phiprop_insert_phi. (pass_phiprop::execute): Update call to propagate_with_phi. Call simple_dce_from_worklist if there was a change. Signed-off-by: Andrew Pinski Diff: --- gcc/tree-ssa-phiprop.cc | 28 ++-- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc index 041521ef106..2a1cdae46d2 100644 --- a/gcc/tree-ssa-phiprop.cc +++ b/gcc/tree-ssa-phiprop.cc @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "stor-layout.h" #include "tree-ssa-loop.h" #include "tree-cfg.h" +#include "tree-ssa-dce.h" /* This pass propagates indirect loads through the PHI node for its address to make the load source possibly non-addressable and to @@ -132,12 +133,15 @@ phivn_valid_p (struct phiprop_d *phivn, tree name, basic_block bb) static tree phiprop_insert_phi (basic_block bb, gphi *phi, gimple *use_stmt, - struct phiprop_d *phivn, size_t n) + struct phiprop_d *phivn, size_t n, + bitmap dce_ssa_names) { tree res; gphi *new_phi = NULL; edge_iterator ei; edge e; + tree phi_result = PHI_RESULT (phi); + bitmap_set_bit (dce_ssa_names, SSA_NAME_VERSION (phi_result)); gcc_assert (is_gimple_assign (use_stmt) && gimple_assign_rhs_code (use_stmt) == MEM_REF); @@ -276,7 +280,7 @@ chk_uses (tree, tree *idx, void *data) static bool propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, - size_t n) + size_t n, bitmap dce_ssa_names) { tree ptr = PHI_RESULT (phi); gimple *use_stmt; @@ -420,9 +424,10 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, goto next; } - phiprop_insert_phi (bb, phi, use_stmt, phivn, n); + phiprop_insert_phi (bb, phi, use_stmt, phivn, n, dce_ssa_names); - /* Remove old stmt. The phi is taken care of by DCE. */ + /* Remove old stmt. The phi and all of maybe its depedencies +will be removed later via simple_dce_from_worklist. */ gsi = gsi_for_stmt (use_stmt); /* Unlinking the VDEF here is fine as we are sure that we process stmts in execution order due to aggregate copies having VDEFs @@ -442,16 +447,15 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn, is the first load transformation. */ else if (!phi_inserted) { - res = phiprop_insert_phi (bb, phi, use_stmt, phivn, n); + res = phiprop_insert_phi (bb, phi, use_stmt, phivn, n, dce_ssa_names); type = TREE_TYPE (res); /* Remember the value we created for *ptr. */ phivn[SSA_NAME_VERSION (ptr)].value = res; phivn[SSA_NAME_VERSION (ptr)].vuse = vuse; - /* Remove old stmt. The phi is taken care of by DCE, if we -want to delete it here we also have to delete all intermediate -copies. */ + /* Remove old stmt. The phi and all of maybe its depedencies +will be removed later via simple_dce_from_worklist. */ gsi = gsi_for_stmt (use_stmt); gsi_remove (, true); @@ -514,6 +518,7 @@ pass_phiprop::execute (function *fun) gphi_iterator gsi; unsigned i; size_t n; + auto_bitmap dce_ssa_names; calculate_dominance_info (CDI_DOMINATORS); @@ -531,11 +536,14 @@ pass_phiprop::execute (function *fun) if (bb_has_abnormal_pred (bb)) continue; for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next ()) - did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n); + did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n, dce_ssa_names); } if (did_something) -gsi_commit_edge_inserts (); +{ + gsi_commit_edge_inserts (); + simple_dce_from_worklist (dce_ssa_names); +} free (phivn);