Commit Graph

183616 Commits

Author SHA1 Message Date
Mikael Pettersson
8b6ebc025c [PATCH] Fix Ada bootstrap failure on Cygwin since switch to C++11 (PR98590)
gcc/ada
	PR bootstrap/98590
	* cstreams.c: Ensure fileno_unlocked() is visible on Cygwin.
2021-03-02 15:20:06 -07:00
Michael Matloob
d1776b7757 compiler: allow //go:embed in files underscore-importing embed
The embed spec allows for //go:embed to be used in files that
underscore-import package "embed". This is useful for embeds to
[]byte and string vars because the embed.FS type may not be referenced
if those are the only types of embeds in a file. Because the compiler
previously checked whether there were any aliases to the embed
package to decide if //go:embed could be used, it would reject
files with only underscore imports of embed. Instead, record
whether the embed import is encountered at all, similar to what
is done with unsafe, to decide whether //go:embed is allowed.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/297553
2021-03-02 14:03:26 -08:00
Ian Lance Taylor
df003d1e0b libbacktrace: pass -1 to error callback for unrecognized DWARF
PR libbacktrace/98818
	* dwarf.c (dwarf_buf_error): Add errnum parameter.  Change all
	callers.
	* backtrace.h: Update backtrace_error_callback comment.
2021-03-02 13:46:48 -08:00
David Malcolm
41fbacdd10 diagnostics: fix ICE on fix-it hints on very long lines [PR99323]
PR c/99323 describes an ICE due to a failed assertion deep inside the
fix-it printing machinery, where the fix-it hints on one line have not
been properly sorted in layout's constructor.

The underlying issue occurs when multiple fix-it hints affect a line
wider that LINE_MAP_MAX_COLUMN_NUMBER, where the location_t values for
characters after that threshold fall back to having column zero.

It's not meaningful to try to handle fix-it hints without column
information, so this patch rejects them as they are added to the
rich_location, falling back to the "no fix-it hints on this diagnostic"
case, fixing the crash.

gcc/ChangeLog:
	PR c/99323
	* diagnostic-show-locus.c
	(selftest::test_one_liner_many_fixits_2): Fix accidental usage of
	column 0.

gcc/testsuite/ChangeLog:
	PR c/99323
	* gcc.dg/pr99323-1.c: New test.
	* gcc.dg/pr99323-2.c: New test.

libcpp/ChangeLog:
	PR c/99323
	* line-map.c (rich_location::maybe_add_fixit): Reject fix-it hints
	at column 0.
2021-03-02 15:46:06 -05:00
Martin Sebor
e7ca37649e PR middle-end/99276 - grammar in diagnostics for overflowing the destination
gcc/ChangeLog:

	PR middle-end/99276
	* builtins.c (warn_for_access): Remove stray warning text.
2021-03-02 13:37:01 -07:00
Martin Sebor
397ed1dbff PR middle-end/99295 - documentation on __attribute__((malloc)) is wrong
gcc/ChangeLog:

	PR middle-end/99295
	* doc/extend.texi (attribute malloc): Reword and clarify nonaliasing
	property.
2021-03-02 11:19:49 -07:00
Martin Sebor
66ecb059c9 PR c++/99251 - inconsistent -Wnonnull warning behaviour with dynamic_cast
gcc/cp/ChangeLog:

	PR c++/99251
	* class.c (build_base_path): Call build_if_nonnull.
	* cp-tree.h (build_if_nonnull): Declare.
	* rtti.c (ifnonnull): Rename...
	(build_if_nonnull): ...to this.  Set no-warning bit on COND_EXPR.
	(build_dynamic_cast_1): Adjust to name change.

gcc/testsuite/ChangeLog:

	PR c++/99251
	* g++.dg/warn/Wnonnull9.C: Expect no warnings.
	* g++.dg/warn/Wnonnull12.C: New test.
2021-03-02 11:12:50 -07:00
Jakub Jelinek
5a233ae4d8 dwarf2out: Fix up split-dwarf .debug_macro handling [PR99319]
The -gsplit-dwarf changes came a few months after .debug_macro
and the r0-120109 changes just changed the 2nd operand of
DW_MACRO_GNU_{define,undef}_indirect from the usual .debug_str
section offset argument to leb128 index into .debug_str_offsets
without changing the opcodes.

DWARF5 standardized different opcodes for those, but GCC hasn't been changed
yet for that.
This patch starts using DW_MACRO_define_strx and DW_MACRO_undef_strx
instead of DW_MACRO_define_strp and DW_MACRO_undef_strp when -gsplit-dwarf
-gdwarf-5 -g3.  I'm not sure what to do if anything with the -gdwarf-4
-gsplit-dwarf -g3 -gno-strict-dwarf case, we've been emitting it that way
for 8 years and it is an extension, so presumably the consumers that cared
have already hacks to handle DW_MACRO_GNU_{define,undef}_indirect
differently in .debug_macro 4 sections depending on if it is
.debug_macro.dwo or .debug_macro.
Another change the patch does is that it will use
DW_MACRO_{define,undef}_str{p,x} even with -gdwarf-5 -gstrict-dwarf -g3,
for DWARF 4 we were doing that only for -gno-strict-dwarf as we've emitted
.debug_macro section only in that case.

