platform/upstream/gcc.git
20 months agogccrs: fixed compiler error message on wildcard pattern within expression
Abdul Rafey [Sun, 29 Jan 2023 11:35:23 +0000 (17:05 +0530)]
gccrs: fixed compiler error message on wildcard pattern within expression

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::null_denotation): Add proper error
when seeing wildcard var on right side of assignment.

gcc/testsuite/ChangeLog:

* rust/compile/issue-867.rs: New test.

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
20 months agogccrs: moved operator.h to util/rust-operators.h
Abdul Rafey [Sun, 29 Jan 2023 11:29:17 +0000 (16:59 +0530)]
gccrs: moved operator.h to util/rust-operators.h

gcc/rust/ChangeLog:

* ast/rust-ast.cc: Fix include list.
* ast/rust-expr.h: Likewise.
* hir/tree/rust-hir-expr.h: Likewise.
* rust-backend.h: Likewise.
* util/rust-lang-item.h: Likewise.
* operator.h: Moved to...
* util/rust-operators.h: ...here.

Signed-off-by: Abdul Rafey <abdulrafeyq@gmail.com>
20 months agogccrs: Rename file rust-ast-full-test.cc to rust-ast.cc
Parthib [Sat, 28 Jan 2023 16:37:45 +0000 (22:07 +0530)]
gccrs: Rename file rust-ast-full-test.cc to rust-ast.cc

gcc/rust/ChangeLog:

* Make-lang.in: Rename object file.
* ast/rust-ast-full-test.cc: Moved to...
* ast/rust-ast.cc: ...here.

20 months agogccrs: Added missing GroupedPattern visitors for code generation
Owen Avery [Wed, 11 Jan 2023 16:57:28 +0000 (11:57 -0500)]
gccrs: Added missing GroupedPattern visitors for code generation

gcc/rust/ChangeLog:

* backend/rust-compile-pattern.cc (CompilePatternCaseLabelExpr::visit): Add proper
visitor.
(CompilePatternBindings::visit): Likewise.
* backend/rust-compile-pattern.h: Declare them.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: Add type resolution for grouped patterns
Owen Avery [Wed, 11 Jan 2023 16:56:05 +0000 (11:56 -0500)]
gccrs: Add type resolution for grouped patterns

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit): Add proper
visitor.

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

gcc/rust/ChangeLog:

* hir/tree/rust-hir-pattern.h: Add get_item method.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: Add HIR lowering for GroupedPattern
Owen Avery [Wed, 11 Jan 2023 16:54:54 +0000 (11:54 -0500)]
gccrs: Add HIR lowering for GroupedPattern

gcc/rust/ChangeLog:

* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::visit): Add proper visitor.
* hir/rust-ast-lower-pattern.h: Declare it.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: Do not crash on empty macros expand. Fixes #1712
Lyra [Tue, 24 Jan 2023 13:15:42 +0000 (14:15 +0100)]
gccrs: Do not crash on empty macros expand. Fixes #1712

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

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (transcribe_expression): Fix ICE when expanding
empty macros.

gcc/testsuite/ChangeLog:

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

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

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-pattern.h: Support GroupedPattern properly.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: testsuite: Handle Windows carriage returns properly
Arthur Cohen [Wed, 11 Jan 2023 10:36:11 +0000 (11:36 +0100)]
gccrs: testsuite: Handle Windows carriage returns properly

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

gcc/testsuite/ChangeLog:

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

20 months agogccrs: Change how CompileVarDecl outputs Bvariable's
Owen Avery [Wed, 11 Jan 2023 17:05:39 +0000 (12:05 -0500)]
gccrs: Change how CompileVarDecl outputs Bvariable's

This allows patterns to declare multiple/no variables

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc (HIRCompileBase::compile_locals_for_block):
Allow patterns to declare zero or multiple variables.
* backend/rust-compile-var-decl.h: Change function declaration.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: diagnostics: Add underline for tokens in diagnostics.
mxlol233 [Wed, 11 Jan 2023 12:36:13 +0000 (20:36 +0800)]
gccrs: diagnostics: Add underline for tokens in diagnostics.

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

gcc/rust/ChangeLog:

* lex/rust-lex.cc (Lexer::build_token): Make location enclose entire token.
(Lexer::parse_byte_char): Likewise.
(Lexer::parse_byte_string): Likewise.
(Lexer::parse_raw_byte_string): Likewise.
(Lexer::parse_raw_identifier): Likewise.
(Lexer::parse_string): Likewise.
(Lexer::parse_identifier_or_keyword): Likewise.
(Lexer::parse_raw_string): Likewise.
(Lexer::parse_non_decimal_int_literal): Likewise.
(Lexer::parse_decimal_int_or_float): Likewise.
(Lexer::parse_char_or_lifetime): Likewise.

gcc/testsuite/ChangeLog:

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

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

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

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add get_locus method.
* ast/rust-expr.h: Likewise.
* ast/rust-macro.h: Likewise.

Signed-off-by: Xiao Ma <mxlol233@outlook.com>
20 months agogccrs: Reuse TypeCheckPattern on LetStmt's
Owen Avery [Tue, 10 Jan 2023 00:54:55 +0000 (19:54 -0500)]
gccrs: Reuse TypeCheckPattern on LetStmt's

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

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Cleanup LetStmt
type checking.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
20 months agogccrs: Support associated type bound arguments
Philip Herron [Sat, 7 Jan 2023 14:41:12 +0000 (14:41 +0000)]
gccrs: Support associated type bound arguments

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

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

Fixes #1720

gcc/rust/ChangeLog:

* hir/tree/rust-hir-path.h: Add const get_identifier and get_type method.
* typecheck/rust-hir-path-probe.h: Use new SubstitutionArgumentMappings constructor.
* typecheck/rust-hir-trait-resolve.cc: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeCheckBase::get_predicate_from_bound):
Do not assert failure on size mismatch anymore.
(TypeBoundPredicate::TypeBoundPredicate): Use new SubstitutionArgumentMappings constructor.
(TypeBoundPredicate::operator=): Likewise.
(TypeBoundPredicate::apply_generic_arguments): Likewise.
(TypeBoundPredicateItem::get_tyty_for_receiver): Likewise.
(TypeBoundPredicate::get_num_associated_bindings): Likewise.
(TypeBoundPredicate::lookup_associated_type): Fix implementation for new system.
(TypeBoundPredicate::get_associated_type_items): Likewise.
* typecheck/rust-tyty.cc (SubstitutionRef::get_mappings_from_generic_args): Add new
behavior.
(SubstitutionRef::infer_substitions): Use new constructor and add comment.
(SubstitutionRef::solve_missing_mappings_from_this): Use new constructor.
* typecheck/rust-tyty.h: Define new constructors.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
20 months agogccrs: Add name resolution to generic argument associated item bindings
Philip Herron [Sat, 7 Jan 2023 17:15:23 +0000 (17:15 +0000)]
gccrs: Add name resolution to generic argument associated item bindings

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

Addresses #1720

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveGenericArgs::go): Add name resolution to
Trait items.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
20 months agogccrs: Implement declarative macro 2.0 parser
Raiki Tamura [Sun, 18 Dec 2022 16:48:54 +0000 (01:48 +0900)]
gccrs: Implement declarative macro 2.0 parser

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (class MacroItem): Remove forward declaration.
* ast/rust-ast-full-test.cc (MacroRulesDefinition):
Rework MacroRulesDefinition class
* ast/rust-ast.h (class MacroItem): Remove abstract class.
* ast/rust-item.h (class MacroItem): Remove forward declaration.
* ast/rust-macro.h (class MacroItem): Likewise.
(class MacroRulesDefinition): Add MacroKind enum.
(class MacroInvocation): Fix inheritance.
* lex/rust-token.h: Token "macro" is now used.
* parse/rust-parse-impl.h (Parser::parse_item): Add handling for MACRO.
(Parser::parse_vis_item): Call into parse_decl_macro_def.
(Parser::parse_macro_item): Delete function.
(Parser::parse_macro_rules_def): Return MBE macros only.
(Parser::parse_decl_macro_def): New function.
(Parser::parse_stmt): Handle MACRO token.
(Parser::parse_stmt_or_expr_without_block): Call into parse_macro_rules_def.
* parse/rust-parse.h: Declare new function.

gcc/testsuite/ChangeLog:

* rust/compile/decl_macro1.rs: New test.
* rust/compile/decl_macro2.rs: New test.
* rust/compile/decl_macro3.rs: New test.
* rust/compile/decl_macro4.rs: New test.
* rust/compile/decl_macro5.rs: New test.
* rust/compile/decl_macro6.rs: New test.
* rust/compile/decl_macro7.rs: New test.
* rust/execute/torture/decl_macro1.rs: New test.
* rust/execute/torture/decl_macro2.rs: New test.
* rust/execute/torture/decl_macro3.rs: New test.
* rust/execute/torture/decl_macro4.rs: New test.

Signed-off-by: Raiki Tamura <tamaron1203@gmail.com>
20 months agogccrs: rust: add bound parsing in parse_generic_arg.
mxlol233 [Wed, 4 Jan 2023 13:21:59 +0000 (21:21 +0800)]
gccrs: rust: add bound parsing in parse_generic_arg.

gcc/rust/ChangeLog:

* parse/rust-parse-impl.h (Parser::parse_generic_arg): Add proper bound parsing.

gcc/testsuite/ChangeLog:

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

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

Use StackedContext instead. Fix error string

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

gcc/rust/ChangeLog:

* checks/errors/rust-const-checker.cc (ConstChecker::visit): Use StackedContext
class.

gcc/testsuite/ChangeLog:

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

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

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

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (check_target_attr): New function.
(UnsafeChecker::check_function_attr): Call into `check_target_attr`.
(UnsafeChecker::visit): Check for target_feature attributes.
* checks/errors/rust-unsafe-checker.h: Add declarations.
* util/rust-attributes.cc: Add attribute.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
20 months agogccrs: fatal_error_flag: Fix typo in error message
Arthur Cohen [Fri, 16 Dec 2022 12:38:36 +0000 (13:38 +0100)]
gccrs: fatal_error_flag: Fix typo in error message

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Fix typo.

20 months agoMAINTAINERS: Add myself as CTF and BTF reviewer
Indu Bhagat [Thu, 6 Apr 2023 06:23:33 +0000 (23:23 -0700)]
MAINTAINERS: Add myself as CTF and BTF reviewer

ChangeLog:

* MAINTAINERS: Add myself.

20 months ago[testsuite] enable -maltivec like vect_int for signbit-2.c
Alexandre Oliva [Wed, 5 Apr 2023 14:27:19 +0000 (11:27 -0300)]
[testsuite] enable -maltivec like vect_int for signbit-2.c

Explicitly enable altivec if it's supported.  vect_int tests for
powerpc_altivec_ok, but without the explicit option, if altivec is not
enabled by default, we end up expecting vectorization that doesn't
occur.

for  gcc/testsuite/ChangeLog

* gcc.dg/signbit-2.c: Add -maltivec if supported.

