Commit Graph

187518 Commits

Author SHA1 Message Date
Stafford Horne eff8110674 or1k: Add mcmodel option to handle large GOTs
When building libgeos we get an error with:

    linux-uclibc/9.3.0/crtbeginS.o: in function `__do_global_dtors_aux':
    crtstuff.c:(.text+0x118): relocation truncated to fit: R_OR1K_GOT16 against symbol `__cxa_finalize' defined in .text section in
    /home/shorne/work/openrisc/3eb9f9d0f6d8274b2d19753c006bd83f7d536e3c/output/host/or1k-buildroot-linux-uclibc/sysroot/lib/libc.so.

This is caused by GOT code having a limit of 64k.  In OpenRISC this
looks to be the only relocation code pattern to be limited to 64k.

This patch allows specifying a new option -mcmodel=large which can be
used to generate 2 more instructions to construct 32-bit addresses for
up to 4G GOTs.

gcc/ChangeLog:

	PR target/99783
	* config/or1k/or1k-opts.h: New file.
	* config/or1k/or1k.c (or1k_legitimize_address_1, print_reloc):
	Support generating gotha relocations if -mcmodel=large is
	specified.
	* config/or1k/or1k.h (TARGET_CMODEL_SMALL, TARGET_CMODEL_LARGE):
	New macros.
	* config/or1k/or1k.opt (mcmodel=): New option.
	* doc/invoke.texi (OpenRISC Options): Document mcmodel.
2021-08-15 07:22:58 +09:00
Martin Sebor 96194a07bd Diagnose mismatches between array and scalar new and delete [PR101791].
Resolves:
PR middle-end/101791 - missing warning on a mismatch between scalar and array forms of new and delete

gcc/ChangeLog:

	PR middle-end/101791
	* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Use new argument
	to valid_new_delete_pair_p.
	* tree.c (valid_new_delete_pair_p): Add argument.
	* tree.h (valid_new_delete_pair_p): Same.

gcc/testsuite/ChangeLog:

	PR middle-end/101791
	* g++.dg/warn/Wmismatched-new-delete-6.C: New test.
	* g++.dg/warn/Wmismatched-new-delete-7.C: New test.
2021-08-14 13:25:41 -06:00
Jakub Jelinek 240f07805d i386: Fix ICE with V64QImode broadcast permutation with -mavx512f -mno-avx512bw
The testcase shows another problem, for TARGET_AVX512BW we have a single insn
doing broadcast from the first element, but don't have one for broadcast
of 2nd+ element (so for d->perm[0] we must return false), but for
TARGET_AVX512F && !TARGET_AVX512BW we don't even have support for that other
broadcast.  V64QImode case was just added to the AVX2 cases which had
gcc_assert (!TARGET_AVX2 || d->perm[0]);
but for V64QImode we actually need
gcc_assert (!TARGET_AVX512BW || d->perm[0]);

2021-08-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/101896
	* config/i386/i386-expand.c (expand_vec_perm_broadcast_1)
	<case E_V64QImode>: For this mode assert
	!TARGET_AVX512BW || d->perm[0] rather than !TARGET_AVX2 || d->perm[0].

	* gcc.target/i386/avx512f-pr101896.c: New test.
2021-08-14 11:44:46 +02:00
GCC Administrator 261512fa6d Daily bump. 2021-08-14 00:16:29 +00:00
Michael Meissner 58eec9908c Fix xxeval predicates (PR 99921).
I noticed that the xxeval built-in function used the altivec_register_operand
predicate.  Since it takes vsx registers, this might force the register
allocate to issue a move when it could use a traditional floating point
register.  This patch fixes that.

2021-08-13  Michael Meissner  <meissner@linux.ibm.com>

gcc/
	PR target/99921
	* config/rs6000/altivec.md (xxeval): Use register_predicate
	instead of altivec_register_predicate.
2021-08-13 19:43:27 -04:00
Thomas Schwinge 2cc65fcbd4 Adjust 'libgomp.oacc-c-c++-common/static-variable-1.c'
... for 'gcc/gimplify.c:gimplify_scan_omp_clauses' changes in recent
commit d0befed793 "openmp: Add support
for OpenMP 5.1 masked construct".

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/static-variable-1.c: Adjust.
2021-08-13 22:53:58 +02:00
Martin Sebor fb85d6eb6c Warn for reads from write-only arguments [PR101734].
Resolves:
PR middle-end/101734 - missing warning reading from a write-only object

gcc/ChangeLog:

	PR middle-end/101734
	* tree-ssa-uninit.c (maybe_warn_read_write_only): New function.
	(maybe_warn_operand): Call it.

gcc/testsuite/ChangeLog:

	PR middle-end/101734
	* gcc.dg/uninit-42.c: New test.
2021-08-13 12:23:58 -06:00
Ian Lance Taylor e5c00544cc runtime: use C cast syntax in stack.c
Didn't notice earlier because this code is only used on systems that
do not support -fsplit-stack.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/342051
2021-08-13 10:38:36 -07:00
Martin Liska 4998404915 ipa: "naked" attribute implies "noipa" attribute
PR ipa/101354

gcc/ChangeLog:

	* attribs.c (decl_attributes): Make naked functions "noipa"
	  functions.
2021-08-13 16:04:26 +02:00
Martin Liska fa28520fad ipa: do not make localaliases for target_clones [PR101261]
PR ipa/101261

gcc/ChangeLog:

	* symtab.c (symtab_node::noninterposable_alias): Do not create
	  local aliases for target_clone functions as the clonning pass
	  rejects aliases.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr101261.c: New test.
2021-08-13 15:44:11 +02:00
Martin Liska 5eb304a3e5 opts: do not repeat a string in errors
gcc/ChangeLog:

	* opts.c (LIVE_PATCHING_OPTION): Define.
	(control_options_for_live_patching): Use it in error messages.
2021-08-13 15:43:36 +02:00
Jan Hubicka 4341b1b165 Introduce EAF_NOREAD and cleanup EAF_UNUSED + ipa-modref
this patch add EAF_NOREAD (as disucssed on IRC already) and fixes meaning
of EAF_UNUSED to be really unused and not "does not escape, is not clobbered,
read or returned" since we have separate flags for each of the properties
now.

Since number of flags has grown I refactored the code a bit to avoid
repeated uses of complex flag combinations and also simplified the logic of
merging.