2021-03-02  Jakub Jelinek  <jakub@redhat.com>

	PR debug/99319
	* dwarf2out.c (output_macinfo_op): Use DW_MACRO_*_str* even with
	-gdwarf-5 -gstrict-dwarf.  For -gsplit-dwarf -gdwarf-5 use
	DW_MACRO_*_strx instead of DW_MACRO_*_strp.  Handle
	DW_MACRO_define_strx and DW_MACRO_undef_strx.
	(save_macinfo_strings): Use DW_MACRO_*_str* even with
	-gdwarf-5 -gstrict-dwarf.  Handle DW_MACRO_define_strx and
	DW_MACRO_undef_strx.
2021-03-02 18:25:45 +01:00
Eric Botcazou
168b75ff54 Fix PR ada/99095
This is a regression present on the mainline and 10 branch, where we fail
to make the bounds explicit for the return value of a function returning
an unconstrained array of a limited record type.

gcc/ada/
	PR ada/99095
	* sem_ch8.adb (Check_Constrained_Object): Restrict again the special
	optimization for limited types to non-array types except in the case
	of an extended return statement.
gcc/testsuite/
	* gnat.dg/limited5.adb: New test.
2021-03-02 18:00:09 +01:00
Martin Liska
f8e4d7a659 analyzer: remove dead code
The issue is reported by Clang:

warning: private field 'm_engine' is not used [-Wunused-private-field]

gcc/analyzer/ChangeLog:

	* diagnostic-manager.cc (diagnostic_manager::emit_saved_diagnostics):
	Do not pass engine.
2021-03-02 14:39:50 +01:00
Patrick Palka
e52f8ec25c c++: Fix satisfaction of placeholder type constraints [PR96443]
This fixes the way we check satisfaction of constraints on placeholder
types in various deduction contexts, and in particular when the
constraint is dependent.

Firstly, when evaluating the return type requirement of a compound
requirement, we currently substitute the outer template arguments into
the constraint before checking satisfaction. But we should instead be
passing in the complete set of template arguments to satisfaction and
not do a prior separate substitution.  Our current approach leads to us
incorrectly rejecting the testcase concepts-return-req2.C below.

Secondly, when checking the constraints on a placeholder variable or
return type, we don't consider the template arguments of the enclosing
context at all.  This leads to bogus errors during satisfaction when the
constraint is dependent as in the testcase concepts-placeholder3.C
below.

In order to fix these two issues, we need to be able to normalize the
constraints on a placeholder 'auto' on demand, which in turn requires us
to know the template parameters that were in scope where the 'auto' was
introduced.  This information currently doesn't seem to be easily available
when we need it, so this patch turns PLACEHOLDER_TYPE_CONSTRAINTS into a
TREE_LIST whose TREE_PURPOSE additionally holds the value of
current_template_parms whence a constrained 'auto' was formed.

This patch also removes some seemingly wrong handling of placeholder
type arguments from tsubst_parameter_mapping.  The code doesn't trigger
with the example used in the comments, because type_uses_auto doesn't
look inside non-deduced contexts such as the operand of decltype.  And
the call to do_auto_deduction seems confused because if 'arg' is a type,
then so is 'parm', and therefore 'init' too is a type, but
do_auto_deduction expects it to be an expression.  Before this patch,
this code was dead (as far as our testsuite can tell), but now it breaks
other parts of this patch, so let's remove it.

gcc/cp/ChangeLog:

	PR c++/96443
	PR c++/96960
	* constraint.cc (type_deducible_p): Don't substitute into the
	constraints, and instead just pass 'args' to do_auto_deduction
	as the outer template arguments.
	(tsubst_parameter_mapping): Remove confused code for handling
	placeholder type arguments.
	(normalize_placeholder_type_constraint): Define.
	(satisfy_constraint_expression): Use it to handle placeholder
	'auto' types.
	* cp-tree.h (PLACEHOLDER_TYPE_CONSTRAINTS_INFO): Define.
	(PLACEHOLDER_TYPE_CONSTRAINTS): Redefine in terms of the above.
	* pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: Use
	PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
	(make_constrained_placeholder_type): Set
	PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
	(do_auto_deduction): Clarify comments about the outer_targs
	parameter.  Rework satisfaction of a placeholder type constraint
	to pass in the complete set of template arguments directly to
	constraints_satisfied_p.
	(splice_late_return_type): Use PLACEHOLDER_TYPE_CONSTRAINTS_INFO
	instead.  Also rebuild the the constraint info on the new auto.

gcc/testsuite/ChangeLog:

	PR c++/96443
	PR c++/96960
	* g++.dg/concepts/abbrev9.C: New test.
	* g++.dg/cpp2a/concepts-lambda15.C: New test.
	* g++.dg/cpp2a/concepts-placeholder3.C: New test.
	* g++.dg/cpp2a/concepts-return-req2.C: New test.
	* g++.dg/cpp2a/concepts-ts1.C: Add dg-bogus directive to the
	call to f15 that we expect to accept.
2021-03-02 07:49:29 -05:00
Patrick Palka
276cb81bec c++: Delay normalizing nested requirements until satisfaction
This sets up the functionality for controlling the initial set of
template parameters to pass to normalization when dealing with a
constraint-expression that is not associated with some constrained
declaration, for instance when normalizing a nested requirement of a
requires expression, or the constraints on a placeholder type.