20 months agoFix typo in -param=vect-induction-float= attributes
Andrew Pinski [Thu, 6 Apr 2023 04:13:00 +0000 (21:13 -0700)]
Fix typo in -param=vect-induction-float= attributes

There was a typo in the attributes of the option
-param=vect-induction-float= for IntegerRange.
This fixes that typo.

Committed as obvious after a build/test.

gcc/ChangeLog:

PR tree-optimization/109427
* params.opt (-param=vect-induction-float=):
Fix option attribute typo for IntegerRange.

20 months agotestsuite: fix proc unsupported overriding in modules.exp [PR108899]
Alexandre Oliva [Wed, 5 Apr 2023 14:27:28 +0000 (11:27 -0300)]
testsuite: fix proc unsupported overriding in modules.exp [PR108899]

The overrider of proc unsupported in modules.exp had two problems
reported by Thomas Schwinge, even after Jakub Jelínek's fix:

- it remained in effect while running other dejagnu testsets

- it didn't quote correctly the argument list passed to it, which
  caused test names to be surrounded by curly braces, as in:

UNSUPPORTED: {...}

This patch fixes both issues, obsoleting and reverting Jakub's change,
by dropping the overrider and renaming the saved proc back, and by
using uplevel's argument list splicing.

Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
for  gcc/testsuite/ChangeLog

PR testsuite/108899
* g++.dg/modules/modules.exp (unsupported): Drop renaming.
Fix quoting.

20 months agoDaily bump.
GCC Administrator [Thu, 6 Apr 2023 00:16:43 +0000 (00:16 +0000)]
Daily bump.

20 months agoPR modula2/109423 cc1gm2 ICE if an INCL or EXCL is performed on an unknown set
Gaius Mulley [Wed, 5 Apr 2023 22:07:46 +0000 (23:07 +0100)]
PR modula2/109423 cc1gm2 ICE if an INCL or EXCL is performed on an unknown set

This patch fixes an ICE if attempting to INCL or EXCL on an unknown
set.  The fix was to correct an error format string.  Also included in
the patch are patches to remove unused variables.  The patch also
marks a variable as written in BuildAdr.

gcc/m2/ChangeLog:

PR modula2/109423
* gm2-compiler/M2Base.def (Unbounded): Remove.
* gm2-compiler/M2Error.def (ErrorAbort0): Add noreturn
attribute.
* gm2-compiler/M2Quads.mod (BuildInclProcedure): Correct
error format string.
(BuildExceptProcedure): Correct error format string.
(BuildAdrFunction): Call PutWriteQuad when taking the
address of a variable.
* gm2-libs-ch/SysExceptions.c (_M2_SysExceptions_init): Add
parameters.
* gm2-libs-ch/wrapc.c (_M2_wrapc_init): Add parameters.
* gm2-libs/DynamicStrings.mod (DumpStringInfo): Remove t.
(PopAllocationExemption): Remove f.
* gm2-libs/FIO.mod (BufferedWrite): Remove result.
* gm2-libs/FormatStrings.mod (Copy): Remove endpos and
afterperc.
(HandlePercent): Remove result.
* gm2-libs/Indexing.mod (RemoveIndiceFromIndex): Remove k.
* gm2-libs/M2Dependent.mod (CreateModule): Remove p0
and p1.
(DumpModuleData): Remove mptr.
(ConstructModules): Remove nulp.
* gm2-libs/RTExceptions.mod (PopHandler): Remove i.
* gm2-libs/RTint.mod (Listen): Remove b4s, b4m, afs
and afm.
* gm2-libs/SFIO.mod (ReadS): Remove c.
* gm2-libs/StringConvert.mod (doDecimalPlaces): Remove
whole and fraction.

gcc/testsuite/ChangeLog:

* gm2/pim/fail/setunknown.mod: New test.
PR modula2/109423
* gm2/pim/fail/setunknown2.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
20 months agolibstdc++: Fix some freestanding test failures
Arsen Arsenović [Tue, 4 Apr 2023 21:24:52 +0000 (23:24 +0200)]
libstdc++: Fix some freestanding test failures

At some point, <charconv> was added to the non-hosted bit of the C++17
block, which induced failures in many tests.

In addition, some tests also lacked a dg-require-effective-target hosted
tag.

libstdc++-v3/ChangeLog:

* include/precompiled/stdc++.h (C++17): Don't double-include
<charconv>, once with wrong conditions.
* testsuite/18_support/96817.cc: Require hosted.
* testsuite/18_support/bad_exception/59392.cc: Ditto.
* testsuite/20_util/scoped_allocator/108952.cc: Ditto.
* testsuite/20_util/uses_allocator/lwg3527.cc: Ditto.
* testsuite/29_atomics/atomic/operators/pointer_partial_void.cc:
Ditto.

20 months agolibstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED
Arsen Arsenović [Tue, 4 Apr 2023 17:25:09 +0000 (19:25 +0200)]
libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED

Supporting the debug mode in freestanding is a non-trivial job, so
instead, as a best-effort, enable assertions, which are light and easy.

libstdc++-v3/ChangeLog:

* include/bits/c++config: When __STDC_HOSTED__ is zero,
disable _GLIBCXX_DEBUG and, if it was set, enable
_GLIBCXX_ASSERTIONS.
* testsuite/lib/libstdc++.exp (check_v3_target_debug_mode):
Include <bits/c++config.h> when determining whether debug is
set, in order to inherit the logic from above

20 months agolibstdc++: Add a test for <version> FTM redefinitions
Arsen Arsenović [Wed, 8 Mar 2023 16:01:24 +0000 (17:01 +0100)]
libstdc++: Add a test for <version> FTM redefinitions

This test detects redefinitions by compiling stdc++.h and <version>, by
disabling the system_header pragma on the latter, to allow warnings in
it.  Thanks Patrick Palka for the suggestion.

libstdc++-v3/ChangeLog:

* testsuite/17_intro/versionconflict.cc: New test.
* include/std/version: Allow disabling the system_header pragma
via _GLIBCXX_TESTING_SYSHDR.

20 months agolibstdc++: Harmonize <version> and other headers
Arsen Arsenović [Wed, 8 Mar 2023 11:04:11 +0000 (12:04 +0100)]
libstdc++: Harmonize <version> and other headers

Due to recent, large changes in libstdc++, the feature test macros
declared in <version> got out of sync with the other headers that
possibly declare them.

libstdc++-v3/ChangeLog:

* include/bits/unique_ptr.h (__cpp_lib_constexpr_memory):
Synchronize the definition block with...
* include/bits/ptr_traits.h (__cpp_lib_constexpr_memory):
... this one here.  Also define the 202202L value, rather than
leaving it up to purely unique_ptr.h, so that the value is
synchronized across all headers.
(__gnu_debug::_Safe_iterator_base): Move into new conditional
block.
* include/std/memory (__cpp_lib_atomic_value_initialization):
Define on freestanding under the same conditions as in
atomic_base.h.
* include/std/version (__cpp_lib_robust_nonmodifying_seq_ops):
Also define on freestanding.
(__cpp_lib_to_chars): Ditto.
(__cpp_lib_gcd): Ditto.
(__cpp_lib_gcd_lcm): Ditto.
(__cpp_lib_raw_memory_algorithms): Ditto.
(__cpp_lib_array_constexpr): Ditto.
(__cpp_lib_nonmember_container_access): Ditto.
(__cpp_lib_clamp): Ditto.
(__cpp_lib_constexpr_char_traits): Ditto.
(__cpp_lib_constexpr_string): Ditto.
(__cpp_lib_sample): Ditto.
(__cpp_lib_lcm): Ditto.
(__cpp_lib_constexpr_iterator): Ditto.
(__cpp_lib_constexpr_char_traits): Ditto.
(__cpp_lib_interpolate): Ditto.
(__cpp_lib_constexpr_utility): Ditto.
(__cpp_lib_shift): Ditto.
(__cpp_lib_ranges): Ditto.
(__cpp_lib_move_iterator_concept): Ditto.
(__cpp_lib_constexpr_numeric): Ditto.
(__cpp_lib_constexpr_functional): Ditto.
(__cpp_lib_constexpr_algorithms): Ditto.
(__cpp_lib_constexpr_tuple): Ditto.
(__cpp_lib_constexpr_memory): Ditto.

20 months agoFix 22_locale/locale/cons/12658_thread-2.cc on hppa.
John David Anglin [Wed, 5 Apr 2023 15:40:52 +0000 (15:40 +0000)]
Fix 22_locale/locale/cons/12658_thread-2.cc on hppa.

2023-04-05  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:

* testsuite/22_locale/locale/cons/12658_thread-2.cc: Double
timeout factor on hppa*-*-*.

20 months ago[RFA][Bug target/108892 ][13 regression] Force re-recognition after changing RTL...
Jeff Law [Wed, 5 Apr 2023 15:16:29 +0000 (09:16 -0600)]
[RFA][Bug target/108892 ][13 regression] Force re-recognition after changing RTL structure of an insn

So as mentioned in the PR the underlying issue here is combine changes the form of an existing insn, but fails to force re-recognition.  As a result other parts of the compiler blow up.

>                   /* Temporarily replace the set's source with the
>                      contents of the REG_EQUAL note.  The insn will
>                      be deleted or recognized by try_combine.  */
>                   rtx orig_src = SET_SRC (set);                   rtx orig_dest = SET_DEST (set);                   if (GET_CODE (SET_DEST (set)) == ZERO_EXTRACT)
>                     SET_DEST (set) = XEXP (SET_DEST (set), 0);
>                   SET_SRC (set) = note;
>                   i2mod = temp;
>                   i2mod_old_rhs = copy_rtx (orig_src);
>                   i2mod_new_rhs = copy_rtx (note);
>                   next = try_combine (insn, i2mod, NULL, NULL,
>                                       &new_direct_jump_p,                                       last_combined_insn);
>                   i2mod = NULL;
>                   if (next)
>                     {
>                       statistics_counter_event (cfun, "insn-with-note combine", 1);
>                       goto retry;
>                     }                   SET_SRC (set) = orig_src;
>                   SET_DEST (set) = orig_dest;

This code replaces the SET_SRC of an insn in the RTL stream with the contents of a REG_EQUAL note.  So given an insn like this:

> (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
>         (ior:DI (reg:DI 200)
>             (reg:DI 251))) "j.c":14:5 -1
>      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
>         (nil)))

It replaces the (ior ...) with a (const_int ...).  The resulting insn is passed to try_combine which will try to recognize it, then use it in a combination attempt.  Recognition succeeds with the special define_insn_and_split pattern in the risc-v backend resulting in:

> (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
>         (const_int 25769803782 [0x600000006])) "j.c":14:5 177 {*mvconst_internal}
>      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
>         (nil)))

This is as-expected.  Now assume we were unable to combine anything, so try_combine returns NULL_RTX.  The quoted code above restores SET_SRC (and SET_DEST) resulting in:

> (insn 122 117 127 2 (set (reg:DI 157 [ _46 ])
>         (ior:DI (reg:DI 200)
>             (reg:DI 251))) "j.c":14:5 177 {*mvconst_internal}
>      (expr_list:REG_EQUAL (const_int 25769803782 [0x600000006])
>         (nil)))

But this doesn't get re-recognized and we ICE later in LRA.

The fix is trivial, reset the INSN_CODE to force re-recognition in the case where try_combine fails.

PR target/108892
gcc/
* combine.cc (combine_instructions): Force re-recognition when
after restoring the body of an insn to its original form.

gcc/testsuite/
* gcc.c-torture/compile/pr108892.c: New test.

20 months agoAdd assember CFI directives to millicode division and remainder routines.
John David Anglin [Wed, 5 Apr 2023 14:44:54 +0000 (14:44 +0000)]
Add assember CFI directives to millicode division and remainder routines.

The millicode division and remainder routines trap division by zero.
The unwinder needs these directives to unwind divide by zero traps.

2023-04-05  John David Anglin  <danglin@gcc.gnu.org>

libgcc/ChangeLog:

PR target/109374
* config/pa/milli64.S (RETURN_COLUMN): Define.
($$divI): Add CFI directives.
($$divU): Likewise.
($$remI): Likewise.
($$remU): Likewise.

20 months agoipa: Avoid another ICE when dealing with type-incompatibilities (PR 108959)
Martin Jambor [Wed, 5 Apr 2023 14:36:49 +0000 (16:36 +0200)]
ipa: Avoid another ICE when dealing with type-incompatibilities (PR 108959)

PR 108959 shows one more example where undefined code with type
incompatible accesses to stuff passed in parameters can cause an ICE
because we try to create a VIEW_CONVERT_EXPR of mismatching sizes:

1. IPA-CP tries to push one type from above,

2. IPA-SRA (correctly) decides the parameter is useless because it is
   only used to construct an argument to another function which does not
   use it and so the formal parameter should be removed,

3. but the code reconciling IPA-CP and IPA-SRA transformations still
   wants to perform the IPA-CP and overrides the built-in DCE of
   useless statements and tries to stuff constants into them
   instead, constants of a type with mismatching type and size.

This patch avoids the situation in IPA-SRA by purging the IPA-CP
results from any "aggregate" constants that are passed in parameters
which are detected to be useless.  It also removes IPA value range and
bits information associated with removed parameters stored in the same
structure so that the useless information is not streamed later on.

gcc/ChangeLog:

2023-03-22  Martin Jambor  <mjambor@suse.cz>

PR ipa/108959
* ipa-sra.cc (zap_useless_ipcp_results): New function.
(process_isra_node_results): Call it.

gcc/testsuite/ChangeLog:

2023-03-17  Martin Jambor  <mjambor@suse.cz>

PR ipa/108959
* gcc.dg/ipa/pr108959.c: New test.

20 months ago[PATCH] RISC-V: Fix SEW64 of vrsub.vx runtime fail in RV32 system
Ju-Zhe Zhong [Wed, 5 Apr 2023 13:46:36 +0000 (07:46 -0600)]
[PATCH] RISC-V: Fix SEW64 of vrsub.vx runtime fail in RV32 system

It's quite obvious that the order of vrsub SEW64 is wrong.

gcc/ChangeLog:

* config/riscv/vector.md: Fix incorrect operand order.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/bug-23.C: New test.

20 months agolibstdc++: Define std::sub_match::swap member function (LWG 3204)
Jonathan Wakely [Tue, 4 Apr 2023 19:28:59 +0000 (20:28 +0100)]
libstdc++: Define std::sub_match::swap member function (LWG 3204)

This was approved at the C++ meeting in February.

libstdc++-v3/ChangeLog:

* include/bits/regex.h (sub_match::swap): New function.
* testsuite/28_regex/sub_match/lwg3204.cc: New test.

20 months ago[PATCH] RISC-V: Fix PR109399 VSETVL PASS bug
Juzhe-Zhong [Wed, 5 Apr 2023 01:20:47 +0000 (19:20 -0600)]
[PATCH] RISC-V: Fix PR109399 VSETVL PASS bug

        PR 109399

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc
(pass_vsetvl::compute_local_backward_infos): Update user vsetvl in local
demand fusion.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/vsetvl/pr109399.c: New test.

20 months agoRISC-V: Fix typos
Li Xu [Wed, 5 Apr 2023 01:12:26 +0000 (19:12 -0600)]
RISC-V: Fix typos

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.def: Fix typo.
* config/riscv/riscv.cc (riscv_dwarf_poly_indeterminate_value): Ditto.
* config/riscv/vector-iterators.md: Ditto.

20 months agoDaily bump.
GCC Administrator [Wed, 5 Apr 2023 00:16:53 +0000 (00:16 +0000)]
Daily bump.

20 months agodoc: md.texi (Including Patterns): Fix page break
Hans-Peter Nilsson [Tue, 4 Apr 2023 15:45:19 +0000 (17:45 +0200)]
doc: md.texi (Including Patterns): Fix page break

The line-break in the example looked odd, even more so with
a page-break in the middle of it, due to recently added text
in preceding pages.

* doc/md.texi (Including Patterns): Fix page break.

20 months agoRegenerate gcc.pot
Joseph Myers [Tue, 4 Apr 2023 17:06:15 +0000 (17:06 +0000)]
Regenerate gcc.pot

* gcc.pot: Regenerate.

20 months agoFortran: reject module variable as character length in PARAMETER [PR104349]
Harald Anlauf [Mon, 3 Apr 2023 19:34:01 +0000 (21:34 +0200)]
Fortran: reject module variable as character length in PARAMETER [PR104349]

gcc/fortran/ChangeLog:

PR fortran/104349
* expr.cc (check_restricted): Adjust check for valid variables in
restricted expressions: make no exception for module variables.

gcc/testsuite/ChangeLog:

PR fortran/104349
* gfortran.dg/der_charlen_1.f90: Adjust dg-patterns.
* gfortran.dg/pr104349.f90: New test.

20 months agorange-op-float: Fix reverse ops of comparisons [PR109386]
Jakub Jelinek [Tue, 4 Apr 2023 14:13:06 +0000 (16:13 +0200)]
range-op-float: Fix reverse ops of comparisons [PR109386]

I've missed one of my recent range-op-float.cc changes (likely the
r13-6967 one) caused
FAIL: libphobos.phobos/std/math/algebraic.d execution test
FAIL: libphobos.phobos_shared/std/math/algebraic.d execution test
regressions, distilled into a C testcase below.