Merging is bit tricky since we have flags that implies other flags
(like NOESCAPE implies NODIRECTESCAPE) but code that sets only NOESCAPE.
Perhaps it would make sense to update fnspecs to always set flag along with
all the implications, but for now I am handlingit in merge.

I made only trivial update to tree-ssa-structalias to handle EAF_NORETURN in
normal function handling, but not in pure functions.  The problem is that the
way constraints are generated for pure functions makes this difficult.
I think logical step is to track whether function reads/stores global memory
and rewrite the constraint generation so we can handle normal, pure and const
in unified manner.

Bootstrapped/regtested x86_64-linux, plan to commit it after furhter testing.

The patch improves alias oracle stats for cc1plus somewhat.

From:

Alias oracle query stats:
  refs_may_alias_p: 72380497 disambiguations, 82649832 queries
  ref_maybe_used_by_call_p: 495184 disambiguations, 73366950 queries
  call_may_clobber_ref_p: 259312 disambiguations, 263253 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 38006 queries
  nonoverlapping_refs_since_match_p: 21157 disambiguations, 65698 must overlaps, 87756 queries
  aliasing_component_refs_p: 63141 disambiguations, 2164695 queries
  TBAA oracle: 25975753 disambiguations 61449632 queries
               12138220 are in alias set 0
               11316663 queries asked about the same object
               144 queries asked about the same alias set
               0 access volatile
               10472885 are dependent in the DAG
               1545967 are aritificially in conflict with void *

Modref stats:
  modref use: 23857 disambiguations, 754515 queries
  modref clobber: 1392162 disambiguations, 17753512 queries
  3450241 tbaa queries (0.194341 per modref query)
  534816 base compares (0.030125 per modref query)

PTA query stats:
  pt_solution_includes: 12394915 disambiguations, 20235925 queries
  pt_solutions_intersect: 1365299 disambiguations, 14638068 queries

To:

Alias oracle query stats:
  refs_may_alias_p: 72629640 disambiguations, 82903333 queries
  ref_maybe_used_by_call_p: 502474 disambiguations, 73612186 queries
  call_may_clobber_ref_p: 261806 disambiguations, 265659 queries
  nonoverlapping_component_refs_p: 0 disambiguations, 38007 queries
  nonoverlapping_refs_since_match_p: 21139 disambiguations, 65772 must overlaps, 87816 queries
  aliasing_component_refs_p: 63144 disambiguations, 2164330 queries
  TBAA oracle: 26059018 disambiguations 61571714 queries
               12158033 are in alias set 0
               11326115 queries asked about the same object
               144 queries asked about the same alias set
               0 access volatile
               10484493 are dependent in the DAG
               1543911 are aritificially in conflict with void *

Modref stats:
  modref use: 24008 disambiguations, 712712 queries
  modref clobber: 1395917 disambiguations, 17163694 queries
  3465657 tbaa queries (0.201918 per modref query)
  537591 base compares (0.031321 per modref query)

PTA query stats:
  pt_solution_includes: 12468934 disambiguations, 20295402 queries
  pt_solutions_intersect: 1391917 disambiguations, 14665265 queries

I think it is mostly due to better heandling of EAF_NODIRECTESCAPE.

Honza

gcc/ChangeLog:

2021-08-12  Jan Hubicka  <hubicka@ucw.cz>

	* ipa-modref.c (dump_eaf_flags): Dump EAF_NOREAD.
	(implicit_const_eaf_flags, implicit_pure_eaf_flags,
	 ignore_stores_eaf_flags): New constants.
	(remove_useless_eaf_flags): New function.
	(eaf_flags_useful_p): Use it.
	(deref_flags): Add EAF_NOT_RETURNED if flag is unused;
	handle EAF_NOREAD.
	(modref_lattice::init): Add EAF_NOREAD.
	(modref_lattice::add_escape_point): Do not reacord escape point if
	result is unused.
	(modref_lattice::merge): EAF_NOESCAPE implies EAF_NODIRECTESCAPE;
	use remove_useless_eaf_flags.
	(modref_lattice::merge_deref): Use ignore_stores_eaf_flags.
	(modref_lattice::merge_direct_load): Add EAF_NOREAD
	(analyze_ssa_name_flags): Fix handling EAF_NOT_RETURNED
	(analyze_parms): Use remove_useless_eaf_flags.
	(ipa_merge_modref_summary_after_inlining): Use ignore_stores_eaf_flags.
	(modref_merge_call_site_flags): Add caller and ecf_flags parameter;
	use remove_useless_eaf_flags.
	(modref_propagate_flags_in_scc): Update.
	* ipa-modref.h: Turn eaf_flags_t back to char.
	* tree-core.h (EAF_NOT_RETURNED): Fix.
	(EAF_NOREAD): New constant
	* tree-ssa-alias.c: (ref_maybe_used_by_call_p_1): Check for
	EAF_NOREAD.
	* tree-ssa-structalias.c (handle_rhs_call): Handle new flags.
	(handle_pure_call): Likewise.

gcc/testsuite/ChangeLog:

2021-08-12  Jan Hubicka  <hubicka@ucw.cz>

	* gcc.dg/tree-ssa/modref-6.c: Update.
2021-08-13 10:04:52 +02:00
prathamesh.kulkarni e37ddb91a8 arm: Add check for arm_softfp_ok in pr98435.c.
gcc/testsuite/ChangeLog:
	* gcc.target/arm/simd/pr98435.c: Add dg-require-effective-target
	arm_softfp_ok.
2021-08-13 12:29:46 +05:30
Sergei Trofimovich 62e420293a libbacktrace: fix b2test_buildid test on non-english locales
On LANG=ru_RU.UTF-8 'b2test_buildid' test fails due to localized readelf
output:

$ LANG=ru_RU.UTF-8 readelf -n b2test | fgrep 4e37e8f
    ID сборки: 4e37e8fead8d6e8b0a9dc95ea25cd784dff3a393
$ LANG=C readelf -n b2test | fgrep 4e37e8f
    Build ID: 4e37e8fead8d6e8b0a9dc95ea25cd784dff3a393

libbacktrace/

	* install-debuginfo-for-buildid.sh.in: Force non-localized readelf
	output with LANG=C.