The main new ingredient here is the data member norm_info::initial_parms
which can be set by callers of the normalization routines to communicate
the in-scope template parameters for the supplied constraint-expression,
rather than always falling back to using current_template_parms.

This patch then uses this functionality in our handling of nested
requirements so that we can delay normalizing them until needed for
satisfaction.  We currently immediately normalize nested requirements at
parse time, where we have the necessary template context, and cache the
normal form in their TREE_TYPE node.  With this patch, we now delay
normalization until needed (as with other constraint expressions), and
instead store the current value of current_template_parms in their
TREE_TYPE node (which we use to restore the template context at
normalization time).

In the subsequent patch, this functionality will also be used to
normalize placeholder type constraints during auto deduction.

gcc/cp/ChangeLog:

	* constraint.cc (build_parameter_mapping): Rely on the caller to
	determine the in-scope template parameters.
	(norm_info::norm_info): Delegate the tsubst_flags_t constructor
	to the two-parameter constructor.  In the two-parameter
	constructor, fold in the definition of make_context, set
	initial_parms appropriately, and don't set the now-removed
	orig_decl member.
	(norm_info::make_context): Remove, now that its only use is
	inlined into the caller.
	(norm_info::update_context): Adjust call to
	build_parameter_mapping to pass in the relevant set of in-scope
	template parameters.
	(norm_info::ctx_parms): Define this member function.
	(norm_info::context): Initialize to NULL_TREE.
	(norm_info::orig_decl): Remove this data member.
	(norm_info::initial_parms): Define this data member.
	(normalize_atom): Adjust call to build_parameter_mapping to pass
	in the relevant set of in-scope template parameters.  Use
	info.initial_parms instead of info.orig_decl.
	(normalize_constraint_expression): Take a norm_info object
	instead of a bool.  Cache the result of normalization.
	(tsubst_nested_requirement): Call satisfy_constraint_expression
	instead of satisfy_constraint, so that we normalize on demand.
	(satisfy_constraint_expression): Handle a NESTED_REQ argument.
	Adjust call to normalize_constraint_expression.
	(finish_nested_requirement): Set the TREE_TYPE of the NESTED_REQ
	to current_template_parms.
	(diagnose_nested_requirements): Go through
	satisfy_constraint_expression, as with tsubst_nested_requirement.
2021-03-02 07:38:41 -05:00
Patrick Palka
04b10596fe c++: Some preparatory type canonicalization fixes
The patches that follow revealed some latent type canonicalization
issues during normalization/satisfaction, due to normalization of
some constraint-expressions now being performed in different contexts
and more frequently (since the normalization caches get frequently
emptied in a checking compiler).  The issues are:

1. In tsubst_parameter_mapping, we canonicalize the arguments of a
   substituted TYPE_ARGUMENT_PACK only if the argument we started with
   wasn't a TYPE_ARGUMENT_PACK.  We should canonicalize a substituted
   TYPE_ARGUMENT_PACK regardless of what we started with.

2. We currently set DECL_CONTEXT and CONSTRAINT_VAR_P on each of the
   parameters introduced in a requires expression _after_ we're done
   processing the requirements.  But meanwhile we may have already
   built and computed the canonical form of a type that uses one of
   these PARM_DECLs (as say an operand to decltype).  But the canonical
   form depends on the result of cp_tree_equal, which in turn depends on
   the value of CONSTRAINT_VAR_P and DECL_CONTEXT.  So we must set these
   fields earlier, before processing requirements.

3. In do_auto_deduction, we use the result of finish_decltype_type later
   as a template argument, so we should canonicalize the result too.
   (While we're here, we should pass 'complain' to finish_decltype_type,
   which fixes the testcase auto1.C below.)

gcc/cp/ChangeLog:

	* constraint.cc (tsubst_parameter_mapping): Canonicalize the
	arguments of a substituted TYPE_ARGUMENT_PACK even if we've
	started with a TYPE_ARGUMENT_PACK.
	(finish_requires_expr): Don't set DECL_CONTEXT and
	CONSTRAINT_VAR_P on each of the introduced parameters here.
	* parser.c (cp_parser_requirement_parameter_list): Instead set
	these fields earlier, here.
	* pt.c (do_auto_deduction): Canonicalize the result of
	do_auto_deduction.  Pass 'complain' to finish_decltype_type.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/auto1.C: New test.
2021-03-02 07:38:37 -05:00
Patrick Palka
d6378b9785 c++: Avoid building garbage trees from tsubst_requires_expr
Since we no longer partially instantiate REQUIRES_EXPRs, we don't need
to rebuild its requirements during tsubst_requires_expr.

gcc/cp/ChangeLog:

	* constraint.cc (tsubst_simple_requirement): Just return
	boolean_true_node on success.
	(tsubst_type_requirement): Likewise.
	(tsubst_compound_requirement): Likewise.
	(tsubst_nested_requirement): Likewise.
	(tsubst_requirement_body): Remove.
	(check_constaint_variables): Rename to ...
	(check_constraint_variables): ... this.
	(tsubst_constraint_variables): Adjust.
	(tsubst_requires_expr): Fold tsubst_requirement_body into here.
2021-03-02 07:38:13 -05:00
Andreas Krebbel
2bd58910b0 IBM Z: arch14: New instrinsics
This adds support for 5 new builtins.