In the testcase, we have
!(u >= v)
condition where both u and v are results of fabs*, which guards
t1 = u u<= __FLT_MAX__;
and
t2 = v u<= __FLT_MAX__;
comparisons.  From false u >= v where u and v have [0.0, +Inf] NAN
ranges we (incorrectly deduce that one of them is [nextafterf (0.0, 1.0), +Inf] NAN
and the other is [0.0, nextafterf (+Inf, 0.0)] NAN and from that deduce that
one of the comparisons is always true, because UNLE_EXPR with the maximum
representable number are false only if the value is +Inf and our ranges tell
that is not possible.

The bug is that the u >= v comparison determines a sensible range only when
it is true - we then know neither operand can be NAN and it behaves
correctly.  But when the comparison is false, our current code gives
sensible answers only if the other op can't be NAN.  If it can be NAN,
whenever it is NAN, the comparison is always false regardless of the other
value, so the other value needs to be VARYING.
Now, foperator_unordered_lt::op1_range etc. had code to deal with that
for op?.known_nan (), but as the testcase shows, it is enough if it may be a
NAN at runtime to make it VARYING.

So, the following patch replaces for all those BRS_FALSE cases of the normal
non-equality comparisons if (opOTHER.known_isnan ()) r.set_varying (type);
to do it also if maybe_isnan ().

For the unordered or ... comparisons, it is similar for BRS_TRUE.  Those
comparisons are true whenever either operand is NAN, or if neither is NAN,
the corresponding normal comparison.  So, if those comparisons are true
and other operand might be a NAN, we can't tell (VARYING), if it is false,
currently handling is correct.

2023-04-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109386
* range-op-float.cc (foperator_lt::op1_range, foperator_lt::op2_range,
foperator_le::op1_range, foperator_le::op2_range,
foperator_gt::op1_range, foperator_gt::op2_range,
foperator_ge::op1_range, foperator_ge::op2_range): Make r varying for
BRS_FALSE case even if the other op is maybe_isnan, not just
known_isnan.
(foperator_unordered_lt::op1_range, foperator_unordered_lt::op2_range,
foperator_unordered_le::op1_range, foperator_unordered_le::op2_range,
foperator_unordered_gt::op1_range, foperator_unordered_gt::op2_range,
foperator_unordered_ge::op1_range, foperator_unordered_ge::op2_range):
Make r varying for BRS_TRUE case even if the other op is maybe_isnan,
not just known_isnan.

* gcc.c-torture/execute/ieee/pr109386.c: New test.

20 months agosanitizer: missing signed integer overflow errors [PR109107]
Marek Polacek [Mon, 13 Mar 2023 22:50:25 +0000 (18:50 -0400)]
sanitizer: missing signed integer overflow errors [PR109107]

Here we're failing to detect a signed overflow with -O because match.pd,
since r8-1516, transforms

  c = (a + 1) - (int) (short int) b;

into

  c = (int) ((unsigned int) a + 4294946117);

wrongly eliding the overflow.  This kind of problems is usually
avoided by using TYPE_OVERFLOW_SANITIZED in the appropriate place.
The first match.pd hunk in the patch fixes it.  I've constructed
a testcase for each of the surrounding cases as well.  Then I
noticed that fold_binary_loc/associate has the same problem, so I've
added a TYPE_OVERFLOW_SANITIZED there as well (it may be too coarse,
sorry).  Then I found yet another problem, but instead of fixing it
now I've opened 109134.  I could probably go on and find a dozen more.

PR sanitizer/109107

gcc/ChangeLog:

* fold-const.cc (fold_binary_loc): Use TYPE_OVERFLOW_SANITIZED
when associating.
* match.pd: Use TYPE_OVERFLOW_SANITIZED.

gcc/testsuite/ChangeLog:

* c-c++-common/ubsan/pr109107-1.c: New test.
* c-c++-common/ubsan/pr109107-2.c: New test.
* c-c++-common/ubsan/pr109107-3.c: New test.
* c-c++-common/ubsan/pr109107-4.c: New test.

20 months agoarm: Fix vcreate definition
Stam Markianos-Wright [Tue, 4 Apr 2023 12:06:41 +0000 (13:06 +0100)]
arm: Fix vcreate definition

From the initial merge of the MVE backend, the vcreate
intrinsic has had the vector lanes mixed up, compared
to the intended (as per the ACLE) definition. This is
also a discrepancy with clang:
https://godbolt.org/z/4n93e5aqj

This patches simply switches the operands around and
makes the tests more specific on the input registers
(I do not touch the output Q regs as they vary based
on softfp/hardfp or the input registers when the input
is a constant, since, in that case, a single register
is loaded with a constant and then the same register is
used twice as "vmov q0[2], q0[0], r2, r2" and the reg
num might not always be guaranteed).

gcc/ChangeLog:

* config/arm/mve.md (mve_vcvtq_n_to_f_<supf><mode>): Swap operands.
(mve_vcreateq_f<mode>): Swap operands.

gcc/testsuite/ChangeLog:

* gcc.target/arm/mve/intrinsics/vcreateq_f16.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_f32.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_s16.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_s32.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_s64.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_s8.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_u16.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_u32.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_u64.c: Tighten test.
* gcc.target/arm/mve/intrinsics/vcreateq_u8.c: Tighten test.

20 months agolibstdc++: Fix outdated docs about demangling exception messages
Jonathan Wakely [Tue, 4 Apr 2023 11:04:14 +0000 (12:04 +0100)]
libstdc++: Fix outdated docs about demangling exception messages

The string returned by std::bad_exception::what() hasn't been a mangled
name since PR libstdc++/14493 was fixed for GCC 4.2.0, so remove the
docs showing how to demangle it.

libstdc++-v3/ChangeLog:

* doc/xml/manual/extensions.xml: Remove std::bad_exception from
example program.
* doc/html/manual/ext_demangling.html: Regenerate.

20 months agoamdgcn: Add 64-bit vector not
Andrew Stubbs [Mon, 3 Apr 2023 11:16:11 +0000 (12:16 +0100)]
amdgcn: Add 64-bit vector not

gcc/ChangeLog:

* config/gcn/gcn-valu.md (one_cmpl<mode>2<exec>): New.

20 months agoriscv: Fix bootstrap [PR109384]
Jakub Jelinek [Tue, 4 Apr 2023 09:20:28 +0000 (11:20 +0200)]
riscv: Fix bootstrap [PR109384]

The following patch unbreaks riscv bootstrap, where it previously failed
on -Werror=format-diag warning promoted to error.

Ok for trunk?

Or shall it say e.g.
"%<-march=%s%>: %<zfinx%> extension conflicts with %<f>"
?
Or say if the current condition is true, do
const char *ext = "zfinx";
if (subset_list->lookup ("zdinx"))
  ext = "zdinx";
else if (subset_list->lookup ("zhinx"))
  ext = "zhinx";
else if (subset_list->lookup ("zhinxmin"))
  ext = "zhinxmin";
and
"%<-march=%s%>: %qs extension conflicts with %<f>", arch, ext
?  Or do similar check for which extension to print against it,
const char *ext = "zfinx";
const char *ext2 = "f";
if (subset_list->lookup ("zdinx"))
  {
    ext = "zdinx";
    if (subset_list->lookup ("d"))
      ext2 = "d";
  }
else if (subset_list->lookup ("zhinx"))
  {
    ext = "zhinx";
    if (subset_list->lookup ("zfh"))
      ext2 = "zfh";
  }
else if (subset_list->lookup ("zhinxmin"))
  {
    ext = "zhinxmin";
    if (subset_list->lookup ("zfhmin"))
      ext2 = "zfhmin";
  }
"%<-march=%s%>: %qs extension conflicts with %qs", arch, ext, ext2
?

2023-04-04  Jakub Jelinek  <jakub@redhat.com>

PR target/109384
* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
Reword diagnostics about zfinx conflict with f, formatting fixes.

* gcc.target/riscv/arch-19.c: Expect a different message about zfinx
vs. f conflict.

20 months agoconfig: -pthread shouldn't link with -lpthread on Solaris
Rainer Orth [Tue, 4 Apr 2023 08:27:09 +0000 (10:27 +0200)]
config: -pthread shouldn't link with -lpthread on Solaris

libpthread has been folded into libc since Solaris 10 and replaced by a
filter on libc.  Linking with libpthread thus only creates unnecessary
runtime overhead.

This patch thus removes linking with -lpthread if -pthread/-pthreads is
specified, thus getting rid of the libpthread dependency in libatomic,
libgdruntime, libgomp, libgphobos, and libitm.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 (both Solaris 11.3 and 11.4).

2023-04-03  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* config/sol2.h (LIB_SPEC): Don't link with -lpthread.

20 months agotree-optimization/109304 - properly handle instrumented aliases
Richard Biener [Tue, 28 Mar 2023 08:06:12 +0000 (08:06 +0000)]
tree-optimization/109304 - properly handle instrumented aliases

When adjusting calls to reflect instrumentation we failed to handle
calls to aliases since they appear to have no body.  Instead resort
to symtab node availability.  The patch also avoids touching
internal function calls in a more obvious way (builtins might
have a body available).

profiledbootstrap & regtest running on x86_64-unknown-linux-gnu.

Honza - does this look OK?

PR tree-optimization/109304
* tree-profile.cc (tree_profiling): Use symtab node
availability to decide whether to skip adjusting calls.
Do not adjust calls to internal functions.

* gcc.dg/pr109304.c: New testcase.

20 months agors6000: Fix vector_set_var_p9 by considering BE [PR108807]
Kewen Lin [Tue, 4 Apr 2023 02:47:54 +0000 (21:47 -0500)]
rs6000: Fix vector_set_var_p9 by considering BE [PR108807]

As PR108807 exposes, the current handling in function
rs6000_expand_vector_set_var_p9 doesn't take care of big
endianness.  Currently the function is to rotate the
target vector by moving element to-be-set to element 0,
set element 0 with the given val, then rotate back.  To
get the permutation control vector for the rotation, it
makes use of lvsr and lvsl, but the element ordering is
different for BE and LE (like element 0 is the most
significant one on BE while the least significant one on
LE), this patch is to add consideration for BE and make
sure permutation control vectors for rotations are expected.

As tested, it helped to fix the below failures:

FAIL: gcc.target/powerpc/pr79251-run.p9.c execution test
FAIL: gcc.target/powerpc/pr89765-mc.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-10d.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-11d.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-14d.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-16d.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-18d.c execution test
FAIL: gcc.target/powerpc/vsx-builtin-9d.c execution test
PR target/108807

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_expand_vector_set_var_p9): Fix gen
function for permutation control vector by considering big endianness.

20 months agors6000: Fix vector parity support [PR108699]
Kewen Lin [Tue, 4 Apr 2023 02:47:44 +0000 (21:47 -0500)]
rs6000: Fix vector parity support [PR108699]

The failures on the original failed case builtin-bitops-1.c
and the associated test case pr108699.c here show that the
current support of parity vector mode is wrong on Power.
The hardware insns vprtyb[wdq] which operate on the least
significant bit of each byte per element, they doesn't match
what RTL opcode parity needs, but the current implementation
expands it with them wrongly.

This patch is to fix the handling with one more insn vpopcntb.

PR target/108699

gcc/ChangeLog:

* config/rs6000/altivec.md (*p9v_parity<mode>2): Rename to ...
(rs6000_vprtyb<mode>2): ... this.
* config/rs6000/rs6000-builtins.def (VPRTYBD): Replace parityv2di2 with
rs6000_vprtybv2di2.
(VPRTYBW): Replace parityv4si2 with rs6000_vprtybv4si2.
(VPRTYBQ): Replace parityv1ti2 with rs6000_vprtybv1ti2.
* config/rs6000/vector.md (parity<mode>2 with VEC_IP): Expand with
popcountv16qi2 and the corresponding rs6000_vprtyb<mode>2.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/p9-vparity.c: Add scan-assembler-not for vpopcntb
to distinguish parity byte from parity.
* gcc.target/powerpc/pr108699.c: New test.

20 months agoc++: friend template matching [PR107484]
Jason Merrill [Mon, 3 Apr 2023 22:23:58 +0000 (18:23 -0400)]
c++: friend template matching [PR107484]

Here friend matching tries to find a matching non-template friend and fails,
so we mark the friend as a template specialization to be determined later.
Then cplus_decl_attributes tries again to find a matching function and gets
confused by DECL_TEMPLATE_INSTANTIATION without DECL_TEMPLATE_INFO.  But it
doesn't make sense for find_last_decl to be trying to match anything with
DECL_USE_TEMPLATE set; those are matched elsewhere.

PR c++/107484

gcc/cp/ChangeLog:

* decl2.cc (find_last_decl): Return early if DECL_USE_TEMPLATE.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/friend25.C: New test.

20 months agodoc: md.texi (Insn Splitting): Tweak wording for readability.
Hans-Peter Nilsson [Tue, 14 Mar 2023 01:06:34 +0000 (02:06 +0100)]
doc: md.texi (Insn Splitting): Tweak wording for readability.

I needed to check what was allowed in a define_split, but
had problems understanding what was meant by "Splitting of
jump instruction into sequence that over by another jump
instruction".

* doc/md.texi (Insn Splitting): Tweak wording for readability.

Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
20 months agoDaily bump.
GCC Administrator [Tue, 4 Apr 2023 00:16:31 +0000 (00:16 +0000)]
Daily bump.

20 months agoc++: ICE with loopy var tmpl auto deduction [PR109300]
Patrick Palka [Mon, 3 Apr 2023 22:49:37 +0000 (18:49 -0400)]
c++: ICE with loopy var tmpl auto deduction [PR109300]

Now that we resolve non-dependent variable template-ids ahead of time,
cp_finish_decl needs to handle a new invalid situation: we can end up
trying to instantiate a variable template with deduced type before we
fully parsed its initializer.

PR c++/109300

gcc/cp/ChangeLog:

* decl.cc (cp_finish_decl): Diagnose ordinary auto deduction
with no initializer, instead of asserting.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/var-templ79.C: New test.

20 months agoUpdate gcc sv.po
Joseph Myers [Mon, 3 Apr 2023 22:07:53 +0000 (22:07 +0000)]
Update gcc sv.po

* sv.po: Update.

20 months agoPR modula2/109388 clang warnings related to Modula-2
Gaius Mulley [Mon, 3 Apr 2023 14:04:06 +0000 (15:04 +0100)]
PR modula2/109388 clang warnings related to Modula-2

This patch removes an unused parameter 'module' from
DoVariableDeclaration in M2GCCDeclare.mod.  It also removes unused
procedures from PHBuild.bnf.

gcc/m2/ChangeLog:

PR modula2/109388
* gm2-compiler/M2GCCDeclare.mod (DoVariableDeclaration):
Remove second parameter module.  Adjust all callers to
remove the second parameter.
* gm2-compiler/PHBuild.bnf (CheckAndInsert): Remove.
(InStopSet): Remove.
(PeepToken): Remove.
(PushQualident): Remove.
(SimpleDes): Remove.
(ActualParameters): Remove.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
20 months agoipa: Avoid constructing aggregate jump functions with huge offsets (PR 109303)
Martin Jambor [Mon, 3 Apr 2023 13:53:36 +0000 (15:53 +0200)]
ipa: Avoid constructing aggregate jump functions with huge offsets (PR 109303)