2021-08-13 07:29:12 +01:00
Ian Lance Taylor c5b21c3f4c libgo: update to Go1.17rc2
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/341629
2021-08-12 20:23:07 -07:00
GCC Administrator 72be20e202 Daily bump. 2021-08-13 00:16:43 +00:00
Ian Lance Taylor 0ace3d4d0a runtime: run gofmt on testdata/testwinsignal/main.go 2021-08-12 17:15:16 -07:00
Ian Lance Taylor 1196b60f8f compiler: store pointers to go:notinheap types indirectly
This is the gofrontend version of https://golang.org/cl/264480.

For golang/go#42076

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/340609
2021-08-12 16:33:10 -07:00
Jakub Jelinek d0befed793 openmp: Add support for OpenMP 5.1 masked construct
This construct has been introduced as a replacement for master
construct, but unlike that construct is slightly more general,
has an optional clause which allows to choose which thread
will be the one running the region, it can be some other thread
than the master (primary) thread with number 0, or it could be no
threads or multiple threads (then of course one needs to be careful
about data races).

It is way too early to deprecate the master construct though, we don't
even have OpenMP 5.0 fully implemented, it has been deprecated in 5.1,
will be also in 5.2 and removed in 6.0.  But even then it will likely
be a good idea to just -Wdeprecated warn about it and still accept it.