gcc/ChangeLog:

	* config/s390/s390-builtin-types.def (BT_FN_V4SF_V8HI_UINT): New
	builtin signature.
	(BT_FN_V8HI_V8HI_UINT): Likewise.
	(BT_FN_V8HI_V4SF_V4SF_UINT): Likewise.
	* config/s390/s390-builtins.def (B_NNPA): New macro definition.
	(s390_vclfnhs, s390_vclfnls, s390_vcrnfs, s390_vcfn, s390_vcnf):
	New builtin definitions.
	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Bump
	vector extension version.
	* config/s390/s390.c (s390_expand_builtin): Check if builtins are
	available with current -march level.
	* config/s390/s390.md (UNSPEC_NNPA_VCLFNHS_V8HI)
	(UNSPEC_NNPA_VCLFNLS_V8HI, UNSPEC_NNPA_VCRNFS_V8HI)
	(UNSPEC_NNPA_VCFN_V8HI, UNSPEC_NNPA_VCNF_V8HI): New constants.
	* config/s390/vecintrin.h (vec_extend_to_fp32_hi): New macro.
	(vec_extend_to_fp32_lo): Likewise.
	(vec_round_from_fp32): Likewise.
	(vec_convert_to_fp16): Likewise.
	(vec_convert_from_fp16): Likewise.
	* config/s390/vx-builtins.md (vclfnhs_v8hi): New insn pattern.
	(vclfnls_v8hi): Likewise.
	(vcrnfs_v8hi): Likewise.
	(vcfn_v8hi): Likewise.
	(vcnf_v8hi): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/zvector/vec-nnpa-fp16-convert.c: New test.
	* gcc.target/s390/zvector/vec-nnpa-fp32-convert-1.c: New test.
	* gcc.target/s390/zvector/vec_convert_from_fp16.c: New test.
	* gcc.target/s390/zvector/vec_convert_to_fp16.c: New test.
	* gcc.target/s390/zvector/vec_extend_to_fp32_hi.c: New test.
	* gcc.target/s390/zvector/vec_extend_to_fp32_lo.c: New test.
	* gcc.target/s390/zvector/vec_round_from_fp32.c: New test.
2021-03-02 11:58:31 +01:00
Andreas Krebbel
796a35b2bd IBM Z: arch14: Add command line options
Prepare GCC for a future architecture extension.

gcc/ChangeLog:

	* common/config/s390/s390-common.c (processor_flags_table): New entry.
	* config.gcc: Enable arch14 for --with-arch and --with-tune.
	* config/s390/driver-native.c (s390_host_detect_local_cpu): Pick
	arch14 for unknown CPU models.
	* config/s390/s390-opts.h (enum processor_type): Add PROCESSOR_ARCH14.
	* config/s390/s390.c (s390_issue_rate): Add case for PROCESSOR_ARCH14.
	(s390_get_sched_attrmask): Likewise.
	(s390_get_unit_mask): Likewise.
	* config/s390/s390.h (enum processor_flags): Add PF_NNPA and PF_ARCH14.
	(TARGET_CPU_ARCH14, TARGET_CPU_ARCH14_P, TARGET_CPU_NNPA)
	(TARGET_CPU_NNPA_P, TARGET_ARCH14, TARGET_ARCH14_P, TARGET_NNPA)
	(TARGET_NNPA_P): New macro definitions.
	* config/s390/s390.md ("cpu_facility", "enabled"): Add arch14 and nnpa.
	* config/s390/s390.opt: Add PROCESSOR_ARCH14.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp: Add check for nnpa facility.
2021-03-02 11:58:31 +01:00
Jakub Jelinek
ff92ede8d2 vrp: Improve register_edge_assert_for [PR95757]
The Wstringop-overflow-25.c testcase doesn't emit one of the expected
warnings on targets that don't do short curcuiting due to target costs
(or e.g. with --param=logical-op-non-short-circuit=0 on all targets).

The problem is that only reassoc2 optimizes:
  _49 ={v} unsigned_value_source;
  if (_49 == 0)
    goto <bb 7>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 536870913]:
  if (_49 > 2)
    goto <bb 7>; [50.00%]
  else
    goto <bb 6>; [50.00%]

  <bb 6> [local count: 268435457]:
  _53 = _49 + 1;
into:
  _49 ={v} unsigned_value_source;
  _48 = _49 + 18446744073709551615;
  _1 = _48 > 1;
  if (_1 != 0)
    goto <bb 6>; [50.00%]
  else
    goto <bb 5>; [50.00%]

  <bb 5> [local count: 268435457]:
  _53 = _49 + 1;
(but, note the _1 = _48 > 1; if (_1 != 0)),
then dom3 is run and because of that if (_1 != 0) vs. if (_48 > 1) doesn't
register edge asserts for _48 and _49) and so we don't get
SSA_NAME_RANGE_INFO for _53 (and ditto for vrp2) and only afterwards comes
forwprop4 that canonicalizes it to if (_48 > 1).  While with
--param=logical-op-non-short-circuit=1 it is already reassoc1 that optimizes
it and forwprop3 that propagates it, so we have on the SSA_NAME
corresponding to _53 above SSA_NAME_RANGE_INFO and during expansion we warn.

The following patch fixes it by handling those not yet propagated
comparisons into GIMPLE_COND in register_edge_assert_for.  We already
have all the infrastructure there to handle the --param=logical-op-non-short-circuit=1
| and &s.