We are in the process of changing data structures holding information
about constants passed by reference and in aggregates to use unsigned
int offsets rather than HOST_WIDE_INT (which was selected simply
because that is what fell out of get_ref_base_and_extent at that time)
in order to conserve memory, especially at WPA time.

PR 109303 testcase discovers that we do not properly check that we
only create jump functions with offsets (plus sizes) that fit into the
smaller type.  This patch adds the necessary check.

gcc/ChangeLog:

2023-03-30  Martin Jambor  <mjambor@suse.cz>

PR ipa/109303
* ipa-prop.cc (determine_known_aggregate_parts): Check that the
offset + size will be representable in unsigned int.

gcc/testsuite/ChangeLog:

2023-03-30  Jakub Jelinek  <jakub@redhat.com>
    Martin Jambor  <mjambor@suse.cz>

PR ipa/109303
* gcc.dg/pr109303.c: New test.

20 months agobuild: Check that -lzstd can be linked
Rainer Orth [Mon, 3 Apr 2023 08:34:45 +0000 (10:34 +0200)]
build: Check that -lzstd can be linked

Recent Solaris 11.4 SRUs bundle zstd, but only the 64-bit libraries (no
idea why).  Because of this, in 32-bit builds cc1 etc. fail to link with
undefined references to various ZSTD_* functions from lto-compress.o.
This happens because currently only the presence of <zstd.h> is
necessary to enable zstd support in lto-compress.cc etc.

This patch checks for libzstd first and disables zstd support if
missing.

Tested on sparc-sun-solaris2.11 with the system installation of zstd
(64-bit only) and a locally-compiled one (specified with --with-zstd).

2023-03-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* configure.ac (ZSTD_LIB): Move before zstd.h check.
Unset gcc_cv_header_zstd_h without libzstd.
* configure: Regenerate.

20 months agoparam: document ranger-recompute-depth
Martin Liska [Mon, 3 Apr 2023 08:04:22 +0000 (10:04 +0200)]
param: document ranger-recompute-depth

gcc/ChangeLog:

* doc/invoke.texi: Document new param.

20 months agoAdded item entry in docs for the new check_effective_target.
Cupertino Miranda [Mon, 3 Apr 2023 04:15:00 +0000 (22:15 -0600)]
Added item entry in docs for the new check_effective_target.

gcc/
* doc/sourcebuild.texi (const_volatile_readonly_section): Document
new check_effective_target function.

20 months agoRISC-V: Fix typo
Li Xu [Mon, 3 Apr 2023 03:58:52 +0000 (21:58 -0600)]
RISC-V: Fix typo

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.def (vuint32m8_t): Fix typo.
(vfloat32m8_t): Likewise

20 months agors6000: Modify test case after mode promotion disabled
Haochen Gui [Fri, 31 Mar 2023 04:51:32 +0000 (12:51 +0800)]
rs6000: Modify test case after mode promotion disabled

gcc/testsuite/
PR target/102146
* gcc.target/powerpc/pr56605.c: Modify the match pattern for dump
scan.

20 months agoDocument signbitm2.
liuhongt [Fri, 31 Mar 2023 06:52:51 +0000 (14:52 +0800)]
Document signbitm2.

gcc/ChangeLog:

* doc/md.texi: Document signbitm2.

20 months agoDaily bump.
GCC Administrator [Mon, 3 Apr 2023 00:16:43 +0000 (00:16 +0000)]
Daily bump.

20 months agoFix gnat.dg/opt39.adb on hppa.
John David Anglin [Sun, 2 Apr 2023 21:27:46 +0000 (21:27 +0000)]
Fix gnat.dg/opt39.adb on hppa.

Add hppa*-*-* to dg-additional-options list.

2023-04-02  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

PR target/109375
* gnat.dg/opt39.adb: Add hppa*-*-* to dg-additional-options list.

20 months agoSkip gnat.dg/prot7.adb on hppa.
John David Anglin [Sun, 2 Apr 2023 20:03:48 +0000 (20:03 +0000)]
Skip gnat.dg/prot7.adb on hppa.

Test needs to be skipped if the target does not support atomic primitives.

2023-04-02  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

PR target/109376
* gnat.dg/prot7.adb: Skip on hppa.

20 months agoPR modula2/109336 pass -fmod= though and build m2/stage2/cc1gm2 libs
Gaius Mulley [Sun, 2 Apr 2023 19:30:43 +0000 (20:30 +0100)]
PR modula2/109336 pass -fmod= though and build m2/stage2/cc1gm2 libs

This patch enables gm2 to pass -fmod= though to cc1gm2.  It also
builds the libraries for m2/stage2/cc1gm2 with no named path and
full debugging.

gcc/m2/ChangeLog:

PR modula2/109336
* Make-lang.in (GM2_O): Set to -O0.
(GM2_LIBS): Remove target libraries and replace with build libs.
(BUILD-LIBS): New declaration.
(m2/gm2-libs/libgm2.a): New rule.
(m2/gm2-libs/%.o): New rule.
(m2/gm2-libs/choosetemp.o): New rule.
* gm2-compiler/M2ColorString.mod (append): Use ADR rather than
implicit conversion.
* gm2-compiler/M2Comp.mod (Compile): Add qprintf messages for when
a source file is not found.  Improve comments and formatting.
* gm2-libs-ch/cgetopt.c (cgetopt_cgetopt_long): Remove
ansi-decl.h.  Add getopt.h.
(cgetopt_cgetopt_long_only): Change cgetopt_ to getopt_.
* gm2spec.cc (lang_specific_driver): Do not skip -fmod=.
Remove comment.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
20 months agolibiberty: Make strstr.c in libiberty ANSI compliant
Jakub Jelinek [Sun, 2 Apr 2023 18:05:31 +0000 (20:05 +0200)]
libiberty: Make strstr.c in libiberty ANSI compliant

On Fri, Nov 13, 2020 at 11:53:43AM -0700, Jeff Law via Gcc-patches wrote:
>
> On 5/1/20 6:06 PM, Seija Kijin via Gcc-patches wrote:
> > The original code in libiberty says "FIXME" and then says it has not been
> > validated to be ANSI compliant. However, this patch changes the function to
> > match implementations that ARE compliant, and such code is in the public
> > domain.
> >
> > I ran the test results, and there are no test failures.
>
> Thanks.  This seems to be the standard "simple" strstr implementation. 
> There's significantly faster implementations available, but I doubt it's
> worth the effort as the version in this file only gets used if there is
> no system strstr.c.

Except that PR109306 says the new version is non-compliant and
is certainly slower than what we used to have.  The only problem I see
on the old version (sure, it is not very fast version) is that for
strstr ("abcd", "") it returned "abcd"+4 rather than "abcd" because
strchr in that case changed p to point to the last character and then
strncmp returned 0.

The question reported in PR109306 is whether memcmp is required not to
access characters beyond the first difference or not.
For all of memcmp/strcmp/strncmp, C17 says:
"The sign of a nonzero value returned by the comparison functions memcmp, strcmp, and strncmp
is determined by the sign of the difference between the values of the first pair of characters (both
interpreted as unsigned char) that differ in the objects being compared."
but then in memcmp description says:
"The memcmp function compares the first n characters of the object pointed to by s1 to the first n
characters of the object pointed to by s2."
rather than something similar to strncmp wording:
"The strncmp function compares not more than n characters (characters that follow a null character
are not compared) from the array pointed to by s1 to the array pointed to by
s2."
So, while for strncmp it seems clearly well defined when there is zero
terminator before reaching the n, for memcmp it is unclear if say
int
memcmp (const void *s1, const void *s2, size_t n)
{
  int ret = 0;
  size_t i;
  const unsigned char *p1 = (const unsigned char *) s1;
  const unsigned char *p2 = (const unsigned char *) s2;

  for (i = n; i; i--)
    if (p1[i - 1] != p2[i - 1])
      ret = p1[i - 1] < p2[i - 1] ? -1 : 1;
  return ret;
}
wouldn't be valid implementation (one which always compares all characters
and just returns non-zero from the first one that differs).

So, shouldn't we just revert and handle the len == 0 case correctly?

I think almost nothing really uses it, but still, the old version
at least worked nicer with a fast strchr.
Could as well strncmp (p + 1, s2 + 1, len - 1) if that is preferred
because strchr already compared the first character.

2023-04-02  Jakub Jelinek  <jakub@redhat.com>

PR other/109306
* strstr.c: Revert the 2020-11-13 changes.
(strstr): Return s1 if len is 0.

20 months agoRISC-V: Fix reload fail issue on vector mac instructions
Juzhe-Zhong [Wed, 29 Mar 2023 02:47:26 +0000 (10:47 +0800)]
RISC-V: Fix reload fail issue on vector mac instructions

Vector mac instructions has LRA issue during high register pressure,
It will failed to reload when picked first alternative, because it will
require reload 2 input operands into same register as input operand,
so we adding an extra operand to generate one more move pattern to
relax such restricted constraint.

This path fix ICE of ternary intrinsic:
bug.C:144:2: error: unable to find a register to spill
  144 |  }
      |  ^
bug.C:144:2: error: this is the insn:
(insn 462 972 919 24 (set (reg/v:VNx8DI 546 [orig:192 var_10 ] [192])
        (if_then_else:VNx8DI (unspec:VNx8BI [
                    (reg/v:VNx8BI 603 [orig:179 var_13 ] [179])
                    (const_int 13 [0xd])
                    (const_int 2 [0x2])
                    (const_int 0 [0]) repeated x2
                    (reg:SI 66 vl)
                    (reg:SI 67 vtype)
                ] UNSPEC_VPREDICATE)
            (plus:VNx8DI (mult:VNx8DI (reg/v:VNx8DI 605 [orig:190 var_6 ] [190])
                    (reg/v:VNx8DI 547 [orig:160 var_51 ] [160]))
                (reg/v:VNx8DI 548 [orig:161 var_52 ] [161]))
            (reg/v:VNx8DI 605 [orig:190 var_6 ] [190]))) "bug.C":131:48 4171 {*pred_maddvnx8di}
     (expr_list:REG_DEAD (reg/v:VNx8DI 605 [orig:190 var_6 ] [190])
        (expr_list:REG_DEAD (reg/v:VNx8BI 603 [orig:179 var_13 ] [179])
            (expr_list:REG_DEAD (reg/v:VNx8DI 547 [orig:160 var_51 ] [160])
                (expr_list:REG_DEAD (reg/v:VNx8DI 548 [orig:161 var_52 ] [161])
                    (nil))))))

gcc/ChangeLog:

* config/riscv/vector.md: Fix RA constraint.

gcc/testsuite/ChangeLog:

* g++.target/riscv/rvv/base/bug-19.C: New test.
* g++.target/riscv/rvv/base/bug-20.C: New test.
* g++.target/riscv/rvv/base/bug-21.C: New test.
* g++.target/riscv/rvv/base/bug-22.C: New test.

Signed-off-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
Co-authored-by: kito-cheng <kito.cheng@sifive.com>
20 months agoRISC-V: Fix ICE and codegen error of scalar move in RV32 system.
Juzhe-Zhong [Wed, 29 Mar 2023 02:42:59 +0000 (10:42 +0800)]
RISC-V: Fix ICE and codegen error of scalar move in RV32 system.