The patch also contains something I should have done much earlier,
for clauses that accept some integral expression where we only care
about the value, forces during gimplification that value into
either a min invariant (as before), SSA_NAME or a fresh temporary,
but never e.g. a user VAR_DECL, so that for those clauses we don't
need to worry about adjusting it.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree.def (OMP_MASKED): New tree code.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_FILTER.
	* tree.h (OMP_MASKED_BODY, OMP_MASKED_CLAUSES, OMP_MASKED_COMBINED,
	OMP_CLAUSE_FILTER_EXPR): Define.
	* tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FILTER entry.
	(omp_clause_code_name): Likewise.
	(walk_tree_1): Handle OMP_CLAUSE_FILTER.
	* tree-nested.c (convert_nonlocal_omp_clauses,
	convert_local_omp_clauses): Handle OMP_CLAUSE_FILTER.
	(convert_nonlocal_reference_stmt, convert_local_reference_stmt,
	convert_gimple_call): Handle GIMPLE_OMP_MASTER.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FILTER.
	(dump_generic_node): Handle OMP_MASTER.
	* gimple.def (GIMPLE_OMP_MASKED): New gimple code.
	* gimple.c (gimple_build_omp_masked): New function.
	(gimple_copy): Handle GIMPLE_OMP_MASKED.
	* gimple.h (gimple_build_omp_masked): Declare.
	(gimple_has_substatements): Handle GIMPLE_OMP_MASKED.
	(gimple_omp_masked_clauses, gimple_omp_masked_clauses_ptr,
	gimple_omp_masked_set_clauses): New inline functions.
	(CASE_GIMPLE_OMP): Add GIMPLE_OMP_MASKED.
	* gimple-pretty-print.c (dump_gimple_omp_masked): New function.
	(pp_gimple_stmt_1): Handle GIMPLE_OMP_MASKED.
	* gimple-walk.c (walk_gimple_stmt): Likewise.
	* gimple-low.c (lower_stmt): Likewise.
	* gimplify.c (is_gimple_stmt): Handle OMP_MASTER.
	(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_FILTER.  For clauses
	that take one expression rather than decl or constant, force
	gimplification of that into a SSA_NAME or temporary unless min
	invariant.
	(gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_FILTER.
	(gimplify_expr): Handle OMP_MASKED.
	* tree-inline.c (remap_gimple_stmt): Handle GIMPLE_OMP_MASKED.
	(estimate_num_insns): Likewise.
	* omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FILTER.
	(check_omp_nesting_restrictions): Handle GIMPLE_OMP_MASKED.  Adjust
	diagnostics for existence of masked construct.
	(scan_omp_1_stmt, lower_omp_master, lower_omp_1, diagnose_sb_1,
	diagnose_sb_2): Handle GIMPLE_OMP_MASKED.
	* omp-expand.c (expand_omp_synch, expand_omp, omp_make_gimple_edges):
	Likewise.
gcc/c-family/
	* c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_MASKED.
	(enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FILTER.
	* c-pragma.c (omp_pragmas_simd): Add masked construct.
	* c-common.h (enum c_omp_clause_split): Add C_OMP_CLAUSE_SPLIT_MASKED
	enumerator.
	(c_finish_omp_masked): Declare.
	* c-omp.c (c_finish_omp_masked): New function.
	(c_omp_split_clauses): Handle combined masked constructs.
gcc/c/
	* c-parser.c (c_parser_omp_clause_name): Parse filter clause name.
	(c_parser_omp_clause_filter): New function.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER.
	(OMP_MASKED_CLAUSE_MASK): Define.
	(c_parser_omp_masked): New function.
	(c_parser_omp_parallel): Handle parallel masked.
	(c_parser_omp_construct): Handle PRAGMA_OMP_MASKED.
	* c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_FILTER.
gcc/cp/
	* parser.c (cp_parser_omp_clause_name): Parse filter clause name.
	(cp_parser_omp_clause_filter): New function.
	(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FILTER.
	(OMP_MASKED_CLAUSE_MASK): Define.
	(cp_parser_omp_masked): New function.
	(cp_parser_omp_parallel): Handle parallel masked.
	(cp_parser_omp_construct, cp_parser_pragma): Handle PRAGMA_OMP_MASKED.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_FILTER.
	* pt.c (tsubst_omp_clauses): Likewise.
	(tsubst_expr): Handle OMP_MASKED.
gcc/testsuite/
	* c-c++-common/gomp/clauses-1.c (bar): Add tests for combined masked
	constructs with clauses.
	* c-c++-common/gomp/clauses-5.c (foo): Add testcase for filter clause.
	* c-c++-common/gomp/clause-dups-1.c (f1): Likewise.
	* c-c++-common/gomp/masked-1.c: New test.
	* c-c++-common/gomp/masked-2.c: New test.
	* c-c++-common/gomp/masked-combined-1.c: New test.
	* c-c++-common/gomp/masked-combined-2.c: New test.
	* c-c++-common/goacc/uninit-if-clause.c: Remove xfails.
	* g++.dg/gomp/block-11.C: New test.
	* g++.dg/gomp/tpl-masked-1.C: New test.
	* g++.dg/gomp/attrs-1.C (bar): Add tests for masked construct and
	combined masked constructs with clauses in attribute syntax.
	* g++.dg/gomp/attrs-2.C (bar): Likewise.
	* gcc.dg/gomp/nesting-1.c (f1, f2): Add tests for masked construct
	nesting.
	* gfortran.dg/goacc/host_data-tree.f95: Allow also SSA_NAMEs in if
	clause.
	* gfortran.dg/goacc/kernels-tree.f95: Likewise.
libgomp/
	* testsuite/libgomp.c-c++-common/masked-1.c: New test.
2021-08-12 22:41:17 +02:00
Jakub Jelinek 408d88af60 libcpp: Fix ICE with -Wtraditional preprocessing [PR101638]
The following testcase ICEs in cpp_sys_macro_p, because cpp_sys_macro_p
is called for a builtin macro which doesn't use node->value.macro union
member but a different one and so dereferencing it ICEs.
As the testcase is distilled from contemporary glibc headers, it means
basically -Wtraditional now ICEs on almost everything.

The fix can be either the patch below, return true for builtin macros,
or we could instead return false for builtin macros, or the fix could
be also (untested):
--- libcpp/expr.c       2021-05-07 10:34:46.345122608 +0200
+++ libcpp/expr.c       2021-08-12 09:54:01.837556365 +0200
@@ -783,13 +783,13 @@ cpp_classify_number (cpp_reader *pfile,

       /* Traditional C only accepted the 'L' suffix.
          Suppress warning about 'LL' with -Wno-long-long.  */
-      if (CPP_WTRADITIONAL (pfile) && ! cpp_sys_macro_p (pfile))
+      if (CPP_WTRADITIONAL (pfile))
        {
          int u_or_i = (result & (CPP_N_UNSIGNED|CPP_N_IMAGINARY));
          int large = (result & CPP_N_WIDTH) == CPP_N_LARGE
                       && CPP_OPTION (pfile, cpp_warn_long_long);

-         if (u_or_i || large)
+         if ((u_or_i || large) && ! cpp_sys_macro_p (pfile))
            cpp_warning_with_line (pfile, large ? CPP_W_LONG_LONG : CPP_W_TRADITIONAL,
                                   virtual_location, 0,
                                   "traditional C rejects the \"%.*s\" suffix",
The builtin macros at least currently don't add any suffixes
or numbers -Wtraditional would like to warn about.  For floating
point suffixes, -Wtraditional calls cpp_sys_macro_p only right
away before emitting the warning, but in the above case the ICE
is because cpp_sys_macro_p is called even if the number doesn't
have any suffixes (that is I think always for builtin macros
right now).

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/101638
	* macro.c (cpp_sys_macro_p): Return true instead of
	crashing on builtin macros.

	* gcc.dg/cpp/pr101638.c: New test.
2021-08-12 22:40:11 +02:00
Michael Meissner 8464894c86 Fix typo in fold-vec-load-builtin_vec_xl-* tests.
When I checked in the fix for running tests on power10 systems with
power10 code generation, I had a typo in the
fold-vec-load-builtin_vec_xl-* tests, swapping 'x' and 'v' in the p?lxv
pattern.

gcc/testsuite/
2021-08-12  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-char.c: Fix
	typo in regular expression.
	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-double.c:
	Likewise.
	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-float.c:
	Likewise.
	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-int.c:
	Likewise.
	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-longlong.c:
	Likewise.
	* gcc.target/powerpc/fold-vec-load-builtin_vec_xl-short.c:
	Likewise.
2021-08-12 16:36:49 -04:00
Uros Bizjak 8c8df06e46 [i386] Introduce scalar version of avx512f_vmscalef.
2021-08-12  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/98309
	* config/i386/i386.md (avx512f_scalef<mode>2): New insn pattern.
	(ldexp<mode>3): Use avx512f_scalef<mode>2.
	(UNSPEC_SCALEF): Move from ...
	* config/i386/sse.md (UNSPEC_SCALEF): ... here.
2021-08-12 21:19:46 +02:00
Jan Hubicka a6da2cddcf Fix condition testing void functions in ipa-split.
gcc/ChangeLog:

2021-08-12  Jan Hubicka  <hubicka@ucw.cz>

	* ipa-split.c (consider_split): Fix condition testing void functions.
2021-08-12 20:52:54 +02:00
Jonathan Wakely 9017326e19 libstdc++: Add additional overload of std::lerp [PR101870]
The [cmath.syn] p1 wording about additional overloads sufficient to
handle any arithmetic types also applies to std::lerp. This adds a new
overload of std::lerp that does the required promotions to support
arguments of arbitrary arithmetic types.

A new __promoted_t alias template is added, which the C++17 function
templates std::hypot and std::lerp can use to avoid instantiating the
__promote_3 class template.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101870
	* include/c_global/cmath (hypot): Use __promoted_t.
	(lerp): Add new overload accepting any arithmetic types.
	* include/ext/type_traits.h (__promoted_t): New alias template.
	* testsuite/26_numerics/lerp.cc: Moved to...
	* testsuite/26_numerics/lerp/1.cc: ...here.
	* testsuite/26_numerics/lerp/constexpr.cc: New test.
	* testsuite/26_numerics/lerp/version.cc: New test.
2021-08-12 19:46:16 +01:00
Jonathan Wakely b1c0e8599a libstdc++: Make some #error strings consistent with other tests
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/lerp.cc: Add header name to #error.
	* testsuite/26_numerics/midpoint/integral.cc: Likewise.
	* testsuite/26_numerics/midpoint/version.cc: New test.
2021-08-12 19:46:16 +01:00
Jonathan Wakely 20ce14c799 libstdc++: Add [[nodiscard]] to experimental::randint
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/experimental/random (experimental::randint): Add
	nodiscard attribute.
2021-08-12 19:46:16 +01:00
Sergei Trofimovich 27a1fb385b c++: fix ptrmemfunc template instantiation [PR101219]
r12-1804 ("cp: add support for per-location warning groups.") among other
things removed warning suppression from a few places including ptrmemfuncs.

This exposed a bug in warning detection code as a reference to missing
BINFO (it's intentionally missing for ptrmemfunc types):

    crash_signal
        gcc/toplev.c:328
    perform_or_defer_access_check(tree_node*, tree_node*, tree_node*, int, access_failure_info*)
        gcc/cp/semantics.c:490
    finish_non_static_data_member(tree_node*, tree_node*, tree_node*)
        gcc/cp/semantics.c:2208
    ...

The change special cases ptrmemfuncs in templace substitution by using
build_ptrmemfunc_access_expr() instead of finish_non_static_data_member().

gcc/cp/ChangeLog:

	PR c++/101219
	* pt.c (tsubst_copy_and_build): Use build_ptrmemfunc_access_expr
	to construct ptrmemfunc expression instantiation.

gcc/testsuite/ChangeLog:

	PR c++/101219
	* g++.dg/warn/pr101219.C: New test.
2021-08-12 19:43:07 +01:00
Martin Uecker d2ba65ab60 Evaluate type arguments of sizeof that are structs of variable size [PR101838]
Evaluate type arguments of sizeof for all types of variable size
and not just for VLAs. This fixes PR101838 and some issues related
to PR29970 where statement expressions need to be evaluated so that
the size is well defined.

2021-08-12  Martin Uecker  <muecker@gwdg.de>

gcc/c/
	PR c/101838
	PR c/29970
	* c-typeck.c (c_expr_sizeof_type): Evaluate
	size expressions for structs of variable size.

gcc/testsuite/
	PR c/101838
	* gcc.dg/vla-stexp-2.c: New test.
2021-08-12 20:36:42 +02:00
Aldy Hernandez 34cd97ff94 Remove legacy back threader.
At this point I don't see any use for the legacy mode, which I had
originally left in place during the transition.

This patch removes the legacy back threader, and cleans up the code a
bit.  There are no functional changes to the non-legacy code.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* doc/invoke.texi: Remove docs for threader-mode param.
	* flag-types.h (enum threader_mode): Remove.
	* params.opt: Remove threader-mode param.
	* tree-ssa-threadbackward.c (class back_threader): Remove
	path_is_unreachable_p.
	Make find_paths private.
	Add maybe_thread and thread_through_all_blocks.
	Remove reference marker for m_registry.
	Remove reference marker for m_profit.
	(back_threader::back_threader): Adjust for registry and profit not
	being references.
	(dump_path): Move down.
	(debug): Move down.
	(class thread_jumps): Remove.
	(class back_threader_registry): Remove m_all_paths.
	Remove destructor.
	(thread_jumps::thread_through_all_blocks): Move to back_threader
	class.
	(fsm_find_thread_path): Remove
	(back_threader::maybe_thread): New.
	(back_threader::thread_through_all_blocks): Move from
	thread_jumps.
	(back_threader_registry::back_threader_registry): Remove
	m_all_paths.
	(back_threader_registry::~back_threader_registry): Remove.
	(thread_jumps::find_taken_edge): Remove.
	(thread_jumps::check_subpath_and_update_thread_path): Remove.
	(thread_jumps::maybe_register_path): Remove.
	(thread_jumps::handle_phi): Remove.
	(handle_assignment_p): Remove.
	(thread_jumps::handle_assignment): Remove.
	(thread_jumps::fsm_find_control_statement_thread_paths): Remove.
	(thread_jumps::find_jump_threads_backwards): Remove.
	(thread_jumps::find_jump_threads_backwards_with_ranger): Remove.
	(try_thread_blocks): Rename find_jump_threads_backwards to
	maybe_thread.
	(pass_early_thread_jumps::execute): Same.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Remove call into the legacy
	code and adjust for ranger threader.
2021-08-12 20:27:56 +02:00
Jonathan Wakely d3a7fbcb7c libstdc++: Add #error to some files that depend on a specific standard mode
Give more explicit errors if these files are not built with the correct
-std options.

libstdc++-v3/ChangeLog:

	* src/c++98/locale_init.cc: Require C++11.
	* src/c++98/localename.cc: Likewise.
	* src/c++98/misc-inst.cc: Require C++98.
2021-08-12 15:03:22 +01:00
Tobias Burnus 432de08498 OpenMP 5.1: Add proc-bind 'primary' support
In OpenMP 5.1 "master thread" was changed to "primary thread" and
the proc_bind clause and the OMP_PROC_BIND environment variable
now take 'primary' as argument as alias for 'master', while the
latter is deprecated.
This commit accepts 'primary' and adds the named constant
omp_proc_bind_primary and changes 'master thread' in the
documentation; however, given that not even OpenMP 5.0 is
fully supported, omp_display_env and the dumps currently
still output 'master' and there is no deprecation warning
when using the 'master' in the proc_bind clause.

gcc/c/ChangeLog:

	* c-parser.c (c_parser_omp_clause_proc_bind): Accept
	'primary' as alias for 'master'.

gcc/cp/ChangeLog:

	* parser.c (cp_parser_omp_clause_proc_bind): Accept
	'primary' as alias for 'master'.

gcc/fortran/ChangeLog:

	* gfortran.h (gfc_omp_proc_bind_kind): Add OMP_PROC_BIND_PRIMARY.
	* dump-parse-tree.c (show_omp_clauses): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.
	* intrinsic.texi (OMP_LIB): Mention OpenMP 5.1; add
	omp_proc_bind_primary.
	* openmp.c (gfc_match_omp_clauses): Accept
	'primary' as alias for 'master'.
	* trans-openmp.c (gfc_trans_omp_clauses): Handle
	OMP_PROC_BIND_PRIMARY.

gcc/ChangeLog:

	* tree-core.h (omp_clause_proc_bind_kind): Add
	OMP_CLAUSE_PROC_BIND_PRIMARY.
	* tree-pretty-print.c (dump_omp_clause): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.

libgomp/ChangeLog:

	* env.c (parse_bind_var): Accept 'primary' as alias for
	'master'.
	(omp_display_env): Add TODO comment to
	change 'master' to 'primary' in proc_bind for OpenMP 5.1.
	* libgomp.texi: Change 'master thread' to 'primary thread'
	in line with OpenMP 5.1.
	(omp_get_proc_bind): Add omp_proc_bind_primary and note that
	omp_proc_bind_master is an alias of it.
	(OMP_PROC_BIND): Mention 'PRIMARY'.
	* omp.h.in (__GOMP_DEPRECATED_5_1): Define.
	(omp_proc_bind_primary): Add.
	(omp_proc_bind_master): Deprecate for OpenMP 5.1.
	* omp_lib.f90.in (omp_proc_bind_primary): Add.
	(omp_proc_bind_master): Deprecate for OpenMP 5.1.
	* omp_lib.h.in (omp_proc_bind_primary): Add.
	* testsuite/libgomp.c/affinity-1.c: Check that
	'primary' works and is identical to 'master'.

gcc/testsuite/ChangeLog:

	* c-c++-common/gomp/pr61486-2.c: Duplicate one proc_bind(master)
	testcase and test proc_bind(primary) instead.
	* gfortran.dg/gomp/affinity-1.f90: Likewise.
2021-08-12 15:49:49 +02:00
Claudiu Zissulescu 2d7967a10c arc: Small data doesn't need fcommon option
ARC backend is defaulting to -fcommon. This is not anylonger needed, remove it.

gcc/
2021-08-12  Claudiu Zissulescu  <claziss@synopsys.com>

	* common/config/arc/arc-common.c (arc_option_init_struct): Remove
	fno-common reference.
	* config/arc/arc.c (arc_override_options): Remove overriding of
	flag_no_common.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2021-08-12 15:31:47 +03:00
Hans-Peter Nilsson fb0cd8f111 gfortran.dg/PR82376.f90: Avoid matching a file-path
I had a file-path to sources with the substring "new" in it,
and (only) this test regressed compared to results from
another build without "new" in the name.

The test does
 ! { dg-final { scan-tree-dump-times "new" 4 "original" } }
i.e. the contents of the tree-dump-file .original needs to match
the undelimited string "new" exactly four times.  Very brittle.

In the dump-file, there are three lines with calls to new:
     D.908 = new ((integer(kind=4) *) data);
 integer(kind=4) * new (integer(kind=4) & data)
   static integer(kind=4) * new (integer(kind=4) &);

But, there's also a line, which for me and cris-elf looked like:
 _gfortran_runtime_error_at (&"At line 46 of file
  /X/xyzzynewfrob/gcc/testsuite/gfortran.dg/PR82376.f90"[1]{lb: 1 sz: 1},
  &"Pointer actual argument \'new\' is not associated"[1]{lb: 1 sz: 1});
The fourth match is obviously intended to match this line, but only
with *one* match, whereas the path can as above yield another hit.

With Tcl, the regexp for matching the " " *and* the "'"
*and* the "\" gets a bit unsightly, so I suggest just
matching the "new" calls, which according to the comment in
the test is the key point.  You can't have a file-path with
spaces and parentheses in a gcc build.  I'm also making use
of {} rather than "" needing one level of quoting; the "\("
is needed because the matched string is a regexp.

testsuite:
	* gfortran.dg/PR82376.f90: Robustify match.
2021-08-12 14:10:12 +02:00
Jakub Jelinek 04b4f31525 i386: Fix up V32HImode permutations with -mno-avx512bw [PR101860]
My patch from yesterday apparently broke some V32HImode permutations
as the testcase shows.
The first function assumed it would never be called in d->testing_p mode
and so went right away into emitting the code.
And the second one assumed V32HImode would never reach it, which now
can for the !TARGET_AVX512BW case.  We don't have a instruction
in that case though.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	PR target/101860
	* config/i386/i386-expand.c (ix86_expand_vec_one_operand_perm_avx512):
	If d->testing_p, return true after performing checks instead of
	actually expanding the insn.
	(expand_vec_perm_broadcast_1): Handle V32HImode - assert
	!TARGET_AVX512BW and return false.

	* gcc.target/i386/avx512f-pr101860.c: New test.
2021-08-12 11:26:57 +02:00
Jakub Jelinek 01f8a8b48e openmp: Diagnose syntax mismatches between declare target and end declare target
OpenMP 5.1 says:
For any directive that has a paired end directive, including those with a begin
and end pair, both directives must use either the attribute syntax or the
pragma syntax.

The following patch enforces it with the only pair so far recognized in C++
(Fortran has many, but on the other side doesn't have attribute syntax).

While I initially wanted to use vec<bool, va_gc> *member; in there, that
unfortunately doesn't work, one gets linker errors and I guess it is fixable,
but for begin declare target we'll need a struct anyway to store device_type
etc.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	* cp-tree.h (omp_declare_target_attr): New type.
	(struct saved_scope): Change type of omp_declare_target_attribute
	from int to vec<omp_declare_target_attr, va_gc> * and move it.
	* parser.c (cp_parser_omp_declare_target): Instead of
	incrementing scope_chain->omp_declare_target_attribute, push
	a struct containing parser->lexer->in_omp_attribute_pragma to
	the vector.
	(cp_parser_omp_end_declare_target): Instead of decrementing
	scope_chain->omp_declare_target_attribute, pop a structure
	from it.  Diagnose mismatching declare target vs.
	end declare target syntax.
	* semantics.c (finish_translation_unit): Use vec_safe_length
	and vec_safe_truncate on scope_chain->omp_declare_target_attributes.
	* decl2.c (cplus_decl_attributes): Use vec_safe_length
	on scope_chain->omp_declare_target_attributes.

	* g++.dg/gomp/attrs-12.C: New test.
2021-08-12 09:34:16 +02:00
Jakub Jelinek ef07b918a7 openmp: Diagnose another case of mixing parameter and attribute syntax
This patch diagnoses cases like:
  #pragma omp parallel
  [[omp::directive (declare simd)]] int foo ();
or
  #pragma omp taskgroup
  int bar [[omp::directive (declare simd)]] (int);
where the pragma is on the same declaration statement as the declare simd
attribute.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	* parser.c (cp_parser_lambda_body): Add temp overrides
	for parser->{omp_declare_simd,oacc_routine,omp_attrs_forbidden_p}.
	(cp_parser_statement): Restore parser->omp_attrs_forbidden_p for
	cp_parser_declaration_statement.
	(cp_parser_default_argument): Add temp override for
	parser->omp_attrs_forbidden_p.
	(cp_parser_late_parsing_omp_declare_simd): Diagnose declare simd
	or declare variant in attribute syntax on a declaration immediately
	following an OpenMP construct in pragma syntax.

	* g++.dg/gomp/attrs-11.C: Add new tests.
2021-08-12 09:34:16 +02:00
Jakub Jelinek 9b7ab853bf c++: Fix ICE on defaulted spaceship with pointer return type [PR94162]
The spaceship-synth-neg6.C testcase ICEs because we call cat_tag_for
on the explicit return type, but pointer types don't have
TYPE_LINKAGE_IDENTIFIER.  The patch fixes that by checking for
CLASS_TYPE_P only and also adds verification that it is in std
namespace, so we don't return non-cc_last for my_namespace::partial_ordering.

The g++.dg/cpp2a/spaceship-synth11.C testcase is from a PR that has been
fixed with r12-619-gfc178519771db508c03611cff4a1466cf67fce1d (but
not backported to 11).

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

gcc/cp/
	PR c++/94162
	* method.c (cat_tag_for): Return cc_last for !CLASS_TYPE_P
	or for classes not in std namespace.
gcc/testsuite/
	PR c++/99429
	* g++.dg/cpp2a/spaceship-synth11.C: New test.

	PR c++/94162
	* g++.dg/cpp2a/spaceship-synth-neg6.C: New test.
2021-08-12 09:34:16 +02:00
Jakub Jelinek c84f79e9e3 openmp: Diagnose omp::directive/sequence on using-directive
With the using-directive parsing changes, we now emit only a warning
for [[omp::directive (...)]] on using-directive.  While that is right
without -fopenmp/-fopenmp-simd, when OpenMP is enabled, that should
be an error as OpenMP (is going to) disallow such attributes there
as they do not appertain to a statement.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	* name-lookup.c (finish_using_directive): Diagnose omp::directive
	or omp::sequence attributes on using-directive.

	* g++.dg/gomp/attrs-11.C: Adjust expected diagnostics.
2021-08-12 09:34:16 +02:00
Jakub Jelinek 3890c28ac5 c++: Fix up parsing of attributes for using-directive
As I've said earlier and added xfails in gen-attrs-76.C test,
https://eel.is/c++draft/namespace.udir#nt:using-directive
has attribute-specifier-seq[opt] at the start, not at the end before ;
as gcc is expecting.
IMHO we should continue parsing at the end the GNU attributes
because using namespace N __attribute__((strong));, while not supported
anymore, used to be supported in the past, but my code searches for
using namespace N [[gnu::strong]]; didn't reveal anything at all.

2021-08-12  Jakub Jelinek  <jakub@redhat.com>

	* parser.c (cp_parser_block_declaration): Call
	cp_parser_using_directive for C++11 attributes followed by
	using namespace tokens.
	(cp_parser_using_directive): Parse C++11 attributes at the start
	of the directive rather than at the end, only parse GNU attributes
	at the end.

	* g++.dg/lookup/strong-using.C: Add test using [[gnu::strong]]
	as well.
	* g++.dg/lookup/strong-using2.C: Likewise.
	* g++.dg/cpp0x/gen-attrs-58.C: Move alignas(int) before
	using namespace.
	* g++.dg/cpp0x/gen-attrs-59.C: Move alignas(X) before
	using namespace, add tests for alignas before semicolon.
	* g++.dg/cpp0x/gen-attrs-76.C: Remove xfails.  Add test for
	C++11 attributes on using directive before semicolon.
2021-08-12 09:34:16 +02:00
Eric Botcazou 2bdf17de1d Make -no-pie option work for native Windows
Binutils 2.36/2.37 generate PIE executables by default on native Windows
(because --dynamicbase is the default) so it makes sense to have a simple
way to counter that and -no-pie seems appropriate, all the more so that
it is automatically passed when building the compiler itself.

gcc/
	* configure.ac (PE linker --disable-dynamicbase support): New check.
	* configure: Regenerate.
	* config.in: Likewise.
	* config/i386/mingw32.h (LINK_SPEC_DISABLE_DYNAMICBASE): New define.
	(LINK_SPEC): Use it.
	* config/i386/mingw-w64.h (LINK_SPEC_DISABLE_DYNAMICBASE): Likewise.
	(LINK_SPEC): Likewise.
2021-08-12 09:33:31 +02:00
liuhongt 95e1eca43d Combine avx_vec_concatv16si and avx512f_zero_extendv16hiv16si2_1 to avx512f_zero_extendv16hiv16si2_2.
Add define_insn_and_split to combine avx_vec_concatv16si/2 and
avx512f_zero_extendv16hiv16si2_1 since the latter already zero_extend
the upper bits, similar for other patterns which are related to
pmovzx{bw,wd,dq}.

It will do optimization like

-       vmovdqa %ymm0, %ymm0    # 7     [c=4 l=6]  avx_vec_concatv16si/2
        vpmovzxwd       %ymm0, %zmm0    # 22    [c=4 l=6]  avx512f_zero_extendv16hiv16si2
        ret             # 25    [c=0 l=1]  simple_return_internal

gcc/ChangeLog:

	PR target/101846
	* config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_2): New
	post_reload define_insn_and_split.
	(*avx512bw_zero_extendv32qiv32hi2_2): Ditto.
	(*sse4_1_zero_extendv8qiv8hi2_4): Ditto.
	(*avx512f_zero_extendv16hiv16si2_2): Ditto.
	(*avx2_zero_extendv8hiv8si2_2): Ditto.
	(*sse4_1_zero_extendv4hiv4si2_4): Ditto.
	(*avx512f_zero_extendv8siv8di2_2): Ditto.
	(*avx2_zero_extendv4siv4di2_2): Ditto.
	(*sse4_1_zero_extendv2siv2di2_4): Ditto.
	(VI248_256, VI248_512, VI148_512, VI148_256, VI148_128): New
	mode iterator.

gcc/testsuite/ChangeLog:

	PR target/101846
	* gcc.target/i386/pr101846-1.c: New test.
2021-08-12 14:02:53 +08:00
Patrick Palka 21fd62e5ca c++: constexpr std::construct_at on empty field [PR101663]
Here during constexpr evaluation of

  std::construct_at(&a._M_value)

we find ourselves in cxx_eval_store_expression where the target object
is 'a._M_value' and the initializer is {}.  Since _M_value is an empty
[[no_unique_address]] member we don't create a sub-CONSTRUCTOR for it,
so we end up in the early exit code path for empty stores with mismatched
types and trip over the assert therein

  gcc_assert (is_empty_class (TREE_TYPE (init)) && !lval);

because lval is true.  The reason it's true is because the INIT_EXPR in
question is the LHS of a COMPOUND_EXPR, and evaluation of the LHS is
always performed with lval=true (to indicate there's no lvalue-to-rvalue
conversion).

This patch makes the code path in question handle the lval=true case
appropriately rather than asserting.  In passing, it also consolidates
the duplicate implementations of std::construct_at/destroy_at in some
of the C++20 constexpr tests into a common header file.

	PR c++/101663

gcc/cp/ChangeLog:

	* constexpr.c (cxx_eval_store_expression): Handle the lval=true
	case in the early exit code path for empty stores with mismatched
	types.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/construct_at.h: New convenience header file that
	defines minimal implementations of std::construct_at/destroy_at,
	split out from ...
	* g++.dg/cpp2a/constexpr-new5.C: ... here.
	* g++.dg/cpp2a/constexpr-new6.C: Use the header.
	* g++.dg/cpp2a/constexpr-new14.C: Likewise.
	* g++.dg/cpp2a/constexpr-new20.C: New test.
2021-08-11 20:59:53 -04:00
GCC Administrator 58f8750342 Daily bump. 2021-08-12 00:16:28 +00:00
Jonathan Wakely 93f1dbc7cd libstdc++: Fix test that fails randomly [PR101866]
This test assumes that the same sequence of three values cannot occur,
which is incorect. It's unlikely, but not impossible.

Perform the check in a loop, so that in the unlikely event of an
identical sequence, we retry. If the library code is buggy it will keep
producing the same sequence and the test will time out. If the code is
working correctly then we will usually break out of the loop after one
iteration, or very rarely after two or three.

libstdc++-v3/ChangeLog:

	PR libstdc++/101866
	* testsuite/experimental/random/randint.cc: Loop and retry if
	reseed() produces the same sequence.
2021-08-11 23:39:34 +01:00
Bill Schmidt 873273449a rs6000: Add available-everywhere and ancient builtins
2021-08-11  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin-new.def: Add always, power5, and
	power6 stanzas.
2021-08-11 16:34:33 -05:00
Bill Schmidt ba6aa47470 rs6000: Add VSX builtins
2021-08-11  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin-new.def: Add vsx stanza.
2021-08-11 16:34:23 -05:00
Bill Schmidt 6cc92e946e rs6000: Add the rest of the [altivec] stanza to the builtins file
2021-06-10  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-builtin-new.def: Finish altivec stanza.
	* config/rs6000/rs6000-call.c (rs6000_init_builtins): Move
	initialization of pcvoid_type_node here...
	(altivec_init_builtins): ...from here.
	* config/rs6000/rs6000.h (rs6000_builtin_type_index): Add
	RS6000_BTI_const_ptr_void.
	(pcvoid_type_node): New macro.
2021-08-11 16:34:15 -05:00
Patrick Palka 9707d2e5db c++: parameterized requires-expr as default argument [PR101725]
Here we're rejecting the default template argument

  requires (T t) { x(t); }

because we consider the 't' in the requirement to be a local variable
(according to local_variable_p), and we generally forbid local variables
from appearing inside default arguments.  We can perhaps fix this by
giving special treatment to parameters introduced by requires-expressions,
but DR 2082 relaxed the restriction about local variables appearing within
default arguments to permit them inside unevaluated operands thereof.
So this patch just implements DR 2082 which also fixes this PR since a
requires-expression is an unevaluated context.

	PR c++/101725
	DR 2082

gcc/cp/ChangeLog:

	* cp-tree.h (unevaluated_p): Return true for REQUIRES_EXPR.
	* decl.c (local_variable_p_walkfn): Don't walk into unevaluated
	operands.
	* parser.c (cp_parser_primary_expression) <case CPP_NAME>: Never
	reject uses of local variables in unevaluated contexts.
	* tree.c (cp_walk_subtrees) <case REQUIRES_EXPR>: Increment
	cp_unevaluated_operand.  Use cp_walk_tree directly instead of
	WALK_SUBTREE to avoid the goto.  Use REQUIRES_EXPR_REQS instead
	of TREE_OPERAND directly.

gcc/testsuite/ChangeLog:

	* g++.dg/DRs/dr2082.C: New test.
	* g++.dg/cpp2a/concepts-uneval4.C: New test.
2021-08-11 16:53:53 -04:00
Jakub Jelinek ee8f9ff00d c++: Optimize constinit thread_local vars [PR101786]
The paper that introduced constinit mentioned in rationale that constinit
can be used on externs as well and that it can be used to avoid the
thread_local initialization wrappers, because the standard requires that
if constinit is present on any declaration, it is also present on the
initialization declaration, even if it is in some other TU etc.

There is a small problem though, we use the tls wrappers not just if
the thread_local variable needs dynamic initialization, but also when
it has static initialization, but non-trivial destructor, as the
"dynamic initialization" in that case needs to register the destructor.

So, the following patch optimizes constinit thread_local vars only
if we can prove they will not have non-trivial destructors.  That includes
the case where we have incomplete type where we don't know and need to
conservatively assume the type will have non-trivial destructor at the
initializing declaration side.

2021-08-11  Jakub Jelinek  <jakub@redhat.com>

	PR c++/101786
	* decl2.c (var_defined_without_dynamic_init): Return true for
	DECL_DECLARED_CONSTINIT_P with complete type and trivial destructor.

	* g++.dg/cpp2a/constinit16.C: New test.
2021-08-11 22:00:29 +02:00
Patrick Palka 7e39d1a15f c++: recognize class-scope non-template dguides [PR79501]
It looks like we still don't recognize class-scope non-template
deduction guides even after r12-2260.   This is because deduction guides
are tagged as such in cp_parser_init_declarator after calling
cp_parser_declarator, but in cp_parser_member_declaration we call
cp_parser_declarator directly.

So let's tag them in cp_parser_member_declaration as well.

	PR c++/79501

gcc/cp/ChangeLog:

	* parser.c (maybe_adjust_declarator_for_dguide): New, split
	out from ...
	(cp_parser_init_declarator): ... here.
	(cp_parser_member_declaration): Use it.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction98.C: New test.
2021-08-11 15:59:22 -04:00