2021-03-02  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/95757
	* tree-vrp.c (register_edge_assert_for): Remove superfluous ()s around
	condition.  Call register_edge_assert_for_1 for == 0, != 0, == 1 and
	!= 1 comparisons if name is lhs of a comparison.
2021-03-02 11:49:12 +01:00
Andreas Krebbel
34d39d1409 IBM Z: Run mul-signed-overflow tests only on z14
gcc/testsuite/ChangeLog:

	* gcc.target/s390/mul-signed-overflow-1.c: Run only on z14.
	* gcc.target/s390/mul-signed-overflow-2.c: Run only on z14.
2021-03-02 10:55:54 +01:00
Michael Meissner
76c99cb113 Fix __sprintfkf prototype in libgcc.
The prototype of __sprintfkf in _sprintfkf.h did not match the function in
_sprintfkf.c.  This patch fixes the prototype.  I also included the
_sprintfkf.h file in _sprintfkf.c to make sure the prototype is correct and to
eliminate a warning about declaring the function without a previous
declaration.

libgcc/
2021-03-01  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/_sprintfkf.h (__sprintfkf): Fix prototype to match
	the function.
	* config/rs6000/_sprintfkf.c: Include _sprintfkf.h.
2021-03-01 22:13:33 -05:00
GCC Administrator
8893888621 Daily bump. 2021-03-02 00:16:32 +00:00
Eric Botcazou
3104dbdcf4 Do not call Set_Cloned_Subtype on private type
Build_Discriminated_Subtype may be invoked on a E_Record_Type_With_Private,
in which case it builds a E_Record_Subtype_With_Private which does not have
the Cloned_Subtype field.

gcc/ada/
	PR ada/99020
	* sem_ch3.adb (Build_Discriminated_Subtype): Set the Cloned_Subtype
	only if the type is not private.
2021-03-02 01:05:38 +01:00
Iain Sandoe
491d5b3cf8 dwarf2unwind : Force the CFA after remember/restore pairs [44107/48097].
This address one of the more long-standing and serious regressions
for Darwin.  GCC emits unwind code by default on the assumption that
the unwinder will be (of have the same capability) as the one in the
current libgcc_s.  For Darwin platforms, this is not the case - some
of them are based on the libgcc_s from GCC-4.2.1 and some are using
the unwinder provided by libunwind (part of the LLVM project). The
latter implementation has gradually adopted a section that deals with
GNU unwind.

The most serious problem for some of the platform versions is in
handling DW_CFA_remember/restore_state pairs.  The DWARF description
talks about these in terms of saving/restoring register rows; this is
what GCC originally did (and is what the unwinders do for the Darwin
versions based on libgcc_s).

However, in r118068, this was changed so that not only the registers
but also the current frame address expression were saved.  The unwind
code assumes that the unwinder will do this; some of Darwin's unwinders
do not, leading to lockups etc.  To date, the only solution has been
to replace the system libgcc_s with a newer one which is not a viable
solution for many end-users (since that means overwritting the one
provided with the system installation).

The fix here provides a target hook that allows the target to specify
that the CFA should be reinstated after a DW_CFA_restore.  This fixes
the issue (and also the closed WONTFIX of 44107).

(As a matter of record, it also fixes reported Java issues if
 backported to GCC-5).

gcc/ChangeLog:

	PR target/44107
	PR target/48097
	* config/darwin-protos.h (darwin_should_restore_cfa_state): New.
	* config/darwin.c (darwin_should_restore_cfa_state): New.
	* config/darwin.h (TARGET_ASM_SHOULD_RESTORE_CFA_STATE): New.
	* doc/tm.texi: Regenerated.
	* doc/tm.texi.in: Document TARGET_ASM_SHOULD_RESTORE_CFA_STATE.
	* dwarf2cfi.c (connect_traces): If the target requests, restore
	the CFA expression after a DW_CFA_restore.
	* target.def (TARGET_ASM_SHOULD_RESTORE_CFA_STATE): New hook.
2021-03-01 19:37:09 +00:00
Martin Liska
4ed0a92f6c s390: add exceptions for param modified by target pragma
gcc/ChangeLog:

	PR target/99313
	* optc-save-gen.awk: Add 4 more exceptions.

gcc/testsuite/ChangeLog:

	PR target/99313
	* gcc.target/s390/target-attribute/pr99313.c: New test.
2021-03-01 15:42:35 +01:00
Nathan Sidwell
2e0bb9eec2 c++: Completeness of typedef structs [PR 99294]
When we read in a class definition, we use fixup_type_variants to
propagate the now-completed fields of the class's TYPE to other
variants.  Unfortunately that doesn't propagate all of them, and in
this case we had a typedef to an (incomplete) instantiation.  That
typedef ended up with a VOIDmode, which blew up gimple expansion as
the type itself isn't VOID.  Without modules, that information is
propagated in finalize_type_size when laying out the class.  But that
doesn't happen with stream-in -- we already know the layout.  There is
already some overlap between the two functions, now there's a bit
more.  In fixup_type_variants, I pay attention to the TYPE_NAME to
decide whether to override a user's TYPE_ALIGN -- variants of the
main-variant typedef just copy the main-variant.  Other variants
recalculate.  Overaligning is still permitted.