We need to reset the AVL to 0 or 1 for scalar move for RV32 system,
For any non-zero AVL input, we set that to 1, and zero will keep as zero.

We are using wrong way (by andi with 1) before to achieve that, and it
will cause ICE with const_int, and also wrong behavior, so now we have
two code path, one for const_int and one for non-const_int.

bug.C:144:2: error: unrecognizable insn:
  144 |  }
      |  ^
(insn 684 683 685 26 (set (reg:SI 513)
        (and:SI (const_int 4 [0x4])
            (const_int 1 [0x1]))) "bug.C":115:47 -1
     (nil))

andi a4,a4,1 ===> sgtu a4,a4,zero
vsetlvi tu        vsetvli tu
vlse              vlse

gcc/ChangeLog:

* config/riscv/riscv-protos.h (gen_avl_for_scalar_move): New function.
* config/riscv/riscv-v.cc (gen_avl_for_scalar_move): New function.
* config/riscv/vector.md: Fix scalar move bug.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/scalar_move-6.c: Adapt test.
* gcc.target/riscv/rvv/base/scalar_move-9.c: New test.

20 months agoDaily bump.
GCC Administrator [Sun, 2 Apr 2023 00:16:59 +0000 (00:16 +0000)]
Daily bump.

20 months agoc++: NTTP constraint depending on outer parms [PR109160]
Patrick Palka [Sat, 1 Apr 2023 16:01:30 +0000 (12:01 -0400)]
c++: NTTP constraint depending on outer parms [PR109160]

Here we're crashing during satisfaction for the NTTP 'C<B> auto V'
ultimately because convert_template_argument / unify don't pass all
outer template arguments to do_auto_deduction, and during satisfaction
we need to know all arguments.  While these callers do pass some outer
arguments, they are only sufficient to properly substitute the
(level-lowered) 'auto' and are not necessarily the entire set.

Fortunately it seems these callers have access to the full set of outer
arguments via convert_template_argument's 'in_decl' parameter and
unify's 'tparms' parameter.  So this patch adds a new parameter to
do_auto_deduction, used only during adc_unify deduction, through which
these callers can pass the enclosing (partially instantiated) template
and from which do_auto_deduction can obtain _all_ outer template
arguments for sake of satisfaction.

This patch also ensures that the 'in_decl' argument passed to
coerce_template_parms is always a TEMPLATE_DECL, which in turn allows us
to pass it as-is to do_auto_deduction; the only coerce_template_parms
caller that needed adjustment was tsubst_decl it seems.

PR c++/109160

gcc/cp/ChangeLog:

* cp-tree.h (do_auto_deduction): Add defaulted tmpl parameter.
* pt.cc (convert_template_argument): Pass 'in_decl' as 'tmpl' to
do_auto_deduction.
(tsubst_decl) <case VAR_/TYPE_DECL>: Pass 'tmpl' instead of 't' as
'in_decl' to coerce_template_parms.
(unify) <case TEMPLATE_PARM_INDEX>: Pass TPARMS_PRIMARY_TEMPLATE
as 'tmpl' to do_auto_deduction.
(do_auto_deduction): Document default arguments.  Rename local
variable 'tmpl' to 'ctmpl'.  Use 'tmpl' to obtain a full set of
template arguments for satisfaction in the adc_unify case.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-placeholder12.C: New test.

20 months agoc++: improve "NTTP argument considered unused" fix [PR53164, PR105848]
Patrick Palka [Sat, 1 Apr 2023 14:19:08 +0000 (10:19 -0400)]
c++: improve "NTTP argument considered unused" fix [PR53164, PR105848]

r13-995-g733a792a2b2e16 worked around the problem of (pointer to)
function NTTP arguments not always getting marked as odr-used, by
redundantly calling mark_used on the substituted ADDR_EXPR callee of a
CALL_EXPR.  That is just a narrow workaround however, since it assumes
the function is later called, but the use as a template argument alone
should constitute an odr-use of the function (since template arguments
are an evaluated context, and we're really passing its address); we
shouldn't need to subsequently call or otherwise use the function NTTP
argument.

This patch fixes this in a more general way by walking the template
arguments of each specialization that's about to be instantiated and
redundantly calling mark_used on all entities used within.  As before,
the call to mark_used as it worst a no-op, but it compensates for the
situation where the specialization was first formed in a template context
in which mark_used is inhibited.

Another approach would be to call mark_used whenever we substitute a
TEMPLATE_PARM_INDEX, but that would result in many more redundant calls
to mark_used compared to this approach.  And as the second testcase
below illustrates, we also need to walk C++20 class NTTP arguments which
can be large and thus expensive to walk repeatedly.  The change to
invalid_tparm_referent_p is needed to avoid incorrectly rejecting class
NTTP arguments containing function pointers as in the testcase.

(The third testcase is unrelated to this fix, but it helped rule out an
earlier approach I was considering and it seems we don't have existing
test coverage for this situation.)

PR c++/53164
PR c++/105848

gcc/cp/ChangeLog:

* pt.cc (invalid_tparm_referent_p): Accept ADDR_EXPR of
FUNCTION_DECL.
(instantiate_class_template): Call mark_template_arguments_used.
(tsubst_copy_and_build) <case CALL_EXPR>: Revert r13-995 change.
(mark_template_arguments_used): Define.
(instantiate_body): Call mark_template_arguments_used.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr3a.C: New test.
* g++.dg/template/fn-ptr3b.C: New test.
* g++.dg/template/fn-ptr4.C: New test.

20 months agoChange "long_double" into "long double" for C prototypes from Fortran.
Thomas Koenig [Sat, 1 Apr 2023 08:20:32 +0000 (10:20 +0200)]
Change "long_double" into "long double" for C prototypes from Fortran.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (get_c_type_name): Fix "long_long"
type name to be "long long".

20 months agorange-op-float: Further foperator_{,not_}equal::fold_range fix
Jakub Jelinek [Sat, 1 Apr 2023 07:32:20 +0000 (09:32 +0200)]
range-op-float: Further foperator_{,not_}equal::fold_range fix

On Fri, Mar 31, 2023 at 12:45:10PM +0200, Jakub Jelinek via Gcc-patches wrote:
>    - there is a missing case (not handled in this patch) where both operands
>      are known to be zeros, but not singleton zeros

This patch adds those cases.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

* range-op-float.cc (foperator_equal::fold_range): If at least
one of the op ranges is not singleton and neither is NaN and all
4 bounds are zero, return [1, 1].
(foperator_not_equal::fold_range): In the same case return [0, 0].

20 months agorange-op-float: Further comparison fixes
Jakub Jelinek [Sat, 1 Apr 2023 07:30:31 +0000 (09:30 +0200)]
range-op-float: Further comparison fixes

On Fri, Mar 31, 2023 at 09:57:54AM +0200, Jakub Jelinek via Gcc-patches wrote:
> and so if maybe_isnan, they always return [0, 1].  Now, thinking about it,
> this is unnecessary pessimization, for the case where the ... block
> returns range_false (type) we actually could do it also if maybe_isnan (op1,
> op2), because if one or both operands are NAN, the comparison will be false,
> and if neither is NAN, the comparison will be also false.  Will fix
> incrementally today.

Here it is.
1) the foperator_{,not_}equal::fold_range cases
   - we have correctly first a case handling known_isnan on either operand,
     return there range_false (type) - EQ, resp. range_true (type) - NE
   - next we handle the singleton cases, maybe_isnan + singleton isn't
     singleton, so these are ok
   - there is a missing case (not handled in this patch) where both operands
     are known to be zeros, but not singleton zeros
   - there is some !maybe_isnan (op1, op2) handling which tries to prove
     when the operands are certainly not equal and results in
     range_false (type) - EQ, resp. range_true (type) - NE
   - otherwise range_true_and_false (type)
   Now, I think (and this patch implements it) that the !maybe_isnan (op1, op2)
   check is unnecessary.  If we prove that when ignoring maybe NANs, the
   ranges don't intersect and so the comparison is always false for EQ or
   always true for NE, if NANs can appear, it doesn't change anything on
   that either, for EQ if NAN appears, the result is false like what we
   proved for the finite ranges, for NE if NAN appears, the result is true
   like what we proved for the finite ranges
2) foperator_{lt,le,gt,ge}::fold_range cases
   - these have correctly known_isnan on either operand first and return
     there range_false (type)
   - then !maybe_isnan (op1, op2) condition guarded checks
   - finally range_true_and_false (type) - so do that for
     maybe_isnan (op1, op2)
   Here in the !maybe_isnan (op1, op2) guarded code we have some condition
   which results in range_true (type), another condition which results in
   range_false (type) and otherwise range_true_and_false (type).
   Now, the condition which results in range_false (type) can be IMHO done
   also for the maybe_isnan (op1, op2) cases, because it is [0, 0]
   if both operands are finite or [0, 0] if either operand is NAN.
3) finally, LTGT_EXPR wasn't handled at all.  LTGT_EXPR is the inverse
   comparision to UNEQ_EXPR, I believe both raise exceptions only if
   either operand is sNaN, UNEQ_EXPR is true if both operands are
   either equal or either of the operands is NAN, while LTGT_EXPR is
   true if the operands compare either smaller or larger and is false if
   either of the operands is NAN.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

* range-op-float.cc (foperator_equal::fold_range): Perform the
non-singleton handling regardless of maybe_isnan (op1, op2).
(foperator_not_equal::fold_range): Likewise.
(foperator_lt::fold_range, foperator_le::fold_range,
foperator_gt::fold_range, foperator_ge::fold_range): Perform the
real_* comparison check which results in range_false (type)
even if maybe_isnan (op1, op2).  Simplify.
(foperator_ltgt): New class.
(fop_ltgt): New variable.
(floating_op_table::floating_op_table): Handle LTGT_EXPR using
fop_ltgt.

* gcc.dg/torture/inf-compare-1.c: Add dg-additional-options
-fno-tree-dominator-opts -fno-tree-vrp.
* gcc.dg/torture/inf-compare-1-float.c: Likewise.
* gcc.dg/torture/inf-compare-2.c: Likewise.
* gcc.dg/torture/inf-compare-2-float.c: Likewise.

20 months agotestsuite: Add testcase for already fixed PR [PR109362]
Jakub Jelinek [Sat, 1 Apr 2023 07:00:22 +0000 (09:00 +0200)]
testsuite: Add testcase for already fixed PR [PR109362]

This PR got fixed with r13-137.
Add a testcase to make sure it doesn't reappear.

2023-04-01  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/109362
* gcc.target/i386/pr109362.c: New test.

20 months agoaarch64, builtins: Include PR registers in FUNCTION_ARG_REGNO_P etc. [PR109254]
Jakub Jelinek [Sat, 1 Apr 2023 06:55:55 +0000 (08:55 +0200)]
aarch64, builtins: Include PR registers in FUNCTION_ARG_REGNO_P etc. [PR109254]