I also added a TYPE_ALIGN_RAW accessor, and fixed a bug in the
alignment streaming I noticed.  I did not refactor TYPE_ALIGN beyond
using the new accessor.  (It could be written as ((1 << align_raw) >>
1), rather than use the conditional.)

	PR c++/99294
	gcc/
	* tree.h (TYPE_ALIGN_RAW): New accessor.
	(TYPE_ALIGN): Use it.
	gcc/cp/
	* class.c (fixup_type_variants): Propagate mode, precision,
	alignment & emptiness.
	* module.cc (trees_out::type_node): Use TYPE_ALIGN_RAW.
	(trees_in::tree_node): Rematerialize alignment here.
	gcc/testsuite/
	* g++.dg/modules/pr99294.h: New.
	* g++.dg/modules/pr99294_a.C: New.
	* g++.dg/modules/pr99294_b.C: New.
2021-03-01 05:57:53 -08:00
Jan Hubicka
150bde36c1 Fix ICE in compute_fn_summary
PR ipa/98338
	* ipa-fnsummary.c (compute_fn_summary): Fix sanity check.
2021-03-01 14:36:11 +01:00
Eric Botcazou
074226d5aa Fix wrong result for 1.0/3.0 at -O2 -fno-omit-frame-pointer -frounding-math
This wrong-code PR for the C++ compiler on x86-64/Windows is a regression
in GCC 9 and later, but the underlying issue has probably been there since
SEH was implemented and is exposed by this comment in config/i386/winnt.c:

  /* SEH records saves relative to the "current" stack pointer, whether
     or not there's a frame pointer in place.  This tracks the current
     stack pointer offset from the CFA.  */
  HOST_WIDE_INT sp_offset;

That's not what the (current) Microsoft documentation says; instead it says:

  /* SEH records offsets relative to the lowest address of the fixed stack
     allocation.  If there is no frame pointer, these offsets are from the
     stack pointer; if there is a frame pointer, these offsets are from the
     value of the stack pointer when the frame pointer was established, i.e.
     the frame pointer minus the offset in the .seh_setframe directive.  */

That's why the implementation is correct only under the condition that the
frame pointer be established *after* the fixed stack allocation; as a matter
of fact, that's clearly the model underpinning SEH, but is the opposite of
what is done e.g. on Linux.

However the issue is mostly papered over in practice because:

  1. SEH forces use_fast_prologue_epilogue to false, which in turns forces
save_regs_using_mov to false, so the general regs are always pushed when
they need to be saved, which eliminates the offset computation for them.

  2. As soon as a frame is larger than 240 bytes, the frame pointer is fixed
arbitrarily to 128 bytes above the stack pointer, which of course requires
that it be established after the fixed stack allocation.

So you need a small frame clobbering one of the call-saved XMM registers in
order to generate wrong SEH unwind info.

The attached fix makes sure that the frame pointer is always established
after the fixed stack allocation by pointing it at or below the lowest used
register save area, i.e. the SSE save area, and removing the special early
saves in the prologue; the end result is a uniform prologue sequence for
SEH whatever the frame size.  And it avoids a discrepancy between cases
where the number of saved general regs is even and cases where it is odd.

gcc/
	PR target/99234
	* config/i386/i386.c (ix86_compute_frame_layout): For a SEH target,
	point the hard frame pointer to the SSE register save area instead
	of the general register save area.  Perform only minimal adjustment
	for small frames if it is initially not correctly aligned.
	(ix86_expand_prologue): Remove early saves for a SEH target.
	* config/i386/winnt.c (struct seh_frame_state): Document constraint.
gcc/testsuite/
	* g++.dg/eh/seh-xmm-unwind.C: New test.
2021-03-01 07:58:50 +01:00
GCC Administrator
2c83c3fbd2 Daily bump. 2021-03-01 00:16:29 +00:00
Joseph Myers
6838d1b33d Update gcc de.po, sv.po.
* de.po, sv.po: Update.
2021-02-28 22:34:35 +00:00
Iain Sandoe
3c173f7890 testsuite, coroutines : Mark final awaiters and co_await operators noexcept.
This is part of the requirement of [dcl.fct.def.coroutine]/15.

In addition to promise final_suspend() calls, the following cases must
also be noexcept as per discussion in PR95616.

- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor

Fixed for missing cases in the testsuite as a prerequisite to fixing
PR95616.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr94879-folly-1.C: Make final suspend
	expression components noexcept.
	* g++.dg/coroutines/pr94883-folly-2.C: Likewise.
	* g++.dg/coroutines/pr95345.C: Likewise.
2021-02-28 16:28:12 +00:00
Jason Merrill
7e5d7fc7e6 c++: Fix attr-lambda3.C
Some testcase for a change I was testing had an unnecessary ; at the end of
a line that caused a test failure on the 10 branch, so I mistakenly removed
it from this one.  Oops.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/attr-lambda3.C: Add missing ;
2021-02-28 09:17:10 -05:00
Jakub Jelinek
48ca2185bf fortran: Fix up wording of 3 OpenMP diagnostic messages [PR99303]
As reported in the PR, some diagnostic messages need wording improvements.

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/99303
	* openmp.c (gfc_omp_requires_add_clause): Fix up diagnostic message
	wordings.
	(resolve_omp_clauses): Likewise.
2021-02-28 11:16:33 +01:00
Jakub Jelinek
3a77ca7d36 fortran: Replace double space in diagnostic with a single one [PR99300]
The diagnostic had "  " in it instead of just " ".

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/99300
	* frontend-passes.c (doloop_code): Replace double space in diagnostics
	with a single space.
2021-02-28 11:14:24 +01:00
Jakub Jelinek
d3805e6d57 typos: Fix various typos - mainly misspelled reference* [PR99304]
The PR is about a typo in handle_malloc_attribute diagnostic message,
but grepping around I found many other cases and while fixing those I've
noticed a couple of other typos.

2021-02-28  Jakub Jelinek  <jakub@redhat.com>

	PR c/99304
	* ipa.c (symbol_table::remove_unreachable_nodes): Fix a comment
	typo - referneced -> referenced.
	* tree.c (component_ref_size): Fix comment typo -
	refernce -> reference.
	* tree-ssa-alias.c (access_path_may_continue_p): Fix comment typo -
	traling -> trailing.
	(aliasing_component_refs_p): Fix comment typos -
	refernce -> reference and refernece -> reference and
	traling -> trailing.
	(nonoverlapping_refs_since_match_p): Fix comment typo -
	referneces -> references.
	* doc/invoke.texi (--param modref-max-bases): Fix a typo -
	referneces -> references.
gcc/c-family/
	* c-attribs.c (handle_malloc_attribute): Fix a typo in inform
	message - refernced -> referenced.  Remove superfluous space before
	closing paren of function calls.
gcc/lto/
	* lto-symtab.c (lto_symtab_prevailing_virtual_decl): Fix comment
	typos - refernced -> referenced and
	devirtualizaiton -> devirtualization.
2021-02-28 11:12:57 +01:00
GCC Administrator
ec9dc4fa08 Daily bump. 2021-02-28 00:16:18 +00:00
Jason Merrill
5d9d6c1cd8 c++: Allow GNU attributes before lambda -> [PR90333]
In my 9.3/10 patch for 90333 I allowed attributes between [] and (), and
after the trailing return type, but not in the place that GCC 8 expected
them, and we've gotten several bug reports about that.  So let's allow them
there, as well.

gcc/cp/ChangeLog:

	PR c++/90333
	* parser.c (cp_parser_lambda_declarator_opt): Accept GNU attributes
	between () and ->.

gcc/testsuite/ChangeLog:

	PR c++/90333
	* g++.dg/ext/attr-lambda3.C: New test.
2021-02-27 15:44:27 -05:00
Iain Sandoe
a938e4616d Darwin : Update a disgnostic message [NFC].
The avoids a contraction and a format diagnostic warning.

gcc/ChangeLog:

	* config/host-darwin.c (darwin_gt_pch_use_address): Modify
	diagnostic message to avoid use of a contraction and format
	warning.
2021-02-27 16:31:54 +00:00
Iain Sandoe
e3eda9a0e1 libgomp, testsuite : Require alias support for PR96390 testcase.
This fails everywhere on Darwin, which does not have support for
symbol aliases.  Add a dg-require-alias to UNSUPPORT it.

libgomp/ChangeLog:

	* testsuite/libgomp.c-c++-common/pr96390.c: Require alias
	support from the target.
2021-02-27 16:31:34 +00:00
Jonathan Wakely
699672d4dc libstdc++: Fix conversions from date types to integers [PR 99301]
The conversions to integer types are explicit, so need to use the
correct type. Converting to uint32_t only works if that is the same type
as unsigned.

libstdc++-v3/ChangeLog:

	PR libstdc++/99301
	* include/std/chrono (year_month_day::_M_days_since_epoch()):
	Convert chrono::month and chrono::day to unsigned before
	converting to uint32_t.
2021-02-27 12:53:15 +00:00
Jakub Jelinek
652623f7c6 gcse, ipa-devirt: Use %wd/%wu instead of HOST_WIDE_INT_PRINT* in diagnostics [PR99288]
HOST_WIDE_INT_PRINT* in the string literals of warning/error/inform etc.
make those messages non-translatable, and we have a perfectly fine
alternative when not using system *printf - %w{d,u}.

2021-02-27  Jakub Jelinek  <jakub@redhat.com>

	PR other/99288
	* gcse.c (gcse_or_cprop_is_too_expensive): Use %wu instead of
	HOST_WIDE_INT_PRINT_UNSIGNED in warning format string.
	* ipa-devirt.c (ipa_odr_read_section): Use %wd instead of
	HOST_WIDE_INT_PRINT_DEC in inform format string.  Fix comment
	typos.
2021-02-27 10:43:28 +01:00
GCC Administrator
06a9f20f97 Daily bump. 2021-02-27 00:16:23 +00:00
David Malcolm
ded7355b3d analyzer: implement exploded_path copy ctor
gcc/analyzer/ChangeLog:
	* engine.cc (exploded_path::exploded_path): New copy-ctor.
	* exploded-graph.h (exploded_path::operator=): Drop decl.
2021-02-26 16:35:32 -05:00
Joseph Myers
95a82679f6 Update gcc de.po.
* de.po: Update.
2021-02-26 19:32:34 +00:00
Alexandre Oliva
9d5b4b60bd revert just-added duplicate fpic target requirement
A moment after pushing the previous patch, I noticed the fpic target
requirement markers had already been added to some of the files in the
patch from long ago that I've just contributed.  This patch reverts
the duplicates.