The following testcase is miscompiled on aarch64-linux in the regname pass,
because while the function takes arguments in the p0 register,
FUNCTION_ARG_REGNO_P doesn't reflect that, so DF doesn't know the register is
used in register passing. It sees 2 chains with p1 register and wants to
replace the second one and as DF doesn't know p0 is live at the start of the
function, it will happily use p0 register even when it is used in subsequent
instructions.

The following patch fixes that.  FUNCTION_ARG_REGNO_P returns non-zero
for p0-p3 (unconditionally, seems for the floating/vector registers it
doesn't conditionalize them on TARGET_FLOAT either, but if you want,
I can conditionalize p0-p3 on TARGET_SVE), similarly
targetm.calls.function_value_regno_p returns true for p0-p3 registers
if TARGET_SVE (again for consistency, that function conditionalizes
the float/vector on TARGET_FLOAT).

Now, that change broke bootstrap in libobjc and some
__builtin_apply_args/__builtin_apply/__builtin_return tests.  The
aarch64_get_reg_raw_mode hook already documents that SVE scalable arg/return
passing is fundamentally incompatible with those builtins, but unlike
the floating/vector regs where it forces a fixed vector mode, I think
there is no fixed mode which could be used for p0-p3.  So, I have tweaked
the generic code so that it uses VOIDmode return from that hook to signal
that a register shouldn't be touched by
__builtin_apply_args/__builtin_apply/__builtin_return
despite being mentioned in FUNCTION_ARG_REGNO_P or
targetm.calls.function_value_regno_p.

gcc/
2023-04-01  Jakub Jelinek  <jakub@redhat.com>

PR target/109254
* builtins.cc (apply_args_size): If targetm.calls.get_raw_arg_mode
returns VOIDmode, handle it like if the register isn't used for
passing arguments at all.
(apply_result_size): If targetm.calls.get_raw_result_mode returns
VOIDmode, handle it like if the register isn't used for returning
results at all.
* target.def (get_raw_result_mode, get_raw_arg_mode): Document what it
means to return VOIDmode.
* doc/tm.texi: Regenerated.
* config/aarch64/aarch64.cc (aarch64_function_value_regno_p): Return
TARGET_SVE for P0_REGNUM.
(aarch64_function_arg_regno_p): Also return true for p0-p3.
(aarch64_get_reg_raw_mode): Return VOIDmode for PR_REGNUM_P regs.

gcc/testsuite/
2023-04-01  Jakub Jelinek  <jakub@redhat.com>
    Richard Sandiford  <richard.sandiford@arm.com>

PR target/109254
* gcc.target/aarch64/sve/pr109254.c: New test.

20 months agoc++,coroutines: Stabilize names of promoted slot vars [PR101118].
Iain Sandoe [Thu, 30 Mar 2023 07:44:23 +0000 (13:14 +0530)]
c++,coroutines: Stabilize names of promoted slot vars [PR101118].

When we need to 'promote' a value (i.e. store it in the coroutine frame) it
is given a frame entry name.  This was based on the DECL_UID for slot vars.
However, when LTO is used, the names from multiple TUs become visible at the
same time, and the DECL_UIDs usually differ between units.  This leads to a
"ODR mismatch" warning for the frame type.

The fix here is to use the current promoted temporaries count to produce
the name, this is stable between TUs and computed per coroutine.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101118

gcc/cp/ChangeLog:

* coroutines.cc (flatten_await_stmt): Use the current count of
promoted temporaries to build a unique name for the frame entries.

20 months agoDaily bump.
GCC Administrator [Sat, 1 Apr 2023 00:17:38 +0000 (00:17 +0000)]
Daily bump.

20 months agolibstdc++: Teach optimizer that empty COW strings are empty [PR107087]
Jonathan Wakely [Fri, 31 Mar 2023 12:44:04 +0000 (13:44 +0100)]
libstdc++: Teach optimizer that empty COW strings are empty [PR107087]

The compiler doesn't know about the invariant that the _S_empty_rep()
object is immutable and so _M_length and _M_refcount are always zero.
This means that we get warnings about writing possibly-non-zero length
strings into buffers that can't hold them. If we teach the compiler that
the empty rep is always zero length, it knows it can be copied into any
buffer.

For Stage 1 we might want to also consider adding this to capacity():

if (_S_empty_rep()._M_capacity != 0)
  __builtin_unreachable();

And this to _Rep::_M_is_leaked() and _Rep::_M_is_shared():

  if (_S_empty_rep()._M_refcount != 0)
    __builtin_unreachable();

libstdc++-v3/ChangeLog:

PR tree-optimization/107087
* include/bits/cow_string.h (basic_string::size()): Add
optimizer hint that _S_empty_rep()._M_length is always zero.
(basic_string::length()): Call size().

20 months agotestsuite, analyzer: Fix up pipe-glibc.c testcase [PR107396]
Jakub Jelinek [Fri, 31 Mar 2023 20:48:44 +0000 (22:48 +0200)]
testsuite, analyzer: Fix up pipe-glibc.c testcase [PR107396]

The gcc.dg/analyzer/pipe-glibc.c test FAILs when using recent glibc headers
and succeeds with older headers.
The important change is that
https://sourceware.org/git/?p=glibc.git;a=commit;h=c1760eaf3b575ad174fd88b252fd16bd525fa818
in 2021 added __attribute__ ((__malloc__ (fclose, 1))) attribute to fdopen,
so in write_to_pipe there is an excess warning:
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c: In function 'write_to_pipe':
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: warning: use of possibly-NULL 'stream' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument]
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:27:12: note: (1) this call could return NULL
.../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: note: (2) argument 4 ('stream') from (1) could be NULL where non-null expected
<built-in>: note: argument 4 of '__builtin_fwrite' must be non-null
Strangely, nothing is reported on the read_from_pipe function, seems
fwrite/fprintf/fputc etc. are builtins in GCC and we mark the FILE *
arguments as nonnull there on the builtin declarations, while fgetc/fread
etc. aren't builtins and glibc doesn't mark any of those using nonnull.
Shall we change that on the glibc side?

Anyway, because this differs based on glibc version and I think the
above warning is not the primary intention of the test, I think it is
best to tweak it so that this warning isn't reported.
Another option would be avoid using glibc headers and use our own
declarations, or make sure we add the malloc with fclose attribute ourselves
(but fdopen in the libc headers could be a macro, so not sure
__typeof (fdopen) fdopen __attribute__ ((__malloc__, __malloc__ (fclose, 1)));
would work).  Or use -Wno-analyzer-possible-null-arguments in
dg-additional-options?

2023-03-31  Jakub Jelinek  <jakub@redhat.com>

PR analyzer/107396
* gcc.dg/analyzer/pipe-glibc.c (read_from_pie, write_to_pipe): Exit
if fdopen returns NULL.

20 months agoAdjust testcases to not produce errors..
Andrew MacLeod [Fri, 31 Mar 2023 19:42:43 +0000 (15:42 -0400)]
Adjust testcases to not produce errors..

tree-optimization/109363
gcc/testsuite/
* g++.dg/warn/Wstringop-overflow-4.C: Always check bogus message.
* gcc.dg/tree-ssa/pr23109.c: Disable better recomputations.

20 months agoLRA: Implement commutative operands exchange for combining secondary memory reload...
Vladimir N. Makarov [Fri, 31 Mar 2023 15:04:44 +0000 (11:04 -0400)]
LRA: Implement commutative operands exchange for combining secondary memory reload and original insn

The patch implements trying commutative operands exchange for
combining secondary memory reload and original insn.

        PR rtl-optimization/109052

gcc/ChangeLog:

* lra-constraints.cc: (combine_reload_insn): New function.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr109052-2.c: New.

20 months agolibstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339]
Jonathan Wakely [Fri, 31 Mar 2023 12:38:14 +0000 (13:38 +0100)]
libstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339]

We pass a const-reference to *this before it's constructed, and GCC
assumes that all const-references are accessed. Add the access attribute
to say it's not accessed.

libstdc++-v3/ChangeLog:

PR libstdc++/109339
* include/std/stop_token (_Stop_state_ptr(const stop_source&)):
Add attribute access with access-mode 'none'.
* testsuite/30_threads/stop_token/stop_source/109339.cc: New test.

20 months agolibstdc++: Revert addition of boolean flag to net::ip::basic_endpoint
Jonathan Wakely [Fri, 31 Mar 2023 12:17:00 +0000 (13:17 +0100)]
libstdc++: Revert addition of boolean flag to net::ip::basic_endpoint

As pointed out in P2641R1, we can use GCC's __builtin_constant_p to
emulate the proposed std::is_active_member. This allows us to detect
which of the union members is active during constant evaluation, so we
don't need the extra bool data member. We still can't support constexpr
until C++20 though, as we need to change the active member during
constant evaluation.

libstdc++-v3/ChangeLog:

* include/experimental/internet (ip::basic_endpoint::_M_if_v6):
Revert change from member function to data member. Fix for
constant evaluation by detecting which union member is active.
(ip::basic_endpoint::resize): Revert changes to update _M_is_v6
flag.

20 months agorange-op-float, value-range: Fix up handling of UN{LT,LE,GT,GE,EQ}_EXPR and handle...
Jakub Jelinek [Fri, 31 Mar 2023 11:41:34 +0000 (13:41 +0200)]
range-op-float, value-range: Fix up handling of UN{LT,LE,GT,GE,EQ}_EXPR and handle comparisons in get_tree_range [PR91645]

When looking into PR91645, I've noticed we handle UN{LT,LE,GT,GE,EQ}_EXPR
comparisons incorrectly.
All those are unordered or ..., we correctly return [1, 1] if one or
both operands are known NANs, and correctly ask the non-UN prefixed
op to fold_range if neither operand may be NAN.
But for the case where one or both operands may be NAN, we always
return [0, 1].  The UN* fold_range tries to handle it by asking
the non-UN prefixed fold_range and if it returns [1, 1] return that,
if it returns [0, 0] or [0, 1] return [0, 1], which makes sense,
because the maybe NAN means that it is the non-UN prefixed fold_range
unioned with [1, 1] in case the maybe NAN is actually NAN at runtime.
The problem is that the non-UN prefixed fold_range always returns [0, 1]
because those fold_range implementations are like:
  if (op1.known_isnan () || op2.known_isnan ())
    r = range_false (type);
  else if (!maybe_isnan (op1, op2))
    {
...
    }
  else
    r = range_true_and_false (type);
and so if maybe_isnan, they always return [0, 1].  Now, thinking about it,
this is unnecessary pessimization, for the case where the ... block
returns range_false (type) we actually could do it also if maybe_isnan (op1,
op2), because if one or both operands are NAN, the comparison will be false,
and if neither is NAN, the comparison will be also false.  Will fix
incrementally today.
Anyway, the following patch fixes it by asking the non-UN prefixed
fold_range on ranges with NAN cleared, which I think does the right
thing in all cases.

Another change in the patch is that range_query::get_tree_range
always returned VARYING for comparisons, this patch allows to ask about
those as well (they are very much like binary ops, except they take
the important type from the types of the operands rather than result).

Initially I've developed this patch together with changes to tree-call-cdce.cc,
but those result in one regression and apparently aren't actually needed to
fix this bug, the range-op-float.cc changes are enough.

2023-03-31  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/91645
* range-op-float.cc (foperator_unordered_lt::fold_range,
foperator_unordered_le::fold_range,
foperator_unordered_gt::fold_range,
foperator_unordered_ge::fold_range,
foperator_unordered_equal::fold_range): Call the ordered
fold_range on ranges with cleared NaNs.
* value-query.cc (range_query::get_tree_range): Handle also
COMPARISON_CLASS_P trees.

* gcc.target/i386/pr103559-1.c: New test.
* gcc.target/i386/pr103559-2.c: New test.
* gcc.target/i386/pr103559-3.c: New test.
* gcc.target/i386/pr103559-4.c: New test.

20 months agoc++tools: Fix Makefile to properly clean and rebuild [PR101834]
Jonathan Wakely [Thu, 30 Mar 2023 12:03:11 +0000 (13:03 +0100)]
c++tools: Fix Makefile to properly clean and rebuild [PR101834]

The c++tools makefile doesn't remove progressively more files in each of
mostlyclean, clean, and distclean. Instead, each removes a different set
of files (and some files are not removed by any target). Use
prerequisites so that everything is removed.

Also, building in the $objdir/c++tools directory doesn't work, because
the INSTALL variable is never set. It works when building from the
top-level because INSTALL is set in the environment when recursively
invoking make for sub-directories.

c++tools/ChangeLog:

PR bootstrap/101834
* Makefile.in (INSTALL): Set variable.
(mostlyclean): Mark as a phony target.
(clean): Add mostlyclean as a prerequisite.
(distclean): Add clean as a prerequisite and remove more files.
(maintainer-clean): Add distclean as a prerequisite.

20 months agoRISC-V: Fix missing file dependency in RISC-V back-end [PR109328]
Kito Cheng [Fri, 31 Mar 2023 06:40:36 +0000 (14:40 +0800)]
RISC-V: Fix missing file dependency in RISC-V back-end [PR109328]

gcc/ChangeLog:

PR target/109328
* config/riscv/t-riscv: Add missing dependencies.

Co-authored-by: Andrew Pinski <pinskia@gmail.com>
20 months agoAdjust memory_move_cost for MASK_REGS when MODE_SIZE > 8.
liuhongt [Wed, 8 Feb 2023 03:03:14 +0000 (11:03 +0800)]
Adjust memory_move_cost for MASK_REGS when MODE_SIZE > 8.

It's impossible to put modes whose size > 8 into MASK_REGS.

gcc/ChangeLog:

* config/i386/i386.cc (inline_memory_move_cost): Return 100
for MASK_REGS when MODE_SIZE > 8.

20 months agoc-c++-common/Warray-bounds.c: Fix excess warnings on LLP64
Jonathan Yong [Mon, 27 Feb 2023 10:20:52 +0000 (10:20 +0000)]
c-c++-common/Warray-bounds.c: Fix excess warnings on LLP64

Excess errors on x86_64-w64-mingw32:
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:50:3: warning: array subscript 4611686018427387902 is above array bounds of 'struct S16[]' [-Warray-bounds=]
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:55:3: warning: array subscript 4611686018427387902 is above array bounds of 'struct S16[]' [-Warray-bounds=]
/home/user/p/gcc/src/gcc-git/gcc/testsuite/c-c++-common/Warray-bounds.c:90:3: warning: array subscript 658812288346769699 is above array bounds of 'struct S16[][7]' [-Warray-bounds=]

gcc/testsuite/ChangeLog:

* c-c++-common/Warray-bounds.c: Fix excess warnings on
LLP64.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
20 months agoRename ufix_trunc/ufloat* patterns to fixuns_trunc/floatuns* to align with standard...
liuhongt [Thu, 30 Mar 2023 07:43:25 +0000 (15:43 +0800)]
Rename ufix_trunc/ufloat* patterns to fixuns_trunc/floatuns* to align with standard pattern name.

There's some typo for the standard pattern name for unsigned_{float,fix},
it should be floatunsmn2/fixuns_truncmn2, not ufloatmn2/ufix_truncmn2
in current trunk, the patch fix the typo, also change all though
ufix_trunc/ufloat patterns.

Also vcvttps2udq is available under AVX512VL, so it can be generated
directly instead of being emulated via vcvttps2dq.

gcc/ChangeLog:

PR target/85048
* config/i386/i386-builtin.def (BDESC): Adjust icode name from
ufloat/ufix to floatuns/fixuns.
* config/i386/i386-expand.cc
(ix86_expand_vector_convert_uns_vsivsf): Adjust comments.
* config/i386/sse.md
(ufloat<sseintvecmodelower><mode>2<mask_name><round_name>):
Renamed to ..
(<mask_codefor>floatuns<sseintvecmodelower><mode>2<mask_name><round_name>):.. this.
(<mask_codefor><avx512>_ufix_notrunc<sf2simodelower><mode><mask_name><round_name>):
Renamed to ..
(<mask_codefor><avx512>_fixuns_notrunc<sf2simodelower><mode><mask_name><round_name>):
.. this.
(<fixsuffix>fix_truncv16sfv16si2<mask_name><round_saeonly_name>):
Renamed to ..
(fix<fixunssuffix>_truncv16sfv16si2<mask_name><round_saeonly_name>):.. this.
(ufloat<si2dfmodelower><mode>2<mask_name>): Renamed to ..
(floatuns<si2dfmodelower><mode>2<mask_name>): .. this.
(ufloatv2siv2df2<mask_name>): Renamed to ..
(<mask_codefor>floatunsv2siv2df2<mask_name>): .. this.
(ufix_notrunc<mode><si2dfmodelower>2<mask_name><round_name>):
Renamed to ..
(fixuns_notrunc<mode><si2dfmodelower>2<mask_name><round_name>):
.. this.
(ufix_notruncv2dfv2si2): Renamed to ..
(fixuns_notruncv2dfv2si2):.. this.
(ufix_notruncv2dfv2si2_mask): Renamed to ..
(fixuns_notruncv2dfv2si2_mask): .. this.
(*ufix_notruncv2dfv2si2_mask_1): Renamed to ..
(*fixuns_notruncv2dfv2si2_mask_1): .. this.
(ufix_truncv2dfv2si2): Renamed to ..
(*fixuns_truncv2dfv2si2): .. this.
(ufix_truncv2dfv2si2_mask): Renamed to ..
(fixuns_truncv2dfv2si2_mask): .. this.
(*ufix_truncv2dfv2si2_mask_1): Renamed to ..
(*fixuns_truncv2dfv2si2_mask_1): .. this.
(ufix_truncv4dfv4si2<mask_name>): Renamed to ..
(fixuns_truncv4dfv4si2<mask_name>): .. this.
(ufix_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>):
Renamed to ..
(fixuns_notrunc<mode><sseintvecmodelower>2<mask_name><round_name>):
.. this.
(ufix_trunc<mode><sseintvecmodelower>2<mask_name>): Renamed to ..
(<mask_codefor>fixuns_trunc<mode><sseintvecmodelower>2<mask_name>):
.. this.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr85048.C: New test.

20 months agoDaily bump.
GCC Administrator [Fri, 31 Mar 2023 00:17:02 +0000 (00:17 +0000)]
Daily bump.

20 months agoc++: anonymous union member reference [PR105452]
Jason Merrill [Thu, 30 Mar 2023 03:27:38 +0000 (23:27 -0400)]
c++: anonymous union member reference [PR105452]

While parsing the anonymous union, we don't yet know that it's an anonymous
union, so we build the reference to 'v' in the static_assert relative to the
union type.  But at instantiation time we know it's an anonymous union, so
we need to avoid trying to check access for 'v' in the union again; the
simplest approach seemed to be to make accessible_p step out to the
containing class.

While looking at this I also noticed that we were having trouble with DMI in
an anonymous union referring to members of the containing class; there
we just need to give current_class_ptr the right type.

PR c++/105452

gcc/cp/ChangeLog:

* search.cc (type_context_for_name_lookup): New.
(accessible_p): Handle anonymous union.
* init.cc (maybe_instantiate_nsdmi_init): Use
type_context_for_name_lookup.
* parser.cc (cp_parser_class_specifier): Likewise.
* cp-tree.h (type_context_for_name_lookup): Declare.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/anon8.C: New test.

20 months agoc++: generic lambda and function ptr conv [PR105221]
Jason Merrill [Thu, 30 Mar 2023 15:07:17 +0000 (11:07 -0400)]
c++: generic lambda and function ptr conv [PR105221]

We weren't properly considering the function pointer conversions in
deduction between FUNCTION_TYPE; we just hardcoded the
UNIFY_ALLOW_MORE_CV_QUAL semantics, which are backwards when deducing for a
template conversion function like the one in a generic lambda.  And when I
started checking the ALLOW flags, I needed to make sure they stay set to
avoid breaking trailing13.C.

PR c++/105221

gcc/cp/ChangeLog:

* pt.cc (unify) [FUNCTION_TYPE]: Handle function pointer
conversions.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/noexcept-type27.C: New test.

20 months agolibiberty: Remove a reference to the Glibc manual
Gerald Pfeifer [Thu, 30 Mar 2023 21:41:24 +0000 (23:41 +0200)]
libiberty: Remove a reference to the Glibc manual

longjmp is not specific to Glibc, and GCC supports lots of systems
that do not use Glibc. Plus this link has been broken in the web
version for ages without a good way to fix.

libiberty/ChangeLog:

* obstacks.texi (Preparing for Obstacks): Remove a (broken)
reference to the Glibc manual.

20 months agoc++: Fix up ICE in build_min_non_dep_op_overload [PR109319]
Jakub Jelinek [Thu, 30 Mar 2023 21:08:25 +0000 (23:08 +0200)]
c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]

The following testcase ICEs, because grok_array_decl during
processing_template_decl handling of a non-dependent subscript
emits a -Wcomma-subscript pedwarn, we decide to pass to the
single index argument the index expressions as if it was wrapped
with () around it, but then when preparing it for later instantiation
we don't actually take that into account and ICE on a mismatch of
number of index arguments (the overload expects a single index,
testcase has two index expressions in this case).
For non-dependent subscript which are builtin subscripts we also
emit the same pedwarn and don't ICE, but emit the same pedwarn
again whenever we instantiate it, which is also IMHO undesirable,
it is enough to warn once during parsing the template.

The following patch fixes it by turning even the original index expressions
(those which didn't go through make_args_non_dependent) into a single
index using comma expression(s).

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/109319
* decl2.cc (grok_array_decl): After emitting a pedwarn for
-Wcomma-subscript, if processing_template_decl set orig_index_exp
to compound expr from orig_index_exp_list.

* g++.dg/cpp23/subscript14.C: New test.