for  gcc/testsuite/ChangeLog

	* gcc.target/powerpc/pr67789.c: Revert fpic target requirement
	duplication.
	* gcc.target/powerpc/pr83629.c: Likewise.
	* gcc.target/powerpc/pr84112.c: Likewise.
2021-02-26 12:27:55 -03:00
Olivier Hainque
1c922c1e56 Add missing dg-require-effective-target fpic directives to powerpc tests
for  gcc/testsuite/ChangeLog

	* gcc.target/powerpc/compress-float-ppc-pic.c: Add
	dg-require-effective-target fpic.
	* gcc.target/powerpc/ppc-eabi.c: Likewise.
	* gcc.target/powerpc/pr26350.c: Likewise.
	* gcc.target/powerpc/pr67789.c: Likewise.
	* gcc.target/powerpc/pr79439-1.c: Likewise.
	* gcc.target/powerpc/pr79439-2.c: Likewise.
	* gcc.target/powerpc/pr79439-3.c: Likewise.
	* gcc.target/powerpc/pr83629.c: Likewise.
	* gcc.target/powerpc/pr84112.c: Likewise.
2021-02-26 12:09:27 -03:00
Richard Biener
c173346aac middle-end/99281 - avoid bitfield stores into addressable types
This avoids doing bitfield stores into the return object of calls
when using return-slot optimization and the type is addressable.
Instead we have to pass down the original target RTX to the call
expansion which otherwise tries to create a new temporary.

2021-02-26  Richard Biener  <rguenther@suse.de>

	PR middle-end/99281
	* expr.c (store_field): For calls with return-slot optimization
	and addressable return type expand the store directly.

	* g++.dg/pr99218.C: New testcase.
2021-02-26 12:34:27 +01:00
Jakub Jelinek
0f161cc849 c++: Implement P1102R2 - Down with ()!
The following patch implements P1102R2.
For attributes, we have already attribute parsing before the parameter
declarations and so when that is omitted, if the attributes are first we
already accept it.

2021-02-26  Jakub Jelinek  <jakub@redhat.com>

	* parser.c (cp_parser_lambda_declarator_opt): Implement
	P1102R2 - Down with ()! Make ()s optional before lambda specifiers
	for -std={c,gnu}++2b or with pedwarn in earlier versions.

	* g++.dg/cpp23/lambda-specifiers1.C: New test.
2021-02-26 10:47:07 +01:00
Jakub Jelinek
27f9a87886 c++: Fix operator() lookup in lambdas [PR95451]
During name lookup, name-lookup.c uses:
            if (!(!iter->type && HIDDEN_TYPE_BINDING_P (iter))
                && (bool (want & LOOK_want::HIDDEN_LAMBDA)
                    || !is_lambda_ignored_entity (iter->value))
                && qualify_lookup (iter->value, want))
              binding = iter->value;
Unfortunately as the following testcase shows, this doesn't work in
generic lambdas, where we on the auto b = ... lambda ICE and on the
auto d = lambda reject it even when it should be valid.  The problem
is that the binding doesn't have a FUNCTION_DECL with
LAMBDA_FUNCTION_P for the operator(), but an OVERLOAD with
TEMPLATE_DECL for such FUNCTION_DECL.

The following patch fixes that in is_lambda_ignored_entity, other
possibility would be to do that before calling is_lambda_ignored_entity
in name-lookup.c.

2021-02-26  Jakub Jelinek  <jakub@redhat.com>

	PR c++/95451
	* lambda.c (is_lambda_ignored_entity): Before checking for
	LAMBDA_FUNCTION_P, use OVL_FIRST.  Drop FUNCTION_DECL check.

	* g++.dg/cpp1y/lambda-generic-95451.C: New test.
2021-02-26 10:43:28 +01:00
Richard Biener
ff7a515446 c/99275 - fix missing space in diagnostic
This fixes a missing space as reported by translators.

2021-02-26  Richard Biener  <rguenther@suse.de>

	PR c/99275
	* builtins.c (warn_string_no_nul): Fix diagnostic formatting.
2021-02-26 08:51:33 +01:00
Jason Merrill
7c657339d6 c++: Fix class NTTP constness handling [PR98810]
Here, when substituting still-dependent args into an alias template, we see
a non-const type because the default argument is non-const, and is not a
template parm object because it's still dependent.

gcc/cp/ChangeLog:

	PR c++/98810
	* pt.c (tsubst_copy) [VIEW_CONVERT_EXPR]: Add const
	to a class non-type template argument that needs it.

gcc/testsuite/ChangeLog:

	PR c++/98810
	* g++.dg/cpp2a/nontype-class-defarg1.C: New test.
2021-02-25 22:57:48 -05:00
Peter Bergner
0159535adb rs6000: Fix ICE in rs6000_init_builtins when compiling with -mcpu=440 [PR99279]
The initialization of compat builtins assumes the builtin we are creating
a compatible builtin for exists and ICEs if it doesn't.  However, there are
valid reasons why some builtins are disabled for a particular compile.
In this case, the MMA builtins are disabled for -mcpu=440 (and other cpus),
so instead of ICEing, we should just skip adding the MMA compat builtin.

2021-02-25  Peter Bergner  <bergner@linux.ibm.com>

gcc/
	PR target/99279
	* config/rs6000/rs6000-call.c (rs6000_init_builtins): Replace assert
	with an "if" test.
2021-02-25 21:35:28 -06:00