Compare commits

...

2753 Commits

Author SHA1 Message Date
Nathan Sidwell
65165eb3f8 Add -f[no-]header-guard-opt
Added so that one can determine the include graph from the -E output.
2021-02-03 11:37:35 -08:00
Nathan Sidwell
000bee388b Merge commit '84110515b93' into devel/c++-modules 2021-02-03 06:48:16 -08:00
Martin Liska
84110515b9 Fill up padding in lto_section struct.
gcc/ChangeLog:

	PR lto/98912
	* lto-streamer-out.c (produce_lto_section): Fill up missing
	padding.
	* lto-streamer.h (struct lto_section): Add _padding field.
2021-02-03 13:18:52 +01:00
Eric Botcazou
e8c87bc07b Fix regression with partial rep clause on variant record type
It can yield an incorrect layout when there is a partial representation
clause on a discriminated record type with a variant part.

gcc/ada/
	* gcc-interface/decl.c (components_to_record): If the first component
	with rep clause is the _Parent field with variable size, temporarily
	set it aside when computing the internal layout of the REP part again.
	* gcc-interface/utils.c (finish_record_type): Revert to taking the
	maximum when merging sizes for all record types with rep clause.
	(merge_sizes): Put SPECIAL parameter last and adjust recursive calls.
2021-02-03 11:38:04 +01:00
Eric Botcazou
fc130ab54f Assorted LTO fixes for Ada
This polishes a few rough edges visible in LTO mode.

gcc/ada/
	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Make the
	two fields of the fat pointer type addressable, and do not make the
	template type read-only.
	<E_Record_Type>: If the type has discriminants mark it as may_alias.
	* gcc-interface/utils.c (make_dummy_type): Likewise.
	(build_dummy_unc_pointer_types): Likewise.
2021-02-03 11:12:50 +01:00
Tobias Burnus
e3f9f80bfa Fortran: Fix Array dependency with local coarrays [PR98913]
gcc/fortran/ChangeLog:

	PR fortran/98913
	* dependency.c (gfc_dep_resolver): Treat local access
	to coarrays like any array access in dependency analysis.

gcc/testsuite/ChangeLog:

	PR fortran/98913
	* gfortran.dg/coarray/array_temporary.f90: New test.
2021-02-03 10:34:18 +01:00
Richard Biener
1b06fcb0c9 more memory leak fixes
This fixes more memory leaks as discovered by building 521.wrf_r.

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

	* lto-streamer.c (lto_get_section_name): Free temporary
	buffer.
	* tree-loop-distribution.c
	(loop_distribution::merge_dep_scc_partitions): Free edge data.
2021-02-03 10:04:13 +01:00
Jakub Jelinek
176c7bd840 ifcvt: Avoid ICEs trying to force_operand random RTL [PR97487]
As the testcase shows, RTL ifcvt can throw random RTL (whatever it found in
some insns) at expand_binop or expand_unop and expects it to do something
(and then will check if it created valid insns and punts if not).
These functions in the end if the operands don't match try to
copy_to_mode_reg the operands, which does
if (!general_operand (x, VOIDmode))
  x = force_operand (x, temp);
but, force_operand is far from handling all possible RTLs, it will ICE for
all more unusual RTL codes.  Basically handles just simple arithmetic and
unary RTL operations if they have an optab and
expand_simple_binop/expand_simple_unop ICE on others.

The following patch fixes it by adding some operand verification (whether
there is a hope that copy_to_mode_reg will succeed on those).  It is added
both to noce_emit_move_insn (not needed for this exact testcase,
that function simply tries to recog the insn as is and if it fails,
handles some simple binop/unop cases; the patch performs the verification
of their operands) and noce_try_sign_mask.

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

	PR middle-end/97487
	* ifcvt.c (noce_can_force_operand): New function.
	(noce_emit_move_insn): Use it.
	(noce_try_sign_mask): Likewise.  Formatting fix.

	* gcc.dg/pr97487-1.c: New test.
	* gcc.dg/pr97487-2.c: New test.
2021-02-03 09:10:29 +01:00
Jakub Jelinek
eb69a49c4d lra-constraints: Fix error-recovery for bad inline-asms [PR97971]
The following testcase has ice-on-invalid, it can't be reloaded, but we
shouldn't ICE the compiler because the user typed non-sense.

In current_insn_transform we have:
  if (process_alt_operands (reused_alternative_num))
    alt_p = true;

  if (check_only_p)
    return ! alt_p || best_losers != 0;

  /* If insn is commutative (it's safe to exchange a certain pair of
     operands) then we need to try each alternative twice, the second
     time matching those two operands as if we had exchanged them.  To
     do this, really exchange them in operands.

     If we have just tried the alternatives the second time, return
     operands to normal and drop through.  */

  if (reused_alternative_num < 0 && commutative >= 0)
    {
      curr_swapped = !curr_swapped;
      if (curr_swapped)
        {
          swap_operands (commutative);
          goto try_swapped;
        }
      else
        swap_operands (commutative);
    }

  if (! alt_p && ! sec_mem_p)
    {
      /* No alternative works with reloads??  */
      if (INSN_CODE (curr_insn) >= 0)
        fatal_insn ("unable to generate reloads for:", curr_insn);
      error_for_asm (curr_insn,
                     "inconsistent operand constraints in an %<asm%>");
      lra_asm_error_p = true;
...
and so handle inline asms there differently (and delete/nullify them after
this) - fatal_insn is only called for non-inline asm.
But in process_alt_operands we do:
                /* Both the earlyclobber operand and conflicting operand
                   cannot both be user defined hard registers.  */
                if (HARD_REGISTER_P (operand_reg[i])
                    && REG_USERVAR_P (operand_reg[i])
                    && operand_reg[j] != NULL_RTX
                    && HARD_REGISTER_P (operand_reg[j])
                    && REG_USERVAR_P (operand_reg[j]))
                  fatal_insn ("unable to generate reloads for "
                              "impossible constraints:", curr_insn);
and thus ICE even for inline-asms.

I think it is inappropriate to delete/nullify the insn in
process_alt_operands, as it could be done e.g. in the check_only_p mode,
so this patch just returns false in that case, which results in the
caller have alt_p false, and as inline asm isn't simple move, sec_mem_p
will be also false (and it isn't commutative either), so for check_only_p
it will suggests to the callers it isn't ok and otherwise will emit
error and delete/nullify the inline asm insn.

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

	PR middle-end/97971
	* lra-constraints.c (process_alt_operands): For inline asm, don't call
	fatal_insn, but instead return false.

	* gcc.target/i386/pr97971.c: New test.
2021-02-03 09:10:29 +01:00
Jakub Jelinek
1b5572edb8 i386: Remove V1DImode shift expanders [PR98287]
On Tue, Feb 02, 2021 at 02:23:55PM +0100, Richard Biener wrote:
> All I say is that the x86 target
> should either not advertise V1DF shifts or advertise the basic
> ops that reasonable simplification would expect to exist.

The backend has several V1?Imode shifts, but optab only for those V1DImode
ones:

grep '[la]sh[lr]v1[qhsdtox]' tmp-mddump.md
(define_insn ("mmx_ashlv1di3")
(define_insn ("mmx_lshrv1di3")
(define_insn ("avx512bw_ashlv1ti3")
(define_insn ("avx512bw_lshrv1ti3")
(define_insn ("sse2_ashlv1ti3")
(define_insn ("sse2_lshrv1ti3")
(define_expand ("ashlv1di3")
(define_expand ("lshrv1di3")
  emit_insn (gen_sse2_lshrv1ti3 (tmp, gen_lowpart (V1TImode, operands[1]),

I think it has been introduced with
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89021#c13

Before we didn't have any V1DImode expanders (except mov/movmisalign, but
those are needed and are supplied for other V1??mode modes too).

This patch just removes the two V1DImode shift expanders with standard names.

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

	PR tree-optimization/98287
	* config/i386/mmx.md (<insn><mode>3): For shifts don't enable expander
	for V1DImode.

	* gcc.dg/pr98287.c: New test.
2021-02-03 09:10:28 +01:00
Tamar Christina
5e606ed90a slp: Split out patterns away from using SLP_ONLY into their own flag
Previously the SLP pattern matcher was using STMT_VINFO_SLP_VECT_ONLY as a way
to dissolve the SLP only patterns during SLP cancellation.  However it seems
like the semantics for STMT_VINFO_SLP_VECT_ONLY are slightly different than what
I expected.

Namely that the non-SLP path can still use a statement marked
STMT_VINFO_SLP_VECT_ONLY.  One such example is masked loads which are used both
in the SLP and non-SLP path.

To fix this I now introduce a new flag STMT_VINFO_SLP_VECT_ONLY_PATTERN which is
used only by the pattern matcher.

gcc/ChangeLog:

	PR tree-optimization/98928
	* tree-vect-loop.c (vect_analyze_loop_2): Change
	STMT_VINFO_SLP_VECT_ONLY to STMT_VINFO_SLP_VECT_ONLY_PATTERN.
	* tree-vect-slp-patterns.c (complex_pattern::build): Likewise.
	* tree-vectorizer.h (STMT_VINFO_SLP_VECT_ONLY_PATTERN): New.
	(class _stmt_vec_info): Add slp_vect_pattern_only_p.

gcc/testsuite/ChangeLog:

	PR tree-optimization/98928
	* gcc.target/i386/pr98928.c: New test.
2021-02-03 08:06:11 +00:00
GCC Administrator
548b75d822 Daily bump. 2021-02-03 00:16:23 +00:00
Ian Lance Taylor
8e4a738d25 gotools: for "make check" run "go test embed/internal/embedtest"
* Makefile.am (check-embed): New target.
	(check): Depend on check-embed.  Examine embed-testlog.
	(mostlyclean-local): Add check-embed-dir.
	(.PHONY): Add check-embed.
	* Makefile.in: Regenerate.
2021-02-02 12:41:01 -08:00
Richard Biener
5d5130ad5c fix memory leaks
This fixes various vec<> memory leaks as discovered compiling 521.wrf_r.

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

	* gimple-loop-interchange.cc (prepare_data_references):
	Release vectors.
	* gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise.
	* tree-ssa-loop-im.c (hoist_memory_references): Likewise.
	* tree-vect-stmts.c (vectorizable_condition): Do not
	allocate vectors.
	(vectorizable_comparison): Likewise.
2021-02-02 20:07:30 +01:00
Martin Liska
db53dd4f78 Add test-case.
gcc/testsuite/ChangeLog:

	PR target/97510
	* gcc.target/i386/pr97510.c: New test.
2021-02-02 20:05:48 +01:00
Jason Merrill
709718d4d8 c++: Member fns and deduction guide rewriting [PR98929]
My patch for 96199 had us re-substitute the parameter types of a constructor
in order to rewrite mentions of members into dependent references.  We need
to do that for member functions, too.

gcc/cp/ChangeLog:

	PR c++/98929
	PR c++/96199
	* error.c (dump_expr): Ignore dummy object.
	* pt.c (tsubst_baselink): Handle dependent scope.

gcc/testsuite/ChangeLog:

	PR c++/98929
	* g++.dg/cpp1z/class-deduction-decltype1.C: New test.
2021-02-02 12:11:39 -05:00
Kyrylo Tkachov
d14cf89b94 aarch64: Reimplement vrsqrte* intrinsics with builtins
Another very simple move from inline asm to builtins.
Only two intrinsics this time.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (ursqrte): Define builtin.
	* config/aarch64/aarch64-simd.md (aarch64_ursqrte<mode>): New pattern.
	* config/aarch64/arm_neon.h (vrsqrte_u32): Reimplement using builtin.
	(vrsqrteq_u32): Likewise.
2021-02-02 15:53:19 +00:00
Kyrylo Tkachov
8fdfd0cfdb aarch64: Reimplement vqmovun_high* intrinsics using builtins
Another transition from inline asm to builtin.
Only 3 intrinsics converted this time but they use the "+w" constraint in their inline asm
so are more likely to generate redundant moves so benefit more from reimplementation.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (sqxtun2): Define builtin.
	* config/aarch64/aarch64-simd.md (aarch64_sqxtun2<mode>_le): Define.
	(aarch64_sqxtun2<mode>_be): Likewise.
	(aarch64_sqxtun2<mode>): Likewise.
	* config/aarch64/arm_neon.h (vqmovun_high_s16): Reimplement using builtin.
	(vqmovun_high_s32): Likewise.
	(vqmovun_high_s64): Likewise.
	* config/aarch64/iterators.md (UNSPEC_SQXTUN2): Define.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/narrow_high-intrinsics.c: Adjust sqxtun2 scan.
2021-02-02 15:53:01 +00:00
Paul Thomas
831ff94a88 Fortran: Check remains fixed by patch for PRs 96100/101 [PR91862].
2021-02-02  Paul Thomas  <pault@gcc.gnu.org>

gcc/testsuite
	PR fortran/91862
	* gfortran.dg/pr91862.f90: New test.
2021-02-02 13:55:50 +00:00
Kyrylo Tkachov
13d8be9121 aarch64: Update flags for bfloat16 builtins
This patch updates the flags for the bfloat16 builtins.
The bfdot ones aren't affected by the FPCR/FPSR so can be AUTO_FP
whereas the bfmlal ones follow the normal floating-point instructions and get FP.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (bfdot_lane, bfdot_laneq): Use
	AUTO_FP flags.
	(bfmlalb_lane, bfmlalt_lane, bfmlalb_lane_q, bfmlalt_lane_q): Use FP flags.
2021-02-02 12:14:39 +00:00
Kyrylo Tkachov
4b8a7a6e81 aarch64: Relax flags for floating-point builtins to FP where appropriate
This patch relaxes various floating-point builtins to use the FP flags to signify they
made use the FPCR or raise exceptions.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (fcmla_lane0, fcmla_lane90,
	fcmla_lane180, fcmla_lane270, fcmlaq_lane0, fcmlaq_lane90, fcmlaq_lane180,
	fcmlaq_lane270, scvtf, ucvtf, fcvtzs, fcvtzu, scvtfsi, scvtfdi, ucvtfsi,
	ucvtfdi, fcvtzshf, fcvtzuhf, fmlal_lane_low, fmlsl_lane_low,
	fmlal_laneq_low, fmlsl_laneq_low, fmlalq_lane_low, fmlslq_lane_low,
	fmlalq_laneq_low, fmlslq_laneq_low, fmlal_lane_high, fmlsl_lane_high,
	fmlal_laneq_high, fmlsl_laneq_high, fmlalq_lane_high, fmlslq_lane_high,
	fmlalq_laneq_high, fmlslq_laneq_high): Use FP flags.
2021-02-02 12:14:39 +00:00
Kyrylo Tkachov
e8062ad468 aarch64: Add and use FLAG_LOAD in builtins
We already have a STORE flag that we use for builtins. This patch introduces a LOAD set
that uses AUTO_FP and FLAG_READ_MEMORY. This allows for more aggressive optimisation of the load
intrinsics.

Turns out we have a great many testcases that do:
float16x4x2_t
f_vld2_lane_f16 (float16_t * p, float16x4x2_t v)
{
  float16x4x2_t res;
  /* { dg-error "lane 4 out of range 0 - 3" "" { target *-*-* } 0 } */
  res = vld2_lane_f16 (p, v, 4);
  /* { dg-error "lane -1 out of range 0 - 3" "" { target *-*-* } 0 } */
  res = vld2_lane_f16 (p, v, -1);
  return res;
}

but since the first res is unused it now gets eliminated early on before we get to give an error
message. Ideally we'd like to warn for both.
This patch takes the conservative approach and doesn't convert the load-lane builtins to LOAD ;
that's something we can improve later.

gcc/ChangeLog:

	* config/aarch64/aarch64-builtins.c (FLAG_LOAD): Define.
	* config/aarch64/aarch64-simd-builtins.def (ld1x2, ld2, ld3, ld4, ld2r,
	ld3r, ld4r, ld1, ld1x3, ld1x4): Use LOAD flags.
2021-02-02 12:14:39 +00:00
Kyrylo Tkachov
5cebc81821 aarch64: Relax some builtins to AUTO_FP
This patch relaxes the flags for some builtins to AUTO_FP. These
builtins do permutes and similar, so they shouldn't get the FP flags
when operating on floating-point modes as they don't care about
FPCR/FPSR and exceptions.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (combine, zip1, zip2,
	uzp1, uzp2, trn1, trn2, simd_bsl): Use AUTO_FP flags.
2021-02-02 12:14:39 +00:00
Kyrylo Tkachov
7bcd5e09fb aarch64: Relax builtin flags for integer builtins
This patch relaxes the flags for most integer builtins to NONE as they don't read/write memory
and don't care about the FPCR/FPSR or exceptions so we should be more aggressive with them.

This leads to fallout in a testcase where the result of an intrinsic was unused and it is now
DCE'd. The testcase is adjusted.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (clrsb, clz, ctz, popcount,
	vec_smult_lane_, vec_smlal_lane_, vec_smult_laneq_, vec_smlal_laneq_,
	vec_umult_lane_, vec_umlal_lane_, vec_umult_laneq_, vec_umlal_laneq_,
	ashl, sshl, ushl, srshl, urshl, sdot_lane, udot_lane, sdot_laneq,
	udot_laneq, usdot_lane, usdot_laneq, sudot_lane, sudot_laneq, ashr,
	ashr_simd, lshr, lshr_simd, srshr_n, urshr_n, ssra_n, usra_n, srsra_n,
	ursra_n, sshll_n, ushll_n, sshll2_n, ushll2_n, ssri_n, usri_n, ssli_n,
	ssli_n, usli_n, bswap, rbit, simd_bsl, eor3q, rax1q, xarq, bcaxq): Use
	NONE builtin flags.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/arg-type-diagnostics-1.c: Return result from foo.
2021-02-02 12:14:39 +00:00
Jonathan Wakely
886f9f519c libstdc++: Fix markup for status tables in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2011.xml: Remove stray table cell.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise.
	* doc/html/manual/status.html: Regenerate.
2021-02-02 09:55:52 +00:00
Jakub Jelinek
1592b74350 tree-vect-patterns: Don't create over widening patterns for stmts used in reductions [PR98848]
As discussed in the PR, the reduction code isn't able to cope with type
promotions/demotions in the reduction computation, so if we recognize an
over-widening pattern that has vect_reduction_def type, we most likely make
it non-vectorizable.

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

	PR tree-optimization/98848
	* tree-vect-patterns.c (vect_recog_over_widening_pattern): Punt if
	STMT_VINFO_DEF_TYPE (last_stmt_info) is vect_reduction_def.

	* gcc.dg/vect/pr98848.c: New test.
	* gcc.dg/vect/pr92205.c: Remove xfail.
2021-02-02 10:32:23 +01:00
Jakub Jelinek
eedda4e160 testsuite: Add testcase for already fixed PR [PR97960]
This testcase has been fixed by
r11-5904-g4cf70c20cb10acd6fb1016611d05540728176b60
so I'm checking it in so that we can close the PR.

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

	PR tree-optimization/97960
	* g++.dg/torture/pr97960.C: New test.
2021-02-02 10:01:40 +01:00
Kito Cheng
bc7c2b34c3 PR target/98743: Fix ICE in convert_move for RISC-V
- Check `from` mode is not BLMmode before call store_expr, calling store_expr
   with BLKmode will cause ICE.

 - Verified with riscv64, x86_64 and aarch64, no introduce new regression.

Note: Those logic was introduced by 3e60ddeb82,
      so I cc Jakub for reivew.

Changes for V2:

 - Checking mode of `from` rather than mode of `to`.
 - Verified on riscv64, x86_64 and aarch64 again.

gcc/ChangeLog:

	PR target/98743
	* expr.c: Check mode before calling store_expr.

gcc/testsuite/ChangeLog:

	PR target/98743
	* g++.dg/opt/pr98743.C: New.
2021-02-02 16:56:06 +08:00
Christophe Lyon
250fd9fb11 arm: Auto-vectorization for MVE: vorn
This patch enables MVE vornq instructions for auto-vectorization.  MVE
vornq insns in mve.md are modified to use ior instead of unspec
expression.

2021-02-01  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/iterators.md (supf): Remove VORNQ_S and VORNQ_U.
	(VORNQ): Remove.
	* config/arm/mve.md (mve_vornq_s<mode>): New entry for vorn
	instruction using expression ior.
	(mve_vornq_u<mode>): New expander.
	(mve_vornq_f<mode>): Use ior code instead of unspec.
	* config/arm/unspecs.md (VORNQ_S, VORNQ_U, VORNQ_F): Remove.

	gcc/testsuite/
	* gcc.target/arm/simd/mve-vorn.c: Add vorn tests.
2021-02-02 08:53:57 +00:00
Alexandre Oliva
7881135568 restore current_function_decl after re-gimplifying nested ADDR_EXPRs
Ada makes extensive use of nested functions, which turn all automatic
variables of the enclosing function that are used in nested ones into
members of an artificial FRAME record type.

The address of a local variable is usually passed to asan marking
functions without using a temporary.  asan_expand_mark_ifn will reject
an ADDR_EXPRs if it's split out from the call into an SSA_NAMEs.

Taking the address of a member of FRAME within a nested function was
not regarded as a gimple val: while introducing FRAME variables,
current_function_decl pointed to the outermost function, even while
processing a nested function, so decl_address_invariant_p, checking
that the context of the variable is current_function_decl, returned
false for such ADDR_EXPRs.

decl_address_invariant_p, called when determining whether an
expression is a legitimate gimple value, compares the context of
automatic variables with current_function_decl.  Some of the
tree-nested function processing doesn't set current_function_decl, but
ADDR_EXPR-processing bits temporarily override it.  However, they
restore it before re-gimplifying, which causes even ADDR_EXPRs
referencing automatic variables in the FRAME struct of a nested
function to not be regarded as address-invariant.

This patch moves the restores of current_function_decl in the
ADDR_EXPR-handling bits after the re-gimplification, so that the
correct current_function_decl is used when testing for address
invariance.


for  gcc/ChangeLog

	* tree-nested.c (convert_nonlocal_reference_op): Move
	current_function_decl restore after re-gimplification.
	(convert_local_reference_op): Likewise.

for  gcc/testsuite/ChangeLog

	* gcc.dg/asan/nested-1.c: New.
2021-02-02 00:00:30 -03:00
David Malcolm
8a2750086d analyzer: directly explore within static functions [PR93355,PR96374]
PR analyzer/93355 tracks that -fanalyzer fails to report the FILE *
leak in read_alias_file in intl/localealias.c.

One reason for the failure is that read_alias_file is marked as
"static", and the path leading to the single call of
read_alias_file is falsely rejected as infeasible due to
PR analyzer/96374.  I have been attempting to fix that bug, but
don't have a good solution yet.

Previously, -fanalyzer only directly explored "static" functions
if they were needed for call summaries, instead forcing them to
be indirectly explored, but if we have a feasibility bug like
above, we will fail to report any issues in a function that's
only called by such a falsely infeasible path.

It now seems wrong to me to reject directly exploring static
functions: even if there is currently no way to call a function,
it seems reasonable to warn about bugs within them, since
otherwise these latent bugs are a timebomb in the code.

Hence this patch reworks toplevel_function_p to directly explore
almost all functions, working around these feasiblity issues.
It introduces a naming convention that "__analyzer_"-prefixed
function names don't get directly explored, since this is
useful in the analyzer's DejaGnu-based tests.

This workaround gets PR analyzer/93355 closer to working, but
unfortunately there is a second instance of PR analyzer/96374
within read_alias_file itself which means even with this patch
-fanalyzer falsely rejects the path as infeasible.

Still, this ought to help in other cases, and simplifies the
implementation.

gcc/analyzer/ChangeLog:
	PR analyzer/93355
	PR analyzer/96374
	* engine.cc (toplevel_function_p): Simplify so that
	we only reject functions with a "__analyzer_" prefix.
	(add_any_callbacks): Delete.
	(exploded_graph::build_initial_worklist): Update for
	dropped param of toplevel_function_p.
	(exploded_graph::build_initial_worklist): Don't bother
	looking for callbacks that are reachable from global
	initializers.

gcc/testsuite/ChangeLog:
	PR analyzer/93355
	PR analyzer/96374
	* gcc.dg/analyzer/conditionals-3.c: Add "__analyzer_"
	prefix to support subroutines where necessary.
	* gcc.dg/analyzer/data-model-1.c: Likewise.
	* gcc.dg/analyzer/feasibility-1.c (called_by_test_6a): New.
	(test_6a): New.
	* gcc.dg/analyzer/params.c: Add "__analyzer_" prefix to support
	subroutines where necessary.
	* gcc.dg/analyzer/pr96651-2.c: Likewise.
	* gcc.dg/analyzer/signal-4b.c: Likewise.
	* gcc.dg/analyzer/single-field.c: Likewise.
	* gcc.dg/analyzer/torture/conditionals-2.c: Likewise.
2021-02-01 21:54:11 -05:00
David Malcolm
f2f639c4a7 analyzer: add more feasibility test cases [PR93355,PR96374]
This patch adds a couple more reduced test cases derived from the
integration test for PR analyzer/93355.  In both cases, the analyzer
falsely rejects the buggy code paths as being infeasible due to
PR analyzer/96374, and so the tests are marked as XFAIL for now.

gcc/testsuite/ChangeLog:
	PR analyzer/93355
	PR analyzer/96374
	* gcc.dg/analyzer/pr93355-localealias-feasibility-2.c: New test.
	* gcc.dg/analyzer/pr93355-localealias-feasibility-3.c: New test.
2021-02-01 21:52:41 -05:00
Iain Buclaw
6a481021a6 d: Fix junk in generated symbol on powerpc64-*-* [PR98921]
This adds a special formatter to OutBuffer to handle formatted printing
of integers, a common case.  The replacement is faster and safer.

In dmangle.c, it also gets rid of a number of problematic casts, as seen
on powerpc64 targets.

Reviewed-on: https://github.com/dlang/dmd/pull/12174

gcc/d/ChangeLog:

	PR d/98921
	* dmd/MERGE: Merge upstream dmd 5e2a81d9c.
2021-02-02 01:24:14 +01:00
GCC Administrator
f7884fb176 Daily bump. 2021-02-02 00:16:23 +00:00
Kyrylo Tkachov
850e5878f8 aarch64: Reimplement vrshrn* intrinsics using builtins
This patch moves the vrshrn* intrinsics to builtins away from inline
asm.

It's a bit of code, but it's very similar to the recent vsrhn*
reimplementation except that we use an unspec rather than standard RTL
codes for the functionality.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (rshrn, rshrn2):
	Define builtins.
	* config/aarch64/aarch64-simd.md (aarch64_rshrn<mode>_insn_le):
	Define.
	(aarch64_rshrn<mode>_insn_be): Likewise.
	(aarch64_rshrn<mode>): Likewise.
	(aarch64_rshrn2<mode>_insn_le): Likewise.
	(aarch64_rshrn2<mode>_insn_be): Likewise.
	(aarch64_rshrn2<mode>): Likewise.
	* config/aarch64/aarch64.md (unspec): Add UNSPEC_RSHRN.
	* config/aarch64/arm_neon.h (vrshrn_high_n_s16): Reimplement
	using builtin.
	(vrshrn_high_n_s32): Likewise.
	(vrshrn_high_n_s64): Likewise.
	(vrshrn_high_n_u16): Likewise.
	(vrshrn_high_n_u32): Likewise.
	(vrshrn_high_n_u64): Likewise.
	(vrshrn_n_s16): Likewise.
	(vrshrn_n_s32): Likewise.
	(vrshrn_n_s64): Likewise.
	(vrshrn_n_u16): Likewise.
	(vrshrn_n_u32): Likewise.
	(vrshrn_n_u64): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/narrow_high-intrinsics.c: Adjust rshrn2
	assembly scan.
2021-02-01 21:10:35 +00:00
David Malcolm
11d4ec5d45 analyzer: fix false positives with *UNKNOWN_PTR [PR98918]
PR analyzer/98918 reports various false positives and state explosions
on correct code that frees nodes and other pointers in a singly-linked
list.

The issue is that state-merger in the loop leads to UNKNOWN_VALUEs,
and these are then erroneously used to form compound symbolic values
and regions, such as;
  INIT_VAL((*UNKNOWN(struct marker *)).ref)
and:
  (*INIT_VAL((*UNKNOWN(struct marker * *))))
The malloc state machine then treats these symbolic values as
identifying specific pointers, and thus e.g. erroneously reports a
double-free when
  INIT_VAL((*UNKNOWN(struct marker *)).ref)
is freed twice (on subsequent iterations of the loop).

Similarly, the increasingly complex compound symbolic values have
sm-state which prevents state merging, and eventually lead to the
analysis hitting safety limits and stopping.

This patch makes various compound values involving UNKNOWN be
themselves UNKNOWN, resolving both the false positives and the state
explosions.

gcc/analyzer/ChangeLog:
	PR analyzer/98918
	* region-model-manager.cc
	(region_model_manager::get_or_create_initial_value):
	Fold the initial value of *UNKNOWN_PTR to an UNKNOWN value.
	(region_model_manager::get_field_region): Fold the value
	of UNKNOWN_PTR->FIELD to *UNKNOWN_PTR_OF_&FIELD_TYPE.

gcc/testsuite/ChangeLog:
	PR analyzer/98918
	* gcc.dg/analyzer/pr98918.c: New test.
2021-02-01 15:13:39 -05:00
François Dumont
33a1e511b5 libstdc++: Make deque iterator operator- usable with value-init iterators
N3644 implies that operator- can be used on value-init iterators. We now return
0 if both iterators are value initialized. If only one is value initialized we
keep the UB by returning the result of a normal computation which is a meaningless
value.

libstdc++-v3/ChangeLog:

	PR libstdc++/70303
	* include/bits/stl_deque.h (std::deque<>::operator-(iterator, iterator)):
	Return 0 if both iterators are value-initialized.
	* testsuite/23_containers/deque/70303.cc: New test.
	* testsuite/23_containers/vector/70303.cc: New test.
2021-02-01 19:19:53 +01:00
Sergei Trofimovich
11056ab768 tree-optimization/98499 - fix modref analysis on RVO statements
Before the change RVO gimple statements were treated as local
stores by modres analysis. But in practice RVO escapes target.

2021-02-01  Sergei Trofimovich  <siarheit@google.com>

gcc/ChangeLog:

	PR tree-optimization/98499
	* ipa-modref.c (analyze_ssa_name_flags): treat RVO
	conservatively and assume all possible side-effects.

gcc/testsuite/ChangeLog:

	PR tree-optimization/98499
	* g++.dg/pr98499.C: new test.
2021-02-01 18:13:42 +00:00
Kyrylo Tkachov
8bfdf51d85 aarch64: Reimplement vmovl_high_* intrinsics using builtins
The vmovl_high_* intrinsics map down to the SXTL2/UXTL2 instructions
that already have appropriately-named patterns and expanders,
so it's straightforward to wire them up.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (vec_unpacks_hi,
	vec_unpacku_hi_): Define builtins.
	* config/aarch64/arm_neon.h (vmovl_high_s8): Reimplement using
	builtin.
	(vmovl_high_s16): Likewise.
	(vmovl_high_s32): Likewise.
	(vmovl_high_u8): Likewise.
	(vmovl_high_u16): Likewise.
	(vmovl_high_u32): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/simd/vmovl_high_1.c: New test.
2021-02-01 16:45:05 +00:00
Kyrylo Tkachov
6b2034c479 aarch64: Reimplement vabdl_* intrinsics using builtins
Another simple set of intrinsic moved to builtins in the straightforward
way.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (sabdl, uabdl):
	Define builtins.
	* config/aarch64/aarch64-simd.md (aarch64_<sur>abdl<mode>): New
	pattern.
	* config/aarch64/aarch64.md (unspec): Define UNSPEC_SABDL,
	UNSPEC_UABDL.
	* config/aarch64/arm_neon.h (vabdl_s8): Reimplemet using
	builtin.
	(vabdl_s16): Likewise.
	(vabdl_s32): Likewise.
	(vabdl_u8): Likewise.
	(vabdl_u16): Likewise.
	(vabdl_u32): Likewise.
	* config/aarch64/iterators.md (ABDL): New int iterator.
	(sur): Handle UNSPEC_SABDL, UNSPEC_UABDL.
2021-02-01 16:45:05 +00:00
Martin Sebor
6a2053773b Document various BLOCK macros.
gcc/ChangeLog:

	* tree.h (BLOCK_VARS): Add comment.
	(BLOCK_SUBBLOCKS): Same.
	(BLOCK_SUPERCONTEXT): Same.
	(BLOCK_ABSTRACT_ORIGIN): Same.
	(inlined_function_outer_scope_p): Same.
2021-02-01 09:17:21 -07:00
Martin Sebor
0718336a52 Reset front end trees before they make it into the middle end (PR middle-end/97172).
gcc/ChangeLog:

	PR middle-end/97172
	* attribs.c (attr_access::free_lang_data): Define new function.
	* attribs.h (attr_access::free_lang_data): Declare new function.

gcc/c/ChangeLog:

	PR middle-end/97172
	* c-decl.c (free_attr_access_data): New function.
	(c_parse_final_cleanups): Call free_attr_access_data.

gcc/testsuite/ChangeLog:

	PR middle-end/97172
	* gcc.dg/pr97172.c: New test.
2021-02-01 09:09:52 -07:00
Jonathan Wakely
90c9b2c176 libstdc++: Update C++17 status table for <charconv>
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2011.xml: Update std::call_once
	status.
	* doc/xml/manual/status_cxx2014.xml: Likewise.
	* doc/xml/manual/status_cxx2017.xml: Likewise. Update
	std::from_chars and std::to_chars status. Fix formatting.
	* doc/html/manual/status.html: Regenerate.
2021-02-01 16:06:45 +00:00
Martin Sebor
445d6db649 Avoid -Wstringop-truncation.
libiberty/ChangeLog:

	* dyn-string.c (dyn_string_insert_cstr): Use memcpy instead of strncpy
	to avoid -Wstringop-truncation.
2021-02-01 09:00:02 -07:00
Richard Biener
d7bd009ab0 Fix statistic accounting for auto_vec and auto_bitmap
This fixes accounting issues with using auto_vec and auto_bitmap
for -fmem-report.

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

	* vec.h (auto_vec::auto_vec): Add memory stat parameters
	and pass them on.
	* bitmap.h (auto_bitmap::auto_bitmap): Likewise.
2021-02-01 16:51:29 +01:00
Martin Sebor
c2f8e378d6 Verify a warning for a class with a ref-qualified assignment (PR c++/98835).
gcc/testsuite/ChangeLog:
	PR c++/98835
	* g++.dg/Wclass-memaccess-6.C: New test.
2021-02-01 08:42:58 -07:00
Patrick Palka
7e534fb7d8 c++: Fix ICE from verify_ctor_sanity [PR98295]
In this testcase we're crashing during constexpr evaluation of the
ARRAY_REF b[0] as part of evaluation of the lambda's by-copy capture of b
(which is encoded as a VEC_INIT_EXPR<b>).  Since A's constexpr default
constructor is not yet defined, b's initialization is not actually
constant, but because A is an empty type, evaluation of b from
cxx_eval_array_ref is successful and yields an empty CONSTRUCTOR.
And since this CONSTRUCTOR is empty, we {}-initialize the desired array
element, and end up crashing from verify_ctor_sanity during evaluation
of this initializer because we updated new_ctx.ctor without updating
new_ctx.object: the former now has type A[3] and the latter is still the
target of a TARGET_EXPR for b[0][0] created from cxx_eval_vec_init
(and so has type A).

This patch fixes this by setting new_ctx.object appropriately at the
same time that we set new_ctx.ctor from cxx_eval_array_reference.

gcc/cp/ChangeLog:

	PR c++/98295
	* constexpr.c (cxx_eval_array_reference): Also set
	new_ctx.object when setting new_ctx.ctor.

gcc/testsuite/ChangeLog:

	PR c++/98295
	* g++.dg/cpp0x/constexpr-98295.C: New test.
2021-02-01 10:27:45 -05:00
Marek Polacek
bab669f2fc c++: Improve sorry for __builtin_has_attribute [PR98355]
__builtin_has_attribute doesn't work in templates yet (bug 92104), so
in r11-471 I added a sorry.  But that only caught type-dependent
expressions and we also want to sorry on value-dependent expressions.
This patch uses uses_template_parms, but guarded with p_t_d, because
u_t_p sets p_t_d and then v_d_e_p considers variables with reference
types value-dependent, which breaks builtin-has-attribute-6.c.

This is a regression and I also plan to apply this to gcc-10.

gcc/cp/ChangeLog:

	PR c++/98355
	* parser.c (cp_parser_has_attribute_expression): Use
	uses_template_parms instead of type_dependent_expression_p.

gcc/testsuite/ChangeLog:

	PR c++/98355
	* g++.dg/ext/builtin-has-attribute2.C: New test.
2021-02-01 10:09:11 -05:00
Jason Merrill
6e0a231a4a c++: alias in qualified-id in template arg [PR98570]
template_args_equal has handled dependent alias specializations for a while,
but in this testcase the actual template argument is a SCOPE_REF, so we
called cp_tree_equal, which doesn't handle aliases specially when we get to
them.

This patch generalizes this by setting a flag so structural_comptypes will
check for template alias equivalence (if we aren't doing partial ordering).
The existing flag, comparing_specializations, was too broad; in particular,
when we're doing decls_match, we want to treat corresponding parameters as
equivalent, so we need to separate that from alias comparison.  So I
introduce the comparing_dependent_aliases flag.

From looking at other uses of comparing_specializations, it seems to me that
the new flag is what modules wants, as well.

The other use of comparing_specializations in structural_comptypes is a hack
to deal with spec_hasher::equal not calling push_to_top_level, which we
also don't want to tie to the alias comparison semantics.

This patch also changes how we get to structural comparison of aliases from
checking TYPE_CANONICAL in comptypes to marking the aliases as getting
structural comparison when they are built, which is more consistent with how
e.g. typename is handled.

As I mention in the comment for comparing_dependent_aliases, I think the
default should be to treat different dependent aliases for the same type as
distinct, only treating them as equal during deduction (particularly partial
ordering).  But that's a matter for the C++ committee, to try in stage 1.

gcc/cp/ChangeLog:

	PR c++/98570
	* cp-tree.h: Declare it.
	* pt.c (comparing_dependent_aliases): New flag.
	(template_args_equal, spec_hasher::equal): Set it.
	(dependent_alias_template_spec_p): Assert that we don't
	get non-types other than error_mark_node.
	(instantiate_alias_template): SET_TYPE_STRUCTURAL_EQUALITY
	on complex alias specializations.  Set TYPE_DEPENDENT_P here.
	(tsubst_decl): Not here.
	* module.cc (module_state::read_cluster): Set
	comparing_dependent_aliases instead of
	comparing_specializations.
	* tree.c (cp_tree_equal): Remove comparing_specializations
	module handling.
	* typeck.c (structural_comptypes): Adjust.
	(comptypes): Remove comparing_specializations handling.

gcc/testsuite/ChangeLog:

	PR c++/98570
	* g++.dg/cpp0x/alias-decl-targ1.C: New test.
2021-02-01 09:49:42 -05:00
Jonathan Wright
bec5dbae56 testsuite: aarch64: Add tests for vmlXl_high intrinsics
Add tests for vmlal_high_* and vmlsl_high_* Neon intrinsics. Since
these intrinsics are only supported for AArch64, these tests are
restricted to only run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-01-31  Jonathan Wright  <jonathan.wright@arm.com>

	* gcc.target/aarch64/advsimd-intrinsics/vmlXl_high.inc:
	New test template.
	* gcc.target/aarch64/advsimd-intrinsics/vmlXl_high_lane.inc:
	New test template.
	* gcc.target/aarch64/advsimd-intrinsics/vmlXl_high_laneq.inc:
	New test template.
	* gcc.target/aarch64/advsimd-intrinsics/vmlXl_high_n.inc:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlal_high.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlal_high_lane.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlal_high_laneq.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlal_high_n.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlsl_high.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlsl_high_lane.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlsl_high_laneq.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmlsl_high_n.c:
	New test.
2021-02-01 14:13:59 +00:00
Jonathan Wright
8db8a00476 testsuite: aarch64: Add tests for vmull_high intrinsics
Add tests for vmull_high_* Neon intrinsics. Since these intrinsics
are only supported for AArch64, these tests are restricted to only
run on AArch64 targets.

gcc/testsuite/ChangeLog:

2021-01-29  Jonathan Wright  <jonathan.wright@arm.com>

	* gcc.target/aarch64/advsimd-intrinsics/vmull_high.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmull_high_lane.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmull_high_laneq.c:
	New test.
	* gcc.target/aarch64/advsimd-intrinsics/vmull_high_n.c:
	New test.
2021-02-01 14:13:04 +00:00
Tamar Christina
0a3eccb6ef AArch64: Change canonization of smlal and smlsl in order to be able to optimize the vec_dup
g:87301e3956d44ad45e384a8eb16c79029d20213a and
g:ee4c4fe289e768d3c6b6651c8bfa3fdf458934f4 changed the intrinsics to be
proper RTL but accidentally ended up creating a regression because of the
ordering in the RTL pattern.

The existing RTL that combine should try to match to remove the vec_dup is
aarch64_vec_<su>mlal_lane<Qlane> and aarch64_vec_<su>mult_lane<Qlane> which
expects the select register to be the second operand of mult.

The pattern introduced has it as the first operand so combine was unable to
remove the vec_dup.  This flips the order such that the patterns optimize
correctly.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (aarch64_<su>mlal_n<mode>,
	aarch64_<su>mlsl<mode>, aarch64_<su>mlsl_n<mode>): Flip mult operands.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/advsimd-intrinsics/smlal-smlsl-mull-optimized.c: New test.
2021-02-01 13:50:43 +00:00
Patrick Palka
1b303ef6cc c++: Add testcase for PR84494
We correctly accept this testcase ever since r10-5143.

gcc/testsuite/ChangeLog:

	PR c++/84494
	* g++.dg/cpp1y/constexpr-84494.C: New test.
2021-02-01 08:48:46 -05:00
Xing GUO
bbe6998b22 RISC-V: Fix gcc.target/riscv/attribute-18.c
gcc/testsuite/ChangeLog:

	* gcc.target/riscv/attribute-18.c: Add -mriscv-attribute option.
2021-02-01 17:35:48 +08:00
Richard Biener
972918eea8 rtl-optimization/98863 - prune RD with LIVE in STV
This sets DF_RD_PRUNE_DEAD_DEFS like all other uses of the UD/DU
chain problems which makes the RD problem consume a lot less memory.

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

	PR rtl-optimization/98863
	* config/i386/i386-features.c (convert_scalars_to_vector):
	Set DF_RD_PRUNE_DEAD_DEFS.
2021-02-01 09:21:26 +01:00
Xionghu Luo
b90d051ecb testsuite: Update pr79251 ilp32 store regex
BE ilp32 Linux generates extra stack stwu instructions which shouldn't
be counted in, \m … \M is needed around each instruction, not just the
beginning and end of the entire pattern.

gcc/testsuite/ChangeLog:

2021-02-01  Xionghu Luo  <luoxhu@linux.ibm.com>

	* gcc.target/powerpc/pr79251.p8.c: Update store count regex.
	* gcc.target/powerpc/pr79251.p9.c: Likewise.
2021-01-31 21:01:38 -06:00
GCC Administrator
94d5ba26f9 Daily bump. 2021-02-01 00:16:20 +00:00
Eric Botcazou
2b5af10348 Add missing definition of SIZE_MAX
If the stdint.h system file follows the ISO C99 specification, it might
not define SIZE_MAX in C++ by default, so provide a local fallback.

gcc/
	* system.h (SIZE_MAX): Define if not already defined.
2021-01-31 23:25:56 +01:00
Iain Sandoe
98342bdd2b testsuite, Darwin : Skip ELF-specific tests.
A number of ELF-specific tests were introduced in r11-6140, one
of which fails on all Mach-O/Darwin platforms.

On examination, the tests have no meaningful parallel for Mach-O
which dead strips at the symbol level, and does not make use of
function sections (the fact that a used and an unused symbol are
placed in the same section will not affect dead stripping).

Given that the tests do not demonstrate anything useful on Darwin,
skip them.

gcc/testsuite/ChangeLog:

	* c-c++-common/attr-used-5.c: Skip for Darwin.
	* c-c++-common/attr-used-6.c: Likewise.
	* c-c++-common/attr-used-7.c: Likewise.
	* c-c++-common/attr-used-8.c: Likewise.
	* c-c++-common/attr-used-9.c: Likewise.
2021-01-31 13:56:35 +00:00
GCC Administrator
5dfbad4f7c Daily bump. 2021-01-31 00:16:20 +00:00
David Edelsohn
245ccc8e6b testsuite: Update pr79251 ilp32 store counts.
With the recent changes to vector insert optimization, the number of
expected stores for the two testcases has changed.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr79251.p8.c: Update ilp32 store counts.
	* gcc.target/powerpc/pr79251.p9.c: Same.
2021-01-30 17:17:19 -05:00
Aaron Sawdey
1242eb75b3 Fusion patterns for logical-logical
This patch adds a new function to genfusion.pl to generate patterns for
logical-logical fusion. They are enabled by default for power10 and can
be disabled by -mno-power10-fusion-2logical or -mno-power10-fusion.

gcc/ChangeLog
	* config/rs6000/genfusion.pl (gen_2logical): New function to
	generate patterns for logical-logical fusion.
	* config/rs6000/fusion.md: Regenerated patterns.
	* config/rs6000/rs6000-cpus.def: Add
	OPTION_MASK_P10_FUSION_2LOGICAL.
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Enable logical-logical fusion for p10.
	* config/rs6000/rs6000.opt: Add -mpower10-fusion-2logical.
2021-01-30 15:52:27 -06:00
David Edelsohn
349b909bb3 aix: add periods to option explanation.
gcc/ChangeLog:

	* config/rs6000/rs6000.opt: Add periods to new AIX options.
2021-01-30 13:30:00 -05:00
David Edelsohn
2e7750cb51 aix: Permit use of AIX Vector extended ABI mode
AIX only permits use of Altivec VSRs 20-31 in a Vector Extended ABI mode.
This patch explicitly enables use of the VSRs using the new -mabi=vec-extabi
command line option also implemented in LLVM for AIX.

Bootstrapped on powerpc-ibm-aix7.2.3.0 and powerpc64le-linux-gnu.

gcc/ChangeLog:

	* config/rs6000/rs6000.opt (mabi=vec-extabi): New.
	(mabi=vec-default): New.
	* config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
	__EXTABI__ for AIX Vector extended ABI.
	* config/rs6000/rs6000.c (rs6000_debug_reg_global): Print AIX Vector
	extabi info.
	(conditional_register_usage): If AIX vec_extabi enabled, vs20-vs31
	are non-volatile.
	* doc/invoke.texi (PowerPC mabi): Add AIX vec-extabi and vec-default.
2021-01-30 12:08:00 -05:00
Iain Buclaw
92dd3e71f9 libphobos: Synchronize libdruntime bindings with upstream druntime
Reviewed-on: https://github.com/dlang/druntime/pull/3348

gcc/d/ChangeLog:

	* typeinfo.cc (TypeInfoVisitor::visit (TypeInfoDeclaration *)): Don't
	layout m_arg1 and m_arg2 fields.

libphobos/ChangeLog:

	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* libdruntime/MERGE: Merge upstream druntime e4aae28e.
	* libdruntime/Makefile.am (DRUNTIME_DSOURCES): Refresh module list.
	(DRUNTIME_DSOURCES_BIONIC): Add core/sys/bionic/err.d.
	(DRUNTIME_DSOURCES_DARWIN): Add core/sys/darwin/err.d,
	core/sys/darwin/ifaddrs.d, core/sys/darwin/mach/nlist.d,
	core/sys/darwin/mach/stab.d, and core/sys/darwin/sys/attr.d.
	(DRUNTIME_DSOURCES_DRAGONFLYBSD): Add core/sys/dragonflybsd/err.d.
	(DRUNTIME_DSOURCES_FREEBSD): Add core/sys/freebsd/err.d.
	(DRUNTIME_DSOURCES_LINUX): Add core/sys/linux/err.d.
	(DRUNTIME_DSOURCES_NETBSD): Add core/sys/netbsd/err.d.
	(DRUNTIME_DSOURCES_OPENBSD): Add core/sys/openbsd/err.d.
	(DRUNTIME_DSOURCES_POSIX): Add core/sys/posix/locale.d,
	core/sys/posix/stdc/time.d, core/sys/posix/string.d, and
	core/sys/posix/strings.d.
	(DRUNTIME_DSOURCES_SOLARIS): Add core/sys/solaris/err.d.
	(DRUNTIME_DSOURCES_WINDOWS): Add core/sys/windows/sdkddkver.d,
	and core/sys/windows/stdc/time.d
	* libdruntime/Makefile.in: Regenerate.
	* libdruntime/gcc/sections/elf_shared.d (sizeofTLS): New function.
	* testsuite/libphobos.thread/fiber_guard_page.d: Use
	__traits(getMember) to get internal fields.
2021-01-30 16:50:57 +01:00
Jakub Jelinek
accc5ba53e i386, df: Fix up gcc.c-torture/compile/20051216-1.c -O1 -march=cascadelake
>     rtl-optimization/98863 - tame i386 specific RPAD pass
>
> caused
>
> FAIL: gcc.c-torture/compile/20051216-1.c   -O1  (internal compiler error)
> FAIL: gcc.c-torture/compile/20051216-1.c   -O1  (test for excess errors)

The problem is that we don't revert the df flags back.
This patch fixes it by clearing DF_DEFER_INSN_RESCAN after
calling df_process_deferred_rescans, so that it doesn't leak into following
unprepared passes that expect non-deferred rescans.

2021-01-30  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386-features.c (remove_partial_avx_dependency): Clear
	DF_DEFER_INSN_RESCAN after calling df_process_deferred_rescans.

	* gcc.target/i386/20051216-1.c: New test.
2021-01-30 14:58:14 +01:00
Jakub Jelinek
25f303e9a2 testsuite: Fix up gomp/simd-{2,3}.c tests [PR98243]
The test (intentionally) is not gcc.dg/vect/, as it needs -fopenmp and uses
OpenMP directives other than simd and therefore can't rely on default
VECTFLAGS and so I think can't safely use vect_int effective target
either.  So, I'm just making sure it is vectorized on x86 and on aarch64 (the
latter as an example of a target that doesn't need any extra options to get
the vectorization).

2021-01-30  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/98243
	* gcc.dg/gomp/simd-2.c: Add -msse2 on x86.  Restrict
	scan-tree-dump-times to x86 and aarch64 targets.
	* gcc.dg/gomp/simd-3.c: Likewise.
2021-01-30 10:52:57 +01:00
GCC Administrator
2900f2f2c5 Daily bump. 2021-01-30 00:16:19 +00:00
Clément Chigot
4d31df4089 internal/cpu: correctly link to getsystemcfg
Directly set getsystemcfg as //extern in internal/cpu instead of
trying to use the runtime as in Go toolchain.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/287932
2021-01-29 16:12:43 -08:00
Michael Meissner
d761172d9b PR testsuite/98870: Fix IEEE 128-bit fortran test
This test started failing when I changed the mapping of IEEE 128-bit long
double built-in functions on 2021-01-28.  This patch fixes the test so it
uses the correct name.

gcc/testsuite/
2021-01-29  Michael Meissner  <meissner@linux.ibm.com>

	PR testsuite/98870
	* gcc.target/powerpc/ppc-fortran/ieee128-math.f90: Fix the
	expected result.
2021-01-29 17:44:54 -05:00
Will Schmidt
fa00e35c17 [PATCH, rs6000] Fix typo in gcc.target/pr91903.c dg-require stanza
Fix obvious typo in testcases dg-require stanza.

2021-01-29  Will Schmidt <will_schmidt@vnet.ibm.como>

gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/pr91903.c: Fix dg-require stanza.
2021-01-29 16:24:47 -06:00
Vladimir N. Makarov
0202fa3d63 [PR97701] Modify test for trunk
Original test was for gcc-10.  The modified one for trunk.

gcc/testsuite/ChangeLog:

	PR target/97701
	* gcc.target/aarch64/pr97701.c: Modify.
2021-01-29 16:05:58 -05:00
David Malcolm
eb06fdd424 analyzer: consolidate conditionals in paths
This patch adds a simplification to analyzer paths for
repeated CFG edges generated from compound conditionals.
For example, it simplifies:

    |    5 |   if (a && b && c)
    |      |      ^~~~~~~~~~~~
    |      |      |  |    |
    |      |      |  |    (4) ...to here
    |      |      |  |    (5) following ‘true’ branch (when ‘c != 0’)...
    |      |      |  (2) ...to here
    |      |      |  (3) following ‘true’ branch (when ‘b != 0’)...
    |      |      (1) following ‘true’ branch (when ‘a != 0’)...
    |    6 |     __analyzer_dump_path ();
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (6) ...to here

to:

    |    5 |   if (a && b && c)
    |      |      ^
    |      |      |
    |      |      (1) following ‘true’ branch...
    |    6 |     __analyzer_dump_path ();
    |      |     ~~~~~~~~~~~~~~~~~~~~~~~
    |      |     |
    |      |     (2) ...to here

gcc/analyzer/ChangeLog:
	* checker-path.cc (event_kind_to_string): Handle
	EK_START_CONSOLIDATED_CFG_EDGES and
	EK_END_CONSOLIDATED_CFG_EDGES.
	(start_consolidated_cfg_edges_event::get_desc): New.
	(checker_path::cfg_edge_pair_at_p): New.
	* checker-path.h (enum event_kind): Add
	EK_START_CONSOLIDATED_CFG_EDGES and
	EK_END_CONSOLIDATED_CFG_EDGES.
	(class start_consolidated_cfg_edges_event): New class.
	(class end_consolidated_cfg_edges_event): New class.
	(checker_path::delete_events): New.
	(checker_path::replace_event): New.
	(checker_path::cfg_edge_pair_at_p): New decl.
	* diagnostic-manager.cc (diagnostic_manager::prune_path): Call
	consolidate_conditions.
	(same_line_as_p): New.
	(diagnostic_manager::consolidate_conditions): New.
	* diagnostic-manager.h
	(diagnostic_manager::consolidate_conditions): New decl.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/combined-conditionals-1.c: New test.
2021-01-29 15:12:24 -05:00
Vladimir N. Makarov
7f9f83ef30 [PR97701] LRA: Don't narrow class only for REG or MEM.
Reload pseudos of ALL_REGS class did not narrow class from constraint
in insn (set (pseudo) (lo_sum ...)) because lo_sum is considered an
object (OBJECT_P) although the insn is not a classic move.  To permit
narrowing we are starting to use MEM_P and REG_P instead of OBJECT_P.

gcc/ChangeLog:

	PR target/97701
	* lra-constraints.c (in_class_p): Don't narrow class only for REG
	or MEM.

gcc/testsuite/ChangeLog:

	PR target/97701
	* gcc.target/aarch64/pr97701.c: New.
2021-01-29 14:54:41 -05:00
Ian Lance Taylor
726b7aa004 libgo: update to Go1.16rc1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/287493
2021-01-29 11:04:55 -08:00
Will Schmidt
91a95ad2ae [PATCH, rs6000] improve vec_ctf invalid parameter handling.
Hi,
  Per PR91903, GCC ICEs when we attempt to pass a variable
(or out of range value) into the vec_ctf() builtin.  Per
investigation, the parameter checking exists for this
builtin with the int types, but was missing for
the long long types. This problem also occurs for the
vec_cts() builtin, which is also fixed by this patch.

This patch adds the missing CODE_FOR_* entries to the
rs6000_expand_binup_builtin to cover that scenario.
This patch also updates some existing tests to remove
calls to vec_ctf() and vec_cts() that contain negative
values.

PR target/91903

2020-01-29  Will Schmidt  <will_schmidt@vnet.ibm.com>

gcc/ChangeLog:
	* config/rs6000/rs6000-call.c (rs6000_expand_binup_builtin): Add
	clauses for CODE_FOR_vsx_xvcvuxddp_scale and
	CODE_FOR_vsx_xvcvsxddp_scale to the parameter checking code.

gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/pr91903.c: New test.
	* gcc.target/powerpc/builtins-1.fold.h: Update.
	* gcc.target/powerpc/builtins-2.c: Update.
2021-01-29 11:34:59 -06:00
Nathan Sidwell
83bdc9f703 c++: Fix unordered entity array [PR 98843]
A couple of module invariants are that the modules are always
allocated in ascending order and appended to the module array.  The
entity array is likewise ordered, with each module having spans in
that array in ascending order.  Prior to header-units, this was
provided by the way import declarations were encountered.  With
header-units we need to load the preprocessor state of header units
before we parse the C++, and this can lead to incorrect ordering of
the entity array.  I had made the initialization of a module's
language state a little too lazy.  This moves the allocation of entity
array spans into the initial read of a module, thus ensuring the
ordering of those spans.  We won't be looking in them until we've
loaded the language portions of that particular module, and even if we
did, we'd find NULLs there and issue a diagnostic.

	PR c++/98843
	gcc/cp/
	* module.cc (module_state_config): Add num_entities field.
	(module_state::read_entities): The entity_ary span is
	already allocated.
	(module_state::write_config): Write num_entities.
	(module_state::read_config): Read num_entities.
	(module_state::write): Set config's num_entities.
	(module_state::read_initial): Allocate the entity ary
	span here.
	(module_state::read_language): Do not set entity_lwm
	here.
	gcc/testsuite/
	* g++.dg/modules/pr98843_a.C: New.
	* g++.dg/modules/pr98843_b.H: New.
	* g++.dg/modules/pr98843_c.C: New.
2021-01-29 09:11:46 -08:00
Andrew MacLeod
2dd1f94454 tree-optimization/98866 - Compile time hog in VRP
Don't track [1, +INF] for pointer types, treat them as invariant for caching
purposes as they cannot be further refined without evaluating to UNDEFINED.

	PR tree-optimization/98866
	* gimple-range-gori.h (gori_compute:set_range_invariant): New.
	* gimple-range-gori.cc (gori_map::set_range_invariant): New.
	(gori_map::m_maybe_invariant): Rename from all_outgoing.
	(gori_map::gori_map): Rename all_outgoing to m_maybe_invariant.
	(gori_map::is_export_p): Ditto.
	(gori_map::calculate_gori): Ditto.
	(gori_compute::set_range_invariant): New.
	* gimple-range.cc (gimple_ranger::range_of_stmt): Set range
	invariant for pointers evaluating to [1, +INF].
2021-01-29 11:47:18 -05:00
Richard Biener
a7f52181a6 rtl-optimization/98863 - tame i386 specific RPAD pass
This removes analyzing DF with expensive problems which we do not
use at all and which somehow cause 5GB of memory to leak.  Instead
just do a defered rescan of added insns.

2021-01-29  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/98863
	* config/i386/i386-features.c (remove_partial_avx_dependency):
	Do not perform DF analysis.
	(pass_data_remove_partial_avx_dependency): Remove
	TODO_df_finish.
2021-01-29 17:32:19 +01:00
Jonathan Wright
ee4c4fe289 aarch64: Use RTL builtins for [su]mull_n intrinsics
Rewrite [su]mull_n Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-19  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add [su]mull_n
	builtin generator macros.
	* config/aarch64/aarch64-simd.md (aarch64_<su>mull_n<mode>):
	Define.
	* config/aarch64/arm_neon.h (vmull_n_s16): Use RTL builtin
	instead of inline asm.
	(vmull_n_s32): Likewise.
	(vmull_n_u16): Likewise.
	(vmull_n_u32): Likewise.
2021-01-29 13:53:44 +00:00
Kyrylo Tkachov
9b588cfb42 aarch64: Reimplement vabdl_high* intrinsics using builtins
This patch reimplements the vabdl_high intrinsics using builtins.
It slightly cleans up the RTL pattern (the mode iterators) but nothing
interesting apart from that.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (sabdl2, uabdl2):
	Define builtins.
	* config/aarch64/aarch64-simd.md (aarch64_<sur>abdl2<mode>_3):
	Rename to...
	(aarch64_<sur>abdl2<mode>): ... This.
	(<sur>sadv16qi): Adjust use of above.
	* config/aarch64/arm_neon.h (vabdl_high_s8): Reimplement using
	builtin.
	(vabdl_high_s16): Likewise.
	(vabdl_high_s32): Likewise.
	(vabdl_high_u8): Likewise.
	(vabdl_high_u16): Likewise.
	(vabdl_high_u32): Likewise.
2021-01-29 13:49:19 +00:00
Kyrylo Tkachov
9f499a86b2 aarch64: Re-implement vabal_high* intrinsics using builtins
This patch reimplements the vabal_high* intrinsics using RTL builtins.
It's straightforward, defining new unspecs and a new pattern.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (sabal2): Define
	builtin.
	(uabal2): Likewise.
	* config/aarch64/aarch64-simd.md (aarch64_<sur>abal2<mode>): New
	pattern.
	* config/aarch64/aarch64.md (unspec): Add UNSPEC_SABAL2 and
	UNSPEC_UABAL2.
	* config/aarch64/arm_neon.h (vabal_high_s8): Reimplement using
	builtin.
	(vabal_high_s16): Likewise.
	(vabal_high_s32): Likewise.
	(vabal_high_u8): Likewise.
	(vabal_high_u16): Likewise.
	(vabal_high_u32): Likewise.
	* config/aarch64/iterators.md (ABAL2): New mode iterator.
	(sur): Handle UNSPEC_SABAL2, UNSPEC_UABAL2.
2021-01-29 13:49:19 +00:00
Kyrylo Tkachov
d5e0d1f1d2 aarch64: Reimplement vabal* intrinsics using builtins
This patch reimplements the vabal intrinsics with builtins.
The RTL pattern is cleaned up to emit the right .8b suffixes for the
inputs (though .16b is also accepted)
and iterate over the right modes. The pattern's only other use is
through the sadv16qi expander, which is adjusted.

I've verified that the codegen for sadv16qi is not worse off.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (sabal): Define
	builtin.
	(uabal): Likewise.
	* config/aarch64/aarch64-simd.md (aarch64_<sur>abal<mode>_4):
	Rename to...
	(aarch64_<sur>abal<mode>): ... This
	(<sur>sadv16qi): Adust use of the above.
	* config/aarch64/arm_neon.h (vabal_s8): Reimplement using
	builtin.
	(vabal_s16): Likewise.
	(vabal_s32): Likewise.
	(vabal_u8): Likewise.
	(vabal_u16): Likewise.
	(vabal_u32): Likewise.
2021-01-29 13:49:19 +00:00
Kyrylo Tkachov
cb995de62a aarch64: Reimplement vaddlv* intrinsics using builtins
This patch reimplements the vaddlv* intrinsics using builtins.
The vaddlv_s32 and vaddlv_u32 intrinsics actually perform a pairwise
SADDLP/UADDLP instead of a SADDLV/UADDLV but because they only use
two elements it has the same semantics.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (saddlv, uaddlv):
	Define builtins.
	* config/aarch64/aarch64-simd.md (aarch64_<su>addlv<mode>):
	Define.
	* config/aarch64/arm_neon.h (vaddlv_s8): Reimplement using
	builtin.
	(vaddlv_s16): Likewise.
	(vaddlv_u8): Likewise.
	(vaddlv_u16): Likewise.
	(vaddlvq_s8): Likewise.
	(vaddlvq_s16): Likewise.
	(vaddlvq_s32): Likewise.
	(vaddlvq_u8): Likewise.
	(vaddlvq_u16): Likewise.
	(vaddlvq_u32): Likewise.
	(vaddlv_s32): Likewise.
	(vaddlv_u32): Likewise.
	* config/aarch64/iterators.md (VDQV_L): New mode iterator.
	(unspec): Add UNSPEC_SADDLV, UNSPEC_UADDLV.
	(Vwstype): New mode attribute.
	(Vwsuf): Likewise.
	(VWIDE_S): Likewise.
	(USADDLV): New int iterator.
	(su): Handle UNSPEC_SADDLV, UNSPEC_UADDLV.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/simd/vaddlv_1.c: New test.
2021-01-29 13:49:19 +00:00
Jonathan Wright
e053f96a9f aarch64: Use RTL builtins for [su]mlsl_lane[q] intrinsics
Rewrite [su]mlsl_lane[q] Neon intrinsics to use RTL builtins rather
than inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-28  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add [su]mlsl_lane[q]
	builtin generator macros.
	* config/aarch64/aarch64-simd.md (aarch64_vec_<su>mlsl_lane<Qlane>):
	Define.
	* config/aarch64/arm_neon.h (vmlsl_lane_s16): Use RTL builtin
	instead of inline asm.
	(vmlsl_lane_s32): Likewise.
	(vmlsl_lane_u16): Likewise.
	(vmlsl_lane_u32): Likewise.
	(vmlsl_laneq_s16): Likewise.
	(vmlsl_laneq_s32): Likewise.
	(vmlsl_laneq_u16): Likewise.
	(vmlsl_laneq_u32): Likewise.
2021-01-29 13:42:00 +00:00
Richard Biener
0833e3e1ff change unit of --param max-gcse-memory to kB
This changes it from bytes to kB since its value is limited to
2147483648.

2021-01-29  Richard Biener  <rguenther@suse.de>

	* doc/invoke.texi (--param max-gcse-memory): Document unit
	of size.
	* gcse.c (gcse_or_cprop_is_too_expensive): Adjust.
	* params.opt (--param max-gcse-memory): Adjust default and
	document unit of size.
2021-01-29 14:01:21 +01:00
Richard Biener
cb52e59e33 rtl-optimization/98863 - fix PRE/CPROP memory usage check
This fixes overflow of the memory usage estimate in turn failing
to disable itself on WRF with LTO, causing a few GBs worth of
memory peak.

2021-01-29  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/98863
	* gcse.c (gcse_or_cprop_is_too_expensive): Use unsigned
	HOST_WIDE_INT for the memory estimate.
2021-01-29 14:01:21 +01:00
Richard Biener
f4e426f7bd tree-optimization/97627 - Avoid computing niters for fake edges
This avoids computing niters information for fake edges.

2021-01-29  Bin Cheng  <bin.cheng@linux.alibaba.com>
	    Richard Biener  <rguenther@suse.de>

	PR tree-optimization/97627
	* tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions):
	Do not analyze fake edges.

	* g++.dg/pr97627.C: New testcase.
2021-01-29 12:09:10 +01:00
Richard Biener
a8c455bafd rtl-optimization/98144 - tame REE memory usage
This changes the REE dataflow to change the explicit all-ones
starting solution to be implicit via a visited flag, removing
the need to initially start with fully populated bitmaps for
all basic-blocks.  That reduces peak memory use when compiling
the RTL checking enabled insn-extract.c testcase from PR98144
from 6GB to less than 2GB.

2021-01-29  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/98144
	* df.h (df_mir_bb_info): Add con_visited member.
	* df-problems.c (df_mir_alloc): Initialize con_visited,
	do not fully populate IN and OUT.
	(df_mir_reset): Likewise.
	(df_mir_confluence_0): Set con_visited.
	(df_mir_confluence_n): Properly handle implicitely
	fully populated IN and OUT as designated by con_visited
	and update con_visited accordingly.
2021-01-29 12:01:58 +01:00
Jakub Jelinek
e7429bc9d6 arm: Fix up -mcpu=iwmmxt ICEs [PR98849]
The
https://gcc.gnu.org/r11-6707-g7432f255b70811dafaf325d94036ac580891de69
https://gcc.gnu.org/r11-6708-gbfab355012ca0f5219da8beb04f2fdaf757d34b7
changes moved the vashl/vashr/vlshr expanders from neon.md to vec-common.md
and changed their condition from TARGET_NEON to ARM_HAVE_<MODE>_ARITH,
so that they apply also for TARGET_HAVE_MVE.  But, the ARM_HAVE_<MODE>_ARITH
macros are sometimes true also for TARGET_REALLY_IWMMXT, which at least
from quick skimming of former iwmmxt*.md doesn't have such instructions,
so it seems incorrect to enable them for iwmmxt.  Furthermore, even if it
had them, iwmmxt doesn't support any way to broadcast values in those
modes (vec_duplicate and vec_init optabs) and the middle end relies on
if the vector x vector shift/rotate patterns are supported it can emit
vector x scalar shift/rotate by broadcasting the shift amount to a vector.

As the TARGET_NEON vs. TARGET_REALLY_IWMMXT vs. TARGET_HAVE_MVE never seem
to be enabled together, I think we can just write it the following way.

Note, seems iwmmxt actually does support vector x scalar shifts, but doesn't
really enable the optabs that would tell the middle-end code that it does
(and neon and mve don't seem to support those).  I'll defer that to anybody
that cares about iwmmxt (if any).

2021-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR target/98849
	* config/arm/vec-common.md (mve_vshlq_<supf><mode>,
	vashl<mode>3, vashr<mode>3, vlshr<mode>3): Add
	&& !TARGET_REALLY_IWMMXT to conditions.

	* gcc.c-torture/compile/pr98849.c: New test.
2021-01-29 11:54:22 +01:00
Jakub Jelinek
9c445c07cd expand: Fix up find_bb_boundaries [PR98331]
When expansion emits some control flow insns etc. inside of a former GIMPLE
basic block, find_bb_boundaries needs to split it into multiple basic
blocks.
The code needs to ignore debug insns in decisions how many splits to do or
where in between some non-debug insns the split should be done, but it can
decide where to put debug insns if they can be kept and otherwise throws
them away (they can't stay outside of basic blocks).
On the following testcase, we end up in the bb from expander with
control flow insn
debug insns
barrier
some other insn
(the some other insn is effectively dead after __builtin_unreachable and
we'll optimize that out later).
Without debug insns, we'd do the split when encountering some other insn
and split after PREV_INSN (some other insn), i.e. after barrier (and the
splitting code then moves the barrier in between basic blocks).
But if there are debug insns, we actually split before the first debug insn
that appeared after the control flow insn, so after control flow insn,
and get a basic block that starts with debug insns and then has a barrier
in the middle that nothing moves it out of the bb.  This leads to ICEs and
even if it wouldn't, different behavior from -g0.
The reason for treating debug insns that way is a different case, e.g.
control flow insn
debug insns
some other insn
or even
control flow insn
barrier
debug insns
some other insn
where splitting before the first such debug insn allows us to keep them
while otherwise we would have to drop them on the floor, and in those
situations we behave the same with -g0 and -g.

So, the following patch fixes it by resetting debug_insn not just when
splitting the blocks (it is set only after seeing a control flow insn and
before splitting for it if needed), but also when seeing a barrier,
which effectively means we always throw away debug insns after a control
flow insn and before following barrier if any, but there is no way around
that, control flow insn must be the last in the bb (BB_END) and BARRIER
after it, debug insns aren't allowed outside of bb.
We still handle the other cases fine (when there is no barrier or when
debug insns appear only after the barrier).

2021-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98331
	* cfgbuild.c (find_bb_boundaries): Reset debug_insn when seeing
	a BARRIER.

	* gcc.dg/pr98331.c: New test.
2021-01-29 10:30:09 +01:00
Xionghu Luo
280a59d921 testsuite: Run vec_insert case on P8 and P9 with option specified
Move run_test and TEST_VEC_INSERT_ALL to header file for share usage.

gcc/testsuite/ChangeLog:

2021-01-29  Xionghu Luo  <luoxhu@linux.ibm.com>

	* gcc.target/powerpc/pr79251.p8.c: Move TEST_VEC_INSERT_ALL
	to ...
	* gcc.target/powerpc/pr79251.h: ...this.
	* gcc.target/powerpc/pr79251.p9.c: Likewise.
	* gcc.target/powerpc/pr79251-run.c: Move run_test to pr79251.h.
	Rename to...
	* gcc.target/powerpc/pr79251-run.p8.c: ...this.
	* gcc.target/powerpc/pr79251-run.p9.c: New test.
2021-01-29 01:33:09 -06:00
Marek Polacek
f8f5388c9e c++: Fix infinite looping with invalid operator [PR96137]
My r11-86 adjusted cp_parser_class_name to do

-  scope = parser->scope;
+  scope = parser->scope ? parser->scope : parser->context->object_type;
   if (scope == error_mark_node)
     return error_mark_node;

but that caused endless looping in cp_parser_type_specifier_seq (the
while (true) loop) in this invalid test, because we never set a parser
error, therefore cp_parser_type_specifier returned error_mark_node
instead of NULL_TREE, and we never issued the "expected type-specifier"
error.

At first I thought I'd just add cp_parser_simulate_error right before
the return, but that regresses crash81.C -- we'd emit multiple errors
for "T::X".  So the next best thing seemed to revert to pre-r11-86
behavior: return early when parser->scope is bad, otherwise proceed to
get the parser error.

gcc/cp/ChangeLog:

	PR c++/96137
	* parser.c (cp_parser_class_name): If parser->scope is
	error_mark_node, return it, otherwise continue.

gcc/testsuite/ChangeLog:

	PR c++/96137
	* g++.dg/parse/error63.C: New test.
2021-01-28 23:29:35 -05:00
GCC Administrator
85d04a2ecb Daily bump. 2021-01-29 00:16:21 +00:00
Ian Lance Taylor
e6bce7fe17 gccgo driver: always act as though -g is passed
The go1 compiler always turns on debugging, to support Go stack traces
and functions like runtime.Callers.  With the recent switch to turn on
DWARF 5 by default, this caused failures with some versions of gas,
such as 2.35.1, because the assembly code would assume DWARF 5 but the
driver would not pass --gdwarf-5 to gas.  gas would then give an
error: "file number less than one".

This change avoids that problem by having the gccgo driver spec add a
-g option to the command line if no other -g option is present.  The
newly added -g option is passed to the assembler as --gdwarf-5.

	* gospec.c (lang_specific_driver): Add -g if no debugging options
	were passed.
2021-01-28 15:54:03 -08:00
Jakub Jelinek
850a8ec54c c++: Fix -Weffc++ in templates [PR98841]
We emit a bogus warning on the following testcase, suggesting that the
operator should return *this even when it does that already.
The problem is that normally cp_build_indirect_ref_1 ensures that *this
is folded as current_class_ref, but in templates (if return type is
non-dependent, otherwise check_return_expr doesn't check it) it didn't
go through cp_build_indirect_ref_1, but just built another INDIRECT_REF.
Which means it then doesn't compare pointer-equal to current_class_ref.

The following patch fixes it by doing in build_x_indirect_ref for
*this what cp_build_indirect_ref_1 would do.

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

	PR c++/98841
	* typeck.c (build_x_indirect_ref): For *this, return current_class_ref.

	* g++.dg/warn/effc5.C: New test.
2021-01-29 00:39:00 +01:00
Marek Polacek
513ee7d2cd tree: Don't reuse types if TYPE_USER_ALIGN differ [PR94775]
A year ago I submitted this patch:

~~
Here we trip on the TYPE_USER_ALIGN (t) assert in strip_typedefs: it
gets "const d[0]" with TYPE_USER_ALIGN=0 but the result built by
build_cplus_array_type is "const char[0]" with TYPE_USER_ALIGN=1.

When we strip_typedefs the element of the array "const d", we see it's
a typedef_variant_p, so we look at its DECL_ORIGINAL_TYPE, which is
char, but we need to add the const qualifier, so we call
cp_build_qualified_type -> build_qualified_type
where get_qualified_type checks to see if we already have such a type
by walking the variants list, which in this case is:

  char -> c -> const char -> const char -> d -> const d

Because check_base_type only checks TYPE_ALIGN and not TYPE_USER_ALIGN,
we choose the first const char, which has TYPE_USER_ALIGN set.  If the
element type of an array has TYPE_USER_ALIGN, the array type gets it too.

So we can make check_base_type stricter.  I was afraid that it might make
us reuse types less often, but measuring showed that we build the same
amount of types with and without the patch, while bootstrapping.
~~

However, the patch broke a few tests on STRICT_ALIGNMENT platforms and
had to be reverted.  This is another try.  The original patch is kept
unchanged, but I added the finalize_type_size hunk that ought to fix the
STRICT_ALIGNMENT issues.

The problem is that finalize_type_size can clear TYPE_USER_ALIGN on the
main variant of a type, but doesn't clear it on any of the variants.
Then we end up with types which share the same TYPE_MAIN_VARIANT, but
their TYPE_CANONICAL differs and then the usual "canonical types differ
for identical types" follows.

I've created alignas19.C to exercise this scenario.  What happens is:
- when parsing the class S we create a type S in xref_tag,
- we see alignas(8) so common_handle_aligned_attribute sets T_U_A in S,
- we parse the member function fn and build_memfn_type creates a copy
  of S to add const; this variant has T_U_A set,
- we finish_struct S which calls layout_class_type -> finish_record_type
  -> finalize_size_type where we reset T_U_A in S (but const S keeps it),
- finish_non_static_data_member for arr calls maybe_dummy_object with
  type = S,
- maybe_dummy_object calls same_type_ignoring_top_level_qualifiers_p
  to check if S and TREE_TYPE (current_class_ref), which is const S,
  are the same,
- same_type_ignoring_top_level_qualifiers_p creates cv-unqualified
  versions of the passed types.  Previously we'd use our main variant
  S when stripping "const S" of const, but since the T_U_A flags don't
  match (check_base_type), we create a new variant S'.  Then we crash in
  comptypes because S and S' have the same TYPE_MAIN_VARIANT but
  different TYPE_CANONICALs.

With my patch we'll clear T_U_A for S's variants too, and then instead
of S' we'll just use S.

gcc/ChangeLog:

	PR c++/94775
	* stor-layout.c (finalize_type_size): If we reset TYPE_USER_ALIGN in
	the main variant, maybe reset it in its variants too.
	* tree.c (check_base_type): Return true only if TYPE_USER_ALIGN match.
	(check_aligned_type): Check if TYPE_USER_ALIGN match.

gcc/testsuite/ChangeLog:

	PR c++/94775
	* g++.dg/cpp0x/alignas19.C: New test.
	* g++.dg/warn/Warray-bounds15.C: New test.
2021-01-28 16:21:50 -05:00
Jonathan Wakely
a054608c9c libstdc++: Fix copyright dates for simd headers and tests
libstdc++-v3/ChangeLog:

	* include/experimental/bits/numeric_traits.h: Update copyright
	dates.
	* include/experimental/bits/simd.h: Likewise.
	* include/experimental/bits/simd_builtin.h: Likewise.
	* include/experimental/bits/simd_converter.h: Likewise.
	* include/experimental/bits/simd_detail.h: Likewise.
	* include/experimental/bits/simd_fixed_size.h: Likewise.
	* include/experimental/bits/simd_math.h: Likewise.
	* include/experimental/bits/simd_neon.h: Likewise.
	* include/experimental/bits/simd_ppc.h: Likewise.
	* include/experimental/bits/simd_scalar.h: Likewise.
	* include/experimental/bits/simd_x86.h: Likewise.
	* include/experimental/bits/simd_x86_conversions.h: Likewise.
	* include/experimental/simd: Likewise.
	* testsuite/experimental/simd/*: Likewise.
2021-01-28 18:13:03 +00:00
Christophe Lyon
31a0ab9213 arm: Adjust cost of vector of constant zero
Neon vector comparisons have a dedicated version when comparing with
constant zero: it means its cost is free.

Adjust the cost in arm_rtx_costs_internal accordingly, for Neon only,
since MVE does not support this.

2021-01-28  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	PR target/98730
	* config/arm/arm.c (arm_rtx_costs_internal): Adjust cost of vector
	of constant zero for comparisons.

	gcc/testsuite/
	PR target/98730
	* gcc.target/arm/simd/vceqzq_p64.c: Update expected result.
2021-01-28 17:55:45 +00:00
David Edelsohn
e28bd09498 testsuite: Fix up a testcase to find the right ISO_Fortran_binding.h.
gcc/testsuite/ChangeLog:

	* gfortran.dg/ISO_Fortran_binding_18.c: Include
	../../../libgfortran/ISO_Fortran_binding.h rather than
	ISO_Fortran_binding.h.
2021-01-28 12:44:30 -05:00
Michael Meissner
e11e5d3889 Map long double built-ins correctly with IEEE 128-bit long double.
The PowerPC has two different 128-bit long double types, one that uses a pair
of doubles to get more mantissa range, and the other using the IEEE 128-bit
754R binary floating point format.  The pair of doubles has been used as the
traditional format, and we are in the process of moving to allow an
implementation to switch to using IEEE 128-bit floating point.  The GLIBC and
LIBSTDC++ libraries have been modified to have functions using the two
different formats in their libraries with different names.

This patch goes through all of the built-in functions that either take long
double arguments or return long double, and changes the name from the
traditional name to the IEEE 128-bit name.  The minimum GLIBC version to
support IEEE 128-bit floating point is 2.32.

The names changed are:

    *	<name>l is usually mapped to __<name>ieee128;
    *	<extra>printf is mapped to __<extra>printfieee128; (and)
    *	<extra>scanf is mapped to __isoc99_<extra>scanfieee128.

A few functions have different mappings:

    *	dreml		=> __remainderieee128;
    *	gammal		=> __lgammaieee128;
    *	gammal_r	=> __lgammaieee128_r;
    *	lgammal_r	=> __lgammaieee128_r;
    *	nexttoward	=> __nexttoward_to_ieee128;
    *	nexttowardf	=> __nexttowardf_to_ieee128;
    *	nexttowardl	=> __nexttowardl_to_ieee128;
    *	pow10l		=> __exp10ieee128;
    *	scalbl		=> __scalbieee128;
    *	significandl	=> __significandieee128; (and)
    *	sincosl		=> __sincosieee128.

gcc/
2021-01-28  Michael Meissner  <meissner@linux.ibm.com>

	* config/rs6000/rs6000.c (rs6000_mangle_decl_assembler_name): Add
	support for mapping built-in function names for long double
	built-in functions if long double is IEEE 128-bit.

gcc/testsuite/
2021-01-28  Michael Meissner  <meissner@linux.ibm.com>

	* gcc.target/powerpc/float128-longdouble-math.c: New test.
	* gcc.target/powerpc/float128-longdouble-stdio.c: New test.
	* gcc.target/powerpc/float128-math.c: Adjust test for new name
	being generated.  Add support for running test on power10.  Add
	support for running if long double defaults to 64-bits.
2021-01-28 11:30:46 -05:00
Jakub Jelinek
6bb207b468 c++: Fix up handling of register ... asm ("...") vars in templates [PR33661, PR98847]
As the testcase shows, for vars appearing in templates, we don't attach
the asm spec string to the pattern decls, nor pass it back to cp_finish_decl
during instantiation.

The following patch does that.

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

	PR c++/33661
	PR c++/98847
	* decl.c (cp_finish_decl): For register vars with asmspec in templates
	call set_user_assembler_name and set DECL_HARD_REGISTER.
	* pt.c (tsubst_expr): When instantiating DECL_HARD_REGISTER vars,
	pass asmspec_tree to cp_finish_decl.

	* g++.target/i386/pr98847.C: New test.
2021-01-28 16:13:11 +01:00
Jonathan Wright
8a8e515c2b aarch64: Use RTL builtins for [su]mlsl_n intrinsics
Rewrite [su]mlsl_n Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-27  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add [su]mlsl_n
	builtin generator macros.
	* config/aarch64/aarch64-simd.md (aarch64_<su>mlsl_n<mode>):
	Define.
	* config/aarch64/arm_neon.h (vmlsl_n_s16): Use RTL builtin
	instead of inline asm.
	(vmlsl_n_s32): Likewise.
	(vmlsl_n_u16): Likewise.
	(vmlsl_n_u32): Likewise.
2021-01-28 14:18:17 +00:00
Kyrylo Tkachov
ff119f340e aarch64: Fix gcc.target/aarch64/narrow_high-intrinsics.c testism
Pushing to fix recently-updated assembly generation

gcc/testsuite/

	* gcc.target/aarch64/narrow_high-intrinsics.c: Fix shrn2 scan.
2021-01-28 14:10:29 +00:00
Jonathan Wright
87301e3956 aarch64: Use RTL builtins for [su]mlal_n intrinsics
Rewrite [su]mlal_n Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-26  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add [su]mlal_n
	builtin generator macros.
	* config/aarch64/aarch64-simd.md (aarch64_<su>mlal_n<mode>):
	Define.
	* config/aarch64/arm_neon.h (vmlal_n_s16): Use RTL builtin
	instead of inline asm.
	(vmlal_n_s32): Likewise.
	(vmlal_n_u16): Likewise.
	(vmlal_n_u32): Likewise.
2021-01-28 13:12:52 +00:00
Nathan Sidwell
af66f4f1b0 c++: header unit template alias merging [PR 98770]
Typedefs are streamed by streaming the underlying type, and then
recreating the typedef.  But this breaks checking a duplicate is the
same as the original when it is a template alias -- we end up checking
a template alias (eg __void_t) against the underlying type (void).
And those are not the same template alias.  This stops pretendig that
the underlying type is the typedef for that checking and tells
is_matching_decl 'you have a typedef', so it knows what to do.  (We do
not want to recreate the typedef of the duplicate, because that whole
set of nodes is going to go away.)

	PR c++/98770
	gcc/cp/
	* module.cc (trees_out::decl_value): Swap is_typedef & TYPE_NAME
	check order.
	(trees_in::decl_value): Do typedef frobbing only when installing
	a new typedef, adjust is_matching_decl call.  Swap is_typedef
	& TYPE_NAME check.
	(trees_in::is_matching_decl): Add is_typedef parm. Adjust variable
	names and deal with typedef checking.
	gcc/testsuite/
	* g++.dg/modules/pr98770_a.C: New.
	* g++.dg/modules/pr98770_b.C: New.
2021-01-28 04:55:02 -08:00
Kyrylo Tkachov
d61ca09ec9 aarch64: Reimplement vshrn_high_n* intrinsics using builtins
This patch reimplements the vshrn_high_n* intrinsics that generate the
SHRN2 instruction.
It is a vec_concat of the narrowing shift with the bottom part of the
destination register, so we need a little-endian and a big-endian version and an expander to
pick between them.

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (shrn2): Define
	builtin.
	* config/aarch64/aarch64-simd.md (aarch64_shrn2<mode>_insn_le):
	Define.
	(aarch64_shrn2<mode>_insn_be): Likewise.
	(aarch64_shrn2<mode>): Likewise.
	* config/aarch64/arm_neon.h (vshrn_high_n_s16): Reimlplement
	using builtins.
	(vshrn_high_n_s32): Likewise.
	(vshrn_high_n_s64): Likewise.
	(vshrn_high_n_u16): Likewise.
	(vshrn_high_n_u32): Likewise.
	(vshrn_high_n_u64): Likewise.
2021-01-28 11:43:06 +00:00
Kyrylo Tkachov
fdb904a182 aarch64: Reimplement vshrn_n* intrinsics using builtins
This patch reimplements the vshrn_n* intrinsics to use RTL builtins.
These perform a narrowing right shift.

Although the intrinsic generates the half-width mode (e.g. V8HI ->
V8QI), the new pattern generates a full 128-bit mode (V8HI -> V16QI) by representing the
fill-with-zeroes semantics of the SHRN instruction. The narrower (V8QI) result is extracted with a
lowpart subreg.
I found this allows the RTL optimisers to do a better job at optimising
redundant moves away in frequently-occurring SHRN+SRHN2 pairs, like in:
uint8x16_t
foo (uint16x8_t in1, uint16x8_t in2)
{
  uint8x8_t tmp = vshrn_n_u16 (in2, 7);
  uint8x16_t tmp2 = vshrn_high_n_u16 (tmp, in1, 4);
  return tmp2;
}

gcc/ChangeLog:

	* config/aarch64/aarch64-simd-builtins.def (shrn): Define
	builtin.
	* config/aarch64/aarch64-simd.md (aarch64_shrn<mode>_insn_le):
	Define.
	(aarch64_shrn<mode>_insn_be): Likewise.
	(aarch64_shrn<mode>): Likewise.
	* config/aarch64/arm_neon.h (vshrn_n_s16): Reimplement using
	builtins.
	(vshrn_n_s32): Likewise.
	(vshrn_n_s64): Likewise.
	(vshrn_n_u16): Likewise.
	(vshrn_n_u32): Likewise.
	(vshrn_n_u64): Likewise.
	* config/aarch64/iterators.md (vn_mode): New mode attribute.
2021-01-28 11:42:20 +00:00
Eric Botcazou
f7a6d314e7 Fix LTO bootstrap on Windows
The latest fix introduced a comparison of executables and this cannot
directly work on Windows because they are timestamped.  Moreover nobody
sets $(exeext) at top level, at least on MinGW, so you get weird behavior
because some tools add the implicit .exe suffix and others do not.

contrib/
	PR lto/85574
	* compare-lto: Deal with PE-COFF executables specifically.
2021-01-28 11:33:53 +01:00
Harald Anlauf
33a7a93218 PR fortran/86470 - ICE with OpenMP, class(*) allocatable
gfc_call_malloc should malloc an area of size 1 if no size given.

gcc/fortran/ChangeLog:

	PR fortran/86470
	* trans.c (gfc_call_malloc): Allocate area of size 1 if passed
	size is NULL (as documented).

gcc/testsuite/ChangeLog:

	PR fortran/86470
	* gfortran.dg/gomp/pr86470.f90: New test.
2021-01-28 10:13:46 +01:00
Jakub Jelinek
c392d040f6 c++: Some C++20 and C++23 option help fixes
I've noticed we still refer to C++20 as draft standard, and there is a pasto
in C++23 description.

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

	* c.opt (-std=c++2a, -std=c++20, -std=gnu++2a, -std=gnu++20): Remove
	draft from description.
	(-std=c++2b): Fix a pasto, 2020 -> 2023.
2021-01-28 10:00:52 +01:00
Richard Biener
a523add327 rtl-optimization/80960 - avoid creating garbage RTL in DSE
The following avoids repeatedly turning VALUE RTXen into
sth useful and re-applying a constant offset through get_addr
via DSE check_mem_read_rtx.  Instead perform this once for
all stores to be visited in check_mem_read_rtx.  This avoids
allocating 1.6GB of garbage PLUS RTXen on the PR80960
testcase, fixing the memory usage regression from old GCC.

2021-01-27  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/80960
	* dse.c (check_mem_read_rtx): Call get_addr on the
	offsetted address.
2021-01-28 09:14:46 +01:00
Xionghu Luo
fbe37371cf rs6000: Fix vec insert ilp32 ICE and test failures [PR98799]
UNSPEC_SI_FROM_SF is not supported when TARGET_DIRECT_MOVE_64BIT
is false for -m32, don't generate VIEW_CONVERT_EXPR(ARRAY_REF) for
variable vector insert.  Remove rs6000_expand_vector_set_var helper
function, adjust the p8 and p9 definitions position and make them
static.

The previous commit r11-6858 missed check m32, This patch is tested pass
on P7BE{m32,m64}/P8BE{m32,m64}/P8LE/P9LE with
RUNTESTFLAGS="--target_board =unix'{-m32,-m64}'" for BE targets.

gcc/ChangeLog:

2021-01-27  Xionghu Luo  <luoxhu@linux.ibm.com>
	    David Edelsohn  <dje.gcc@gmail.com>

	PR target/98799
	* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
	Don't generate VIEW_CONVERT_EXPR for fcode ALTIVEC_BUILTIN_VEC_INSERT
	when -m32.
	* config/rs6000/rs6000-protos.h (rs6000_expand_vector_set_var):
	Delete.
	* config/rs6000/rs6000.c (rs6000_expand_vector_set): Remove the
	wrapper call rs6000_expand_vector_set_var for cleanup.  Call
	rs6000_expand_vector_set_var_p9 and rs6000_expand_vector_set_var_p8
	directly.
	(rs6000_expand_vector_set_var): Delete.
	(rs6000_expand_vector_set_var_p9): Make static.
	(rs6000_expand_vector_set_var_p8): Make static.

gcc/testsuite/ChangeLog:

2021-01-27  Xionghu Luo  <luoxhu@linux.ibm.com>

	PR target/98827
	* gcc.target/powerpc/fold-vec-insert-char-p8.c: Adjust ilp32.
	* gcc.target/powerpc/fold-vec-insert-char-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-double.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-float-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-float-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-int-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-int-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-longlong.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-short-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-short-p9.c: Likewise.
	* gcc.target/powerpc/pr79251.p8.c: Likewise.
	* gcc.target/powerpc/pr79251.p9.c: Likewise.
	* gcc.target/powerpc/vsx-builtin-7.c: Likewise.
	* gcc.target/powerpc/pr79251-run.c: Build and run with vsx
	option.
2021-01-27 21:34:08 -06:00
Xing GUO
f76d0d8645 RISC-V: Fix -march option parsing when extension exists.
This patch fixes -march option parsing when `p` extension exists,
e.g., -march=rv64imafdcp should produce

.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0_p"

rather than

.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c_p"

gcc/ChangeLog:

	* common/config/riscv/riscv-common.c
	(riscv_subset_list::parsing_subset_version): Fix -march option parsing
	when `p` extension exists.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/attribute-18.c: New test.
2021-01-28 11:25:50 +08:00
GCC Administrator
aa69f0a820 Daily bump. 2021-01-28 00:16:56 +00:00
Harris Snyder
1cdca4261e Fix strides for C descriptors with stride > 2.
libgfortran/ChangeLog:

	* runtime/ISO_Fortran_binding.c (CFI_establish): fixed
	strides for rank >2 arrays.

gcc/testsuite/ChangeLog:

	* gfortran.dg/ISO_Fortran_binding_18.c: New test.
	* gfortran.dg/ISO_Fortran_binding_18.f90: New test.
2021-01-27 22:57:41 +01:00
Vladimir N. Makarov
081c96621d [PR97684] IRA: Recalculate pseudo classes if we added new pseduos since last calculation before updating equiv regs
update_equiv_regs can use reg classes of pseudos and they are set up in
register pressure sensitive scheduling and loop invariant motion and in
live range shrinking.  This info can become obsolete if we add new pseudos
since the last set up.  Recalculate it again if the new pseudos were
added.

gcc/ChangeLog:

	PR rtl-optimization/97684
	* ira.c (ira): Call ira_set_pseudo_classes before
	update_equiv_regs when it is necessary.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/97684
	* gcc.target/i386/pr97684.c: New.
2021-01-27 15:59:05 -05:00
Jason Merrill
9cd7c32549 c++: Dependent using enum [PR97874]
The handling of dependent scopes and unsuitable scopes in lookup_using_decl
was a bit convoluted; I tweaked it for a while and then eventually
reorganized much of the function to hopefully be clearer.  Along the way I
noticed a couple of ways we were mishandling inherited constructors.

The local binding for a dependent using is the USING_DECL.

Implement instantiation of a dependent USING_DECL at function scope.

gcc/cp/ChangeLog:

	PR c++/97874
	* name-lookup.c (lookup_using_decl): Clean up handling
	of dependency and inherited constructors.
	(finish_nonmember_using_decl): Handle DECL_DEPENDENT_P.
	* pt.c (tsubst_expr): Handle DECL_DEPENDENT_P.

gcc/testsuite/ChangeLog:

	PR c++/97874
	* g++.dg/lookup/using4.C: No error in C++20.
	* g++.dg/cpp0x/decltype37.C: Adjust message.
	* g++.dg/template/crash75.C: Adjust message.
	* g++.dg/template/crash76.C: Adjust message.
	* g++.dg/cpp0x/inh-ctor36.C: New test.
	* g++.dg/cpp1z/inh-ctor39.C: New test.
	* g++.dg/cpp2a/using-enum-7.C: New test.
2021-01-27 15:08:05 -05:00
Jakub Jelinek
5516341921 aarch64: Fix up *aarch64_bfxilsi_uxtw [PR98853]
The https://gcc.gnu.org/legacy-ml/gcc-patches/2018-07/msg01895.html
patch that introduced this pattern claimed:
Would generate:

combine_balanced_int:
        bfxil   w0, w1, 0, 16
        uxtw    x0, w0
        ret

But with this patch generates:

combine_balanced_int:
        bfxil   w0, w1, 0, 16
        ret
and it is indeed what it should generate, but it doesn't do that,
it emits bfxil  x0, x1, 0, 16
instead which doesn't zero extend from 32 to 64 bits, but preserves
the bits from the destination register.

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

	PR target/98853
	* config/aarch64/aarch64.md (*aarch64_bfxilsi_uxtw): Use
	%w0, %w1 and %2 instead of %0, %1 and %2.

	* gcc.c-torture/execute/pr98853-1.c: New test.
	* gcc.c-torture/execute/pr98853-2.c: New test.
2021-01-27 20:35:21 +01:00
Aaron Sawdey
7a279bed24 Combine patterns for p10 load-cmpi fusion
This patch adds the first batch of patterns to support p10 fusion. These
will allow combine to create a single insn for a pair of instructions
that power10 can fuse and execute. These particular fusion pairs have the
requirement that only cr0 can be used when fusing a load with a compare
immediate of -1/0/1 (if signed) or 0/1 (if unsigned), so we want combine
to put that requirement in, and if it doesn't work out the splitter
can change it back into 2 insns so scheduling can move them apart.

The patterns are generated by a script genfusion.pl and live in new file
fusion.md. This script will be expanded to generate more patterns for
fusion.

This also adds option -mpower10-fusion which defaults on for power10 and
will gate all these fusion patterns. In addition I have added an
undocumented option -mpower10-fusion-ld-cmpi (which may be removed later)
that just controls the load+compare-immediate patterns. I have made
these default on for power10 but they are not disallowed for earlier
processors because it is still valid code. This allows us to test the
correctness of fusion code generation by turning it on explicitly.

gcc/ChangeLog:

	* config/rs6000/genfusion.pl: New script to generate
	define_insn_and_split patterns so combine can arrange fused
	instructions next to each other.
	* config/rs6000/fusion.md: New file, generated fused instruction
	patterns for combine.
	* config/rs6000/predicates.md (const_m1_to_1_operand): New predicate.
	(non_update_memory_operand): New predicate.
	* config/rs6000/rs6000-cpus.def: Add OPTION_MASK_P10_FUSION and
	OPTION_MASK_P10_FUSION_LD_CMPI to ISA_3_1_MASKS_SERVER and
	POWERPC_MASKS.
	* config/rs6000/rs6000-protos.h (address_is_non_pfx_d_or_x): Add
	prototype.
	* config/rs6000/rs6000.c (rs6000_option_override_internal):
	Automatically set OPTION_MASK_P10_FUSION and
	OPTION_MASK_P10_FUSION_LD_CMPI if target is power10.
	(rs600_opt_masks): Allow -mpower10-fusion
	in function attributes.
	(address_is_non_pfx_d_or_x): New function.
	* config/rs6000/rs6000.h: Add MASK_P10_FUSION.
	* config/rs6000/rs6000.md: Include fusion.md.
	* config/rs6000/rs6000.opt: Add -mpower10-fusion
	and -mpower10-fusion-ld-cmpi.
	* config/rs6000/t-rs6000: Add dependencies involving fusion.md.
2021-01-27 12:24:59 -06:00
Jonathan Wakely
3670dbe490 libstdc++: Regenerate libstdc++ HTML docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2017.xml: Replace invalid entity.
	* doc/html/*: Regenerate.
2021-01-27 17:53:07 +00:00
Jonathan Wright
d53a4f9b68 aarch64: Use RTL builtins for [su]mlal intrinsics
Rewrite [su]mlal Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-26  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add [su]mlal
	builtin generator macros.
	* config/aarch64/aarch64-simd.md (*aarch64_<su>mlal<mode>):
	Rename to...
	(aarch64_<su>mlal<mode>): This.
	* config/aarch64/arm_neon.h (vmlal_s8): Use RTL builtin
	instead of inline asm.
	(vmlal_s16): Likewise.
	(vmlal_s32): Likewise.
	(vmlal_u8): Likewise.
	(vmlal_u16): Likewise.
	(vmlal_u32): Likewise.
2021-01-27 17:44:43 +00:00
Jonathan Wakely
c31a633e13 libstdc++: Use printf to print control characters
Bash and GNU echo do not interpret backslash escapes by default, so use
printf when printing \n or \t in strings.

libstdc++-v3/ChangeLog:

	* testsuite/experimental/simd/generate_makefile.sh: Use printf
	instead of echo when printing escape characters.
2021-01-27 16:37:27 +00:00
Matthias Kretz
02e32295b2 libstdc++: Add simd testsuite
Add a new check-simd target to the testsuite. The new target creates a
subdirectory, generates the necessary Makefiles, and spawns submakes to
build and run the tests. Running this testsuite with defaults on my
machine takes half of the time the dejagnu testsuite required to only
determine whether to run tests. Since the simd testsuite integrated in
dejagnu increased the time of the whole libstdc++ testsuite by ~100%
this approach is a compromise for speed while not sacrificing coverage
too much. Since the test driver is invoked individually per test
executable from a Makefile, make's jobserver (-j) trivially parallelizes
testing.

Testing different flags and with simulator (or remote execution) is
possible. E.g. `make check-simd DRIVEROPTS=-q
target_list="unix{-m64,-m32}{-march=sandybridge,-march=skylake-avx512}{,-
ffast-math}"`
runs the testsuite 8 times in different subdirectories, using 8
different combinations of compiler flags, only outputs failing tests
(-q), and prints all summaries at the end. It skips most ABI tags by
default unless --run-expensive is passed to DRIVEROPTS or
GCC_TEST_RUN_EXPENSIVE is not empty.

To use a simulator, the CHECK_SIMD_CONFIG variable needs to point to a
shell script which calls `define_target <name> <flags> <simulator>` and
set target_list as needed. E.g.:
case "$target_triplet" in
x86_64-*)
  target_list="unix{-march=sandybridge,-march=skylake-avx512}
  ;;
powerpc64le-*)
  define_target power8 "-static -mcpu=power8" "/usr/bin/qemu-ppc64le -cpu
power8"
  define_target power9 -mcpu=power9 "$HOME/bin/run_on_gcc135"
  target_list="power8 power9{,-ffast-math}"
  ;;
esac

libstdc++-v3/ChangeLog:

	* scripts/check_simd: New file. This script is called from the
	the check-simd target. It determines a set of compiler flags and
	simulator setups for calling generate_makefile.sh and passes the
	information back to the check-simd target, which recurses to the
	generated Makefiles.
	* scripts/create_testsuite_files: Remove files below simd/tests/
	from testsuite_files and place them in testsuite_files_simd.
	* testsuite/Makefile.am: Add testsuite_files_simd. Add
	check-simd target.
	* testsuite/Makefile.in: Regenerate.
	* testsuite/experimental/simd/driver.sh: New file. This script
	compiles and runs a given simd test, logging its output and
	status. It uses the timeout command to implement compile and
	test timeouts.
	* testsuite/experimental/simd/generate_makefile.sh: New file.
	This script generates a Makefile which uses driver.sh to compile
	and run the tests and collect the logs into a single log file.
	* testsuite/experimental/simd/tests/abs.cc: New file. Tests
	abs(simd).
	* testsuite/experimental/simd/tests/algorithms.cc: New file.
	Tests min/max(simd, simd).
	* testsuite/experimental/simd/tests/bits/conversions.h: New
	file. Contains functions to support tests involving conversions.
	* testsuite/experimental/simd/tests/bits/make_vec.h: New file.
	Support functions make_mask and make_vec.
	* testsuite/experimental/simd/tests/bits/mathreference.h: New
	file. Support functions to supply precomputed math function
	reference data.
	* testsuite/experimental/simd/tests/bits/metahelpers.h: New
	file. Support code for SFINAE testing.
	* testsuite/experimental/simd/tests/bits/simd_view.h: New file.
	* testsuite/experimental/simd/tests/bits/test_values.h: New
	file. Test functions to easily drive a test with simd objects
	initialized from a given list of values and a range of random
	values.
	* testsuite/experimental/simd/tests/bits/ulp.h: New file.
	Support code to determine the ULP distance of simd objects.
	* testsuite/experimental/simd/tests/bits/verify.h: New file.
	Test framework for COMPARE'ing simd objects and instantiating
	the test templates with value_type and ABI tag.
	* testsuite/experimental/simd/tests/broadcast.cc: New file. Test
	simd broadcasts.
	* testsuite/experimental/simd/tests/casts.cc: New file. Test
	simd casts.
	* testsuite/experimental/simd/tests/fpclassify.cc: New file.
	Test floating-point classification functions.
	* testsuite/experimental/simd/tests/frexp.cc: New file. Test
	frexp(simd).
	* testsuite/experimental/simd/tests/generator.cc: New file. Test
	simd generator constructor.
	* testsuite/experimental/simd/tests/hypot3_fma.cc: New file.
	Test 3-arg hypot(simd,simd,simd) and fma(simd,simd,sim).
	* testsuite/experimental/simd/tests/integer_operators.cc: New
	file. Test integer operators.
	* testsuite/experimental/simd/tests/ldexp_scalbn_scalbln_modf.cc:
	New file. Test ldexp(simd), scalbn(simd), scalbln(simd), and
	modf(simd).
	* testsuite/experimental/simd/tests/loadstore.cc: New file. Test
	(converting) simd loads and stores.
	* testsuite/experimental/simd/tests/logarithm.cc: New file. Test
	log*(simd).
	* testsuite/experimental/simd/tests/mask_broadcast.cc: New file.
	Test simd_mask broadcasts.
	* testsuite/experimental/simd/tests/mask_conversions.cc: New
	file. Test simd_mask conversions.
	* testsuite/experimental/simd/tests/mask_implicit_cvt.cc: New
	file. Test simd_mask implicit conversions.
	* testsuite/experimental/simd/tests/mask_loadstore.cc: New file.
	Test simd_mask loads and stores.
	* testsuite/experimental/simd/tests/mask_operator_cvt.cc: New
	file. Test simd_mask operators convert as specified.
	* testsuite/experimental/simd/tests/mask_operators.cc: New file.
	Test simd_mask compares, subscripts, and negation.
	* testsuite/experimental/simd/tests/mask_reductions.cc: New
	file. Test simd_mask reductions.
	* testsuite/experimental/simd/tests/math_1arg.cc: New file. Test
	1-arg math functions on simd.
	* testsuite/experimental/simd/tests/math_2arg.cc: New file. Test
	2-arg math functions on simd.
	* testsuite/experimental/simd/tests/operator_cvt.cc: New file.
	Test implicit conversions on simd binary operators behave as
	specified.
	* testsuite/experimental/simd/tests/operators.cc: New file. Test
	simd compares, subscripts, not, unary minus, plus, minus,
	multiplies, divides, increment, and decrement.
	* testsuite/experimental/simd/tests/reductions.cc: New file.
	Test reduce(simd).
	* testsuite/experimental/simd/tests/remqo.cc: New file. Test
	remqo(simd).
	* testsuite/experimental/simd/tests/simd.cc: New file. Basic
	sanity checks of simd types.
	* testsuite/experimental/simd/tests/sincos.cc: New file. Test
	sin(simd) and cos(simd).
	* testsuite/experimental/simd/tests/split_concat.cc: New file.
	Test split(simd) and concat(simd, simd).
	* testsuite/experimental/simd/tests/splits.cc: New file. Test
	split(simd_mask).
	* testsuite/experimental/simd/tests/trigonometric.cc: New file.
	Test remaining trigonometric functions on simd.
	* testsuite/experimental/simd/tests/trunc_ceil_floor.cc: New
	file. Test trunc(simd), ceil(simd), and floor(simd).
	* testsuite/experimental/simd/tests/where.cc: New file. Test
	masked operations using where.
2021-01-27 16:37:26 +00:00
Matthias Kretz
2bcceb6fc5 libstdc++: Add std::experimental::simd from the Parallelism TS 2
Adds <experimental/simd>.

This implements the simd and simd_mask class templates via
[[gnu::vector_size(N)]] data members. It implements overloads for all of
<cmath> for simd. Explicit vectorization of the <cmath> functions is not
finished.

The majority of functions are marked as [[gnu::always_inline]] to enable
quasi-ODR-conforming linking of TUs with different -m flags.
Performance optimization was done for x86_64.  ARM, Aarch64, and POWER
rely on the compiler to recognize reduction, conversion, and shuffle
patterns.

Besides verification using many different machine flages, the code was
also verified with different fast-math flags.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2017.xml: Add implementation status
	of the Parallelism TS 2. Document implementation-defined types
	and behavior.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/experimental/simd: New file. New header for
	Parallelism TS 2.
	* include/experimental/bits/numeric_traits.h: New file.
	Implementation of P1841R1 using internal naming. Addition of
	missing IEC559 functionality query.
	* include/experimental/bits/simd.h: New file. Definition of the
	public simd interfaces and general implementation helpers.
	* include/experimental/bits/simd_builtin.h: New file.
	Implementation of the _VecBuiltin simd_abi.
	* include/experimental/bits/simd_converter.h: New file. Generic
	simd conversions.
	* include/experimental/bits/simd_detail.h: New file. Internal
	macros for the simd implementation.
	* include/experimental/bits/simd_fixed_size.h: New file. Simd
	fixed_size ABI specific implementations.
	* include/experimental/bits/simd_math.h: New file. Math
	overloads for simd.
	* include/experimental/bits/simd_neon.h: New file. Simd NEON
	specific implementations.
	* include/experimental/bits/simd_ppc.h: New file. Implement bit
	shifts to avoid invalid results for integral types smaller than
	int.
	* include/experimental/bits/simd_scalar.h: New file. Simd scalar
	ABI specific implementations.
	* include/experimental/bits/simd_x86.h: New file. Simd x86
	specific implementations.
	* include/experimental/bits/simd_x86_conversions.h: New file.
	x86 specific conversion optimizations. The conversion patterns
	work around missing conversion patterns in the compiler and
	should be removed as soon as PR85048 is resolved.
	* testsuite/experimental/simd/standard_abi_usable.cc: New file.
	Test that all (not all fixed_size<N>, though) standard simd and
	simd_mask types are usable.
	* testsuite/experimental/simd/standard_abi_usable_2.cc: New
	file. As above but with -ffast-math.
	* testsuite/libstdc++-dg/conformance.exp: Don't build simd tests
	from the standard test loop. Instead use
	check_vect_support_and_set_flags to build simd tests with the
	relevant machine flags.
2021-01-27 16:37:26 +00:00
Richard Biener
c91db798ec tree-optimization/98854 - avoid some PHI BB vectorization
This avoids cases of PHI node vectorization that just causes us
to insert vector CTORs inside loops for values only required
outside of the loop.

2021-01-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98854
	* tree-vect-slp.c (vect_build_slp_tree_2): Also build
	PHIs from scalars when the number of CTORs matches the
	number of children.

	* gcc.dg/vect/bb-slp-pr98854.c: New testcase.
2021-01-27 17:33:34 +01:00
Jonathan Wright
3fd10728cb aarch64: Use RTL builtins for integer mls_n intrinsics
Rewrite integer mls_n Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-15  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add mls_n builtin
	generator macro.
	* config/aarch64/aarch64-simd.md (*aarch64_mls_elt_merge<mode>):
	Rename to...
	(aarch64_mls_n<mode>): This.
	* config/aarch64/arm_neon.h (vmls_n_s16): Use RTL builtin
	instead of asm.
	(vmls_n_s32): Likewise.
	(vmls_n_u16): Likewise.
	(vmls_n_u32): Likewise.
	(vmlsq_n_s16): Likewise.
	(vmlsq_n_s32): Likewise.
	(vmlsq_n_u16): Likewise.
	(vmlsq_n_u32): Likewise.
2021-01-27 15:55:55 +00:00
Jonathan Wright
d2201ac0df aarch64: Use RTL builtins for integer mls intrinsics
Rewrite integer mls Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/Changelog:

2021-01-11  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add mls builtin
	generator macro.
	* config/aarch64/arm_neon.h (vmls_s8): Use RTL builtin rather
	than asm.
	(vmls_s16): Likewise.
	(vmls_s32): Likewise.
	(vmls_u8): Likewise.
	(vmls_u16): Likewise.
	(vmls_u32): Likewise.
	(vmlsq_s8): Likewise.
	(vmlsq_s16): Likewise.
	(vmlsq_s32): Likewise.
	(vmlsq_u8): Likewise.
	(vmlsq_u16): Likewise.
	(vmlsq_u32): Likewise.
2021-01-27 14:59:08 +00:00
Jonathan Wakely
a199da782f libstdc++: Optimize std::string_view::find [PR 66414]
This reuses the code from std::string::find, which was improved by
r244225, but string_view was not changed to match.

libstdc++-v3/ChangeLog:

	PR libstdc++/66414
	* include/bits/string_view.tcc
	(basic_string_view::find(const CharT*, size_type, size_type)):
	Optimize.
2021-01-27 13:45:52 +00:00
Jonathan Wright
9d66505a5d aarch64: Use RTL builtins for integer mla_n intrinsics
Rewrite integer mla_n Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and
optimization.

gcc/ChangeLog:

2021-01-15  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add mla_n builtin
	generator macro.
	* config/aarch64/aarch64-simd.md (*aarch64_mla_elt_merge<mode>):
	Rename to...
	(aarch64_mla_n<mode>): This.
	* config/aarch64/arm_neon.h (vmla_n_s16): Use RTL builtin
	instead of asm.
	(vmla_n_s32): Likewise.
	(vmla_n_u16): Likewise.
	(vmla_n_u32): Likewise.
	(vmlaq_n_s16): Likewise.
	(vmlaq_n_s32): Likewise.
	(vmlaq_n_u16): Likewise.
	(vmlaq_n_u32): Likewise.
2021-01-27 12:44:49 +00:00
Paul Fee
f004d6d9fa libstdc++: Add string contains member functions for C++2b
This implements WG21 P1679R3, adding contains member functions to
basic_string_view and basic_string.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (basic_string::contains): New
	member functions.
	* include/std/string_view (basic_string_view::contains):
	Likewise.
	* include/std/version (__cpp_lib_string_contains): Define.
	* testsuite/21_strings/basic_string/operations/starts_with/char/1.cc:
	Remove trailing whitespace.
	* testsuite/21_strings/basic_string/operations/starts_with/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/contains/char/1.cc: New test.
	* testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/contains/char/1.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc: New test.
2021-01-27 12:37:36 +00:00
Paul Thomas
4225af228b Fortran: Fix ICE due to elemental procedure pointers [PR93924/5].
2021-01-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/93924
	PR fortran/93925
	* trans-expr.c (gfc_conv_procedure_call): Suppress the call to
	gfc_conv_intrinsic_to_class for unlimited polymorphic procedure
	pointers.
	(gfc_trans_assignment_1): Similarly suppress class assignment
	for class valued procedure pointers.

gcc/testsuite/
	PR fortran/93924
	PR fortran/93925
	* gfortran.dg/proc_ptr_52.f90 : New test.
2021-01-27 11:34:27 +00:00
Jakub Jelinek
686b1cdfdc libgcc, i386: Add .note.GNU-stack sections to the ms sse/avx sav/res
On Linux, GCC emits .note.GNU-stack sections when compiling code to mark
the code as not needing or needing executable stack, missing section means
unknown.  But assembly files need to be marked manually.  We already
mark various *.S files in libgcc manually, but the
avx_resms64f.o
avx_resms64fx.o
avx_resms64.o
avx_resms64x.o
avx_savms64f.o
avx_savms64.o
sse_resms64f.o
sse_resms64fx.o
sse_resms64.o
sse_resms64x.o
sse_savms64f.o
sse_savms64.o
files aren't marked, so when something links it in, it will require
executable stack.  Nothing in the assembly requires executable stack though.

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

	* config/i386/savms64.h: Add .note.GNU-stack section on Linux.
	* config/i386/savms64f.h: Likewise.
	* config/i386/resms64.h: Likewise.
	* config/i386/resms64f.h: Likewise.
	* config/i386/resms64x.h: Likewise.
	* config/i386/resms64fx.h: Likewise.
2021-01-27 11:50:13 +01:00
liuhongt
530b1d6887 Fix ICE for [PR target/98833].
And replace __builtin_ia32_pcmpeqb128 with operator == in libcpp.

gcc/ChangeLog:

	PR target/98833
	* config/i386/sse.md (sse2_gt<mode>3): Drop !TARGET_XOP in condition.
	(*sse2_eq<mode>3): Ditto.

gcc/testsuite/ChangeLog:

	PR target/98833
	* gcc.target/i386/pr98833.c: New test.

libcpp/

	PR target/98833
	* lex.c (search_line_sse2): Replace builtins with == operator.
2021-01-27 18:49:25 +08:00
Jakub Jelinek
6cf4343375 testsuite: Fix TBAA in {sse,avx}*and*p[sd]*.c tests
This patch drops the no-strict-aliasing hack in m128-check.h and instead
ensures the tests read objects with the right dynamic type.

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

	* gcc.target/i386/m128-check.h (CHECK_EXP): Remove
	optimize ("no-strict-aliasing") attribute.
	* gcc.target/i386/sse-andnps-1.c (TEST): Copy e into float[4]
	array to avoid violating TBAA.
	* gcc.target/i386/sse2-andpd-1.c (TEST): Copy e.d into double[2]
	array to avoid violating TBAA.
	* gcc.target/i386/sse-andps-1.c (TEST): Copy e.f into float[4]
	array to avoid violating TBAA.
	* gcc.target/i386/sse2-andnpd-1.c (TEST): Copy e into double[2]
	array to avoid violating TBAA.
2021-01-27 10:22:18 +01:00
Paul Thomas
003f041429 Fortran: Fix ICE due to elemental procedure pointers [PR98472].
2021-01-27  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/98472
	* trans-array.c (gfc_conv_expr_descriptor): Include elemental
	procedure pointers in the assert under the comment 'elemental
	function' and eliminate the second, spurious assert.

gcc/testsuite/
	PR fortran/98472
	* gfortran.dg/elemental_function_5.f90 : New test.
2021-01-27 09:12:54 +00:00
Jakub Jelinek
da5c25f371 Rename PROP_trees to PROP_gimple
PROP_trees actually means GIMPLE IL, rather than GENERIC, so better
not to confuse users.

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

	* tree-pass.h (PROP_trees): Rename to ...
	(PROP_gimple): ... this.
	* cfgexpand.c (pass_data_expand): Replace PROP_trees with PROP_gimple.
	* passes.c (execute_function_dump, execute_function_todo,
	execute_one_ipa_transform_pass, execute_one_pass): Likewise.
	* varpool.c (ctor_for_folding): Likewise.
2021-01-27 10:10:04 +01:00
Jakub Jelinek
efc9ccbfd0 varpool: Restore GENERIC TREE_READONLY automatic var optimization [PR7260]
In 4.8 and earlier we used to fold the following to 0 during GENERIC folding,
but we don't do that anymore because ctor_for_folding etc. has been turned into a
GIMPLE centric API, but as the testcase shows, it is invoked even during
GENERIC folding and there the automatic vars still should have meaningful
initializers.  I've verified that the C++ FE drops TREE_READONLY on
automatic vars with const qualified types if they require non-constant
(runtime) initialization.

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

	PR tree-optimization/97260
	* varpool.c: Include tree-pass.h.
	(ctor_for_folding): In GENERIC return DECL_INITIAL for TREE_READONLY
	non-TREE_SIDE_EFFECTS automatic variables.

	* gcc.dg/tree-ssa/pr97260.c: New test.
2021-01-27 10:08:46 +01:00
GCC Administrator
e62bb7f083 Daily bump. 2021-01-27 00:16:33 +00:00
Paul Fee
78739c2df7 c++: Add support for -std=c++23
Derived from the changes that added C++2a support in 2017.
r8-3237-g026a79f70cf33f836ea5275eda72d4870a3041e5

No C++23 features are added here.
Use of -std=c++23 sets __cplusplus to 202100L.

$ g++ -std=c++23 -dM -E -x c++ - < /dev/null | grep cplusplus
 #define __cplusplus 202100L

gcc/
	* doc/cpp.texi (__cplusplus): Document value for -std=c++23
	or -std=gnu++23.
	* doc/invoke.texi: Document -std=c++23 and -std=gnu++23.
	* dwarf2out.c (highest_c_language): Recognise C++20 and C++23.
	(gen_compile_unit_die): Recognise C++23.

gcc/c-family/
	* c-common.h (cxx_dialect): Add cxx23 as a dialect.
	* c.opt: Add options for -std=c++23, std=c++2b, -std=gnu++23
	and -std=gnu++2b
	* c-opts.c (set_std_cxx23): New.
	(c_common_handle_option): Set options when -std=c++23 is enabled.
	(c_common_post_options): Adjust comments.
	(set_std_cxx20): Likewise.

gcc/testsuite/
	* lib/target-supports.exp (check_effective_target_c++2a):
	Check for C++2a or C++23.
	(check_effective_target_c++20_down): New.
	(check_effective_target_c++23_only): New.
	(check_effective_target_c++23): New.
	* g++.dg/cpp23/cplusplus.C: New.

libcpp/
	* include/cpplib.h (c_lang): Add CXX23 and GNUCXX23.
	* init.c (lang_defaults): Add rows for CXX23 and GNUCXX23.
	(cpp_init_builtins): Set __cplusplus to 202100L for C++23.
2021-01-26 17:11:34 -05:00
Jason Merrill
96253f069e c++: Invisible refs are not restrict [PR97474]
In this testcase, we refer to the a parameter through a reference in its own
member, which we asserted couldn't happen by marking the parameter as
'restrict'.  This assumption could also be broken if the address escapes
from the constructor.

gcc/cp/ChangeLog:

	PR c++/97474
	* call.c (type_passed_as): Don't mark invisiref restrict.

gcc/testsuite/ChangeLog:

	PR c++/97474
	* g++.dg/torture/pr97474.C: New test.
2021-01-26 17:10:58 -05:00
Jason Merrill
a4dfd0f089 c++: constexpr and empty fields [PR97566]
In the discussion of PR98463, Jakub pointed out that in C++17 and up,
cxx_fold_indirect_ref_1 could use the field we build for an empty base.  I
tried implementing that, but it broke one of the tuple tests, so I did some
more digging.

To start with, I generalized the PR98463 patch to handle the case where we
do have a field, for an empty base or [[no_unique_address]] member.  This is
enough also for the no-field case because the member of the empty base must
itself be an empty field; if it weren't, the base would not be empty.

I looked for related PRs and found 97566, which was also fixed by the patch.
After some poking around to figure out why, I noticed that the testcase had
been breaking because E, though an empty class, has an ABI nvsize of one
byte, and we were giving the [[no_unique_address]] FIELD_DECL that
DECL_SIZE, whereas in build_base_field_1 empty base fields always get
DECL_SIZE zero, and various places were relying on that to recognize empty
fields.  So I adjusted both the size and the checking.  When I adjusted
check_bases I wondered if we were correctly handling bases with only empty
data members, but it appears we do.

I'm deferring the cxx_fold_indirect_ref_1 change until stage 1, as I don't
think it actually fixes anything.

gcc/cp/ChangeLog:

	PR c++/97566
	PR c++/98463
	* class.c (layout_class_type): An empty field gets size 0.
	(is_empty_field): New.
	(check_bases): Check it.
	* cp-tree.h (is_empty_field): Declare it.
	* constexpr.c (cxx_eval_store_expression): Check it.
	(cx_check_missing_mem_inits): Likewise.
	* init.c (perform_member_init): Likewise.
	* typeck2.c (process_init_constructor_record): Likewise.

gcc/testsuite/ChangeLog:

	PR c++/97566
	* g++.dg/cpp2a/no_unique_address10.C: New test.
	* g++.dg/cpp2a/no_unique_address9.C: New test.
2021-01-26 15:00:38 -05:00
Jakub Jelinek
e80f1f6b7a testsuite: Fix TBAA in sse*and*p[sd]*.c tests
This patch drops the no-strict-aliasing hack in m128-check.h and instead
ensures the tests read objects with the right dynamic type.

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

	* gcc.target/powerpc/m128-check.h (CHECK_EXP): Remove
	optimize ("no-strict-aliasing") attribute.
	* gcc.target/powerpc/sse-andnps-1.c (TEST): Copy e into float[4]
	array to avoid violating TBAA.
	* gcc.target/powerpc/sse2-andpd-1.c (TEST): Copy e.d into double[2]
	array to avoid violating TBAA.
	* gcc.target/powerpc/sse-andps-1.c (TEST): Copy e.f into float[4]
	array to avoid violating TBAA.
	* gcc.target/powerpc/sse2-andnpd-1.c (TEST): Copy e into double[2]
	array to avoid violating TBAA.
2021-01-26 20:02:29 +01:00
Eric Botcazou
9c41bcc59c Fix PR ada/98228
This is the profiled bootstrap failure for s390x/Linux on the mainline,
which has been introduced by the modref pass but actually exposing an
existing issue in the maybe_pad_type function that is visible on s390x.

The issue is too weak a test for the addressability of the inner component.

gcc/ada/
	    Marius Hillenbrand  <mhillen@linux.ibm.com>

	PR ada/98228
	* gcc-interface/utils.c (maybe_pad_type): Test the size of the new
	packable type instead of its alignment for addressability's sake.
2021-01-26 19:03:58 +01:00
Jakub Jelinek
6e44c09b2d dwarf2asm: Fix bootstrap on powerpc*-*-* [PR98839]
My recent dwarf2asm.c patch broke powerpc*-*-* bootstrap, while most target
define POINTER_SIZE to (cond ? cst1 : cst2) or constant, rs6000 defines
it to a variable, and the arbitrarily chosen type of that variable determines
whether we get warnings on comparison of that against signed or unsigned
ints.

Fixed by adding a cast.

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

	PR bootstrap/98839
	* dwarf2asm.c (dw2_assemble_integer): Cast DWARF2_ADDR_SIZE to int
	in comparison.
2021-01-26 18:13:07 +01:00
Jakub Jelinek
17ad8cdebe aarch64: Tighten up checks for ubfix [PR98681]
The testcase in the patch doesn't assemble, because the instruction requires
that the penultimate operand (lsb) range is [0, 32] (or [0, 64]) and the last
operand's range is [1, 32 - lsb] (or [1, 64 - lsb]).
The INTVAL (shft_amnt) < GET_MODE_BITSIZE (mode) will accept the lsb operand
to be in range [MIN, 32] (or [MIN, 64]) and then we invoke UB in the
compiler and sometimes it will make it through.
The patch changes all the INTVAL uses in that function to UINTVAL,
which isn't strictly necessary, but can be done (e.g. after the
UINTVAL (shft_amnt) < GET_MODE_BITSIZE (mode) check we know it is not
negative and thus INTVAL (shft_amnt) and UINTVAL (shft_amnt) then behave the
same.  But, I had to add INTVAL (mask) > 0 check in that case, otherwise we
risk (hypothetically) emitting instruction that doesn't assemble.
The problem is with masks that have the MSB bit set, while the instruction
can handle those, e.g.
ubfiz w1, w0, 13, 19
will do
(w0 << 13) & 0xffffe000
in RTL we represent SImode constants with MSB set as negative HOST_WIDE_INT,
so it will actually be HOST_WIDE_INT_C (0xffffffffffffe000), and
the instruction uses %P3 to print the last operand, which calls
asm_fprintf (f, "%u", popcount_hwi (INTVAL (x)))
to print that.  But that will not print 19, but 51 instead, will include
there also all the copies of the sign bit.
Not supporting those masks with MSB set isn't a big loss though, they really
shouldn't appear normally, as both GIMPLE and RTL optimizations should
optimize those away (one isn't masking any bits off with such masks, so
just w0 << 13 will do too).

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

	PR target/98681
	* config/aarch64/aarch64.c (aarch64_mask_and_shift_for_ubfiz_p):
	Use UINTVAL (shft_amnt) and UINTVAL (mask) instead of INTVAL (shft_amnt)
	and INTVAL (mask).  Add && INTVAL (mask) > 0 condition.

	* gcc.c-torture/execute/pr98681.c: New test.
2021-01-26 14:48:26 +01:00
Richard Biener
5bbc80d0e4 Fix dumping of VEC_WIDEN_{PLUS,MINUS}_{LO,HI}_EXPR
This avoids dumping them as <<< ??? >>>.

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

	* gimple-pretty-print.c (dump_binary_rhs): Handle
	VEC_WIDEN_{PLUS,MINUS}_{LO,HI}_EXPR.
2021-01-26 14:27:23 +01:00
Richard Biener
4b59dbb5d6 middle-end/98726 - fix VECTOR_CST element access
This fixes VECTOR_CST element access with POLY_INT elements and
allows to produce dump files of the PR98726 testcase without
ICEing.

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

	PR middle-end/98726
	* tree.h (vector_cst_int_elt): Remove.
	* tree.c (vector_cst_int_elt): Use poly_wide_int for computations,
	make static.
2021-01-26 14:27:04 +01:00
Martin Liska
2e81b16c24 liblsan: build missing lsan_posix.cpp file
libsanitizer/ChangeLog:

	PR sanitizer/98828
	* lsan/Makefile.am: Add missing lsan_posix.cpp file.
	* lsan/Makefile.in: Likewise.
2021-01-26 14:14:40 +01:00
Martin Liska
d40b21eebc libgcov: improve profile reproducibility
libgcc/ChangeLog:

	PR gcov-profile/98739
	* libgcov.h (gcov_topn_add_value): Do not train when
	we have a merged profile with a negative number of total
	value.
2021-01-26 12:44:34 +01:00
Thomas Koenig
80198c701a Commit test case for PR 67539.
gcc/testsuite/ChangeLog:

	PR fortran/67539
	* gfortran.dg/elemental_assignment_1.f90: New test.
2021-01-26 12:27:54 +01:00
Tobias Burnus
b3cc0c9a6a testsuite/g++.dg/modules/modules.exp: Janitorial fixes
gcc/testsuite/ChangeLog:

	* g++.dg/modules/modules.exp: Remove unused CXX_MODULE_PATH;
	add previously missing space in '$ident link'.
2021-01-26 11:46:01 +01:00
Andrew Stubbs
d9f5036610 amdgcn: Allow V64DFmode min/max reductions
I don't know why these were disabled. There're no direct min/max DPP
instructions for this mode, but the "use moves" strategy works fine.

gcc/ChangeLog:

	* config/gcn/gcn.c (gcn_expand_reduc_scalar): Use move instructions
	for V64DFmode min/max reductions.
2021-01-26 10:23:43 +00:00
Iain Buclaw
5a36cae275 d: Merge upstream dmd 609c3ce2d, phobos 3dd5df686
D front-end changes:

 - Contracts for pre- and postconditions are now implicitly "this"
   const, so that state can no longer be altered in these functions.

 - Inside a constructor scope, assigning to aggregate declaration
   members is done by considering the first assignment as initialization
   and subsequent assignments as modifications of the constructed
   object.  For const/immutable fields the initialization is accepted in
   the constructor but subsequent modifications are not.  However this
   rule did not apply when inside a constructor scope there is a call to
   a different constructor.  This been changed so it is now an error
   when there's a double initialization of immutable fields inside a
   constructor.

Phobos changes:

 - Don't run unit-tests for unsupported clocks in std.datetime.  The
   phobos and phobos_shared tests now add -fversion=Linux_Pre_2639 if
   required.

 - Deprecate public extern(C) bindings for getline and getdelim in
   std.stdio.  The correct module for bindings is core.sys.posix.stdio.

Reviewed-on: https://github.com/dlang/dmd/pull/12153
	     https://github.com/dlang/phobos/pull/7768

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 609c3ce2d.
	* d-compiler.cc (Compiler::loadModule): Rename to ...
	(Compiler::onParseModule): ... this.
	(Compiler::onImport): New function.
	* d-lang.cc (d_parse_file): Remove call to Compiler::loadModule.

libphobos/ChangeLog:

	* src/MERGE: Merge upstream phobos 3dd5df686.
	* testsuite/libphobos.phobos/phobos.exp: Add compiler flag
	-fversion=Linux_Pre_2639 if target is linux_pre_2639.
	* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.
2021-01-26 09:54:57 +01:00
Jakub Jelinek
eb77a934ee testsuite: Fix up pr98807.c on i686-linux [PR98807]
The new testcase FAILs on i686-linux with:
gcc/testsuite/gcc.dg/pr98807.c: In function 'foo0':
gcc/testsuite/gcc.dg/pr98807.c:20:1: warning: SSE vector return without SSE enabled changes the ABI [-Wpsabi]
gcc/testsuite/gcc.dg/pr98807.c:19:1: note: the ABI for passing parameters with 16-byte alignment has changed in GCC 4.6
gcc/testsuite/gcc.dg/pr98807.c:19:1: warning: SSE vector argument without SSE enabled changes the ABI [-Wpsabi]
FAIL: gcc.dg/pr98807.c (test for excess errors)

Adding usual testcase treatment for such cases.

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

	PR middle-end/98807
	* gcc.dg/pr98807.c: Add -Wno-psabi -w to dg-options.
2021-01-26 09:33:04 +01:00
Jakub Jelinek
7423731691 dwarf2asm: Fix up -gdwarf-64 for 32-bit targets
For the 32-bit targets the limitations of the object
file format (e.g. 32-bit ELF) will not allow > 2GiB debug info anyway,
and as I've just tested, e.g. on x86_64 with -m32 -gdwarf64 will not work
even on tiny testcases:
as: pr64716.o: unsupported relocation type: 0x1
pr64716.s: Assembler messages:
pr64716.s:6013: Error: cannot represent relocation type BFD_RELOC_64
as: pr64716.o: unsupported relocation type: 0x1
pr64716.s:6015: Error: cannot represent relocation type BFD_RELOC_64
as: pr64716.o: unsupported relocation type: 0x1
pr64716.s:6017: Error: cannot represent relocation type BFD_RELOC_64
So yes, we can either do a sorry, error, or could just avoid 64-bit
relocations (depending on endianity instead of emitting
.quad expression_that_needs_relocation
emit
.long expression_that_needs_relocation, 0
or
.long 0, expression_that_needs_relocation

This patch implements that last option, dunno if we need also configure tests
for that or not, maybe some 32-bit targets use 64-bit ELF and can handle such
relocations.

> 64bit relocs are not required here?  That is, can one with
> dwarf64 choose 32bit forms for select offsets (like could
> dwz exploit this?)?

I guess it depends on whether for 32-bit target and -gdwarf64, when
calling dw2_assemble_integer with non-CONST_INT argument we only
need positive values or might need negative ones too.
Because positive ones can be easily emulated through that
.long expression, 0
or
.long 0, expression
depending on endianity, but I'm afraid there is no way to emit
0 or -1 depending on the sign of expression, when it needs relocations.
Looking through dw2_asm_output_delta calls, at least the vast majority
of the calls seem to guarantee being positive, not 100% sure about
one case in .debug_line views, but I'd hope it is ok too.
In most cases, the deltas are between two labels where the first one
in the arguments is later in the same section than the other one,
or where the second argument is the start of a section or another section
base.

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

	* dwarf2asm.c (dw2_assemble_integer): Handle size twice as large
	as DWARF2_ADDR_SIZE if x is not a scalar int by emitting it as
	two halves, one with x and the other with const0_rtx, ordered
	depending on endianity.
2021-01-26 09:20:23 +01:00
Alexandre Oliva
667c8e3327 skip asan-poisoning of discarded vars
GNAT may create temporaries to hold return values of function calls.
If such a temporary is created as part of a dynamic initializer of a
variable in a unit other than the one being compiled, the initializer
is dropped, including the temporary and its binding block.

Don't issue asan mark calls for such variables, they are gone.


for  gcc/ChangeLog

	* gimplify.c (gimplify_decl_expr): Skip asan marking calls for
	temporaries not seen in binding block, and not about to be
	added as gimple variables.

for  gcc/testsuite/ChangeLog

	* gnat.dg/asan1.adb: New test.
	* gnat.dg/asan1_pkg.ads: New additional source.
2021-01-25 21:45:58 -03:00
GCC Administrator
161e4c0862 Daily bump. 2021-01-26 00:16:34 +00:00
Harald Anlauf
a61efd4693 PR fortran/70070 - ICE on initializing character data beyond min/max bound
Check for initialization of substrings beyond bounds in DATA statements.

gcc/fortran/ChangeLog:

	PR fortran/70070
	* data.c (create_character_initializer): Check substring indices
	against bounds.
	(gfc_assign_data_value): Catch error returned from
	create_character_initializer.

gcc/testsuite/ChangeLog:

	PR fortran/70070
	* gfortran.dg/pr70070.f90: New test.
2021-01-25 21:33:53 +01:00
Martin Sebor
d6f1cf644c PR c++/98646 - spurious -Wnonnull calling a member on the result of static_cast
gcc/c-family/ChangeLog:

	PR c++/98646
	* c-common.c (check_nonnull_arg): Adjust warning text.

gcc/cp/ChangeLog:

	PR c++/98646
	* cvt.c (cp_fold_convert): Propagate TREE_NO_WARNING.

gcc/ChangeLog:

	PR c++/98646
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Adjust warning text.

gcc/testsuite/ChangeLog:

	PR c++/98646
	* g++.dg/warn/Wnonnull5.C: Adjust text of an expected warning.
	* g++.dg/warn/Wnonnull10.C: New test.
	* g++.dg/warn/Wnonnull9.C: New test.
2021-01-25 12:41:28 -07:00
Thomas Koenig
7d54cccad3 Commit test case for PR 96386.
gcc/testsuite/ChangeLog:

	* gfortran.dg/associate_57.f90: New test.
2021-01-25 20:27:15 +01:00
Thomas Koenig
a43e0dfb63 Add test case for PR 96843.
gcc/testsuite/ChangeLog:

	PR fortran/96843
	* gfortran.dg/interface_assignment_7.f90: New test.
2021-01-25 20:21:39 +01:00
Kwok Cheung Yeung
0194e2f02d libgomp: Add documentation for omp_fulfill_event runtime function
2021-01-25  Kwok Cheung Yeung  <kcy@codesourcery.com>

	libgomp/
	* libgomp.texi (omp_fulfill_event): New entry.
2021-01-25 09:58:51 -08:00
Martin Liska
d9ad3b422f Fix wrong format for fprintf.
gcc/ChangeLog:

	* value-prof.c (get_nth_most_common_value): Use %s instead
	of %qs string.
2021-01-25 17:49:24 +01:00
Jason Merrill
94ff4c9dd9 c++: [[no_unique_address]] in empty base [PR98463]
In this testcase, cxx_eval_store_expression got confused trying to build up
CONSTRUCTORs for initializing a subobject because the subobject is a member
of an empty base.  In C++14 mode and below we don't build FIELD_DECLs for
empty bases, so the CONSTRUCTOR skipped the empty base, and treated the
member as a member of the derived class, which breaks.

Fixed by recognizing this situation and giving up on trying to build a
CONSTRUCTOR for the inner target at that point; since it doesn't have any
data, we don't need to actually store anything.

gcc/cp/ChangeLog:

	PR c++/98463
	* constexpr.c (get_or_insert_ctor_field): Add check.
	(cxx_eval_store_expression): Handle discontinuity of refs.

gcc/testsuite/ChangeLog:

	PR c++/98463
	* g++.dg/cpp2a/no_unique_address8.C: New test.
2021-01-25 10:36:27 -05:00
Tobias Burnus
10c83fb713 gcc/fortran/intrinsic.texi: Fix typos
gcc/fortran/ChangeLog:

	* intrinsic.texi (CO_BROADCAST, CO_MIN, CO_REDUCE, CO_SUM): Fix typos.
2021-01-25 14:43:52 +01:00
Jakub Jelinek
fe5cb7f94d configure: Add workaround for buggy binutils 2.35 [PR98811]
binutils since https://sourceware.org/bugzilla/show_bug.cgi?id=25612
changes from March last year until the
https://sourceware.org/pipermail/binutils/2020-August/112684.html
fix in early August emits incorrect .debug_info when assembling files
with --gdwarf-5.  Instead of emitting proper DWARF 5 .debug_info header,
it emits DWARF 4 .debug_info header with 5 as the dwarf version instead of
4.  This results e.g. in libgcc.a (morestack.o) having garbage in its
.debug_info sections and e.g. libbacktrace during pretty much all libgo
tests fails miserably.

The following patch adds a workaround for that, don't set
HAVE_AS_GDWARF_5_DEBUG_FLAG if readelf can't read the .debug_info back.

Built tested on x86_64-linux against both binutils 2.35 (buggy ones) and
latest binutils trunk, the former with the patch now has DWARF 3
.debug_line and DWARF 2 .debug_info in morestack.o, while the latter
as before correct DWARF 5 .debug_line and .debug_info.

2021-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98811
	* configure.ac (HAVE_AS_GDWARF_5_DEBUG_FLAG): Only define if
	readelf -wi is able to read the emitted .debug_info back.
	* configure: Regenerated.
2021-01-25 14:20:05 +01:00
Martin Liska
e05a117dc4 Enable -fprofile-reproducible=parallel-runs for profiledbootstrap.
ChangeLog:

	PR gcov-profile/98739
	* Makefile.in: Enable -fprofile-reproducible=parallel-runs
	for profiledbootstrap.
2021-01-25 13:31:05 +01:00
Martin Liska
5089df534b Restore profile reproducibility.
gcc/ChangeLog:

	PR gcov-profile/98739
	* common.opt: Add missing sign symbol.
	* value-prof.c (get_nth_most_common_value): Restore handling
	of PROFILE_REPRODUCIBILITY_PARALLEL_RUNS and
	PROFILE_REPRODUCIBILITY_MULTITHREADED.

libgcc/ChangeLog:

	PR gcov-profile/98739
	* libgcov-merge.c (__gcov_merge_topn): Mark when merging
	ends with a dropped counter.
	* libgcov.h (gcov_topn_add_value): Add return value.
2021-01-25 13:30:34 +01:00
Richard Biener
defc40db9e middle-end/98807 - more vector_element_bits fixes
This simplifies vector_element_bits further, avoiding any mode
dependence and instead relying on boolean vector construction
to populate element precision accordingly.

2021-01-25  Richard Biener  <rguenther@suse.de>

	PR middle-end/98807
	* tree.c (vector_element_bits): Always use precision of
	the element type for boolean vectors.

	* gcc.dg/pr98807.c: New testcase.
2021-01-25 13:18:13 +01:00
Sebastian Huber
0433fc2d7d RTEMS: Fix default linker script
We have to use ENDFILE_SPEC for the default linker script and not
STARTFILE_SPEC, since STARTFILE_SPEC is place before the user provided
library search paths.

gcc/

	* config/rtems.h (STARTFILE_SPEC): Remove qnolinkcmds.
	(ENDFILE_SPEC): Evaluate qnolinkcmds.
2021-01-25 12:31:23 +01:00
Eric Botcazou
5d01fc7c11 Fix internal error on extension with interface at -O2
This is a regression present on the mainline, 10 and 9 branches, in the
form of an internal error with the Ada compiler when a covariant-only
thunk is inlined into its caller.

gcc/ada/
	* gcc-interface/trans.c (make_covariant_thunk): Set the DECL_CONTEXT
	of the parameters and do not set TREE_PUBLIC on the thunk.
	(maybe_make_gnu_thunk): Pass the alias to the covariant thunk.
	* gcc-interface/utils.c (finish_subprog_decl): Set the DECL_CONTEXT
	of the parameters here...
	(begin_subprog_body): ...instead of here.

gcc/testsuite/
	* gnat.dg/thunk2.adb, gnat.dg/thunk2.ads: New test.
	* gnat.dg/thunk2_pkg.ads: New helper.
2021-01-25 11:30:00 +01:00
Paul Thomas
c6b0e33feb Fortran: Fix deferred character lengths in array constructors [PR98517].
2021-01-25  Steve Kargl  <kargl@gcc.gnu.org>

gcc/fortran
	PR fortran/98517
	* resolve.c (resolve_charlen): Check that length expression is
	present before testing for scalar/integer..

gcc/testsuite/
	PR fortran/98517
	* gfortran.dg/charlen_18.f90 : New test.
2021-01-25 10:27:51 +00:00
Sebastian Huber
28229916e1 RTEMS: Fix GCC specification
The use of -nostdlib and -nodefaultlibs disables the processing of
LIB_SPEC (%L) as specified by LINK_COMMAND_SPEC and thus disables the
default linker script for RTEMS.  Move the linker script to
STARTFILE_SPEC which is controlled by -nostdlib and -nostartfiles.  This
fits better since the linker script defines the platform start file
provided by the board support package in RTEMS.

gcc/

	* config/rtems.h (STARTFILE_SPEC): Remove nostdlib and
	nostartfiles handling since this is already done by
	LINK_COMMAND_SPEC.  Evaluate qnolinkcmds.
	(ENDFILE_SPEC): Remove nostdlib and nostartfiles handling since this
	is already done by LINK_COMMAND_SPEC.
	(LIB_SPECS): Remove nostdlib and nodefaultlibs handling since
	this is already done by LINK_COMMAND_SPEC.  Remove qnolinkcmds
	evaluation.
2021-01-25 10:33:52 +01:00
Jakub Jelinek
b7a0507ad9 fold: Fix up strn{case,}cmp folding [PR98771]
As mentioned in the PR, the compiler behaves differently during strncmp
and strncasecmp folding between 32-bit and 64-bit hosts targeting 64-bit
target.  I think that is highly undesirable.

The culprit is the host_size_t_cst_p predicate that is used by
fold_const_call, which punts if the target size_t constants don't fit into
host size_t.  This patch gets rid of that behavior, instead it punts the
same when it doesn't fit into uhwi.

The predicate was used for strncmp and strncasecmp folding and for bcmp, memcmp and
memchr folding.
The constant is in all cases compared to 0, we can do that whether it fits
into size_t or unsigned HOST_WIDE_INT, then it is used in s2 <= s0 or
s2 <= s1 comparisons where s0 and s1 already have uhwi type and represent
the sizes of the objects.
The important difference is for strn{,case}cmp folding, we pass that s2
value as the last argument to the host functions comparing the c_getstr
results.  If s2 fits into size_t, then my patch makes no difference,
but if it is larger, we know the 2 c_getstr objects need to fit into the
host address space, so larger s2 should just act essentially as strcmp
or strcasecmp; as none of those objects can occupy 100% of the address
space, using MIN (SIZE_MAX, s2) achieves that.

2021-01-25  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/98771
	* fold-const-call.c (host_size_t_cst_p): Renamed to ...
	(size_t_cst_p): ... this.  Check and store unsigned HOST_WIDE_INT
	value rather than host size_t.
	(fold_const_call): Change type of s2 from size_t to
	unsigned HOST_WIDE_INT.  Use size_t_cst_p instead of
	host_size_t_cst_p.  For strncmp calls, pass MIN (s2, SIZE_MAX)
	instead of s2 as last argument.
2021-01-25 10:03:40 +01:00
Tamar Christina
389b67feac Arm: Add NEON and MVE complex mul, mla and mls patterns.
This adds implementation for the optabs for complex operations.  With this the
following C code:

  void g (float complex a[restrict N], float complex b[restrict N],
	  float complex c[restrict N])
  {
    for (int i=0; i < N; i++)
      c[i] =  a[i] * b[i];
  }

generates

NEON:

g:
        vmov.f32        q11, #0.0  @ v4sf
        add     r3, r2, #1600
.L2:
        vmov    q8, q11  @ v4sf
        vld1.32 {q10}, [r1]!
        vld1.32 {q9}, [r0]!
        vcmla.f32       q8, q9, q10, #0
        vcmla.f32       q8, q9, q10, #90
        vst1.32 {q8}, [r2]!
        cmp     r3, r2
        bne     .L2
        bx      lr

MVE:

g:
        push    {lr}
        mov     lr, #100
        dls     lr, lr
.L2:
        vldrw.32        q1, [r1], #16
        vldrw.32        q2, [r0], #16
        vcmul.f32       q3, q2, q1, #0
        vcmla.f32       q3, q2, q1, #90
        vstrw.32        q3, [r2], #16
        le      lr, .L2
        ldr     pc, [sp], #4

instead of

g:
        add     r3, r2, #1600
.L2:
        vld2.32 {d20-d23}, [r0]!
        vld2.32 {d16-d19}, [r1]!
        vmul.f32        q14, q11, q9
        vmul.f32        q15, q11, q8
        vneg.f32        q14, q14
        vfma.f32        q15, q10, q9
        vfma.f32        q14, q10, q8
        vmov    q13, q15  @ v4sf
        vmov    q12, q14  @ v4sf
        vst2.32 {d24-d27}, [r2]!
        cmp     r3, r2
        bne     .L2
        bx      lr

and

g:
        add     r3, r2, #1600
.L2:
        vld2.32 {d20-d23}, [r0]!
        vld2.32 {d16-d19}, [r1]!
        vmul.f32        q15, q10, q8
        vmul.f32        q14, q10, q9
        vmls.f32        q15, q11, q9
        vmla.f32        q14, q11, q8
        vmov    q12, q15  @ v4sf
        vmov    q13, q14  @ v4sf
        vst2.32 {d24-d27}, [r2]!
        cmp     r3, r2
        bne     .L2
        bx      lr

respectively.

gcc/ChangeLog:

	* config/arm/iterators.md (rotsplit1, rotsplit2, conj_op, fcmac1,
	VCMLA_OP, VCMUL_OP): New.
	* config/arm/mve.md (mve_vcmlaq<mve_rot><mode>): Support vec_dup 0.
	* config/arm/neon.md (cmul<conj_op><mode>3): New.
	* config/arm/unspecs.md (UNSPEC_VCMLA_CONJ, UNSPEC_VCMLA180_CONJ,
	UNSPEC_VCMUL_CONJ): New.
	* config/arm/vec-common.md (cmul<conj_op><mode>3, arm_vcmla<rot><mode>,
	cml<fcmac1><conj_op><mode>4): New.
2021-01-25 08:56:37 +00:00
GCC Administrator
02551aa999 Daily bump. 2021-01-25 00:16:24 +00:00
GCC Administrator
6b1633378b Daily bump. 2021-01-24 00:16:16 +00:00
Iain Buclaw
81f928ec8e libphobos: Fix executables segfault on mipsel architecture
The dynamic section on MIPS is read-only, but this was not properly
handled in the runtime library.  The segfault only occurred for programs
that linked to the shared libphobos library.

libphobos/ChangeLog:

	PR d/98806
	* libdruntime/gcc/sections/elf_shared.d (MIPS_Any): Declare version
	for MIPS32 and MIPS64.
	(getDependencies): Adjust dlpi_addr on MIPS_Any.
2021-01-24 00:20:25 +01:00
Anthony Sharp
7e0f147a29 c++: private inheritance access diagnostics fix [PR17314]
This patch fixes PR17314. Previously, when class C attempted
to access member a declared in class A through class B, where class B
privately inherits from A and class C inherits from B, GCC would correctly
report an access violation, but would erroneously report that the reason was
because a was "protected", when in fact, from the point of view of class C,
it was really "private". This patch updates the diagnostics code to generate
more correct errors in cases of failed inheritance such as these.

The reason this bug happened was because GCC was examining the
declared access of decl, instead of looking at it in the
context of class inheritance.

gcc/cp/ChangeLog:

2021-01-21  Anthony Sharp  <anthonysharp15@gmail.com>

	* call.c (complain_about_access): Altered function.
	* cp-tree.h (complain_about_access): Changed parameters of function.
	(get_parent_with_private_access): Declared new function.
	* search.c (get_parent_with_private_access): Defined new function.
	* semantics.c (enforce_access): Modified function.
	* typeck.c (complain_about_unrecognized_member): Updated function
	arguments in complain_about_access.

gcc/testsuite/ChangeLog:

2021-01-21  Anthony Sharp  <anthonysharp15@gmail.com>

	* g++.dg/lookup/scoped1.C: Modified testcase to run successfully
	with changes.
	* g++.dg/tc1/dr142.C: Same as above.
	* g++.dg/tc1/dr52.C: Same as above.
	* g++.old-deja/g++.brendan/visibility6.C: Same as above.
	* g++.old-deja/g++.brendan/visibility8.C: Same as above.
	* g++.old-deja/g++.jason/access8.C: Same as above.
	* g++.old-deja/g++.law/access4.C: Same as above.
	* g++.old-deja/g++.law/visibility12.C: Same as above.
	* g++.old-deja/g++.law/visibility4.C: Same as above.
	* g++.old-deja/g++.law/visibility8.C: Same as above.
	* g++.old-deja/g++.other/access4.C: Same as above.
2021-01-23 17:48:31 -05:00
Jakub Jelinek
c63f091db8 rs6000: Fix up __m64 typedef in mmintrin.h [PR97301]
The x86 __m64 type is defined as:
/* The Intel API is flexible enough that we must allow aliasing with other
   vector types, and their scalar components.  */
typedef int __m64 __attribute__ ((__vector_size__ (8), __may_alias__));
and so matches the comment above it in that reads and stores through
pointers to __m64 can alias anything.
But in the rs6000 headers that is the case only for __m128, but not __m64.

The following patch adds that attribute, which fixes the
FAIL: gcc.target/powerpc/sse-movhps-1.c execution test
FAIL: gcc.target/powerpc/sse-movlps-1.c execution test
regressions that appeared when Honza improved ipa-modref.

2021-01-23  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/97301
	* config/rs6000/mmintrin.h (__m64): Add __may_alias__ attribute.
2021-01-23 09:41:58 +01:00
Patrick Palka
a8cef3cba6 c++: 'this' injection and static member functions [PR97399]
In the testcase pr97399.C below, finish_qualified_id_expr at parse time
adds an implicit 'this->' to the expression tmp::integral<T> (because
it's type-dependent, and also current_class_ptr is set at this point)
within the trailing return type.  Later when substituting into this
trailing return type we crash because we can't resolve the 'this', since
tsubst_function_type does inject_this_parm only for non-static member
functions, which tmp::func is not.

This patch fixes this issue by removing the type-dependence check
in finish_qualified_id_expr added by r9-5972, and instead relaxes
shared_member_p to handle dependent USING_DECLs:

> I think I was wrong in my assertion around Alex's patch that
> shared_member_p should abort on a dependent USING_DECL; it now seems
> appropriate for it to return false if we don't know, we just need to
> adjust the comment to say that.

And when parsing a friend function declaration, we shouldn't be setting
current_class_ptr at all, so this patch additionally suppresses
inject_this_parm in this case.

Finally, the self-contained change to cp_parser_init_declarator is so
that we properly communicate static-ness to cp_parser_direct_declarator
when parsing a member function template.  This lets us reject the
explicit use of 'this' in the testcase this2.C below.

gcc/cp/ChangeLog:

	PR c++/97399
	* cp-tree.h (shared_member_p): Adjust declaration.
	* parser.c (cp_parser_init_declarator): If the storage class
	specifier is sc_static, pass true for static_p to
	cp_parser_declarator.
	(cp_parser_direct_declarator): Don't do inject_this_parm when
	the declarator is a friend.
	* search.c (shared_member_p): Change return type to bool and
	adjust function body accordingly.  Return false for a dependent
	USING_DECL instead of aborting.
	* semantics.c (finish_qualified_id_expr): Rely on shared_member_p
	even when type-dependent.

gcc/testsuite/ChangeLog:

	PR c++/88548
	PR c++/97399
	* g++.dg/cpp0x/this2.C: New test.
	* g++.dg/template/pr97399.C: New test.
2021-01-23 00:24:17 -05:00
David Edelsohn
eb9883c131 testsuite: fix gcc.target/powerpc ilp32 failures
The recent vec insert code generation changes were not reflected in the
expected output for ilp32 targets.  This patch updates the expected
instructions and counts.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/fold-vec-insert-char-p9.c: Adjust ilp32.
	* gcc.target/powerpc/fold-vec-insert-float-p9.c: Same.
	* gcc.target/powerpc/fold-vec-insert-int-p9.c: Same.
	* gcc.target/powerpc/fold-vec-insert-longlong.c: Same.
	* gcc.target/powerpc/fold-vec-insert-short-p9.c: Same.
	* gcc.target/powerpc/pr79251.p9.c: Same.
2021-01-22 19:56:14 -05:00
GCC Administrator
8502e23d1f Daily bump. 2021-01-23 00:16:32 +00:00
Jonathan Wright
16b7b8a32d aarch64: Use RTL builtins for integer mla intrinsics
Rewrite integer mla Neon intrinsics to use RTL builtins rather than
inline assembly code, allowing for better scheduling and optimization.

gcc/Changelog:

2021-01-14  Jonathan Wright  <jonathan.wright@arm.com>

	* config/aarch64/aarch64-simd-builtins.def: Add mla builtin
	generator macro.
	* config/aarch64/arm_neon.h (vmla_s8): Use RTL builtin rather
	than asm.
	(vmla_s16): Likewise.
	(vmla_s32): Likewise.
	(vmla_u8): Likewise.
	(vmla_u16): Likewise.
	(vmla_u32): Likewise.
	(vmlaq_s8): Likewise.
	(vmlaq_s16): Likewise.
	(vmlaq_s32): Likewise.
	(vmlaq_u8): Likewise.
	(vmlaq_u16): Likewise.
	(vmlaq_u32): Likewise.
2021-01-22 23:18:11 +00:00
Marek Polacek
89100826ac c++: ICE with noexcept in class in member function [PR96623]
I discovered very strange code in inject_parm_decls:

   if (args && is_this_parameter (args))
     {
       gcc_checking_assert (current_class_ptr == NULL_TREE);
       current_class_ptr = NULL_TREE;

We are tripping up on the assert because when we call inject_parm_decls,
current_class_ptr is set to 'A'.  It was set by inject_this_parameter
after we've parsed the parameter-declaration-clause of the member
function foo.  It seems correct to set ccp/ccr to A::B when we're
late parsing the noexcept-specifiers of bar* functions in B, so that
this-> does the right thing.  Since inject_parm_decls doesn't expect
to see non-null ccp/ccr, reset it before calling inject_parm_decls.

gcc/cp/ChangeLog:

	PR c++/96623
	* parser.c (inject_parm_decls): Remove a redundant assignment.
	(cp_parser_class_specifier_1): Clear current_class_{ptr,ref}
	before calling inject_parm_decls.

gcc/testsuite/ChangeLog:

	PR c++/96623
	* g++.dg/cpp0x/noexcept64.C: New test.
2021-01-22 17:55:06 -05:00
David Edelsohn
ab8cde87ca testsuite: Enable spbp.C on AIX.
This testcase was disabled in the distant past when AIX did not have
support for DWARF and the testcase explicitly invokes DWARF debugging.
This patch re-enables the testcase.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/spbp.C: Remove skip on AIX.
2021-01-22 17:38:50 -05:00
David Malcolm
9cead79073 doc: ensure GCC_EXTRA_DIAGNOSTIC_OUTPUT gets an HTML anchor
This is referenced by my recent release notes changes for GCC 11:
  https://gcc.gnu.org/pipermail/gcc-patches/2021-January/564164.html

gcc/ChangeLog:
	* doc/invoke.texi (GCC_EXTRA_DIAGNOSTIC_OUTPUT): Add @findex
	directive.
2021-01-22 17:07:30 -05:00
Jakub Jelinek
70ab52b8ca testsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/powerpc
Spotted while fixing the rs6000 aliasing issue.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	* gcc.target/powerpc/m128-check.h (CHECK_EXP, CHECK_FP_EXP): Fix a
	typo, UINON_TYPE to UNION_TYPE.
2021-01-22 22:55:44 +01:00
Jakub Jelinek
b30e19b517 testsuite: Fix a typo - UINON_TYPE to UNION_TYPE - in gcc.target/i386
Spotted while fixing the rs6000 aliasing issue.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	* gcc.target/i386/m128-check.h (CHECK_EXP, CHECK_FP_EXP): Fix a typo,
	UINON_TYPE to UNION_TYPE.
	* gcc.target/i386/m256-check.h (CHECK_FP_EXP): Likewise.
	* gcc.target/i386/m512-check.h (CHECK_ROUGH_EXP): Likewise.
2021-01-22 22:51:03 +01:00
Jakub Jelinek
d08677c11d testsuite: Fix sse2-andnpd-1.c and sse-andnps-1.c testscases on powerpc
On Mon, Sep 21, 2020 at 10:12:20AM +0200, Richard Biener wrote:
> On Mon, 21 Sep 2020, Jan Hubicka wrote:
> > these testcases now fails because they contains an invalid type puning
> > that happens via const VALUE_TYPE *v pointer. Since the check function
> > is noinline, modref is needed to trigger the wrong code.
> > I think it is easiest to fix it by no-strict-aliasing.
> >
> > Regtested x86_64-linux, OK?
>
> OK.
>
> >     * gcc.target/i386/m128-check.h: Add no-strict aliasing to
> >     CHECK_EXP macro.
> >
> > diff --git a/gcc/testsuite/gcc.target/i386/m128-check.h b/gcc/testsuite/gcc.target/i386/m128-check.h
> > index 48b23328539..6f414b07be7 100644
> > --- a/gcc/testsuite/gcc.target/i386/m128-check.h
> > +++ b/gcc/testsuite/gcc.target/i386/m128-check.h
> > @@ -78,6 +78,7 @@ typedef union
> >
> >  #define CHECK_EXP(UINON_TYPE, VALUE_TYPE, FMT)             \
> >  static int                                         \
> > +__attribute__((optimize ("no-strict-aliasing")))   \
> >  __attribute__((noinline, unused))                  \
> >  check_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v)     \
> >  {                                                  \

On powerpc64le the tests suffer from the exact same issue.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	* gcc.target/powerpc/m128-check.h (check_##UINON_TYPE): Add
	optimize ("no-strict-aliasing") attribute.
2021-01-22 22:38:31 +01:00
Jakub Jelinek
b485fa167e dwarf2out: Always emit required 0 entries for DWARF 5 in *.debug_line [PR98796]
When GCC is emitting .debug_line or .gnu.debuglto_.debug_line section by
itself (happens either with too old or non-GNU assembler, with
-gno-as-loc-support or with -flto) on empty translation units, it violates
the DWARF 5 requirements.
The standard says:
"The first entry is the current directory of the compilation."
and a few lines later:
"The first entry in the sequence is the primary source file whose file name
exactly matches that given in the DW_AT_name attribute in the compilation
unit debugging information entry."
GCC emits 4 zeros (directory entry format count, directories count,
filename entry format count and filename count), which would be ok if the
spec said The first entry may be rather than is.

I had a brief look at whether I could just fall through into the rest of the
function, but there are too many assumptions that there is at least one
normal file that it can't be done that way easily.

So this patch instead extends the early out code to emit the required
minimum, which is 15 bytes more than we used to emit before.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98796
	* dwarf2out.c (output_file_names): For -gdwarf-5, if there are no
	filenames to emit, still emit the required 0 index directory and
	filename entries that match DW_AT_comp_dir and DW_AT_name of the
	compilation unit.
2021-01-22 22:37:36 +01:00
Jonathan Wright
32a93eac7a MAINTAINERS: Add myself for write after approval
ChangeLog:

2021-01-22  Jonathan Wright  <jonathan.wright@arm.com>

	* MAINTAINERS (Write After Approval): Add myself.
2021-01-22 19:11:21 +00:00
Jason Merrill
90cbc76900 c++: Fix base copy elision thinko [PR98744]
As Jakub points out in the PR, I was mixing up
DECL_HAS_IN_CHARGE_PARM_P (which is true for the abstract maybe-in-charge
constructor) and DECL_HAS_VTT_PARM_P (which is true for a base constructor
that needs to handle virtual bases).

gcc/cp/ChangeLog:

	PR c++/98744
	* call.c (make_base_init_ok): Use DECL_HAS_VTT_PARM_P.

gcc/testsuite/ChangeLog:

	PR c++/98744
	* g++.dg/init/elide7.C: New test.
2021-01-22 13:09:00 -05:00
Jakub Jelinek
a9ed18295b c++: Fix up ubsan false positives on references [PR95693]
Alex' 2 years old change to build_zero_init_1 to return NULL pointer with
reference type for references breaks the sanitizers, the assignment of NULL
to a reference typed member is then instrumented before it is overwritten
with a non-NULL address later on.
That change has been done to fix error recovery ICE during
process_init_constructor_record, where we:
          if (TYPE_REF_P (fldtype))
            {
              if (complain & tf_error)
                error ("member %qD is uninitialized reference", field);
              else
                return PICFLAG_ERRONEOUS;
            }
a few lines earlier, but then continue and ICE when build_zero_init returns
NULL.

The following patch reverts the build_zero_init_1 change and instead creates
the NULL with reference type constants during the error recovery.

The pr84593.C testcase Alex' change was fixing still works as before.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR sanitizer/95693
	* init.c (build_zero_init_1): Revert the 2018-03-06 change to
	return build_zero_cst for reference types.
	* typeck2.c (process_init_constructor_record): Instead call
	build_zero_cst here during error recovery instead of build_zero_init.

	* g++.dg/ubsan/pr95693.C: New test.
2021-01-22 19:04:55 +01:00
Marek Polacek
25fc4d01a8 c++: ICE when mangling operator name [PR98545]
r11-6301 added some asserts in mangle.c, and now we trip over one of
them.  In particular, it's the one asserting that we didn't get
IDENTIFIER_ANY_OP_P when mangling an expression with a dependent name.

As this testcase shows, it's possible to get that, so turn the assert
into an if and write "on".  That changes the mangling in the following
way:

With this patch:

$ c++filt _ZN1i1hIJ1adS1_EEEDTcldtdefpTonclspcvT__EEEDpS2_
decltype (((*this).(operator()))((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

G++10:
$ c++filt _ZN1i1hIJ1adS1_EEEDTcldtdefpTclspcvT__EEEDpS2_
decltype (((*this).(operator()))((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

clang++/icc:
$ c++filt _ZN1i1hIJ1adS1_EEEDTclonclspcvT__EEEDpS2_
decltype ((operator())((a)(), (double)(), (a)())) i::h<a, double, a>(a, double, a)

This is now tracked in PR98756.

gcc/cp/ChangeLog:

	PR c++/98545
	* mangle.c (write_member_name): Emit abi_warn_or_compat_version_crosses
	warnings regardless of abi_version_at_least.
	(write_expression): When the expression is a dependent name
	and an operator name, write "on" before writing its name.

gcc/ChangeLog:

	PR c++/98545
	* doc/invoke.texi: Update C++ ABI Version 15 description.

gcc/testsuite/ChangeLog:

	PR c++/98545
	* g++.dg/abi/mangle76.C: New test.
2021-01-22 13:02:23 -05:00
Paul Thomas
bf8ee9e4ee Fortran: Fix for class functions as associated target [PR98565].
2021-01-22  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/98565
	* trans-intrinsic.c (gfc_conv_associated): Do not add a _data
	component for scalar class function targets. Instead, fix the
	function result and access the _data from that.

gcc/testsuite/
	PR fortran/98565
	* gfortran.dg/associated_target_7.f90 : New test.
2021-01-22 17:11:32 +00:00
Martin Jambor
d7e681fc3a Testcase for old PR 47059
I stumbled across PR 47059 from 2010 which has been addressed by
store-merging.  I am going to close it but would like to add its
testcase too.

gcc/testsuite/ChangeLog:

2021-01-08  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/47059
	* gcc.dg/tree-ssa/pr47059.c: New test.
2021-01-22 18:09:38 +01:00
Kyrylo Tkachov
9d33785f57 tree-ssa-mathopts: Use proper poly_int64 comparison with param_avoid_fma_max_bits [PR 98766]
We ICE here because we end up comparing a poly_int64 with a scalar using
<= rather than maybe_le.
This patch fixes that in the way rich suggests in the PR.

gcc/ChangeLog:

	PR tree-optimization/98766
	* tree-ssa-math-opts.c (convert_mult_to_fma): Use maybe_le when
	comparing against type size with param_avoid_fma_max_bits.

gcc/testsuite/ChangeLog:

	PR tree-optimization/98766
	* gcc.dg/pr98766.c: New test.
2021-01-22 16:40:57 +00:00
Nathan Sidwell
eee8ed2f22 testsuite: Uniquify test names [PR 98795]
Header unit names come from the path the preprocessor determines, and
thus can be absolute.  This tweaks the testsuite to elide that
absoluteness when embedded in a CMI name.  We were also not
distinguishing link and execute tests by the $std flags, so append
them when necessary.

	PR testsuite/98795
	gcc/testsuite/
	* g++.dg/modules/modules.exp (module_cmi_p): Avoid
	embedded absolute paths.
	(module_do_it): Append $std to test name.
2021-01-22 06:44:22 -08:00
Richard Biener
4be156d6be middle-end/98793 - properly handle BLKmode vectors in vector_element_bits
The previous change made AVX512 mask vectors correct but disregarded
the possibility of generic (BLKmode) boolean vectors which are exposed
by the frontends already.

2021-01-22  Richard Biener  <rguenther@suse.de>

	PR middle-end/98793
	* tree.c (vector_element_bits): Key single-bit bool vector on
	integer mode rather than not vector mode.

	* gcc.dg/pr98793.c: New testcase.
2021-01-22 15:23:54 +01:00
Xionghu Luo
e3a8ef8ef2 rs6000: Enable vec_insert for P8 with rs6000_expand_vector_set_var_p8 [PR98093]
Support P8 variable vec_insert and Update testcases' instruction count.

gcc/ChangeLog:

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

	PR target/98093

	* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
	Generate ARRAY_REF(VIEW_CONVERT_EXPR) for P8 and later
	platforms.
	* config/rs6000/rs6000.c (rs6000_expand_vector_set_var): Update
	to call different path for P8 and P9.
	(rs6000_expand_vector_set_var_p9): New function.
	(rs6000_expand_vector_set_var_p8): New function.

gcc/testsuite/ChangeLog:

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

	* gcc.target/powerpc/pr79251.p8.c: New test.
	* gcc.target/powerpc/fold-vec-insert-char-p8.c: Adjust
	instruction counts.
	* gcc.target/powerpc/fold-vec-insert-char-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-double.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-float-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-float-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-int-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-int-p9.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-longlong.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-short-p8.c: Likewise.
	* gcc.target/powerpc/fold-vec-insert-short-p9.c: Likewise.
	* gcc.target/powerpc/vsx-builtin-7.c: Likewise.
2021-01-22 08:05:32 -06:00
Xionghu Luo
b292255975 rs6000: Support variable insert and Expand vec_insert in expander [PR79251]
vec_insert accepts 3 arguments, arg0 is input vector, arg1 is the value
to be insert, arg2 is the place to insert arg1 to arg0.  Current expander
generates stxv+stwx+lxv if arg2 is variable instead of constant, which
causes serious store hit load performance issue on Power.  This patch tries
 1) Build VIEW_CONVERT_EXPR for vec_insert (i, v, n) like v[n&3] = i to
unify the gimple code, then expander could use vec_set_optab to expand.
 2) Expand the IFN VEC_SET to fast instructions: lvsr+insert+lvsl.
In this way, "vec_insert (i, v, n)" and "v[n&3] = i" won't be expanded too
early in gimple stage if arg2 is variable, avoid generating store hit load
instructions.

For Power9 V4SI:
	addi 9,1,-16
	rldic 6,6,2,60
	stxv 34,-16(1)
	stwx 5,9,6
	lxv 34,-16(1)
=>
	rlwinm 6,6,2,28,29
	mtvsrwz 0,5
	lvsr 1,0,6
	lvsl 0,0,6
	xxperm 34,34,33
	xxinsertw 34,0,12
	xxperm 34,34,32

Though instructions increase from 5 to 7, the performance is improved
60% in typical cases.
Tested with V2DI, V2DF V4SI, V4SF, V8HI, V16QI on Power9-LE.

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

gcc/ChangeLog:

	PR target/79251
	PR target/98065

	* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
	Ajdust variable index vec_insert from address dereference to
	ARRAY_REF(VIEW_CONVERT_EXPR) tree expression.
	* config/rs6000/rs6000-protos.h (rs6000_expand_vector_set_var):
	New declaration.
	* config/rs6000/rs6000.c (rs6000_expand_vector_set_var): New function.

2021-01-22  Xionghu Luo  <luoxhu@linux.ibm.com>

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pr79251.p9.c: New test.
	* gcc.target/powerpc/pr79251-run.c: New test.
	* gcc.target/powerpc/pr79251.h: New header.
2021-01-22 08:03:53 -06:00
Martin Liska
b46027c654 Drop time profile for multi-threaded training run.
gcc/ChangeLog:

	PR gcov-profile/98739
	* profile.c (compute_value_histograms): Drop time profile for
	-fprofile-reproducible=multithreaded.
2021-01-22 14:20:53 +01:00
Nathan Sidwell
4804de453e driver: do not check file existence here [PR 98452]
The driver checks whether OPT_SPECIAL_input_file options are readable.
There's no need, the compiler proper will do that anyway.

	gcc/
	* gcc.c (process_command): Don't check OPT_SPECIAL_input_file
	existence here.
2021-01-22 04:56:11 -08:00
Richard Biener
8bad25eb56 middle-end/98773 - always sign extend CHREC_RIGHT
The previous change exposed a miscompile when trying to interpret
CHREC_RIGHT correctly which in fact it already was to the extent
it is used.  The following reverts this part of the change, only
retaining the singling out of HOST_WIDE_INT_MIN.

2021-01-22  Richard Biener  <rguenther@suse.de>

	PR middle-end/98773
	* tree-data-ref.c (initalize_matrix_A): Revert previous
	change, retaining failing on HOST_WIDE_INT_MIN CHREC_RIGHT.

	* gcc.dg/torture/pr98773.c: New testcase.
2021-01-22 12:49:46 +01:00
Jakub Jelinek
36fe1cdc95 match.pd: Replace incorrect simplifications into copysign [PR90248]
In the PR Andrew said he has implemented a simplification that has been
added to LLVM, but that actually is not true, what is in there are
X * (X cmp 0.0 ? +-1.0 : -+1.0) simplifications into +-abs(X)
but what has been added into GCC are (X cmp 0.0 ? +-1.0 : -+1.0)
simplifications into copysign(1, +-X) and then
X * copysign (1, +-X) into +-abs (X).
The problem is with the (X cmp 0.0 ? +-1.0 : -+1.0) simplifications,
they don't work correctly when X is zero.
E.g.
(X > 0.0 ? 1.0 : -1.0)
is -1.0 when X is either -0.0 or 0.0, but copysign will make it return
1.0 for 0.0 and -1.0 only for -0.0.
(X >= 0.0 ? 1.0 : -1.0)
is 1.0 when X is either -0.0 or 0.0, but copysign will make it return
still 1.0 for 0.0 and -1.0 for -0.0.
The simplifications were guarded on !HONOR_SIGNED_ZEROS, but as discussed in
the PR, that option doesn't mean that -0.0 will not ever appear as operand
of some operation, it is hard to guarantee that without compiler adding
canonicalizations of -0.0 to 0.0 after most of the operations and thus
making it very slow, but that the user asserts that he doesn't care if the result
of operations will be 0.0 or -0.0.  Not to mention that some of the
transformations are incorrect even for positive 0.0.

So, instead of those simplifications this patch recognizes patterns where
those ?: expressions are multiplied by X, directly into +-abs.
That works fine even for 0.0 and -0.0 (as long as we don't care about
whether the result is exactly 0.0 or -0.0 in those cases), because
whether the result of copysign is -1.0 or 1.0 doesn't matter when it is
multiplied by 0.0 or -0.0.

As a follow-up, maybe we should add the simplification mentioned in the PR,
in particular doing copysign by hand through
VIEW_CONVERT_EXPR <int, float_X> < 0 ? -float_constant : float_constant
into copysign (float_constant, float_X).  But I think that would need to be
done in phiopt.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/90248
	* match.pd (X cmp 0.0 ? 1.0 : -1.0 -> copysign(1, +-X),
	X cmp 0.0 ? -1.0 : +1.0 -> copysign(1, -+X)): Remove
	simplifications.
	(X * (X cmp 0.0 ? 1.0 : -1.0) -> +-abs(X),
	X * (X cmp 0.0 ? -1.0 : 1.0) -> +-abs(X)): New simplifications.

	* gcc.dg/tree-ssa/copy-sign-1.c: Don't expect any copysign
	builtins.
	* gcc.dg/pr90248.c: New test.
2021-01-22 11:51:22 +01:00
Jakub Jelinek
e287a2a11d on ARRAY_REFs sign-extend offsets only from sizetype's precision [PR98255]
As discussed in the PR, the problem here is that the routines changed in
this patch sign extend the difference of index and low_bound from the
precision of the index, so e.g. when index is unsigned int and contains
value -2U, we treat it as index -2 rather than 0x00000000fffffffeU on 64-bit
arches.
On the other hand, get_inner_reference which is used during expansion, does:
            if (! integer_zerop (low_bound))
              index = fold_build2 (MINUS_EXPR, TREE_TYPE (index),
                                   index, low_bound);

            offset = size_binop (PLUS_EXPR, offset,
                                 size_binop (MULT_EXPR,
                                             fold_convert (sizetype, index),
                                             unit_size));
which effectively requires that either low_bound is constant 0 and then
index in ARRAY_REFs can be arbitrary type which is then sign or zero
extended to sizetype, or low_bound is something else and then index and
low_bound must have compatible types and it is still converted afterwards to
sizetype and from there then a few lines later:
expr.c-  if (poly_int_tree_p (offset))
expr.c-    {
expr.c:      poly_offset_int tem = wi::sext (wi::to_poly_offset (offset),
expr.c-                               TYPE_PRECISION (sizetype));
The following patch makes those routines match what get_inner_reference is
doing.

2021-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98255
	* tree-dfa.c (get_ref_base_and_extent): For ARRAY_REFs, sign
	extend index - low_bound from sizetype's precision rather than index
	precision.
	(get_addr_base_and_unit_offset_1): Likewise.
	* tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Likewise.
	* gimple-fold.c (fold_const_aggregate_ref_1): Likewise.

	* gcc.dg/pr98255.c: New test.
2021-01-22 11:42:03 +01:00
Richard Biener
fd61ca67f9 tree-optimization/98786 - fix issue with phiopt and abnormals
This fixes factor_out_conditional_conversion to avoid creating overlapping
lifetimes for abnormals.  It also makes sure we do deal with a conditional
conversion (at least for one PHI arg def) - for the testcase that wasn't the case.

2021-01-22  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98786
	* tree-ssa-phiopt.c (factor_out_conditional_conversion): Avoid
	adding new uses of abnormals.  Verify we deal with a conditional
	conversion.

	* gcc.dg/torture/pr98786.c: New testcase.
2021-01-22 10:37:51 +01:00
Prathamesh Kulkarni
4e3beaca15 arm: Fix ICE with incompatible values for -mfp16-format [PR98636].
gcc/
2021-01-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR target/98636
	* optc-save-gen.awk: Add arm_fp16_format to checked_options.

gcc/testsuite/
2021-01-22  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR target/98636
	* gcc.target/arm/pr98636.c: New test.
2021-01-22 14:14:20 +05:30
liuhongt
ee78c20e74 Lower AVX512 vector comparison to AVX version when dest is vector.
gcc/ChangeLog:

	PR target/96891
	PR target/98348
	* config/i386/sse.md (VI_128_256): New mode iterator.
	(*avx_cmp<mode>3_1, *avx_cmp<mode>3_2, *avx_cmp<mode>3_3,
	 *avx_cmp<mode>3_4, *avx2_eq<mode>3, *avx2_pcmp<mode>3_1,
	 *avx2_pcmp<mode>3_2, *avx2_gt<mode>3): New
	define_insn_and_split to lower avx512 vector comparison to avx
	version when dest is vector.
	(*<avx512>_cmp<mode>3,*<avx512>_cmp<mode>3,*<avx512>_ucmp<mode>3):
	define_insn_and_split for negating the comparison result.
	* config/i386/predicates.md (float_vector_all_ones_operand):
	New predicate.
	* config/i386/i386-expand.c (ix86_expand_sse_movcc): Use
	general NOT operator without UNSPEC_MASKOP.

gcc/testsuite/ChangeLog:

	PR target/96891
	PR target/98348
	* gcc.target/i386/avx512bw-pr96891-1.c: New test.
	* gcc.target/i386/avx512f-pr96891-1.c: New test.
	* gcc.target/i386/avx512f-pr96891-2.c: New test.
	* gcc.target/i386/avx512f-pr96891-3.c: New test.
	* g++.target/i386/avx512f-pr96891-1.C: New test.
	* gcc.target/i386/bitwise_mask_op-3.c: Adjust testcase.
2021-01-22 12:35:14 +08:00
Marek Polacek
bca467e56f c++: ICE with delayed noexcept and attribute used [PR97966]
Another ICE with delayed noexcept parsing, but a bit gnarlier.

A function definition marked with __attribute__((used)) ought to be
emitted even when it is not referenced in the TU.  For a member function
template marked with __attribute__((used)) this means that it will
be instantiated: in instantiate_class_template_1 we have

11971               /* Instantiate members marked with attribute used.  */
11972               if (r != error_mark_node && DECL_PRESERVE_P (r))
11973                 mark_used (r);

It is not so surprising that this doesn't work well with delayed
noexcept parsing: when we're processing the function template we delay
the parsing, so the member "foo" is found, but then when we're
instantiating it, "foo" hasn't yet been seen, which creates a
discrepancy and a crash ensues.  "foo" hasn't yet been seen because
instantiate_class_template_1 just loops over the class members and
instantiates right away.

To make it work, this patch uses a vector to keep track of members
marked with attribute used and uses it to instantiate such members
only after we're done with the class; in particular, after we have
called finish_member_declaration for each member.  And we ought to
be verifying that we did emit such members, so I've added a bunch
of dg-finals.

gcc/cp/ChangeLog:

	PR c++/97966
	* pt.c (instantiate_class_template_1): Instantiate members
	marked with attribute used only after we're done instantiating
	the class.

gcc/testsuite/ChangeLog:

	PR c++/97966
	* g++.dg/cpp0x/noexcept63.C: New test.
2021-01-21 19:22:01 -05:00
Maciej W. Rozycki
070a1fb5f5 MAINTAINERS: Update my e-mail address
* MAINTAINERS (Write After Approval): Update my e-mail address.
2021-01-22 00:18:14 +00:00
GCC Administrator
7559d465fd Daily bump. 2021-01-22 00:16:22 +00:00
David Edelsohn
9929d04ee2 testsuite: Adjust cpp2a/lambda-uneval regrex
Both lambda-uneval1.C and lambda-uneval5.C test that a symbol is not
declared global by looking for "globl" assembler directive.  The testcases
generate the "lglobl" directive in AIX XCOFF, which is a false positive.
This patch restricts the regex to ignore a prepended "l".  The patch
also tightens the regex to specifically look for space, tab or period
between the "globl" and the symbol.

Tested on powerpc-ibm-aix7.2.3.0 and powerpc64le-linux-gnu.

	* g++.dg/cpp2a/lambda-uneval1.C: Ignore preceding "l" and
	intervening period.
	* g++.dg/cpp2a/lambda-uneval5.C: Ignore preceding "l" and
	explicitly check for intervening space, tab or period.
2021-01-21 18:49:33 -05:00
Vladimir N. Makarov
68ba1039c7 [PR98777] LRA: Use preliminary created pseudo for in LRA elimination subpass
LRA did not extend ira_reg_equiv after generation of a pseudo in
eliminate_regs_in_insn which might results in LRA crash.  It is better not
to extend ira_reg_equiv but to use preliminary generated pseudo.  The
patch implements it.

gcc/ChangeLog:

	PR rtl-optimization/98777
	* lra-int.h (lra_pmode_pseudo): New extern.
	* lra.c (lra_pmode_pseudo): New global.
	(lra): Set it up.
	* lra-eliminations.c (eliminate_regs_in_insn): Use it.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98777
	* gcc.target/riscv/pr98777.c: New.
2021-01-21 18:06:49 -05:00
Ilya Leoshkevich
efb6bc55a9 fwprop: Allow (subreg (mem)) simplifications
Suppose we have:

    (set (reg/v:TF 63) (mem/c:TF (reg/v:DI 62)))
    (set (reg:FPRX2 66) (subreg:FPRX2 (reg/v:TF 63) 0))

It is clearly profitable to propagate the first insn into the second
one and get:

    (set (reg:FPRX2 66) (mem/c:FPRX2 (reg/v:DI 62)))

fwprop actually manages to perform this, but doesn't think the result is
worth it, which results in unnecessary store/load sequences on s390.
Improve the situation by classifying SUBREG -> MEM changes as
profitable.

gcc/ChangeLog:

2021-01-15  Ilya Leoshkevich  <iii@linux.ibm.com>

	* fwprop.c (fwprop_propagation::classify_result): Allow
	(subreg (mem)) simplifications.
2021-01-21 22:48:47 +01:00
Patrick Palka
f645da0e4a c++: Fix excessive instantiation inside decltype [PR71879]
Here after resolving the address of a template-id inside decltype, we
end up instantiating the chosen specialization (from the call to
mark_used in resolve_nondeduced_context), even though only its type is
needed.

This patch sets cp_unevaluated_operand throughout finish_decltype_type,
so that in particular it's set during the call to
resolve_nondeduced_context within.

gcc/cp/ChangeLog:

	PR c++/71879
	* semantics.c (finish_decltype_type): Set up a cp_unevaluated
	sentinel at the start of the function.  Remove a now-redundant
	manual adjustment of cp_unevaluated_operand.

gcc/testsuite/ChangeLog:

	PR c++/71879
	* g++.dg/cpp0x/decltype-71879.C: New test.
2021-01-21 14:04:55 -05:00
Nathan Sidwell
7944753fad c++: Fix null this pointer [PR 98624]
One may not use a null this pointer to invoke a static member
function.  This fixes the remaining ubsan errors found with an
ubsan bootstrap.

	PR c++/98624
	gcc/cp/
	* module.cc (depset::hash::find_dependencies): Add
	module arg.
	(trees_out::core_vals): Check state before calling
	write_location.
	(sort_cluster, module_state::write): Adjust
	find_dependencies call.
2021-01-21 10:41:35 -08:00
Jakub Jelinek
0fb7aa205a c++: Fix up potential_constant_expression_1 FOR/WHILE_STMT handling [PR98672]
The following testcase is rejected even when it is valid.
The problem is that potential_constant_expression_1 doesn't have the
accurate *jump_target tracking cxx_eval_* has, and when the loop has
a condition that isn't guaranteed to be always true, the body isn't walked
at all.  That is mostly a correct conservative behavior, except that it
doesn't detect if there are any return statements in the body, which means
the loop might return instead of falling through to the next statement.
We already have code for return stmt discovery in code snippets we don't
try to evaluate for switches, so this patch reuses that for FOR_STMT
and WHILE_STMT bodies.

Note, I haven't touched FOR_EXPR, with statement expressions it could
have return stmts in it too, or it could have break or continue statements
that wouldn't bind to the current loop but to something outer.  That
case is clearly mishandled by potential_constant_expression_1 even
when the condition is missing or is always true, and it wouldn't surprise me
if cxx_eval_* didn't handle it right either, so I'm deferring that to
separate PR for later.  We'd need proper test coverage for all of that.

> Hmm, IF_STMT probably also needs to check the else clause, if the condition
> isn't a known constant.

You're right, I thought it was ok because it recurses with tf_none, but
if the then branch is potentially constant and only else returns, continues
or breaks, then as the enhanced testcase shows we were mishandling it too.

2021-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98672
	* constexpr.c (check_for_return_continue_data): Add break_stmt member.
	(check_for_return_continue): Also look for BREAK_STMT.  Handle
	SWITCH_STMT by ignoring break_stmt from its body.
	(potential_constant_expression_1) <case FOR_STMT>,
	<case WHILE_STMT>: If the condition isn't constant true, check if
	the loop body can contain a return stmt.
	<case SWITCH_STMT>: Adjust check_for_return_continue_data initializer.
	<case IF_STMT>: If recursion with tf_none is successful,
	merge *jump_target from the branches - returns with highest priority,
	breaks or continues lower.  If then branch is potentially constant and
	doesn't return, check the else branch if it could return, break or
	continue.

	* g++.dg/cpp1y/constexpr-98672.C: New test.
2021-01-21 17:22:45 +01:00
Kyrylo Tkachov
43705f3fa3 aarch64: Use canonical RTL for sqdmlal patterns
The aarch64_sqdml<SBINQOPS:as>l patterns are of the form:
  [(set (match_operand:<VWIDE> 0 "register_operand" "=w")
        (SBINQOPS:<VWIDE>
	  (match_operand:<VWIDE> 1 "register_operand" "0")
	  (ss_ashift:<VWIDE>
	      (mult:<VWIDE>
		(sign_extend:<VWIDE>
		      (match_operand:VSD_HSI 2 "register_operand" "w"))
		(sign_extend:<VWIDE>
		      (match_operand:VSD_HSI 3 "register_operand" "w")))
	      (const_int 1))))]

where SBINQOPS is ss_plus and ss_minus. The problem is that for the
ss_plus case the RTL
is not canonical: the (match_oprand 1) should be the second arm of the
PLUS.
I've seen this manifest in combine missing some legitimate
simplifications because it generates
the canonical ss_plus form and fails to match the pattern.

This patch splits the patterns into the ss_plus and ss_minus forms with
the canonical form for each.
I've seen this improve my testcase (which I can't include as it's too
large and not easy to test reliably).

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (aarch64_sqdml<SBINQOPS:as>l<mode>):
	Split into...
	(aarch64_sqdmlal<mode>): ... This...
	(aarch64_sqdmlsl<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_lane<mode>): Split into...
	(aarch64_sqdmlal_lane<mode>): ... This...
	(aarch64_sqdmlsl_lane<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_laneq<mode>): Split into...
	(aarch64_sqdmlsl_laneq<mode>): ... This...
	(aarch64_sqdmlal_laneq<mode>):  ... And this.
	(aarch64_sqdml<SBINQOPS:as>l_n<mode>): Split into...
	(aarch64_sqdmlsl_n<mode>): ... This...
	(aarch64_sqdmlal_n<mode>): ... And this.
	(aarch64_sqdml<SBINQOPS:as>l2<mode>_internal): Split into...
	(aarch64_sqdmlal2<mode>_internal): ... This...
	(aarch64_sqdmlsl2<mode>_internal): ... And this.
2021-01-21 14:08:29 +00:00
Iain Buclaw
279d3a89b7 d: Enable private member access for __traits
The following traits can now access non-public members:
 - hasMember
 - getMember
 - getOverloads
 - getVirtualMethods
 - getVirtualFuntions

This fixes a long-standing issue in D where the allMembers trait would
correctly return non-public members but those non-public members would
be inaccessible to other traits.

Reviewed-on: https://github.com/dlang/dmd/pull/12135

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 3a7ebef73.
2021-01-21 14:54:48 +01:00
Christophe Lyon
e154009f35 Fix typo in arm_mve.h __arm_vcmpneq_s8 return type
Like all vcmp intrinsics, __arm_vcmpneq_s8 should return a mve_pred16_t.

2021-01-21  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/arm_mve.h (__arm_vcmpneq_s8): Fix return type.
2021-01-21 13:50:01 +00:00
Andrea Corallo
0568f801ef arm: [testuiste] Fix ivopts.c target test [PR96372]
gcc/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
	PR target/96372
	* doc/sourcebuild.texi (arm_thumb2_no_arm_v8_1_lob): Document.

gcc/testsuite/
2021-01-15  Andrea Corallo  <andrea.corallo@arm.com>
	PR target/96372
	* lib/target-supports.exp
	(check_effective_target_arm_thumb2_no_arm_v8_1_lob): Define proc.
	* gcc.target/arm/ivopts.c: Use target
	'arm_thumb2_no_arm_v8_1_lob'.
2021-01-21 14:35:19 +01:00
Jorge D'Elia
9be0a89c95 gcc/fortran/intrinsic.texi: Fix typo
gcc/fortran/ChangeLog:

	* intrinsic.texi (CO_MAX): Fix typo.
2021-01-21 14:24:27 +01:00
Nathan Sidwell
3c1cf7350b c++: Stat-hack for members [PR 98530]
This was a header file that deployed the stat-hack inside a class
(both a member-class and a [non-static data] member had the same
name).  Due to the way that's represented in name lookup we missed the
class.  Sadly just changing the representation globally has
detrimental effects elsewhere, and this is a rare case, so just
creating a new overload on the fly shouldn't be a problem.

	PR c++/98530
	gcc/cp/
	* name-lookup.c (lookup_class_binding): Rearrange a stat-hack.
	gcc/testsuite/
	* g++.dg/modules/stat-mem-1.h: New.
	* g++.dg/modules/stat-mem-1_a.H: New.
	* g++.dg/modules/stat-mem-1_b.C: New.
2021-01-21 04:54:43 -08:00
Jonathan Wakely
a1a967ce1f libstdc++: Regenerate Makefile.in
This removes a trivial whitespace difference between the currently
committed file and the one regenerated by autotools.

libstdc++-v3/ChangeLog:

	* src/c++17/Makefile.in: Regenerate.
2021-01-21 11:56:07 +00:00
Paul Thomas
eaf883710c Fortran: This patch fixes comments 23 and 24 of PR96320.
2021-01-21  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/96320
	* decl.c (gfc_match_modproc): It is not an error to find a
	module procedure declaration within a contains block.
	* expr.c (gfc_check_vardef_context): Pure procedure result is
	assignable. Change 'own_scope' accordingly.
	* resolve.c (resolve_typebound_procedure): A procedure that
	has the module procedure attribute is almost certainly a
	module procedure, whatever its interface.

gcc/testsuite/
	PR fortran/96320
	* gfortran.dg/module_procedure_5.f90 : New test.
	* gfortran.dg/module_procedure_6.f90 : New test.
2021-01-21 10:00:49 +00:00
Richard Biener
f46a40112c testsuite/97299 - more gcc.dg/vect/slp-reduc-3.c massaging
This adds more guards to the VEC_PERM_EXPR scan, namely that
we also could end up with load-lanes and of course no vectorization
at all.  Need dependent scans (scan-if-scan-X PASSed ...).

2021-01-21  Richard Biener  <rguenther@suse.de>

	PR testsuite/97299
	* gcc.dg/vect/slp-reduc-3.c: Amend target selectors.
2021-01-21 10:57:18 +01:00
Richard Biener
8afef308b4 testsuite/98241 - remove ilp32 XFAIL of gcc.dg/pr78973.c
XPASSes as reported.

2021-01-21  Richard Biener  <rguenther@suse.de>

	PR testsuite/98241
	* gcc.dg/pr78973.c: Remove ilp32 XFAIL.
2021-01-21 10:35:11 +01:00
Richard Biener
fa9d1ad2ff testsuite/98224 - un-XFAIL Walloca-2.c on ilp32
As reported this now XPASSes with ranger.

2021-01-21  Richard Biener  <rguenther@suse.de>

	* gcc.dg/Walloca-2.c: Un-XFAIL.
2021-01-21 10:30:56 +01:00
liuhongt
e711b67a90 Fix incorrect optimization by cprop_hardreg.
If SRC had been assigned a mode narrower than the copy, we can't
always link DEST into the chain even they have same
hard_regno_nregs(i.e. HImode/SImode in i386 backend).

i.e
        kmovw   %k0, %edi
        vmovd   %edi, %xmm2
	vpshuflw        $0, %xmm2, %xmm0
        kmovw   %k0, %r8d
        kmovd   %k0, %r9d
...
-	 movl %r9d, %r11d
+	 vmovd %xmm2, %r11d

gcc/ChangeLog:

	PR rtl-optimization/98694
	* regcprop.c (copy_value): If SRC had been assigned a mode
	narrower than the copy, we can't link DEST into the chain even
	they have same hard_regno_nregs(i.e. HImode/SImode in i386
	backend).

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98694
	* gcc.target/i386/pr98694.c: New test.
2021-01-21 13:28:59 +08:00
GCC Administrator
b93d0e36c0 Daily bump. 2021-01-21 00:16:36 +00:00
David Edelsohn
fb39c4fe44 aix: make ctype_inline.h thread-safe and avoid _OBJ_DATA char subscript.
g++.dg/warn/Wstringop-overflow-6.C tests for a bogus overflow warning in
system headers.  This testcase was generating a -Wchar-subscript warning
on AIX because ctype_inline.h was subscripting AIX _OBJ_DATA using a char.
The _M_table case cast the subscript to unsigned char, but the _OBJ_DATA
case did not.

The investigation also exposed that AIX has added a thread-safe variant
of access to __lc_type that had not been applied to the libstdc++
implementation.

This patch casts the subscript to unsigned char and adds the THREAD_SAFE
variant.  libstdc++ always is compiled with pthreads, but it is good
to make the situation explicit and to document the appropriate usage.

Bootstrapped on powerpc-ibm-aix7.2.3.0.

libstdc++-v3/ChangeLog:

	* config/os/aix/ctype_inline.h (bool ctype<char>:: is): Cast
	_OBJ_DATA subscript to unsigned char. Add _THREAD_SAFE access to
	__lc_type.
	(const char* ctype<char>:: is): Same.
2021-01-20 17:42:02 -05:00
Andrew MacLeod
842afc4e28 Re: trapv question
Adjust testcase to so the ADD that is expected to overflow cannot
be optimized.

	gcc/testsuite
	* gcc.dg/torture/ftrapv-2.c: Make overflow instruction unremovable.
2021-01-20 16:30:48 -05:00
Jakub Jelinek
0bb27b81a7 libgomp: Fix up GOMP_task on s390x
On Wed, Jan 20, 2021 at 05:04:39PM +0100, Florian Weimer wrote:
> Sorry, this appears to cause OpenMP task state corruption in RPM.  We
> have only seen this on s390x.

Haven't actually verified it, but my suspection is that this is a caller
stack corruption.

We play with fire with the GOMP_task API/ABI extensions, the GOMP_task
function used to be:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority);
and now:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority, void *detach)
and which of those depend, priority and detach argument is present depends
on the bits in flags.
I'm afraid the compiler just decided to spill the detach = NULL store in
  if ((flags & GOMP_TASK_FLAG_DETACH) == 0)
    detach = NULL;
on s390x into the argument stack slot.  Not a problem if the caller passes
all those 10 arguments, but if not, can clobber random stack location.

This hack should fix it up.  Priority doesn't need changing, but I've
changed it anyway just to be safe.  With the patch none of the 3 arguments
are ever modified, so I'd hope gcc doesn't decide to spill something
unrelated there.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	* task.c (GOMP_task): Rename priority argument to priority_arg,
	add priority automatic variable and modify that variable.  Instead of
	clearing detach argument when GOMP_TASK_FLAG_DETACH bit is not set,
	check flags for that bit.
2021-01-20 22:10:20 +01:00
Nathan Sidwell
911f797a9b c++: Avoid UB in signed shift [PR 98625]
I'd forgotten that left shifting a negative value is UB until C++20.
Insert some casts to do unsigned shifts.

	PT c++/98625
	gcc/cp/
	* module.cc (bytes_in::i, bytes_in::wi): Avoid left shift of
	signed type.
2021-01-20 11:41:51 -08:00
Kyrylo Tkachov
e140f5fd3e aarch64: Split vec_selects of bottom elements into simple move
In certain intrinsics use cases GCC leaves SETs of a bottom-element vec
select lying around:
        (vec_select:DI (reg:V2DI 34 v2 [orig:128 __o ] [128])
            (parallel [
                    (const_int 0 [0])
                ])))

This can be treated as a simple move in aarch64 when done between SIMD
registers for all normal widths.
These go through the aarch64_get_lane pattern.
This patch adds a splitter there to simplify these extracts to a move
that can, perhaps, be optimised a way.
Another benefit is if the destination is memory we can use a simpler STR
instruction rather than ST1-lane.

gcc/

	* config/aarch64/aarch64-simd.md (aarch64_get_lane<mode>):
	Convert to define_insn_and_split.  Split into simple move when moving
	bottom element.

gcc/testsuite/

	* gcc.target/aarch64/vdup_lane_2.c: Scan for fmov rather than
	dup.
2021-01-20 19:29:42 +00:00
Segher Boessenkool
f8c6777766 rs6000: Fix rs6000_emit_le_vsx_store (PR98549)
One of the advantages of LRA is that you can create new pseudos from it
just fine.  The code in rs6000_emit_le_vsx_store was not aware of this.
This patch changes that, in the process fixing PR98549 (where it is
shown that we do call rs6000_emit_le_vsx_store during LRA, which we
used to assert can not happen).

2021-01-20  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000.c (rs6000_emit_le_vsx_store): Change assert.
	Adjust comment.  Simplify code.
2021-01-20 19:00:22 +00:00
Jakub Jelinek
27c792895b debug: Fix up DWARF 5 -g -flto -ffat-lto-objects [PR98765]
As mentioned in the PR, with -gdwarf-5 (or -g now) -flto -ffat-lto-objects,
users can't strip the LTO sections with
strip -p -R .gnu.lto_* -R .gnu.debuglto_* -N __gnu_lto_v1
anymore when GCC is configured against recent binutils.

The problem is that in that case .gnu.debuglto_.debug_line_str section is
then used, which is fine for references to strings in .gnu.debuglto_.*
sections, but not when those references are in .debug_info section too;
those should really reference separate strings in .debug_line_str section.

For .gnu.debuglto_.debug_str vs. .debug_str we handle it right, we
reset_indirect_string the strings and thus force creation of new labels for
the second time.
But for DW_FORM_line_strp as the patch shows, there were multiple problems.
First one was that reset_indirect_string, even when called through traverse
on debug_line_str_hash, didn't do anything at all (fixed by first hunk).
The second bug was that the DW_FORM_line_strp strings, which were supposed
to be only visible through debug_line_str_hash, leaked into debug_str_hash
(second hunk).
And the third thing is that when we reset debug_line_str_hash, we should
still make those strings DW_FORM_line_strp if they are accessed.
One could do it by reinstantiating DW_FORM_line_strp right away in
reset_indirect_string and not clear debug_line_str_hash, but that has the
disadvantage that we then force emitting .debug_line_str strings that aren't
really needed - we need those from the CU DIEs' DW_AT_name and
DW_AT_comp_dir attributes, but when emitting .debug_line section through
assembler, we don't need to emit the strings we only needed for
.gnu.debuglto_.debug_line which is always emitted by the compiler.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98765
	* dwarf2out.c (reset_indirect_string): Also reset indirect strings
	with DW_FORM_line_strp form.
	(prune_unused_types_update_strings): Don't add into debug_str_hash
	indirect strings with DW_FORM_line_strp form.
	(adjust_name_comp_dir): New function.
	(dwarf2out_finish): Call it on CU DIEs after resetting
	debug_line_str_hash.
2021-01-20 18:51:04 +01:00
Vladimir N. Makarov
4334b52427 [PR98722] LRA: Check that target has no 3-op add insn to transform 2 plus expression.
Patch cf2ac1c30a for solving PR97969 was
assumed for targets with absent 3-op add insn.  But the original patch did
not check this.  This patch adds the check.

gcc/ChangeLog:

	PR rtl-optimization/98722
	* lra-eliminations.c (eliminate_regs_in_insn): Check that target
	has no 3-op add insn to transform insns containing two pluses.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/98722
	* g++.target/s390/pr98722.C: New.
2021-01-20 11:44:04 -05:00
Richard Biener
261cdd2319 Handle overflow in dependence analysis lambda ops gracefully
The following tries to handle overflow in the integer computations
done by lambda ops of dependence analysis by failing instead of
silently continuing with overflowed values.

It also avoids treating large unsigned CHREC_RIGHT as negative
unless the chrec is of pointer type and avoids the most negative
integer value to avoid excessive overflow checking (with this
the fix for PR98758 can be partly simplified as seen).

I've added add_hwi and mul_hwi functions computing HOST_WIDE_INT
signed sum and product with indicating overflow, they hopefully
get matched to the appropriate internal functions.

I don't have any testcases triggering overflow in any of the
guarded computations.

2021-01-20  Richard Biener  <rguenther@suse.de>

	* hwint.h (add_hwi): New function.
	(mul_hwi): Likewise.
	* tree-data-ref.c (initialize_matrix_A): Properly translate
	tree constants and avoid HOST_WIDE_INT_MIN.
	(lambda_matrix_row_add): Avoid undefined integer overflow
	and return true on such overflow.
	(lambda_matrix_right_hermite): Handle overflow from
	lambda_matrix_row_add gracefully.  Simplify previous fix.
	(analyze_subscript_affine_affine): Likewise.
2021-01-20 16:32:11 +01:00
Eugene Rozenfeld
49e8c14ef6 Optimize combination of comparisons to dec+compare
This patch adds patterns for optimizing
x < y || y == XXX_MIN to x <= y-1
x >= y && y != XXX_MIN to x > y-1
if y is an integer with TYPE_OVERFLOW_WRAPS.

This fixes pr96674.

Tested on x86_64-pc-linux-gnu.

For this function

bool f(unsigned a, unsigned b)
{
    return (b == 0) | (a < b);
}

the code without the patch is

test   esi,esi
sete   al
cmp    esi,edi
seta   dl
or     eax,edx
ret

the code with the patch is

sub    esi,0x1
cmp    esi,edi
setae  al
ret

	PR tree-optimization/96674
gcc/
	* match.pd: New patterns: x < y || y == XXX_MIN --> x <= y - 1
	x >= y && y != XXX_MIN --> x > y - 1

gcc/testsuite
	* gcc.dg/pr96674.c: New tests.
2021-01-20 16:31:46 +01:00
Patrick Palka
cafcfcb584 c++: Fix tsubsting CLASS_PLACEHOLDER_TEMPLATE [PR95434]
Here, during partial instantiation of the generic lambda, we do
tsubst_copy on the CLASS_PLACEHOLDER_TEMPLATE for U{0} which yields a
(level-lowered) TEMPLATE_TEMPLATE_PARM rather than the corresponding
TEMPLATE_DECL.  This later confuses do_class_deduction which expects
that a CLASS_PLACEHOLDER_TEMPLATE is always a TEMPLATE_DECL.

gcc/cp/ChangeLog:

	PR c++/95434
	* pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: If tsubsting
	CLASS_PLACEHOLDER_TEMPLATE yields a TEMPLATE_TEMPLATE_PARM,
	adjust to its TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL.

gcc/testsuite/ChangeLog:

	PR c++/95434
	* g++.dg/cpp2a/lambda-generic9.C: New test.
2021-01-20 09:44:33 -05:00
Patrick Palka
79e1251b64 c++: Defer access checking when processing bases [PR82613]
When parsing the base-clause of a class declaration, we need to defer
access checking until the entire base-clause has been seen, so that
access can be properly checked relative to the scope of the class with
all its bases attached.  This allows us to accept the declaration of
struct D from Example 2 of [class.access.general] (access12.C below).

Similarly when substituting into the base-clause of a class template,
which is the subject of PR82613.

gcc/cp/ChangeLog:

	PR c++/82613
	* parser.c (cp_parser_class_head): Defer access checking when
	parsing the base-clause until all bases are seen and attached
	to the class type.
	* pt.c (instantiate_class_template): Likewise when substituting
	into dependent bases.

gcc/testsuite/ChangeLog:

	PR c++/82613
	* g++.dg/parse/access12.C: New test.
	* g++.dg/template/access35.C: New test.
2021-01-20 09:43:48 -05:00
Richard Sandiford
ea74a3f548 vect: Fix VLA SLP invariant optimisation [PR98535]
duplicate_and_interleave is the main fallback way of loading
a repeating sequence of elements into variable-length vectors.
The code handles cases in which the number of elements in the
sequence is potentially several times greater than the number
of elements in a vector.

Let:

- NE be the (compile-time) number of elements in the sequence
- NR be the (compile-time) number of vector results and
- VE be the (run-time) number of elements in each vector

The basic approach is to duplicate each element into a
separate vector, giving NE vectors in total, then use
log2(NE) rows of NE permutes to generate NE results.

In the worst case — when VE has no known compile-time factor
and NR >= NE — all of these permutes are necessary.  However,
if VE is known to be a multiple of 2**F, then each of the
first F permute rows produces duplicate results; specifically,
the high permute for a given pair is the same as the low permute.
The code dealt with this by reusing the low result for the
high result.  This part was OK.

However, having duplicate results from one row meant that the
next row did duplicate work.  The redundancies would be optimised
away by later passes, but the code tried to avoid generating them
in the first place.  This is the part that went wrong.

Specifically, NR is typically less than NE when some permutes are
redundant, so the code tried to use NR to reduce the amount of work
performed.  The problem was that, although it correctly calculated
a conservative bound on how many results were needed in each row,
it chose the wrong results for anything other than the final row.

This doesn't usually matter for fully-packed SVE vectors.  We first
try to coalesce smaller elements into larger ones, so normally
VE ends up being 2**VQ (where VQ is the number of 128-bit blocks
in an SVE vector).  In that situation we'd only apply the faulty
optimisation to the final row, i.e. the case it handled correctly.
E.g. for things like:

  void
  f (long *x)
  {
    for (int i = 0; i < 100; i += 8)
      {
        x[i] += 1;
        x[i + 1] += 2;
        x[i + 2] += 3;
        x[i + 3] += 4;
        x[i + 4] += 5;
        x[i + 5] += 6;
        x[i + 6] += 7;
        x[i + 7] += 8;
      }
  }

(already tested by the testsuite), we'd have 3 rows of permutes
producing 4 vector results.  The schemne produced:

1st row: 8 results from 4 permutes, highs duplicates of lows
2nd row: 8 results from 8 permutes (half of which are actually redundant)
3rd row: 4 results from 4 permutes

However, coalescing elements is trickier for unpacked vectors,
and at the moment we don't try to do it (see the GET_MODE_SIZE
check in can_duplicate_and_interleave_p).  Unpacked vectors
therefore stress the code in ways that packed vectors didn't.

The patch fixes this by removing the redundancies from each row,
rather than trying to work around them later.  This also removes
the redundant work in the second row of the example above.

gcc/
	PR tree-optimization/98535
	* tree-vect-slp.c (duplicate_and_interleave): Use quick_grow_cleared.
	If the high and low permutes are the same, remove the high permutes
	from the working set and only continue with the low ones.
2021-01-20 13:16:30 +00:00
Tobias Burnus
a95538b6c5 Fix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers
gcc/testsuite/ChangeLog:

	PR fortran/98763
	* gfortran.dg/gomp/task-detach-1.f90: Use integer(1) to avoid
	missing diagnostic issues with c_intptr_t == default integer kind.
2021-01-20 11:27:26 +01:00
Jakub Jelinek
4d2ecd960a builtins: Fix up two bugs in access_ref::inform_access [PR98721]
The following patch fixes two bugs in the access_ref::inform_access function
(plus some formatting nits).

The first problem is that ref can be various things, e.g. *_DECL, or
SSA_NAME, or IDENTIFIER_NODE.  And allocfn is non-NULL only if ref is
(at least originally) an SSA_NAME initialized to the result of some
allocator function (but not e.g. __builtin_alloca_with_align which is
handled differently).

A few lines above the last hunk of this patch in builtins.c, the code uses
  if (mode == access_read_write || mode == access_write_only)
    {
      if (allocfn == NULL_TREE)
        {
          if (*offstr)
            inform (loc, "at offset %s into destination object %qE of size %s",
                    offstr, ref, sizestr);
          else
            inform (loc, "destination object %qE of size %s", ref, sizestr);
          return;
        }

      if (*offstr)
        inform (loc,
                "at offset %s into destination object of size %s "
                "allocated by %qE", offstr, sizestr, allocfn);
      else
        inform (loc, "destination object of size %s allocated by %qE",
                sizestr, allocfn);
      return;
    }
so if allocfn is NULL, it prints whatever ref is, if it is non-NULL,
it prints instead the allocation function.  But strangely the hunk
a few lines below wasn't consistent with that and instead printed the
first form only if DECL_P (ref) and would ICE if ref wasn't a decl but
still allocfn was NULL.  Fixed by making it consistent what the code does
earlier.

Another bug is that the code earlier contains an ugly hack for VLAs and was
assuming that SSA_NAME_IDENTIFIER must be non-NULL on the lhs of
__builtin_alloca_with_align.  While that is likely true for the cases where
the compiler emits this builtin for VLAs (and it will also be true that
the name of the VLA in that case can be taken from that identifier up to the
first .), the builtin is user accessible as the testcase shows, so one can
have any other SSA_NAME in there.  I think it would be better to add some
more reliable way how to identify VLA names corresponding to
__builtin_alloca_with_align allocations, perhaps internal fn or whatever,
but that is beyond the scope of this patch.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98721
	* builtins.c (access_ref::inform_access): Don't assume
	SSA_NAME_IDENTIFIER must be non-NULL.  Print messages about
	object whenever allocfn is NULL, rather than only when DECL_P
	is true.  Use %qE instead of %qD for that.  Formatting fixes.

	* gcc.dg/pr98721-1.c: New test.
	* gcc.dg/pr98721-2.c: New test.
2021-01-20 09:49:24 +01:00
Richard Biener
34599780d0 tree-optimization/98758 - fix integer arithmetic in data-ref analysis
This fixes some int arithmetic issues and a bogus truncation.

2021-01-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98758
	* tree-data-ref.c (int_divides_p): Use lambda_int arguments.
	(lambda_matrix_right_hermite): Avoid undefinedness with
	signed integer abs and multiplication.
	(analyze_subscript_affine_affine): Use lambda_int.

	* gcc.dg/torture/pr98758.c: New testcase.
2021-01-20 09:38:22 +01:00
Jakub Jelinek
7ab1abf3b8 openmp: Don't ICE on detach clause with erroneous decl [PR98742]
Similarly to how we handle erroneous operands to e.g. allocate clause,
this change just removes those clauses instead of accessing TYPE_MAIN_VARIANT
of its type, which doesn't work on error_mark_node.  Also, just for good
measure, bails out if TYPE_NAME is NULL.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98742
	* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: If
	error_operand_p, remove clause without further checking.  Check
	for non-NULL TYPE_NAME.

	* c-c++-common/gomp/task-detach-2.c: New test.
2021-01-20 08:38:46 +01:00
Tobias Burnus
c05cdfb3f6 OpenMP/Fortran: Fix gfortran.dg/gomp/is_device_ptr-2.f90
gcc/testsuite/ChangeLog:

	PR fortran/98757
	PR fortran/98476
	* gfortran.dg/gomp/is_device_ptr-2.f90: Fix dg-error.
2021-01-20 08:35:18 +01:00
David Malcolm
b83604c75f dwarf2out: reset generation count in toplev::finalize [PR98751]
PR debug/98751 reports an issue in which most of libgccjit's tests
fails in DWARF 5 handling with
  `.Ldebug_loc2' is already defined"
asm errors.

The bogus label is being emitted at the 3rd in-process iteration, at:
  31673	      ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
which on the initial iteration emits:

 145   │ .Ldebug_loc0:

on the 2nd iteration:
 145   │ .Ldebug_loc1:

and on the 3rd iteration:
 145   │ .Ldebug_loc2:

which is a duplicate of a label emitted earlier:
 138   │     .section    .debug_loclists,"",@progbits
 139   │     .long   .Ldebug_loc3-.Ldebug_loc2
 140   │ .Ldebug_loc2:
 141   │     .value  0x5
 142   │     .byte   0x8
 143   │     .byte   0
 144   │     .long   0
 145   │ .Ldebug_loc2:

The issue seems to be that init_sections_and_labels creates the label
  ASM_GENERATE_INTERNAL_LABEL (loc_section_label, DEBUG_LOC_SECTION_LABEL,
			       generation);

where "generation" is a static local to init_sections_and_labels that
increments, and thus eventually hits the duplicate value.

It appears that this value is intended to be either 0 or 1, but in
the libgccjit case the compilation code can be invoked an arbitrary
number of times in-process, and hence can eventually lead to a
label name collision.

This patch adds code to dwarf2out_c_finalize (called by
toplev::finalize in libgccjit) to reset the generation counts,
fixing the issue.

gcc/ChangeLog:
	PR debug/98751
	* dwarf2out.c (output_line_info): Rename static variable
	"generation", moving it out of the function to...
	(output_line_info_generation): New.
	(init_sections_and_labels): Likewise, renaming the variable to...
	(init_sections_and_labels_generation): New.
	(dwarf2out_c_finalize): Reset the new variables.
2021-01-19 19:58:23 -05:00
GCC Administrator
f35a4f9637 Daily bump. 2021-01-20 00:16:46 +00:00
David Edelsohn
6bc6094fa3 testsuite: aix testsuite adjustments
This patch re-enables the DWARF5 tests that seem to be functioning again.
It adds a comment to pr41445-7.c that any changes in lines need to be
reflected in the expected output.

The patch also allows for additional failures in ucs.c and reflects that
builtin-sprintf-warn-20.c requires 4 byte wide char support.

gcc/testsuite/ChangeLog:

	* gcc.dg/cpp/ucs.c: Expect Invalid warning for 2byte wchar.
	* gcc.dg/debug/dwarf2/inline6.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/lang-c11.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/pr41445-7.c: Remove skip AIX.
	* gcc.dg/debug/dwarf2/pr41445-8.c: Remove skip AIX.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-20.c: Require 4byte wchar.
2021-01-19 18:50:29 -05:00
Joseph Myers
a311dfaf92 Update gcc de.po.
* de.po: Update.
2021-01-19 23:29:33 +00:00
Marek Polacek
2b27f37f90 c++: Crash when deducing template arguments [PR98659]
maybe_instantiate_noexcept doesn't expect to see error_mark_node, but
the new callsite I introduced in r11-6476 can pass error_mark_node to
it.  So cope.

gcc/cp/ChangeLog:

	PR c++/98659
	* pt.c (maybe_instantiate_noexcept): Return false if FN is
	error_mark_node.

gcc/testsuite/ChangeLog:

	PR c++/98659
	* g++.dg/template/deduce8.C: New test.
2021-01-19 17:41:20 -05:00
Ian Lance Taylor
eed40bca6f compiler: initialize variables with go:embed directives
This completes the compiler work for go:embed.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281536
2021-01-19 14:29:18 -08:00
Marek Polacek
d89b00c095 c++: ICE with USING_DECL redeclaration [PR98687]
My recent patch that introduced push_using_decl_bindings didn't
handle USING_DECL redeclaration, therefore things broke.  This patch
amends that by breaking out a part of finish_nonmember_using_decl
out to a separate function, push_using_decl_bindings, and calling it.
It needs an overload, because name_lookup is only available inside
of name-lookup.c.

gcc/cp/ChangeLog:

	PR c++/98687
	* name-lookup.c (push_using_decl_bindings): New, broken out of...
	(finish_nonmember_using_decl): ...here.
	* name-lookup.h (push_using_decl_bindings): Update declaration.
	* pt.c (tsubst_expr): Update the call to push_using_decl_bindings.

gcc/testsuite/ChangeLog:

	PR c++/98687
	* g++.dg/lookup/using64.C: New test.
	* g++.dg/lookup/using65.C: New test.
2021-01-19 17:13:00 -05:00
Martin Sebor
9693e255ee PR middle-end/98664 - inconsistent -Wfree-nonheap-object for inlined calls to system headers
gcc/ChangeLog:

	PR middle-end/98664
	* tree-ssa-live.c (remove_unused_scope_block_p): Keep scopes for
	all functions, even if they're not declared artificial or inline.
	* tree.c (tree_inlined_location): Use macro expansion location
	only if scope traversal fails to expose one.

gcc/testsuite/ChangeLog:

	PR middle-end/98664
	* gcc.dg/Wvla-larger-than-4.c: Adjust expected output.
	* gcc.dg/plugin/diagnostic-test-inlining-3.c: Same.
	* g++.dg/warn/Wfree-nonheap-object-5.C: New test.
	* gcc.dg/Wfree-nonheap-object-4.c: New test.
2021-01-19 15:10:30 -07:00
Patrick Palka
29853c6532 c++: Always check access during late-parsing of members [PR58993]
This patch removes a vestigial use of dk_no_check from
cp_parser_late_parsing_for_member, which ideally should have been
removed as part of the PR41437 patch that improved access checking
inside templates.  This allows us to correctly reject f1 and f2 in
the testcase access34.C below (whereas before we'd only reject f3).

Additional testing revealed a new access issue when late-parsing a hidden
friend within a class template.  In the testcase friend68.C below, we're
tripping over the checking assert from friend_accessible_p(f, S::j, S, S)
during lookup of j in x.j (for which type_dependent_object_expression_p
returns false, which is why we're doing the lookup at parse time).  The
reason for the assert failure is that DECL_FRIENDLIST(S) contains f but
DECL_BEFRIENDING_CLASSES(f) is empty, and so friend_accessible_p (which
looks at DECL_BEFRIENDING_CLASSES) wants to return false, but is_friend
(which looks at DECL_FRIENDLIST) returns true.

For sake of symmetry one would expect that DECL_BEFRIENDING_CLASSES(f)
contains S, but add_friend avoids updating DECL_BEFRIENDING_CLASSES when
the class type (S in this case) is dependent, for some reason.

This patch works around this issue by making friend_accessible_p
consider the DECL_FRIEND_CONTEXT of the access scope.  Thus we sidestep
the DECL_BEFRIENDING_CLASSES / DECL_FRIENDLIST asymmetry issue while
correctly validating the x.j access at parse time.

A earlier version of this patch checked friend_accessible_p instead of
protected_accessible_p in the DECL_FRIEND_CONTEXT hunk below, but this
had the side effect of making us accept the ill-formed testcase friend69.C
below (ill-formed because the hidden friend g is not actually a member
of A, so g doesn't have access to B's members despite B befriending A).

gcc/cp/ChangeLog:

	PR c++/41437
	PR c++/58993
	* search.c (friend_accessible_p): If scope is a hidden friend
	defined inside a dependent class, consider access from the
	class.
	* parser.c (cp_parser_late_parsing_for_member): Don't push a
	dk_no_check access state.

gcc/testsuite/ChangeLog:

	PR c++/41437
	PR c++/58993
	* g++.dg/opt/pr87974.C: Adjust.
	* g++.dg/template/access34.C: New test.
	* g++.dg/template/friend68.C: New test.
	* g++.dg/template/friend69.C: New test.
2021-01-19 16:20:00 -05:00
Marek Polacek
c37f1d4081 c++: ICE when late parsing noexcept/NSDMI [PR98333]
Since certain members of a class are a complete-class context
[class.mem.general]p7, we delay their parsing untile the whole class has
been parsed.  For instance, NSDMIs and noexcept-specifiers.  The order
in which we perform this delayed parsing matters; we were first parsing
NSDMIs and only they did we parse noexcept-specifiers.   That turns out
to be wrong: since NSDMIs may use noexcept-specifiers, we must process
noexcept-specifiers first.  Otherwise we'll ICE in code that doesn't
expect to see DEFERRED_PARSE.

This doesn't just shift the problem, noexcept-specifiers can use members
with a NSDMI just fine, and I've also tested a similar test with this
member function:

  bool f() { return __has_nothrow_constructor (S<true>); }

and that compiled fine too.

gcc/cp/ChangeLog:

	PR c++/98333
	* parser.c (cp_parser_class_specifier_1): Perform late-parsing
	of NSDMIs before late-parsing of noexcept-specifiers.

gcc/testsuite/ChangeLog:

	PR c++/98333
	* g++.dg/cpp0x/noexcept62.C: New test.
2021-01-19 15:38:12 -05:00
Nathan Sidwell
7266ff2a24 c++: Remove unused fn
I had two overloads of a function, but only one was needed.  Let's keep
the constant one.

	gcc/cp/
	* module.cc (identifier): Merge overloads.
2021-01-19 11:37:42 -08:00
Nathan Sidwell
6e6f3ed47e c++: Fix null this pointer [PR 98624]
There's no need for this function to have an object, so make it
static and avoid UB.

	PR c++/98624
	gcc/cp/
	* module.cc (trees_out::write_location): Make static.
2021-01-19 11:37:03 -08:00
Richard Sandiford
6a2a38620c alias: Fix offset checks involving section anchors [PR92294]
memrefs_conflict_p assumes that:

  [XB + XO, XB + XO + XS)

does not alias

  [YB + YO, YB + YO + YS)

whenever:

  [XO, XO + XS)

does not intersect

  [YO, YO + YS)

In other words, the accesses can alias only if XB == YB at runtime.

However, this doesn't cope correctly with section anchors.
For example, if XB is an anchor symbol and YB is at offset
XO from the anchor, then:

  [XB + XO, XB + XO + XS)

overlaps

  [YB, YB + YS)

whatever the value of XO is.  In other words, when doing the
alias check for two symbols whose local definitions are in
the same block, we should apply the known difference between
their block offsets to the intersection test above.

gcc/
	PR rtl-optimization/92294
	* alias.c (compare_base_symbol_refs): Take an extra parameter
	and add the distance between two symbols to it.  Enshrine in
	comments that -1 means "either 0 or 1, but we can't tell
	which at compile time".
	(memrefs_conflict_p): Update call accordingly.
	(rtx_equal_for_memref_p): Likewise.  Take the distance between symbols
	into account.
2021-01-19 17:50:53 +00:00
Will Schmidt
04cdb13202 [PATCH, rs6000] Update pr88233.c test (pr91799)
Hi,

This is a follow-up fix to clean up pr91799.  Per review of test results,
it appears that the combination of target and dg-require stanzas is
not sufficient to properly limit the test to 64-bit only on darwin.

This adds an additional dg-require clause to limit the test to 64-bit
environments.

Tested on power7 and power8 using assorted variations of
  make -k check-gcc-c "RUNTESTFLAGS=powerpc.exp=pr88233.c
  --target_board=unix/'{-mcpu=power7,-mcpu=power6,-mcpu=power8}''{-m32,-m64}'"

PR target/91799

2021-01-19  Will Schmidt <will_schmidt@vnet.ibm.com>

gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/pr88233.c: Update dg- stanzas.
2021-01-19 11:43:14 -06:00
Kyrylo Tkachov
04b472ad0e aarch64: Relax flags of saturation builtins
This patch relaxes the flags for the saturating arithmetic builtins to
NONE, allowing for more optimisation.

gcc/ChangeLog

	* config/aarch64/aarch64-simd-builtins.def (sqshl, uqshl,
	sqrshl, uqrshl, sqadd, uqadd, sqsub, uqsub, suqadd, usqadd, sqmovn,
	uqmovn, sqxtn2, uqxtn2, sqabs, sqneg, sqdmlal, sqdmlsl, sqdmlal_lane,
	sqdmlsl_lane, sqdmlal_laneq, sqdmlsl_laneq, sqdmlal_n, sqdmlsl_n,
	sqdmlal2, sqdmlsl2, sqdmlal2_lane, sqdmlsl2_lane, sqdmlal2_laneq,
	sqdmlsl2_laneq, sqdmlal2_n, sqdmlsl2_n, sqdmull, sqdmull_lane,
	sqdmull_laneq, sqdmull_n, sqdmull2, sqdmull2_lane, sqdmull2_laneq,
	sqdmull2_n, sqdmulh, sqrdmulh, sqdmulh_lane, sqdmulh_laneq,
	sqrdmulh_lane, sqrdmulh_laneq, sqshrun_n, sqrshrun_n, sqshrn_n,
	uqshrn_n, sqrshrn_n, uqrshrn_n, sqshlu_n, sqshl_n, uqshl_n, sqrdmlah,
	sqrdmlsh, sqrdmlah_lane, sqrdmlsh_lane, sqrdmlah_laneq, sqrdmlsh_laneq,
	sqmovun): Use NONE flags.
2021-01-19 17:27:52 +00:00
Kyrylo Tkachov
763b865a17 aarch64: Remove testing of saturation cumulative QC bit
Since we don't guarantee the ordering of the QC flag in FPSR in the
saturation intrinsics, we shouldn't be testing for it.
I want to relax the flags for some of the builtins to enable more
optimisation but that triggers the QC flag tests in
advsimd-intrinsics.exp.
We don't implement the saturation flag access intrinsics in aarch64
anyway and we don't want to.

gcc/testsuite/ChangeLog:

	* gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h
	(CHECK_CUMULATIVE_SAT): Delete.
	(CHECK_CUMULATIVE_SAT_NAMED): Likewise.  Deleted related
	variables.
	* gcc.target/aarch64/advsimd-intrinsics/binary_sat_op.inc:
	Remove uses of the above.
	* gcc.target/aarch64/advsimd-intrinsics/unary_sat_op.inc:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqabs.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqadd.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl.inc: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl_lane.inc:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlXl_n.inc: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlal.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlal_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlal_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmlsl_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmulh.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmulh_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmulh_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmull.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmull_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqdmull_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqmovn.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqmovun.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqneg.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlXh.inc: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlXh_lane.inc:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlah.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlah_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlsh.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmlsh_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_lane.c:
	Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrshl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrshrn_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqrshrun_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshl.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshl_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshlu_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshrn_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqshrun_n.c: Likewise.
	* gcc.target/aarch64/advsimd-intrinsics/vqsub.c: Likewise.
2021-01-19 17:25:42 +00:00
Jeff Law
8227106f56 [committed] Fix dwarf-float.c test in testsuite
gcc/testsuite
	* gcc.dg/debug/dwarf2/dwarf-float.c: Force dwarf-4 generation
	and update expected output.
2021-01-19 08:35:55 -07:00
Richard Biener
66dd412fee ipa/98330 - avoid ICEing on call indirect call
The following avoids ICEing on a indirect calls with a fnspec
in modref analysis.

2021-01-19  Richard Biener  <rguenther@suse.de>

	PR ipa/98330
	* ipa-modref.c (analyze_stmt): Only record a summary for a
	direct call.

	* g++.dg/pr98330.C: New testcase.
	* gcc.dg/pr98330.c: Likewise.
2021-01-19 14:32:25 +01:00
Richard Biener
f27cd6f422 middle-end/98638 - avoid SSA reference to stmts after SSA deconstruction
Since SSA names do leak into global tree data structures like
TYPE_SIZE or in this case GFC_DECL_SAVED_DESCRIPTOR because of
frontend bugs we have to be careful to wipe references to the
CFG when we deconstruct SSA form because we now do ggc_free that.

2021-01-19  Richard Biener  <rguenther@suse.de>

	PR middle-end/98638
	* tree-ssanames.c (fini_ssanames): Zero SSA_NAME_DEF_STMT.
2021-01-19 14:32:14 +01:00
Daniel Hellstrom
4b690f161b sparc,rtems: add __FIX_LEON3FT_TN0018 for affected targets
Enable a define FIX_LEON3FT_TN0018 for the LEON3FT targets affected
by the GRLIB-TN-0018 errata described here:
  https://www.gaisler.com/notes

gcc/

	* config/sparc/rtemself.h (TARGET_OS_CPP_BUILTINS): Add
	built-in define __FIX_LEON3FT_TN0018.
2021-01-19 13:57:58 +01:00
Richard Biener
7d6f7e92c3 ipa/97673 - fix input_location leak
This fixes input_location leaking with an invalid BLOCK from
expand_call_inline to tree_function_versioning via clone
materialization.

2021-01-19  Richard Biener  <rguenther@suse.de>

	PR ipa/97673
	* tree-inline.c (tree_function_versioning): Set input_location
	to UNKNOWN_LOCATION throughout the function.

	* gfortran.dg/pr97673.f90: New testcase.
2021-01-19 13:22:40 +01:00
Tobias Burnus
049bfd186f OpenMP/Fortran: Fixes for {use,is}_device_ptr
gcc/fortran/ChangeLog:

	PR fortran/98476
	* openmp.c (resolve_omp_clauses): Change use_device_ptr
	to use_device_addr for unless type(c_ptr); check all
	list item for is_device_ptr.

gcc/ChangeLog:

	PR fortran/98476
	* omp-low.c (lower_omp_target): Handle nonpointer is_device_ptr.

libgomp/ChangeLog:

	PR fortran/98476
	* testsuite/libgomp.fortran/is_device_ptr-1.f90: New test.

gcc/testsuite/ChangeLog:

	PR fortran/98476
	* gfortran.dg/gomp/map-3.f90: Update expected scan-dump-tree.
	* gfortran.dg/gomp/is_device_ptr-2.f90: New test.
	* gfortran.dg/gomp/use_device_ptr-1.f90: New test.
2021-01-19 11:58:21 +01:00
Martin Jambor
9b8741c98f ipa-sra: Do not remove return values needed because of non-call EH
IPA-SRA already contains a check to figure out that an otherwise dead
parameter is actually required because of non-call exceptions, but it
is not present at the equivalent spot where SRA figures out whether
the return statement is used for anything useful.  This patch adds
that condition there.

Unfortunately, even though this patch should be good enough for any
normal (I'd even say reasonable) use of the compiler, it hints that
when the user manually switches all sorts of DCE, IPA-SRA would
probably leave behind problematic statements manipulating what
originally were return values, just like it does for parameters (PR
93385).  Fixing this properly might unfortunately be a separate issue
from the mentioned bug because the LHS of a call is changed during
call redirection and the caller often is not a clone.  But I'll see
what I can do.

Meanwhile, the patch below has been bootstrapped and tested on x86_64.

gcc/ChangeLog:

2021-01-18  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98690
	* ipa-sra.c (ssa_name_only_returned_p): New parameter fun.  Check
	whether non-call exceptions allow removal of a statement.
	(isra_analyze_call): Pass the appropriate function to
	ssa_name_only_returned_p.

gcc/testsuite/ChangeLog:

2021-01-18  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98690
	* g++.dg/ipa/pr98690.C: New test.
2021-01-19 11:28:48 +01:00
Eric Botcazou
665e80ca5e Fix PR ada/98740
It's a long-standing GENERIC tree sharing issue.

gcc/ada/ChangeLog:
	PR ada/98740
	* gcc-interface/trans.c (add_decl_expr): Always mark TYPE_ADA_SIZE.
2021-01-19 10:44:54 +01:00
Geng Qi
9ee33d7c33 RISC-V: The 'multilib-generator' enhancement.
Think about this case:
  ./multilib-generator rv32imc-ilp32-rv32imac,rv32imacxthead-f
Here are 2 problems:
  1. A unexpected 'xtheadf' extension was made.
  2. The arch 'rv32imac' was not be created.
This modification fix these two, and also sorts 'multi-letter'.

gcc/ChangeLog:
	* config/riscv/arch-canonicalize (longext_sort): New function for
	 sorting 'multi-letter'.
	* config/riscv/multilib-generator: Adjusting the loop of 'alt' in
	'alts'.	The 'arch' may not be the first of 'alts'.
	(_expand_combination): Add underline for the 'ext' without '*'.
	This is because, a single-letter extension can always be treated well
	with a '_' prefix, but it cannot be separated out if it is appended
	to a multi-letter.
2021-01-19 11:44:47 +08:00
Ian Lance Taylor
c907e43941 compiler: read embedcfg files, parse go:embed directives
This change reads go:embed directives and attaches them to variables.
We still don't do anything with the directives.

This change also reads the file passed in the -fgo-embedcfg option.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281533
2021-01-18 16:40:06 -08:00
GCC Administrator
ef1f8ee67d Daily bump. 2021-01-19 00:16:35 +00:00
Jeff Law
9a3ab93ceb [committed] Minor fix to pr41445-7 testcase
gcc/testsuite
	* gcc.dg/debug/dwarf2/pr41445-7.c: Fix expected output.
2021-01-18 16:05:06 -07:00
Ian Lance Taylor
bfde774667 libbacktrace: don't fail tests if dwz fails
* Makefile.am (%_dwz): If dwz fails, use uncompressed debug info.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
2021-01-18 14:45:57 -08:00
Ian Lance Taylor
325e70b47c libbacktrace: use correct directory/filename for DWARF 5
PR debug/98716
	* dwarf.c (read_v2_paths): Allocate zero entry for dirs and
	filenames.
	(read_line_program): Remove parameter u, change caller.  Don't
	subtract one from dirs and filenames index.
	(read_function_entry): Don't subtract one from filenames index.
2021-01-18 14:43:00 -08:00
Vladimir N. Makarov
a89c5d3539 [PR97847] IRA: Skip abnormal critical edge splitting
PPC64 can generate jumps with clobbered pseudo-regs and a BB with
such jump can have abnormal output edges.  IRA hits an assert when trying
to split abnormal critical edge to deal with asm goto output reloads
later.  The patch just skips splitting abnormal edges.  It is assumed
that asm-goto with output reloads can not be in BB with output abnormal edges.

gcc/ChangeLog:

	PR target/97847
	* ira.c (ira): Skip abnormal critical edge splitting.
2021-01-18 16:47:15 -05:00
Patrick Palka
32b6e917ac c++: Add CTAD + pack expansion testcase
After r11-6614 made cp_walk_subtrees walk into the template of a CTAD
placeholder, we now correctly accept the below testcase.  We used to
reject it because find_parameter_packs_r would fail to find the
parameter pack Ts inside the CTAD placeholder within the pack expansion.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction77.C: New test.
2021-01-18 16:41:46 -05:00
Jakub Jelinek
9675ccd64e widening_mul: Fix up signed multiplication overflow check handling [PR98727]
I forgot one line, which means that if the second operand of the multiplication
isn't constant, it would be just the same as the first one.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98727
	* tree-ssa-math-opts.c (match_arith_overflow): Fix up computation of
	second .MUL_OVERFLOW operand for signed multiplication with overflow
	checking if the second operand of multiplication is not constant.

	* gcc.c-torture/execute/pr98727.c: New test.
2021-01-18 19:13:44 +01:00
David Edelsohn
f56e14101b aix: document dwarf 4 default (and TPF default)
gcc/ChangeLog:

	* doc/invoke.texi (-gdwarf): TPF defaults to version 2 and AIX
	defaults to version 4.
2021-01-18 13:12:17 -05:00
John David Anglin
76c1dd15e4 Skip asm goto tests on hppa*-*-*.
gcc/testsuite/ChangeLog:

	PR testsuite/97987
	* gcc.c-torture/compile/asmgoto-2.c: Skip on hppa.
	* gcc.c-torture/compile/asmgoto-5.c: Likewise.
2021-01-18 15:45:47 +00:00
John David Anglin
66cbe54960 Avoid no-stack-protector-attr fails on hppa*-*-*.
gcc/testsuite/ChangeLog:

	* g++.dg/no-stack-protector-attr-3.C: Don't compile on hppa*-*-*.
	* g++.dg/no-stack-protector-attr.C: Likewise.
2021-01-18 15:38:40 +00:00
David Malcolm
c7e276b869 analyzer: use "malloc" attribute
In dce6c58db8 msebor extended the
"malloc" attribute to support user-defined allocator/deallocator
pairs.

This patch extends the "malloc" checker within -fanalyzer to use
these attributes.  It is based on an earlier patch:
  'RFC: add "deallocated_by" attribute for use by analyzer'
    https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555544.html
which added a different attribute.  The patch needed a lot of reworking
to support multiple deallocators per allocator.

My hope was that this would provide a minimal level of markup that would
support library-checking without requiring lots of further markup.
I attempted to use this to detect a memory leak within a Linux
driver (CVE-2019-19078), by adding the attribute to mark these fns:
extern struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags);
extern void usb_free_urb(struct urb *urb);
where there is a leak of a "urb" on an error-handling path.
Unfortunately I ran into the problem that there are various other fns
that take "struct urb *" and the analyzer conservatively assumes that a
urb passed to them might or might not be freed and thus stops tracking
state for them.

Hence this will only detect issues for the simplest cases (without
adding another attribute).

gcc/analyzer/ChangeLog:
	* analyzer.h (is_std_named_call_p): New decl.
	* diagnostic-manager.cc (path_builder::get_sm): New.
	(state_change_event_creator::state_change_event_creator): Add "pb"
	param.
	(state_change_event_creator::on_global_state_change): Don't consider
	state changes affecting other state_machines.
	(state_change_event_creator::on_state_change): Likewise.
	(state_change_event_creator::m_pb): New field.
	(diagnostic_manager::add_events_for_eedge): Pass pb to visitor
	ctor.
	* region-model-impl-calls.cc
	(region_model::impl_deallocation_call): New.
	* region-model.cc: Include "attribs.h".
	(region_model::on_call_post): Handle fndecls referenced by
	__attribute__((deallocated_by(FOO))).
	* region-model.h (region_model::impl_deallocation_call): New decl.
	* sm-malloc.cc: Include "stringpool.h" and "attribs.h".  Add
	leading comment.
	(class api): Delete.
	(enum resource_state): Update comment for change from api to
	deallocator and deallocator_set.
	(allocation_state::allocation_state): Drop api param.  Add
	"deallocators" and "deallocator".
	(allocation_state::m_api): Drop field in favor of...
	(allocation_state::m_deallocators): New field.
	(allocation_state::m_deallocator): New field.
	(enum wording): Add WORDING_DEALLOCATED.
	(struct deallocator): New.
	(struct standard_deallocator): New.
	(struct custom_deallocator): New.
	(struct deallocator_set): New.
	(struct custom_deallocator_set): New.
	(struct standard_deallocator_set): New.
	(struct deallocator_set_map_traits): New.
	(malloc_state_machine::m_malloc): Drop field
	(malloc_state_machine::m_scalar_new): Likewise.
	(malloc_state_machine::m_vector_new): Likewise.
	(malloc_state_machine::m_free): New field
	(malloc_state_machine::m_scalar_delete): Likewise.
	(malloc_state_machine::m_vector_delete): Likewise.
	(malloc_state_machine::deallocator_map_t): New typedef.
	(malloc_state_machine::m_deallocator_map): New field.
	(malloc_state_machine::deallocator_set_cache_t): New typedef.
	(malloc_state_machine::m_custom_deallocator_set_cache): New field.
	(malloc_state_machine::custom_deallocator_set_map_t): New typedef.
	(malloc_state_machine::m_custom_deallocator_set_map): New field.
	(malloc_state_machine::m_dynamic_sets): New field.
	(malloc_state_machine::m_dynamic_deallocators): New field.
	(api::api): Delete.
	(deallocator::deallocator): New ctor.
	(deallocator::hash): New.
	(deallocator::dump_to_pp): New.
	(deallocator::cmp): New.
	(deallocator::cmp_ptr_ptr): New.
	(standard_deallocator::standard_deallocator): New ctor.
	(deallocator_set::deallocator_set): New ctor.
	(deallocator_set::dump): New.
	(custom_deallocator_set::custom_deallocator_set): New ctor.
	(custom_deallocator_set::contains_p): New.
	(custom_deallocator_set::maybe_get_single): New.
	(custom_deallocator_set::dump_to_pp): New.
	(standard_deallocator_set::standard_deallocator_set): New ctor.
	(standard_deallocator_set::contains_p): New.
	(standard_deallocator_set::maybe_get_single): New.
	(standard_deallocator_set::dump_to_pp): New.
	(start_p): New.
	(class mismatching_deallocation): Update for conversion from api
	to deallocator_set and deallocator.
	(double_free::emit): Use %qs.
	(class use_after_free): Update for conversion from api to
	deallocator_set and deallocator.
	(malloc_leak::describe_state_change): Only emit "allocated here" on
	a start->nonnull transition, rather than on other transitions to
	nonnull.
	(allocation_state::dump_to_pp): Update for conversion from api to
	deallocator_set.
	(allocation_state::get_nonnull): Likewise.
	(malloc_state_machine::malloc_state_machine): Likewise.
	(malloc_state_machine::~malloc_state_machine): New.
	(malloc_state_machine::add_state): Update for conversion from api
	to deallocator_set.
	(malloc_state_machine::get_or_create_custom_deallocator_set): New.
	(malloc_state_machine::maybe_create_custom_deallocator_set): New.
	(malloc_state_machine::get_or_create_deallocator): New.
	(malloc_state_machine::on_stmt): Update for conversion from api
	to deallocator_set.  Handle "__attribute__((malloc(FOO)))", and
	the special attribute set on FOO.
	(malloc_state_machine::on_allocator_call): Update for conversion
	from api to deallocator_set.  Add "returns_nonnull" param and use
	it to affect which state to transition to.
	(malloc_state_machine::on_deallocator_call): Update for conversion
	from api to deallocator_set.

gcc/ChangeLog:
	* attribs.h (fndecl_dealloc_argno): New decl.
	* builtins.c (call_dealloc_argno): Split out second half of
	function into...
	(fndecl_dealloc_argno): New.
	* doc/extend.texi (Common Function Attributes): Document the
	interaction between the analyzer and the malloc attribute.
	* doc/invoke.texi (Static Analyzer Options): Likewise.

gcc/testsuite/ChangeLog:
	* gcc.dg/analyzer/attr-malloc-1.c: New test.
	* gcc.dg/analyzer/attr-malloc-2.c: New test.
	* gcc.dg/analyzer/attr-malloc-4.c: New test.
	* gcc.dg/analyzer/attr-malloc-5.c: New test.
	* gcc.dg/analyzer/attr-malloc-6.c: New test.
	* gcc.dg/analyzer/attr-malloc-CVE-2019-19078-usb-leak.c: New test.
	* gcc.dg/analyzer/attr-malloc-misuses.c: New test.
2021-01-18 09:24:46 -05:00
Jonathan Wakely
ec153f96f8 libstdc++: Only test writing to wostream if supported [PR 98725]
libstdc++-v3/ChangeLog:

	PR libstdc++/98725
	* testsuite/20_util/unique_ptr/io/lwg2948.cc:  Do not try to
	write to a wide character stream if wide character support is
	disabled in the library.
2021-01-18 14:23:13 +00:00
Richard Biener
e393f03b1a testsuite/97494 - adjust gcc.dg/vect/slp-11b.c
Support for loop SLP splitting exposed that slp-11b.c has
folding that breaks SLP discovery which isn't what was intended
when the testcase was written.  The following makes it SLP-able
and "only" run into the issue that a load permutation is required.

And tries to adjust the target selectors accordingly.

2021-01-18  Richard Biener  <rguenther@suse.de>

	PR testsuite/97494
	* gcc.dg/vect/slp-11b.c: Adjust.
2021-01-18 15:20:31 +01:00
Andreas Schwab
b8c3f5196e libgomp: enable linux-futex on riscv64
Regtested on riscv64-suse-linux.

libgomp/
	* configure.tgt (riscv64*-*-linux*): Add linux to config_path.
2021-01-18 15:13:48 +01:00
Christophe Lyon
acdc49fabf [arm,testsuite]: Fix options for vceqz_p64.c and vceqzq_p64.c
These two tests need:
dg-require-effective-target arm_crypto_ok
dg-add-options arm_crypto
because they use intrinsics that need -mfpu=crypto-neon-fp-armv8.

2021-01-18  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/testsuite/
	PR target/71233
	* gcc.target/arm/simd/vceqz_p64.c: Use arm_crypto options.
	* gcc.target/arm/simd/vceqzq_p64.c: Likewise.
2021-01-18 13:59:54 +00:00
Richard Biener
104304cd24 testsuite/97299 - fix test condition of gcc.dg/vect/slp-reduc-3.c
This avoids looking for permute optimization when SLP cannot be applied.

2021-01-18  Richard Biener  <rguenther@suse.de>

	PR testsuite/97299
	* gcc.dg/vect/slp-reduc-3.c: Guard VEC_PERM_EXPR scan.
2021-01-18 14:52:12 +01:00
Jonathan Wakely
a81d2f1e41 libstdc++: Fix narrow char test to use stringbuf not wstringbuf
This seems to be a copy & paste error.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_stringstream/cons/char/1.cc: Use
	stringbuf not wstringbuf.
2021-01-18 12:45:10 +00:00
Jakub Jelinek
2e43880dbd libstd++: : Add workaround for as Error: file number less than one error [PR98708]
As mentioned in the PR, since the switch to DWARF5 by default instead of
DWARF4, gcc fails to build when configured against recent binutils.

The problem is that cxx11-ios_failure* is built in separate steps,
-S compilation (with -g -O2) followed by some sed and followed by
-c -g -O2 -g0 assembly.  When gcc is configured against recent binutils
and DWARF5 is the default, we emit .file 0 "..." directive on which the
assembler then fails (unless --gdwarf-5 is passed to it, but we don't want
that generally because on the other side older assemblers don't like -g*
passed to it when invoked on *.s file with compiler generated debug info.

I hope the bug will be fixed soon on the binutils side, but it would be nice
to have a workaround.

The following patch is one of the possibilities, another one is to do that
but add configure check for whether it is needed,
essentially
echo 'int main () { return 0; }' > conftest.c
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -g0 -c conftest.s -o conftest.o
and if the last command fails, we need that -gno-as-loc-support.
Or yet another option would be I think do a different check, whether
${CXX} ${CXXFLAGS} -g -O2 -S conftest.c -o conftest.s
${CXX} ${CXXFLAGS} -g -O2 -c conftest.s -o conftest.o
works and if yes, don't add the -g0 to cxx11-ios_failure*.s assembly.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	PR debug/98708
	* src/c++11/Makefile.am (cxx11-ios_failure-lt.s, cxx11-ios_failure.s):
	Compile with -gno-as-loc-support.
	* src/c++11/Makefile.in: Regenerated.
2021-01-18 11:29:26 +01:00
Sebastian Huber
0f951b3dd3 RTEMS: Fix libgomp build
libgomp/

	* config/rtems/sem.h (gomp_sem_getcount): New function.
2021-01-18 07:24:56 +01:00
Jakub Jelinek
d3b41bde96 libgomp: Don't access gomp_sem_t as int using atomics unconditionally
This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel.  rtems for now
remains broken.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

	* config/linux/sem.h (gomp_sem_getcount): New function.
	* config/posix/sem.h (gomp_sem_getcount): New function.
	* config/posix/sem.c (gomp_sem_getcount): New function.
	* config/accel/sem.h (gomp_sem_getcount): New function.
	* task.c (task_fulfilled_p): Use gomp_sem_getcount.
	(omp_fulfill_event): Likewise.
2021-01-18 07:18:46 +01:00
David Edelsohn
994fb69ac1 testsuite: powerpc fold-vec and sse updates.
Recent code generation changes have affected the count of some instructions.
This patch updates the instruction count for fold-vec-extract on P7 and P8.

Also, some of SSE emulation intrinsics only work on LE systems.

gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/fold-vec-extract-char.p7.c: Adjust addi count.
	* gcc.target/powerpc/fold-vec-extract-double.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-float.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-float.p8.c: Same.
	* gcc.target/powerpc/fold-vec-extract-int.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-int.p8.c: Same.
	* gcc.target/powerpc/fold-vec-extract-short.p7.c: Same.
	* gcc.target/powerpc/fold-vec-extract-short.p8.c: Same.
	* gcc.target/powerpc/sse-andnps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse-movhps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse-movlps-1.c: Restrict to LE.
	* gcc.target/powerpc/sse2-andnpd-1.c: Restrict to LE.
2021-01-17 23:59:26 -05:00
Jerry DeLisle
4905f40401 Fix ChangeLog entries. 2021-01-17 18:27:02 -08:00
GCC Administrator
4c9bcd5c81 Daily bump. 2021-01-18 00:16:27 +00:00
David Edelsohn
b654d23a47 testsuite: Skip DWARF 5 testcases on AIX.
AIX does not support DWARF 5.

This patch skips the DWARF 5-specific testcases.

gcc/testsuite/ChangeLog:

	* g++.dg/debug/dwarf2/inline-ns-2.C: Skip on AIX.
	* g++.dg/debug/dwarf2/inline-var-2.C: Skip on AIX.
	* g++.dg/debug/dwarf2/inline-var-3.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp11.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp14.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp17.C: Skip on AIX.
	* g++.dg/debug/dwarf2/lang-cpp20.C: Skip on AIX.
	* gcc.dg/debug/dwarf2/inline6.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/lang-c11.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/pr41445-7.c: Skip on AIX.
	* gcc.dg/debug/dwarf2/pr41445-8.c: Skip on AIX.
2021-01-17 18:27:35 -05:00
David Edelsohn
56b5d13e27 aix: default to DWARF 4.
GCC now defaults to DWARF 5.  AIX only supports DWARF 4 (3.5).

This patch overrides the default DWARF version to 4 unless explicitly
stated.

gcc/ChangeLog:

	* config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Override
	dwarf_version to 4.
	* config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Same.
2021-01-17 18:10:00 -05:00
Martin Sebor
192105b6a2 Avoid assuming SSA_NAME_IDENTIFIER is nonnull.
gcc/c-family/ChangeLog:

	* c-pretty-print.c (c_pretty_printer::primary_expression): Don't
	assume SSA_NAME_IDENTIFIER evaluates to nonzero.
2021-01-17 15:27:08 -07:00
Martin Jambor
0f4c8f517b ipa: Adjust cgraph verifier to materialization on demand (PR 98222)
after switching to materialization of clones on demand, the verifier
can happen to see edges leading to a clone of a materialized clone.
This means its clone_of is NULL and former_clone_of needs to be
checked in order to verify that the callee is a clone of the original
decl, which it did not do and reported edges to pointing to a wrong
place.

Fixed with the following patch, which has been pre-approved by Honza.
Bootstrapped and tested on x86_64-linux, pushed to master.

Martin

gcc/ChangeLog:

2021-01-15  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98222
	* cgraph.c (clone_of_p): Check also former_clone_of as we climb
	the clone tree.

gcc/testsuite/ChangeLog:

2021-01-15  Martin Jambor  <mjambor@suse.cz>

	PR ipa/98222
	* gcc.dg/ipa/pr98222.c: New test.
2021-01-17 22:32:11 +01:00
Mark Wielaard
3804e937b0 Default to DWARF5
gcc/ChangeLog:

	* common.opt (gdwarf-): Init(5).
	* doc/invoke.texi (-gdwarf): Document default to 5.
2021-01-17 01:36:39 +01:00
GCC Administrator
59cf67d1cf Daily bump. 2021-01-17 00:16:23 +00:00
Jakub Jelinek
a2960a04d5 testsuite: Fix up a testcase to find the right ISO_Fortran_binding.h.
2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: Include
	../../../libgfortran/ISO_Fortran_binding.h rather than
	ISO_Fortran_binding.h.
2021-01-16 22:52:43 +01:00
Kwok Cheung Yeung
a6d22fb21c openmp: Add support for the OpenMP 5.0 task detach clause
2021-01-16  Kwok Cheung Yeung  <kcy@codesourcery.com>

	gcc/
	* builtin-types.def
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
	to...
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
	...this.  Add extra argument.
	* gimplify.c (omp_default_clause): Ensure that event handle is
	firstprivate in a task region.
	(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DETACH.
	(gimplify_adjust_omp_clauses): Likewise.
	* omp-builtins.def (BUILT_IN_GOMP_TASK): Change function type to
	BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR.
	* omp-expand.c (expand_task_call): Add GOMP_TASK_FLAG_DETACH to flags
	if detach clause specified.  Add detach argument when generating
	call to	GOMP_task.
	* omp-low.c (scan_sharing_clauses): Setup data environment for detach
	clause.
	(finish_taskreg_scan): Move field for variable containing the event
	handle to the front of the struct.
	* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DETACH.  Fix
	ordering.
	* tree-nested.c (convert_nonlocal_omp_clauses): Handle
	OMP_CLAUSE_DETACH clause.
	(convert_local_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_DETACH.
	* tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_DETACH.
	Fix ordering.
	(omp_clause_code_name): Add entry for OMP_CLAUSE_DETACH.  Fix
	ordering.
	(walk_tree_1): Handle OMP_CLAUSE_DETACH.

	gcc/c-family/
	* c-pragma.h (pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DETACH.
	Redefine PRAGMA_OACC_CLAUSE_DETACH.

	gcc/c/
	* c-parser.c (c_parser_omp_clause_detach): New.
	(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause.
	(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
	* c-typeck.c (c_finish_omp_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH
	clause.  Prevent use of detach with mergeable and overriding the
	data sharing mode of the event handle.

	gcc/cp/
	* parser.c (cp_parser_omp_clause_detach): New.
	(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH.
	(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
	* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
	Prevent use of detach with mergeable and overriding the	data sharing
	mode of the event handle.

	gcc/fortran/
	* dump-parse-tree.c (show_omp_clauses): Handle detach clause.
	* frontend-passes.c (gfc_code_walker): Walk detach expression.
	* gfortran.h (struct gfc_omp_clauses): Add detach field.
	(gfc_c_intptr_kind): New.
	* openmp.c (gfc_free_omp_clauses): Free detach clause.
	(gfc_match_omp_detach): New.
	(enum omp_mask1): Add OMP_CLAUSE_DETACH.
	(enum omp_mask2): Remove OMP_CLAUSE_DETACH.
	(gfc_match_omp_clauses): Handle OMP_CLAUSE_DETACH for OpenMP.
	(OMP_TASK_CLAUSES): Add OMP_CLAUSE_DETACH.
	(resolve_omp_clauses): Prevent use of detach with mergeable and
	overriding the data sharing mode of the event handle.
	* trans-openmp.c (gfc_trans_omp_clauses): Handle detach clause.
	* trans-types.c (gfc_c_intptr_kind): New.
	(gfc_init_kinds): Initialize gfc_c_intptr_kind.
	* types.def
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
	to...
	(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
	...this.  Add extra argument.

	gcc/testsuite/
	* c-c++-common/gomp/task-detach-1.c: New.
	* g++.dg/gomp/task-detach-1.C: New.
	* gcc.dg/gomp/task-detach-1.c: New.
	* gfortran.dg/gomp/task-detach-1.f90: New.

	include/
	* gomp-constants.h (GOMP_TASK_FLAG_DETACH): New.

	libgomp/
	* fortran.c (omp_fulfill_event_): New.
	* libgomp.h (struct gomp_task): Add detach and completion_sem fields.
	(struct gomp_team): Add task_detach_queue and task_detach_count
	fields.
	* libgomp.map (OMP_5.0.1): Add omp_fulfill_event and omp_fulfill_event_.
	* libgomp_g.h (GOMP_task): Add extra argument.
	* omp.h.in (enum omp_event_handle_t): New.
	(omp_fulfill_event): New.
	* omp_lib.f90.in (omp_event_handle_kind): New.
	(omp_fulfill_event): New.
	* omp_lib.h.in (omp_event_handle_kind): New.
	(omp_fulfill_event): Declare.
	* priority_queue.c (priority_tree_find): New.
	(priority_list_find): New.
	(priority_queue_find): New.
	* priority_queue.h (priority_queue_predicate): New.
	(priority_queue_find): New.
	* task.c (gomp_init_task): Initialize detach field.
	(task_fulfilled_p): New.
	(GOMP_task): Add detach argument.  Ignore detach argument if
	GOMP_TASK_FLAG_DETACH not set in flags.  Initialize completion_sem
	field.	Copy address of completion_sem into detach argument and
	into the start of the data record.  Wait for detach event if task
	not deferred.
	(gomp_barrier_handle_tasks): Queue tasks with unfulfilled events.
	Remove completed tasks and requeue dependent tasks.
	(omp_fulfill_event): New.
	* team.c (gomp_new_team): Initialize task_detach_queue and
	task_detach_count fields.
	(free_team): Free task_detach_queue field.
	* testsuite/libgomp.c-c++-common/task-detach-1.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-2.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-3.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-4.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-5.c: New testcase.
	* testsuite/libgomp.c-c++-common/task-detach-6.c: New testcase.
	* testsuite/libgomp.fortran/task-detach-1.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-2.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-3.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-4.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-5.f90: New testcase.
	* testsuite/libgomp.fortran/task-detach-6.f90: New testcase.
2021-01-16 12:58:13 -08:00
Sebastian Huber
5e5d56919d RTEMS: Add -mcustom-fpu-cfg=fph2 multilib
This multilib supports Nios II configurations with the "Nios II Floating
Point Hardware 2 Component".

gcc/

	* config/nios2/t-rtems: Reset all MULTILIB_* variables.  Shorten
	multilib directory names.  Use MULTILIB_REQUIRED instead of
	MULTILIB_EXCEPTIONS.  Add -mhw-mul -mhw-mulx -mhw-div
	-mcustom-fpu-cfg=fph2 multilib.
2021-01-16 17:54:28 +01:00
Sebastian Huber
42f4e23992 nios2: Add -mcustom-fpu-cfg=fph2
The new -mcustom-fpu-cfg=fph2 option variant is useful to build a
multilib for the "Nios II Floating Point Hardware 2 Component":

https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/ug/ug_nios2_custom_instruction.pdf

Directly using the corresponding -mcustom-insn=N options for this
floating-point unit leads to a combinatorial explosion in the potential
count of multilibs which may break the build.

gcc/

	* config/nios2/nios2.c (NIOS2_FPU_CONFIG_NUM): Adjust value.
	(nios2_init_fpu_configs): Provide register values for new
	-mcustom-fpu-cfg=fph2 option variant.
	* doc/invoke.texi (-mcustom-fpu-cfg=fph2): Document new option
	variant.
2021-01-16 17:54:27 +01:00
Sebastian Huber
7e02426ba0 nios2: Remove custom instruction warnings
Do not warn if custom instructions are not used due to missing
optimization flags.  This prevents build errors with -Werror which
cannot be disabled via a dedicated warning option.

One reason to remove these warnings is to enable a multilib for the
"Nios II Floating Point Hardware 2 Component".  For example, the
libatomic target library in GCC is built with -Werror and the warnings
removed by this patch resulted in errors like:

cc1: error: switch '-mcustom-fmins' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-fmaxs' has no effect unless '-ffinite-math-only' is specified [-Werror]
cc1: error: switch '-mcustom-round' has no effect unless '-fno-math-errno' is specified [-Werror]

gcc/

	* config/nios2/nios2.c (nios2_custom_check_insns): Remove
	custom instruction warnings.
2021-01-16 17:54:27 +01:00
Jakub Jelinek
e2559c3945 match.pd: Optimize ((cst << x) & 1) [PR96669]
While we had a ((1 << x) & 1) != 0 to x == 0 optimization already,
this patch adds ((cst << x) & 1) optimization too, this time the
second constant must be 1 though, not some power of two, but the first
one can be any constant.  If it is even, the result is false, if it is
odd, the result is x == 0.

2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96669
	* match.pd ((CST << x) & 1 -> x == 0): New simplification.

	* gcc.dg/tree-ssa/pr96669-1.c: Adjust regexp.
	* gcc.dg/tree-ssa/pr96669-2.c: New test.
2021-01-16 09:21:52 +01:00
Jakub Jelinek
b673e7547f cd_dce: Return TODO_update_address_taken from last cd_dce [PR96271]
On the following testcase, handle_builtin_memcmp in the strlen pass folds
the memcmp into comparison of two MEM_REFs.  But nothing triggers updating
of addressable vars afterwards, so even when the parameters are no longer
address taken, we force the parameters to stack and back anyway.

This patch causes TODO_update_address_taken to happen right before last forwprop
pass (at the end of last cd_dce), so after strlen1 too.

2021-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96271
	* passes.def: Pass false argument to first two pass_cd_dce
	instances and true to last instance.  Add comment that
	last instance rewrites no longer addressed locals.
	* tree-ssa-dce.c (pass_cd_dce): Add update_address_taken_p member and
	initialize it.
	(pass_cd_dce::set_pass_param): New method.
	(pass_cd_dce::execute): Return TODO_update_address_taken from
	last cd_dce instance.

	* gcc.target/i386/pr96271.c: New test.
2021-01-16 09:20:29 +01:00
H.J. Lu
2c356f221b libstdc++-v3: Add -fcf-protection=none to -march=i486
-fcf-protection is automatically enabled in libstdc++ on Linux/x86.
Starting from

commit 77d372abec
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jan 14 05:56:46 2021 -0800

    x86: Error on -fcf-protection with incompatible target

GCC issues an error on -fcf-protection with incompatible target:

... -fcf-protection ... libstdc++-v3/testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc  -m32   -O2 -g0 -fno-exceptions -fno-asynchronous-unwind-tables -march=i486 ...
cc1plus: error: '-fcf-protection' is not compatible with this target
FAIL: 29_atomics/atomic_flag/test_and_set/explicit-hle.cc (test for excess errors)

Add -fcf-protection=none to -march=i486 to compile explicit-hle.cc.

	* testsuite/29_atomics/atomic_flag/test_and_set/explicit-hle.cc:
	Add -fcf-protection=none to -march=i486.
2021-01-15 17:37:20 -08:00
GCC Administrator
2f7f0d32e7 Daily bump. 2021-01-16 00:16:29 +00:00
Carl Love
f1ad419ebf rs6000, vector integer multiply/divide/modulo instructions
2021-01-15  Carl Love  <cel@us.ibm.com>

gcc/ChangeLog:
	* config/rs6000/altivec.h (vec_mulh, vec_div, vec_dive, vec_mod):
	New defines.
	* config/rs6000/altivec.md (VIlong): Move define to file vsx.md.
	* config/rs6000/rs6000-builtin.def (DIVES_V4SI, DIVES_V2DI,
	DIVEU_V4SI, DIVEU_V2DI, DIVS_V4SI, DIVS_V2DI, DIVU_V4SI,
	DIVU_V2DI, MODS_V2DI, MODS_V4SI, MODU_V2DI, MODU_V4SI,
	MULHS_V2DI, MULHS_V4SI, MULHU_V2DI, MULHU_V4SI, MULLD_V2DI):
	Add builtin define.
	(MULH, DIVE, MOD):  Add new BU_P10_OVERLOAD_2 definitions.
	* config/rs6000/rs6000-call.c (VSX_BUILTIN_VEC_DIV,
	VSX_BUILTIN_VEC_DIVE, P10_BUILTIN_VEC_MOD, P10_BUILTIN_VEC_MULH):
	New overloaded definitions.
	(builtin_function_type) [P10V_BUILTIN_DIVEU_V4SI,
	P10V_BUILTIN_DIVEU_V2DI, P10V_BUILTIN_DIVU_V4SI,
	P10V_BUILTIN_DIVU_V2DI, P10V_BUILTIN_MODU_V2DI,
	P10V_BUILTIN_MODU_V4SI, P10V_BUILTIN_MULHU_V2DI,
	P10V_BUILTIN_MULHU_V4SI]: Add case
	statement for builtins.
	* config/rs6000/rs6000.md (bits): Add new attribute sizes V4SI, V2DI.
	* config/rs6000/vsx.md (VIlong): Moved from config/rs6000/altivec.md.
	(UNSPEC_VDIVES, UNSPEC_VDIVEU): New unspec definitions.
	(vsx_mul_v2di): Add if TARGET_POWER10 statement.
	(vsx_udiv_v2di): Add if TARGET_POWER10 statement.
	(dives_<mode>, diveu_<mode>, div<mode>3, uvdiv<mode>3,
	mods_<mode>, modu_<mode>, mulhs_<mode>, mulhu_<mode>, mulv2di3):
	Add define_insn, mode is VIlong.
	* doc/extend.texi (vec_mulh, vec_mul, vec_div, vec_dive, vec_mod):
	Add builtin descriptions.

gcc/testsuite/ChangeLog:
	* gcc.target/powerpc/builtins-1-p10-runnable.c: New test file.
2021-01-15 17:31:12 -06:00
Eric Botcazou
c029fcb568 Reset force_source_line in final.c
Unlike the other global variables, it is not reset at the beginning of a
function so can leak into the next one.

gcc/ChangeLog:
	* final.c (final_start_function_1): Reset force_source_line.
2021-01-15 22:53:27 +01:00
Jerry DeLisle
b90e4a9741 fortran: Fixes a bug in ISO_Fortran_binding.c.
libgfortran/ChangeLog:

	* runtime/ISO_Fortran_binding.c (CFI_establish): Fixed signed
	  char arrays. Signed char or uint8_t arrays would cause
	  crashes unless an element size is specified.

gcc/testsuite/ChangeLog:

	* gfortran.dg/iso_fortran_binding_uint8_array.f90: New test.
	* gfortran.dg/iso_fortran_binding_uint8_array_driver.c: New test.
2021-01-15 13:48:42 -08:00
Nathan Sidwell
9beb6d88ef c++: Fix qualified array-type construction [PR 98538]
This was an assert that was too picky.  The reason I had to alter
array construction was that on stream in, we cannot dynamically determine
a type's dependentness.  Thus on stream out of the 'problematic' types,
we save the dependentness for reconstruction.  Fortunately the paths into
cp_build_qualified_type_real from streamin with arrays do have the array's
dependentess set as needed.

	PR c++/98538
	gcc/cp/
	* tree.c (cp_build_qualified_type_real): Propagate an array's
	dependentness to the copy, if known.
	gcc/testsuite/
	* g++.dg/template/pr98538.C: New.
2021-01-15 12:45:18 -08:00
Nathan Sidwell
e1efa6af61 preprocessor: Make quoting : [PR 95253]
I missed some testsuite fall out with my patch to fix mkdeps file
mangling.

	PR preprocessor/95253
	gcc/testsuite/
	* g++.dg/modules/dep-1_a.C: Adjust expected output.
	* g++.dg/modules/dep-1_b.C: Likewise.
	* g++.dg/modules/dep-2.C: Likewise.
2021-01-15 12:44:52 -08:00
Jakub Jelinek
0425f4c1b6 match.pd: Generalize the PR64309 simplifications [PR96669]
The following patch generalizes the PR64309 simplifications, so that instead
of working only with constants 1 and 1 it works with any two power of two
constants, and works also for right shift (in that case it rules out the
first one being negative, as it is arithmetic shift then).

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96669
	* match.pd (((1 << A) & 1) != 0 -> A == 0,
	((1 << A) & 1) == 0 -> A != 0): Generalize for 1s replaced by
	possibly different power of two constants and to right shift too.

	* gcc.dg/tree-ssa/pr96669-1.c: New test.
2021-01-15 21:12:14 +01:00
Jakub Jelinek
5c046034e3 match.pd: Optimize (x < 0) ^ (y < 0) to (x ^ y) < 0 etc. [PR96681]
This patch simplifies comparisons that test the sign bit xored together.
If the comparisons are both < 0 or both >= 0, then we should xor the operands
together and compare the result to < 0, if the comparisons are different,
we should compare to >= 0.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96681
	* match.pd ((x < 0) ^ (y < 0) to (x ^ y) < 0): New simplification.
	((x >= 0) ^ (y >= 0) to (x ^ y) < 0): Likewise.
	((x < 0) ^ (y >= 0) to (x ^ y) >= 0): Likewise.
	((x >= 0) ^ (y < 0) to (x ^ y) >= 0): Likewise.

	* gcc.dg/tree-ssa/pr96681.c: New test.
2021-01-15 21:10:44 +01:00
Alexandre Oliva
e63c2161d0 drop -dumpbase-ext from producer string
The -dumpbase and -dumpdir options are excluded from the producer
string output in debug information, but -dumpbase-ext was not.  This
patch excludes it as well.


for  gcc/ChangeLog

	* opts.c (gen_command_line_string): Exclude -dumpbase-ext.
2021-01-15 16:22:54 -03:00
Jason Merrill
d75199f782 c++: Avoid redundant copy in {} init [PR98642]
Here, initializing from { } implies a call to the default constructor for
base.  We were then seeing that we're initializing a base subobject, so we
tried to copy the result of that call.  This is clearly wrong; we should
initialize the base directly from its default constructor.

This patch does a lot of refactoring of unsafe_copy_elision_p and adds
make_safe_copy_elision that will also try to do the base constructor
rewriting from the last patch.

gcc/cp/ChangeLog:

	PR c++/98642
	* call.c (unsafe_return_slot_p): Return int.
	(init_by_return_slot_p): Split out from...
	(unsafe_copy_elision_p): ...here.
	(unsafe_copy_elision_p_opt): New name for old meaning.
	(build_over_call): Adjust.
	(make_safe_copy_elision): New.
	* typeck2.c (split_nonconstant_init_1): Elide copy from safe
	list-initialization.
	* cp-tree.h: Adjust.

gcc/testsuite/ChangeLog:

	PR c++/98642
	* g++.dg/cpp1z/elide5.C: New test.
2021-01-15 13:57:01 -05:00
Jason Merrill
424deca72b c++: Fix copy elision for base initialization
While working on PR98642 I noticed that in this testcase we were eliding the
copy, calling the complete default constructor to initialize the B base
subobject, and therefore wrongly initializing the non-existent A subobject
of B.  The test doesn't care whether the copy is elided or not, but checks
that we are actually calling a base constructor for B.

The patch preserves the elision, but changes the initializer to call the
base constructor instead of the complete constructor.

gcc/cp/ChangeLog:

	* call.c (base_ctor_for, make_base_init_ok): New.
	(build_over_call): Use make_base_init_ok.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/elide4.C: New test.
2021-01-15 13:57:01 -05:00
Tamar Christina
ad26034338 AArch64: Add NEON, SVE and SVE2 RTL patterns for Multiply, FMS and FMA.
This adds implementation for the optabs for complex operations.  With this the
following C code:

  void g (float complex a[restrict N], float complex b[restrict N],
	  float complex c[restrict N])
  {
    for (int i=0; i < N; i++)
      c[i] =  a[i] * b[i];
  }

generates

NEON:

g:
        movi    v3.4s, 0
        mov     x3, 0
        .p2align 3,,7
.L2:
        mov     v0.16b, v3.16b
        ldr     q2, [x1, x3]
        ldr     q1, [x0, x3]
        fcmla   v0.4s, v1.4s, v2.4s, #0
        fcmla   v0.4s, v1.4s, v2.4s, #90
        str     q0, [x2, x3]
        add     x3, x3, 16
        cmp     x3, 1600
        bne     .L2
        ret

SVE:

g:
        mov     x3, 0
        mov     x4, 400
        ptrue   p1.b, all
        whilelo p0.s, xzr, x4
        mov     z3.s, #0
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        fcmla   z0.s, p1/m, z1.s, z2.s, #0
        fcmla   z0.s, p1/m, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

SVE2 (with int instead of float)
g:
        mov     x3, 0
        mov     x4, 400
        mov     z3.b, #0
        whilelo p0.s, xzr, x4
        .p2align 3,,7
.L2:
        ld1w    z1.s, p0/z, [x0, x3, lsl 2]
        ld1w    z2.s, p0/z, [x1, x3, lsl 2]
        movprfx z0, z3
        cmla    z0.s, z1.s, z2.s, #0
        cmla    z0.s, z1.s, z2.s, #90
        st1w    z0.s, p0, [x2, x3, lsl 2]
        incw    x3
        whilelo p0.s, x3, x4
        b.any   .L2
        ret

gcc/ChangeLog:

	* config/aarch64/aarch64-simd.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
	* config/aarch64/iterators.md (UNSPEC_FCMUL,
	UNSPEC_FCMUL180, UNSPEC_FCMLA_CONJ, UNSPEC_FCMLA180_CONJ,
	UNSPEC_CMLA_CONJ, UNSPEC_CMLA180_CONJ, UNSPEC_CMUL, UNSPEC_CMUL180,
	FCMLA_OP, FCMUL_OP, conj_op, rotsplit1, rotsplit2, fcmac1, sve_rot1,
	sve_rot2, SVE2_INT_CMLA_OP, SVE2_INT_CMUL_OP, SVE2_INT_CADD_OP): New.
	(rot): Add UNSPEC_FCMUL, UNSPEC_FCMUL180.
	(rot_op): Renamed to conj_op.
	* config/aarch64/aarch64-sve.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
	* config/aarch64/aarch64-sve2.md (cml<fcmac1><conj_op><mode>4,
	cmul<conj_op><mode>3): New.
2021-01-15 18:50:27 +00:00
Jason Merrill
cd09079cfd c++: Fix list-init of array of no-copy type [PR63707]
build_vec_init_elt models initialization from some arbitrary object of the
type, i.e. copy, but in the case of list-initialization we don't do a copy
from the elements, we initialize them directly.

gcc/cp/ChangeLog:

	PR c++/63707
	* tree.c (build_vec_init_expr): Don't call build_vec_init_elt
	if we got a CONSTRUCTOR.

gcc/testsuite/ChangeLog:

	PR c++/63707
	* g++.dg/cpp0x/initlist-array13.C: New test.
2021-01-15 13:38:14 -05:00
Alexandre Oliva
c0194736b4 gcc.dg/analyzer tests: use __builtin_alloca, not alloca.h
Use __builtin_alloca.  Some systems don't have alloca.h or alloca.


Co-Authored-By: Olivier Hainque <hainque@adacore.com>

for  gcc/testsuite/ChangeLog

	* gcc.dg/analyzer/alloca-leak.c: Drop alloca.h, use builtin.
	* gcc.dg/analyzer/data-model-1.c: Likewise.
	* gcc.dg/analyzer/malloc-1.c: Likewise.
	* gcc.dg/analyzer/malloc-paths-8.c: Likewise.
2021-01-15 15:36:22 -03:00
Jakub Jelinek
aaec739250 testsuite: Add testcase coverage for already fixed [PR96671]
The fix for this PR didn't come with any test coverage, I've added
tests that make sure we optimize it no matter what order of the x ^ y ^ z
operands is used.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96671
	* gcc.dg/tree-ssa/pr96671-1.c: New test.
	* gcc.dg/tree-ssa/pr96671-2.c: New test.
2021-01-15 19:27:53 +01:00
David Malcolm
a3128bf012 bootstrap: fix failing diagnostic selftest on Windows [PR98696]
In one of the selftests in g:f10960558540636800cf5d3d6355969621fbc17e
I didn't consider that paths can contain backslashes, which happens
for the tempfiles on Windows hosts.

gcc/ChangeLog:
	PR bootstrap/98696
	* diagnostic.c
	(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
	Escape the tempfile name when constructing the expected output.
2021-01-15 13:26:39 -05:00
Jakub Jelinek
adb520606c c-family: Improve MEM_REF printing for diagnostics [PR98597]
Ok, here is an updated patch which fixes what I found, and implements what
has been discussed on the mailing list and on IRC, i.e. if the types
are compatible as well as alias sets are same, then it prints
what c_fold_indirect_ref_for_warn managed to create, otherwise it uses
that info for printing offsets using offsetof (except when it starts
with ARRAY_REFs, because one can't have offsetof (struct T[2][2], [1][0].x.y)

The uninit-38.c test (which was the only one I believe which had tests on the
exact spelling of MEM_REF printing) contains mainly changes to have space
before * for pointer types (as that is how the C pretty-printers normally
print types, int * rather than int*), plus what might be considered a
regression from what Martin printed, but it is actually a correctness fix.

When the arg is a pointer with type pointer to VLA with char element type
(let's say the pointer is p), which is what happens in several of the
uninit-38.c tests, omitting the (char *) cast is incorrect, as p + 1
is not the 1 byte after p, but pointer to the end of the VLA.
It only happened to work because of the hacks (which I don't like at all
and are dangerous, DECL_ARTIFICIAL var names with dot inside can be pretty
much anything, e.g. a lot of passes construct their helper vars from some
prefix that designates intended use of the var plus numeric suffix), where
the a.1 pointer to VLA is printed as a which if one is lucky happens to be
a variable with VLA type (rather than pointer to it), and for such vars
a + 1 is indeed &a[0] + 1 rather than &a + 1.  But if we want to do this
reliably, we'd need to make sure it comes from VLA (e.g. verify that the
SSA_NAME is defined to __builtin_alloca_with_align and that there exists
a corresponding VAR_DECL with DECL_VALUE_EXPR that has the a.1 variable
in it).

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98597
	* c-pretty-print.c: Include options.h.
	(c_fold_indirect_ref_for_warn): New function.
	(print_mem_ref): Use it.  If it returns something that has compatible
	type and is TBAA compatible with zero offset, print it and return,
	otherwise print it using offsetof syntax or array ref syntax.  Fix up
	printing if MEM_REFs first operand is ADDR_EXPR, or when the first
	argument has pointer to array type.  Print pointers using the standard
	formatting.

	* gcc.dg/uninit-38.c: Expect a space in between type name and asterisk.
	Expect for now a (char *) cast for VLAs.
	* gcc.dg/uninit-40.c: New test.
2021-01-15 19:21:58 +01:00
Jakub Jelinek
50dbced2f3 openmp: Change the way of building of reduction array type
The PR98597 patch regresses on _Atomic-3.c, as in the C FE building an
array type with qualified elements results in a type incompatible with
when an array type with unqualified elements is qualified afterwards.
This patch adds a workaround for that.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	* c-typeck.c (c_finish_omp_clauses): For reduction build array with
	unqualified element type and then call c_build_qualified_type on the
	ARRAY_TYPE.
2021-01-15 19:21:58 +01:00
Kyrylo Tkachov
d3959070aa [PATCH] aarch64: Implement vmlsl[_high]* intrinsics using builtins
This patch reimplements some more intrinsics using RTL builtins in the
straightforward way.
Thankfully most of the RTL infrastructure is already in place for it.

gcc/
	* config/aarch64/aarch64-simd.md (*aarch64_<su>mlsl_hi<mode>):
	Rename to...
	(aarch64_<su>mlsl_hi<mode>): ... This.
	(aarch64_<su>mlsl_hi<mode>): Define.
	(*aarch64_<su>mlsl<mode): Rename to...
	(aarch64_<su>mlsl<mode): ... This.
	* config/aarch64/aarch64-simd-builtins.def (smlsl, umlsl,
	smlsl_hi, umlsl_hi): Define builtins.
	* config/aarch64/arm_neon.h (vmlsl_high_s8, vmlsl_high_s16,
	vmlsl_high_s32, vmlsl_high_u8, vmlsl_high_u16, vmlsl_high_u32,
	vmlsl_s8, vmlsl_s16, vmlsl_s32, vmlsl_u8,
	vmlsl_u16, vmlsl_u32): Reimplement with builtins.
2021-01-15 17:55:57 +00:00
Uros Bizjak
7d0df0aeb6 i386: Use cpp_define_formatted for __SIZEOF_FLOAT80__ definition
2021-01-15  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	* config/i386/i386-c.c (ix86_target_macros):
	Use cpp_define_formatted for __SIZEOF_FLOAT80__ definition.
2021-01-15 18:16:09 +01:00
Nathan Sidwell
1ba71fabb7 preprocessor: Make quoting : [PR 95253]
Make doesn't need ':' quoting (in a filename).

	PR preprocessor/95253
	libcpp/
	* mkdeps.c (munge): Do not escape ':'.
2021-01-15 08:56:20 -08:00
Nathan Sidwell
492b90f33d c++: Fix langspecs with -fsyntax-only [PR98591]
-fsyntax-only is handled specially in the driver and causes it to add
 '-o /dev/null' (or a suitable OS-specific variant thereof).  PCH is
 handled in the language driver.  I'd not sufficiently protected the
 -fmodule-only action of adding a dummy assembler from the actions of
 -fsyntax-only, so we ended up with two -o options.

	PR c++/98591
	gcc/cp/
	* lang-specs.h: Fix handling of -fmodule-only with -fsyntax-only.
2021-01-15 08:56:20 -08:00
Richard Sandiford
5a783f42d7 aarch64: Add a minipass for fusing CC insns [PR88836]
This patch adds a small target-specific pass to remove redundant SVE
PTEST instructions.  There are two important uses of this:

- Removing PTESTs after WHILELOs (PR88836).  The original testcase
  no longer exhibits the problem due to more recent optimisations,
  but it can still be seen in simple cases like the one in the patch.
  It also shows up in 450.soplex.

- Removing PTESTs after RDFFRs in ACLE code.

This is just an interim “solution” for GCC 11.  I hope to replace
it with something generic and target-independent for GCC 12.
However, the use cases above are very important for performance,
so I'd rather not leave the bug unfixed for yet another release cycle.

Since the pass is intended to be short-lived, I've not added
a command-line option for it.  The pass can be disabled using
-fdisable-rtl-cc_fusion if necessary.

Although what the pass does is independent of SVE, it's motivated
only by SVE cases and doesn't trigger for any non-SVE test I've seen.
I've therefore gated it on TARGET_SVE and restricted it to PTEST
patterns.

gcc/
	PR target/88836
	* config.gcc (aarch64*-*-*): Add aarch64-cc-fusion.o to extra_objs.
	* Makefile.in (RTL_SSA_H): New variable.
	* config/aarch64/t-aarch64 (aarch64-cc-fusion.o): New rule.
	* config/aarch64/aarch64-protos.h (make_pass_cc_fusion): Declare.
	* config/aarch64/aarch64-passes.def: Add pass_cc_fusion after
	pass_combine.
	* config/aarch64/aarch64-cc-fusion.cc: New file.

gcc/testsuite/
	PR target/88836
	* gcc.target/aarch64/sve/acle/general/ldff1_8.c: New test.
	* gcc.target/aarch64/sve/ptest_1.c: Likewise.
2021-01-15 16:45:42 +00:00
Richard Sandiford
f2cc526f47 recog: Fix insn_change_watermark destructor
Noticed while working on something else that the insn_change_watermark
destructor could call cancel_changes for changes that no longer exist.
The loop in cancel_changes is a nop in that case, but:

  num_changes = num;

can mess things up.

I think this would only affect nested uses of insn_change_watermark.

gcc/
	* recog.h (insn_change_watermark::~insn_change_watermark): Avoid
	calling cancel_changes for changes that no longer exist.
2021-01-15 16:45:41 +00:00
Richard Sandiford
7f6cdaa9a8 rtl-ssa: Fix a silly typo
s/ref/reg/ on a previously unused function name.

gcc/
	* rtl-ssa/functions.h (function_info::ref_defs): Rename to...
	(function_info::reg_defs): ...this.
	* rtl-ssa/member-fns.inl (function_info::ref_defs): Rename to...
	(function_info::reg_defs): ...this.
2021-01-15 16:45:40 +00:00
Marius Hillenbrand
f9a577927e IBM Z: Fix linking to libatomic in target test cases
One of the test cases failed to link because of missing paths to
libatomic. Reuse procedures in lib/atomic-dg.exp to gather these paths.

gcc/testsuite/ChangeLog:

2021-01-15  Marius Hillenbrand  <mhillen@linux.ibm.com>

	* gcc.target/s390/s390.exp: Call lib atomic-dg.exp to link
	libatomic into testcases in gcc.target/s390/md.
	* gcc.target/s390/md/atomic_exchange-1.c: Remove no unnecessary
	-latomic.
2021-01-15 15:20:31 +01:00
Christophe Lyon
63999d751d arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics
This patch adds implementations for vceqq_p64, vceqz_p64 and
vceqzq_p64 intrinsics.

vceqq_p64 uses the existing vceq_p64 after splitting the input vectors
into their high and low halves.

vceqz[q] simply call the vceq and vceqq with a second argument equal
to zero.

The added (executable) testcases make sure that the poly64x2_t
variants have results with one element of all zeroes (false) and the
other element with all bits set to one (true).

2021-01-15  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	PR target/71233
	* config/arm/arm_neon.h (vceqz_p64, vceqq_p64, vceqzq_p64): New.

	gcc/testsuite/
	PR target/71233
	* gcc.target/aarch64/advsimd-intrinsics/p64_p128.c: Add tests for
	vceqz_p64, vceqq_p64 and vceqzq_p64.
	* gcc.target/arm/simd/vceqz_p64.c: New test.
	* gcc.target/arm/simd/vceqzq_p64.c: New test.
2021-01-15 14:11:07 +00:00
Christophe Lyon
f1d054017e Revert "arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics"
This reverts commit 1a63064200.
2021-01-15 14:11:07 +00:00
Richard Biener
446703ccc2 tree-optimization/96376 - do not check alignment for invariant loads
The testcases show that we fail to disregard alignment for invariant
loads.  The patch handles them like we handle gather and scatter.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/96376
	* tree-vect-stmts.c (get_load_store_type): Disregard alignment
	for VMAT_INVARIANT.
2021-01-15 15:07:43 +01:00
Martin Liska
dc8475e334 Pytest in tests: improve
gcc/ChangeLog:

	* doc/install.texi: Document that some tests need pytest module.
	* doc/sourcebuild.texi: Likewise.

gcc/testsuite/ChangeLog:

	* lib/gcov.exp: Use 'env python3' for execution of pytests.
	Check that pytest accepts all needed options first.
	Improve formatting of PASS/FAIL lines.
2021-01-15 14:29:43 +01:00
Richard Biener
b36c9cd094 testsuite/96147 - align vector access
This aligns p so that the testcase is meaningful for targets
without a hw misaligned access.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR testsuite/96147
	* gcc.dg/vect/bb-slp-32.c: Align p.
2021-01-15 14:03:37 +01:00
Richard Biener
aa4ee5798f testsuite/96147 - scan for vectorized load
This changes gcc.dg/vect/bb-slp-9.c to scan for a vectorized load
instead of a vectorized BB which then correctly captures the
unaligned load we try to test and not some intermediate built
from scalar vector.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR testsuite/96147
	* gcc.dg/vect/bb-slp-9.c: Scan for a vector load transform.
2021-01-15 14:02:06 +01:00
Richard Biener
e1bd80fb70 testsuite/96147 - key scanning on vect_hw_misalign
gcc.dg/vect/slp-45.c failed to key the vectorization capability
scanning on vect_hw_misalign.  Since the stores are strided
they cannot be (all) analyzed to be aligned.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR testsuite/96147
	* gcc.dg/vect/slp-45.c: Key scanning on
	vect_hw_misalign.
2021-01-15 13:52:12 +01:00
Richard Biener
d03f14c354 testsuite/96147 - remove scanning for ! vect_hw_misalign
This removes scanning that's too difficult to get correct for all
targets, leaving the correctness test for them and keeping the
vectorization capability check to vect_hw_misalign targets.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR testsuite/96147
	* gcc.dg/vect/slp-43.c: Remove ! vect_hw_misalign scan.
2021-01-15 13:50:50 +01:00
Christophe Lyon
1a63064200 arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics
This patch adds implementations for vceqq_p64, vceqz_p64 and
vceqzq_p64 intrinsics.

vceqq_p64 uses the existing vceq_p64 after splitting the input vectors
into their high and low halves.

vceqz[q] simply call the vceq and vceqq with a second argument equal
to zero.

The added (executable) testcases make sure that the poly64x2_t
variants have results with one element of all zeroes (false) and the
other element with all bits set to one (true).

2021-01-15  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	PR target/71233
	* config/arm/arm_neon.h (vceqz_p64, vceqq_p64, vceqzq_p64): New.

	gcc/testsuite/
	PR target/71233
	* gcc.target/aarch64/advsimd-intrinsics/p64_p128.c: Add tests for
	vceqz_p64, vceqq_p64 and vceqzq_p64.
2021-01-15 12:39:19 +00:00
Richard Biener
cb60334b71 testsuite/96098 - remove redundant testcase
The testcase morphed in a way no longer testing what it was originally supposed to do and slightly altering it shows the original issue isn't fixed (anymore).
The limit as set as result of PR91403 (and dups) prevents the issue for larger
arrays but the testcase has

double a[128][128];

which results in a group size of "just" 512 (the limit is 4096).  Avoiding
the 'BB vectorization with gaps at the end of a load is not supported'
by altering it to do

void foo(void)
{
  b[0] = a[0][0];
  b[1] = a[1][0];
  b[2] = a[2][0];
  b[3] = a[3][127];
}

shows that costing has improved further to not account the dead loads making
the previous test inefficient.  In fact the underlying issue isn't fixed
(we do code-generate dead loads).

In fact the vector permute load is even profitable, just the excessive
code-generation issue exists (and is "fixed" by capping it a constant
boundary, just too high for this particular testcase).

The testcase now has "dups", so I'll simply remove it.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR testsuite/96098
	* gcc.dg/vect/bb-slp-pr68892.c: Remove.
2021-01-15 13:32:44 +01:00
Jakub Jelinek
0411ae7f08 libatomic, libgomp, libitc: Fix bootstrap [PR70454]
The recent changes to error on mixing -march=i386 and -fcf-protection broke
bootstrap.  This patch changes lib{atomic,gomp,itm} configury, so that it
only adds -march=i486 to flags if really needed (i.e. when 486 or later isn't
on by default already).  Similarly, it will not use ifuncs if -mcx16
(or -march=i686 for 32-bit) is on by default.

2021-01-15  Jakub Jelinek  <jakub@redhat.com>

	PR target/70454
libatomic/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.  Determine if try_ifunc is needed
	based on preprocessor check on __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
	or __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8.
libgomp/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.
libitm/
	* configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
	be added through preprocessor check on
	__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.
2021-01-15 13:16:42 +01:00
Christophe Lyon
bfab355012 arm: Auto-vectorization for MVE: vshr
This patch enables MVE vshr instructions for auto-vectorization.  New
MVE patterns are introduced that take a vector of constants as second
operand, all constants being equal.

The existing mve_vshrq_n_<supf><mode> is kept, as it takes a single
immediate as second operand, and is used by arm_mve.h.

The vashr<mode>3 and vlshr<mode>3 expanders are moved fron neon.md to
vec-common.md, updated to rely on the normal expansion scheme to
generate shifts by immediate.

2020-12-03  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/mve.md (mve_vshrq_n_s<mode>_imm): New entry.
	(mve_vshrq_n_u<mode>_imm): Likewise.
	* config/arm/neon.md (vashr<mode>3, vlshr<mode>3): Move to ...
	* config/arm/vec-common.md: ... here.

	gcc/testsuite/
	* gcc.target/arm/simd/mve-vshr.c: Add tests for vshr.
2021-01-15 10:37:44 +00:00
Christophe Lyon
7432f255b7 arm: Auto-vectorization for MVE: vshl
This patch enables MVE vshlq instructions for auto-vectorization.

The existing mve_vshlq_n_<supf><mode> is kept, as it takes a single
immediate as second operand, and is used by arm_mve.h.

We move the vashl<mode>3 insn from neon.md to an expander in
vec-common.md, and the mve_vshlq_<supf><mode> insn from mve.md to
vec-common.md, adding the second alternative fron neon.md.

mve_vshlq_<supf><mode> will be used by a later patch enabling
vectorization for vshr, as a unified version of
ashl3<mode3>_[signed|unsigned] from neon.md. Keeping the use of unspec
VSHLQ enables to generate both 's' and 'u' variants.

It is not clear whether the neon_shift_[reg|imm]<q> attribute is still
suitable, since this insn is also used for MVE.

I kept the mve_vshlq_<supf><mode> naming instead of renaming it to
ashl3_<supf>_<mode> as discussed because the reference in
arm_mve_builtins.def automatically inserts the "mve_" prefix and I
didn't want to make a special case for this.

I haven't yet found why the v16qi and v8hi tests are not vectorized.
With dest[i] = a[i] << b[i] and:
  {
    int i;
    unsigned int i.24_1;
    unsigned int _2;
    int16_t * _3;
    short int _4;
    int _5;
    int16_t * _6;
    short int _7;
    int _8;
    int _9;
    int16_t * _10;
    short int _11;
    unsigned int ivtmp_42;
    unsigned int ivtmp_43;

    <bb 2> [local count: 119292720]:

    <bb 3> [local count: 954449105]:
    i.24_1 = (unsigned int) i_23;
    _2 = i.24_1 * 2;
    _3 = a_15(D) + _2;
    _4 = *_3;
    _5 = (int) _4;
    _6 = b_16(D) + _2;
    _7 = *_6;
    _8 = (int) _7;
    _9 = _5 << _8;
    _10 = dest_17(D) + _2;
    _11 = (short int) _9;
    *_10 = _11;
    i_19 = i_23 + 1;
    ivtmp_42 = ivtmp_43 - 1;
    if (ivtmp_42 != 0)
      goto <bb 5>; [87.50%]
    else
      goto <bb 4>; [12.50%]

    <bb 5> [local count: 835156386]:
    goto <bb 3>; [100.00%]

    <bb 4> [local count: 119292720]:
    return;

  }
the vectorizer says:
mve-vshl.c:37:96: note:   ==> examining statement: _5 = (int) _4;
mve-vshl.c:37:96: note:   vect_is_simple_use: operand *_3, type of def: internal
mve-vshl.c:37:96: note:   vect_is_simple_use: vectype vector(8) short int
mve-vshl.c:37:96: missed:   conversion not supported by target.
mve-vshl.c:37:96: note:   vect_is_simple_use: operand *_3, type of def: internal
mve-vshl.c:37:96: note:   vect_is_simple_use: vectype vector(8) short int
mve-vshl.c:37:96: note:   vect_is_simple_use: operand *_3, type of def: internal
mve-vshl.c:37:96: note:   vect_is_simple_use: vectype vector(8) short int
mve-vshl.c:37:117: missed:   not vectorized: relevant stmt not supported: _5 = (int) _4;
mve-vshl.c:37:96: missed:  bad operation or unsupported loop bound.
mve-vshl.c:37:96: note:  ***** Analysis failed with vector mode V8HI

2020-12-03  Christophe Lyon  <christophe.lyon@linaro.org>

	gcc/
	* config/arm/mve.md (mve_vshlq_<supf><mode>): Move to
	vec-commond.md.
	* config/arm/neon.md (vashl<mode>3): Delete.
	* config/arm/vec-common.md (mve_vshlq_<supf><mode>): New.
	(vasl<mode>3): New expander.

	gcc/testsuite/
	* gcc.target/arm/simd/mve-vshl.c: Add tests for vshl.
2021-01-15 10:37:38 +00:00
Richard Biener
2ea6f4a377 tree-optimization/98685 - fix placement of extern converts
Avoid advancing to the next stmt when inserting at region boundary
and deal with a vector def being not the only child.

2021-01-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98685
	* tree-vect-slp.c (vect_schedule_slp_node): Refactor handling
	of vector extern defs.

	* gcc.dg/vect/bb-slp-pr98685.c: New testcase.
2021-01-15 11:26:57 +01:00
Tamar Christina
c4eec1efae testsuite: Fix sed script errors in complex tests
I ran sed script late over the tests which accidentally
introduced a syntax error in the tests.

This fixes it.

Committed under the obvious rule.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/complex/complex-mla-template.c: Fix sed.
	* gcc.dg/vect/complex/complex-mls-template.c: Likewise.
2021-01-15 09:14:30 +00:00
Ian Lance Taylor
b0ccd3922f compiler: add support for reading embedcfg files
This is the code that parses an embedcfg file, which is a JSON file
created by the go command when it sees go:embed directives.  This code
is not yet called, and does not yet do anything.  It's being sent as a
separate CL to isolate just the JSON parsing code.

	* Make-lang.in (GO_OBJS): Add go/embed.o.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281532
2021-01-14 17:28:37 -08:00
GCC Administrator
5fff80fd79 Daily bump. 2021-01-15 00:16:28 +00:00
David Malcolm
b95d97f1a5 jit: remove "Alpha" warning from docs
I removed the "Alpha" warning from the JIT wiki page on
2020-05-18:
  https://gcc.gnu.org/wiki/JIT?action=diff&rev1=47&rev2=48
but forgot to remove it from the documentation, which this
patch does.

gcc/jit/ChangeLog:
	* docs/cp/index.rst: Remove "Alpha" warning.
	* docs/index.rst: Likewise.
	* docs/_build/texinfo/libgccjit.texi: Regenerate
2021-01-14 17:58:53 -05:00
Jason Merrill
f1fc27b6c5 c++: Minor refactoring in process_init_constructor_record
This function had two different local variables for TREE_TYPE (field), one
of which shadowed a parameter, and wasn't using them consistently.

gcc/cp/ChangeLog:

	* typeck2.c (process_init_constructor_record): Use fldtype
	variable consistently.
2021-01-14 17:17:17 -05:00
David Malcolm
387f6c15d3 Handle fancy_abort before diagnostic initialization [PR98586]
If fancy_abort is called before the diagnostic subsystem is initialized,
internal_error will crash internally in a way that prevents a useful
message reaching the user.

This can happen with libgccjit in the case of gcc_assert failures
that occur outside of the libgccjit mutex that guards the rest of
gcc's state, including global_dc (when global_dc may not be
initialized yet, or might be in use by another thread).

I tried a few approaches to fixing this as noted in PR jit/98586
e.g. using a temporary diagnostic_context and initializing it for
the call to internal_error, however the more code that runs, the
more chance there is for other errors to occur.

The best fix appears to be to simply fall back to a minimal abort
implementation that only relies on i18n, as implemented by this
patch.

gcc/ChangeLog:
	PR jit/98586
	* diagnostic.c (diagnostic_kind_text): Break out this array
	from...
	(diagnostic_build_prefix): ...here.
	(fancy_abort): Detect when diagnostic_initialize has not yet been
	called and fall back to a minimal implementation of printing the
	ICE, rather than segfaulting in internal_error.
2021-01-14 17:02:28 -05:00
François Dumont
02e7af1122 libstdc++: Implement N3644 for _GLIBCXX_DEBUG iterators
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/debug/98466.cc: Make it pre-C++11
	compliant.
2021-01-14 22:43:26 +01:00
David Malcolm
f109605585 Add GCC_EXTRA_DIAGNOSTIC_OUTPUT environment variable for fix-it hints
GCC has had the ability to emit fix-it hints in machine-readable form
since GCC 7 via -fdiagnostics-parseable-fixits and
-fdiagnostics-generate-patch.

The former emits additional specially-formatted lines to stderr; the
option and its format were directly taken from a pre-existing option
in clang.

Ideally this could be used by IDEs so that the user can select specific
fix-it hints and have the IDE apply them to the user's source code
(perhaps turning them into clickable elements, perhaps with an
"Apply All" option, etc).  Eclipse CDT has supported this option in
this way for a few years:
  https://bugs.eclipse.org/bugs/show_bug.cgi?id=497670

As a user of Emacs I would like Emacs to support such a feature.
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25987 tracks supporting
GCC fix-it output in Emacs.  The discussion there identifies two issues
with the existing option:

(a) columns in the output are specified as byte-offsets within the
line (for exact compatibility with the option in clang), whereas emacs
would prefer to consume them as what GCC 11 calls "display columns".
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-column-unit

(b) injecting a command-line option into the build is a fiddly manual
step, varying between build systems.  It's far easier for the
user if Emacs simply sets an environment variable when compiling,
GCC uses this to enable the option if it recognizes the value, and
the emacs compilation buffer decodes the additional lines of output
and adds appropriate widgets.  In some ways it is a workaround for
not having a language server.  Doing it this way means that for the
various combinations of older and newer GCC and older and newer Emacs
that a sufficiently modern combination of both can automatically
support the rich fix-it UI, whereas other combinations will either
not provide the envvar, or silently ignore it, gracefully doing
nothing extra.

Hence this patch adds a new GCC_EXTRA_DIAGNOSTIC_OUTPUT environment
variable to GCC which enables output of machine-parseable fix-it hints.

GCC_EXTRA_DIAGNOSTIC_OUTPUT=fixits-v1 is equivalent to the existing
-fdiagnostics-parseable-fixits option.

GCC_EXTRA_DIAGNOSTIC_OUTPUT=fixits-v2 is the same, but changes the
column output mode to "display columns" rather than bytes, as
required by Emacs.

The discussion in that Emacs bug has some concerns about the encoding
of these lines, and, indeed, the encoding of GCC's stderr in general:
currently we emit a mixture of bytes and UTF-8; I believe we emit
filenames as bytes, diagnostic messages as UTF-8, and quote source code
in the original encoding (PR other/93067 covers converting it to UTF-8 on
output).  This patch prints octal-escaped bytes for bytes within
filenames and replacement text that aren't printable (as per
-fdiagnostics-parseable-fixits).

gcc/ChangeLog:
	* diagnostic.c (diagnostic_initialize): Eliminate
	parseable_fixits_p in favor of initializing extra_output_kind from
	GCC_EXTRA_DIAGNOSTIC_OUTPUT.
	(convert_column_unit): New function, split out from...
	(diagnostic_converted_column): ...this.
	(print_parseable_fixits): Add "column_unit" and "tabstop" params.
	Use them to call convert_column_unit on the column values.
	(diagnostic_report_diagnostic): Eliminate conditional on
	parseable_fixits_p in favor of a switch statement on
	extra_output_kind, passing the appropriate values to the new
	params of print_parseable_fixits.
	(selftest::test_print_parseable_fixits_none): Update for new
	params of print_parseable_fixits.
	(selftest::test_print_parseable_fixits_insert): Likewise.
	(selftest::test_print_parseable_fixits_remove): Likewise.
	(selftest::test_print_parseable_fixits_replace): Likewise.
	(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
	New.
	(selftest::diagnostic_c_tests): Call it.
	* diagnostic.h (enum diagnostics_extra_output_kind): New.
	(diagnostic_context::parseable_fixits_p): Delete field in favor
	of...
	(diagnostic_context::extra_output_kind): ...this new field.
	* doc/invoke.texi (Environment Variables): Add
	GCC_EXTRA_DIAGNOSTIC_OUTPUT.
	* opts.c (common_handle_option): Update handling of
	OPT_fdiagnostics_parseable_fixits for change to diagnostic_context
	fields.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c:
	New file.
	* gcc.dg/plugin/diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c:
	New file.
	* gcc.dg/plugin/plugin.exp (plugin_test_list): Add them.
2021-01-14 16:28:38 -05:00
Tamar Christina
59832db9a7 slp: Add Tests for complex mul, mls and mla"
This adds the initial tests for the complex mul, mls and mla.
These will be enabled in the commits that add the optabs.

Committed as obvious variations of existing tests.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/complex/complex-mla-template.c: New test.
	* gcc.dg/vect/complex/complex-mls-template.c: New test.
	* gcc.dg/vect/complex/complex-mul-template.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-double.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-float.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mla-half-float.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-double.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-float.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mls-half-float.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-double.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-float.c: New test.
	* gcc.dg/vect/complex/fast-math-bb-slp-complex-mul-half-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mla-double.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mla-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mla-half-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mls-double.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mls-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mls-half-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mul-double.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mul-float.c: New test.
	* gcc.dg/vect/complex/fast-math-complex-mul-half-float.c: New test.
2021-01-14 21:01:15 +00:00
Tamar Christina
b50df1e749 slp: Add complex operations class to share first match among all matchers
This introduces a common class complex_operations_pattern which encapsulates
the complex add, mul, fma and fms pattern in such a way so that the first match
is shared.

gcc/ChangeLog:

	* tree-vect-slp-patterns.c (class complex_operations_pattern,
	complex_operations_pattern::matches,
	complex_operations_pattern::recognize,
	complex_operations_pattern::build): New.
	(slp_patterns): Use it.
2021-01-14 21:00:10 +00:00
Tamar Christina
478e571a3e slp: support complex FMS and complex FMS conjugate
This adds support for FMS and FMS conjugated to the slp pattern matcher.

Example of matches:

#include <stdio.h>
#include <complex.h>

#define N 200
#define ROT
#define TYPE float
#define TYPE2 float

void g (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] -=  a[i] * (b[i] ROT);
    }
}

void g_f1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] -=  conjf (a[i]) * (b[i]);
    }
}

void g_s1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] -=  a[i] * conjf (b[i] ROT);
    }
}

void caxpy_sub(double complex * restrict y, double complex * restrict x, size_t N, double complex f) {
  for (size_t i = 0; i < N; ++i)
    y[i] -= x[i]* f;
}

gcc/ChangeLog:

	* internal-fn.def (COMPLEX_FMS, COMPLEX_FMS_CONJ): New.
	* optabs.def (cmls_optab, cmls_conj_optab): New.
	* doc/md.texi: Document them.
	* tree-vect-slp-patterns.c (class complex_fms_pattern,
	complex_fms_pattern::matches, complex_fms_pattern::recognize,
	complex_fms_pattern::build): New.
2021-01-14 20:59:12 +00:00
Tamar Christina
31fac31800 slp: support complex FMA and complex FMA conjugate
This adds support for FMA and FMA conjugated to the slp pattern matcher.

Example of instructions matched:

#include <stdio.h>
#include <complex.h>

#define N 200
#define ROT
#define TYPE float
#define TYPE2 float

void g (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] +=  a[i] * (b[i] ROT);
    }
}

void g_f1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] +=  conjf (a[i]) * (b[i] ROT);
    }
}

void g_s1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] +=  a[i] * conjf (b[i] ROT);
    }
}

void caxpy_add(double complex * restrict y, double complex * restrict x, size_t N, double complex f) {
  for (size_t i = 0; i < N; ++i)
    y[i] += x[i]* f;
}

gcc/ChangeLog:

	* internal-fn.def (COMPLEX_FMA, COMPLEX_FMA_CONJ): New.
	* optabs.def (cmla_optab, cmla_conj_optab): New.
	* doc/md.texi: Document them.
	* tree-vect-slp-patterns.c (vect_match_call_p,
	class complex_fma_pattern, vect_slp_reset_pattern,
	complex_fma_pattern::matches, complex_fma_pattern::recognize,
	complex_fma_pattern::build): New.
2021-01-14 20:58:12 +00:00
Tamar Christina
e09173d84d slp: support complex multiply and complex multiply conjugate
This adds support for complex multiply and complex multiply and accumulate to
the vect pattern detector.

Example of instructions matched:

#include <stdio.h>
#include <complex.h>

#define N 200
#define ROT
#define TYPE float
#define TYPE2 float

void g (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] =  a[i] * (b[i] ROT);
    }
}

void g_f1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] =  conjf (a[i]) * (b[i] ROT);
    }
}

void g_s1 (TYPE2 complex a[restrict N], TYPE complex b[restrict N], TYPE complex c[restrict N])
{
  for (int i=0; i < N; i++)
    {
      c[i] =  a[i] * conjf (b[i] ROT);
    }
}

gcc/ChangeLog:

	* internal-fn.def (COMPLEX_MUL, COMPLEX_MUL_CONJ): New.
	* optabs.def (cmul_optab, cmul_conj_optab): New.
	* doc/md.texi: Document them.
	* tree-vect-slp-patterns.c (vect_match_call_complex_mla,
	vect_normalize_conj_loc, is_eq_or_top, vect_validate_multiplication,
	vect_build_combine_node, class complex_mul_pattern,
	complex_mul_pattern::matches, complex_mul_pattern::recognize,
	complex_mul_pattern::build): New.
2021-01-14 20:57:17 +00:00
Tamar Christina
500600c784 slp: Support optimizing load distribution
This introduces a post processing step for the pattern matcher to flatten
permutes introduced by the complex multiplications patterns.

This performs a blend early such that SLP is not cancelled by the LOAD_LANES
permute.  This is a temporary workaround to the fact that loads are not CSEd
during building and is required to produce efficient code.

gcc/ChangeLog:

	* tree-vect-slp.c (optimize_load_redistribution_1): New.
	(optimize_load_redistribution, vect_is_slp_load_node): New.
	(vect_match_slp_patterns): Use it.
2021-01-14 20:54:31 +00:00
Tamar Christina
fe70119531 slp: elide intermediate nodes for complex add and avoid truncate
This applies the same feedback received for MUL and the rest to
ADD which was already committed.  In short it elides the intermediate
nodes vec and avoids the use of truncate on the SLP child.

gcc/ChangeLog:

	* tree-vect-slp-patterns.c (complex_add_pattern::build):
	Elide nodes.
2021-01-14 20:49:55 +00:00
David Malcolm
dea4a32b24 analyzer: fixes to -fdump-analyzer-json
I've been implementing a PyGTK viewer for the output of
-fdump-analyzer-json, to help me debug analyzer issues:
  https://github.com/davidmalcolm/gcc-analyzer-viewer
The viewer is very much just a work in progress.

This patch adds some fields that were missing from the dump, and
fixes some mistakes I spotted whilst working on the viewer.

gcc/analyzer/ChangeLog:
	* engine.cc (strongly_connected_components::to_json): New.
	(worklist::to_json): New.
	(exploded_graph::to_json): JSON-ify the worklist.
	* exploded-graph.h (strongly_connected_components::to_json): New
	decl.
	(worklist::to_json): New decl.
	* store.cc (store::to_json): Fix comment.
	* supergraph.cc (supernode::to_json): Fix reference to
	"returning_call" in comment.  Add optional "fun" to JSON.
	(edge_kind_to_string): New.
	(superedge::to_json): Add "kind" to JSON.
2021-01-14 15:39:14 -05:00
David Malcolm
8a18261afd analyzer: const fixes [PR98679]
gcc/analyzer/ChangeLog:
	PR analyzer/98679
	* analyzer.h (region_offset::operator==): Make const.
	* pending-diagnostic.h (pending_diagnostic::equal_p): Likewise.
	* store.h (binding_cluster::for_each_value): Likewise.
	(binding_cluster::for_each_binding): Likewise.
2021-01-14 15:25:27 -05:00
Marek Polacek
f6ffd449e0 c++: Tweak g++.dg/template/pr98372.C.
This test was failing in C++11 because variable templates are only
available in C++14.

gcc/testsuite/ChangeLog:

	* g++.dg/template/pr98372.C: Only run in C++14 and up.
2021-01-14 14:46:18 -05:00
Harald Anlauf
bdd1b1f555 PR fortran/93340 - fix missed substring simplifications
Substrings were not reduced early enough for use in initializations,
such as DATA statements.  Add an early simplification for substrings
with constant starting and ending points.

gcc/fortran/ChangeLog:

	* gfortran.h (gfc_resolve_substring): Add prototype.
	* primary.c (match_string_constant): Simplify substrings with
	constant starting and ending points.
	* resolve.c: Rename resolve_substring to gfc_resolve_substring.
	(gfc_resolve_ref): Use renamed function gfc_resolve_substring.

gcc/testsuite/ChangeLog:

	* substr_10.f90: New test.
	* substr_9.f90: New test.
2021-01-14 20:25:33 +01:00
Alexandre Oliva
3651c1b5c9 calibrate intervals to avoid zero in futures poll test
We get occasional failures of 30_threads/future/members/poll.cc
on some platforms whose high resolution clock doesn't have such a high
resolution; wait_for_0 ends up as 0, and then some asserts fail as
intervals measured as longer than zero are tested for less than
several times zero.

This patch adds some calibration in the iteration count to set a
measurable base time interval with some additional margin.


for  libstdc++-v3/ChangeLog

	* testsuite/30_threads/future/members/poll.cc: Calibrate
	iteration count.
2021-01-14 16:12:22 -03:00
Alexandre Oliva
6541fcadc8 use sigjmp_buf for analyzer sigsetjmp tests
The sigsetjmp analyzer tests use jmp_buf in sigsetjmp and siglongjmp
calls.  Not every system that supports sigsetjmp uses the same data
structure for setjmp and sigsetjmp, which results in type mismatches.

This patch changes the tests to use sigjmp_buf, that is the
POSIX-specific type for use with sigsetjmp and siglongjmp.


for  gcc/testsuite/ChnageLog

	* gcc.dg/analyzer/sigsetjmp-5.c: Use sigjmp_buf.
	* gcc.dg/analyzer/sigsetjmp-6.c: Likewise.
2021-01-14 16:12:20 -03:00
Alexandre Oliva
088e46b8d4 declare getpass in analyzer/sensitive-1.c test
The getpass function is not available on all systems; and not
necessarily declared in unistd.h, as expected by the sensitive-1
analyzer test.

Since this is a compile-only test, it doesn't really matter if the
function is defined in the system libraries.  All we need is a
declaration, to avoid warnings from calling an undeclared function.
This patch adds the declaration, in a way that is most unlikely to
conflict with any existing declaration.


for  gcc/testsuite/ChangeLog

	* gcc.dg/analyzer/sensitive-1.c: Declare getpass.
2021-01-14 16:12:19 -03:00
Thomas Schwinge
505caa7295 [gcn offloading] Only supported in 64-bit configurations
Similar to nvptx offloading, see PR65099 "nvptx offloading: hard-coded 64-bit
assumptions".

	gcc/
	* config/gcn/mkoffload.c (main): Create an offload image only in
	64-bit configurations.
2021-01-14 20:06:50 +01:00
François Dumont
05a30af3f2 libstdc++: Implement N3644 for _GLIBCXX_DEBUG iterators
libstdc++-v3/ChangeLog:

	PR libstdc++/98466
	* include/bits/hashtable_policy.h (_Node_iterator_base()): Set _M_cur to nullptr.
	(_Node_iterator()): Make default.
	(_Node_const_iterator()): Make default.
	* include/debug/macros.h (__glibcxx_check_erae_range_after): Add _M_singular
	iterator checks.
	* include/debug/safe_iterator.h
	(_GLIBCXX_DEBUG_VERIFY_OPERANDS): Accept if both iterator are value initialized.
	* include/debug/safe_local_iterator.h (_GLIBCXX_DEBUG_VERIFY_OPERANDS):
	Likewise.
	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): Add
	_M_singular checks on input iterators.
	* src/c++11/debug.cc (_Safe_iterator_base::_M_can_compare): Remove _M_singular
	checks.
	* testsuite/23_containers/deque/debug/98466.cc: New test.
	* testsuite/23_containers/unordered_map/debug/98466.cc: New test.
2021-01-14 19:23:54 +01:00
Harald Anlauf
9e1e6e6310 PR fortran/98661 - valgrind issues with error recovery
During error recovery after an invalid derived type specification it was
possible to try to resolve an invalid array specification.  We now skip
this if the component has the ALLOCATABLE or POINTER attribute and the
shape is not deferred.

gcc/fortran/ChangeLog:

	PR fortran/98661
	* resolve.c (resolve_component): Derived type components with
	ALLOCATABLE or POINTER attribute shall have a deferred shape.

gcc/testsuite/ChangeLog:

	PR fortran/98661
	* gfortran.dg/pr98661.f90: New test.
2021-01-14 19:21:05 +01:00
Harald Anlauf
c1a2cf8805 Revert "PR fortran/98661 - valgrind issues with error recovery"
This reverts commit d0d2becf2d.
2021-01-14 19:17:05 +01:00
Harald Anlauf
d0d2becf2d PR fortran/98661 - valgrind issues with error recovery
During error recovery after an invalid derived type specification it was
possible to try to resolve an invalid array specification.  We now skip
this if the component has the ALLOCATABLE or POINTER attribute and the
shape is not deferred.

gcc/fortran/ChangeLog:

	PR fortran/98661
	* resolve.c (resolve_component): Derived type components with
	ALLOCATABLE or POINTER attribute shall have a deferred shape.

gcc/testsuite/ChangeLog:

	PR fortran/98661
	* gfortran.dg/pr98661.f90: New test.
2021-01-14 19:13:16 +01:00
Ian Lance Taylor
9ac3e2feb3 libgo: update hurd support
Patch from Svante Signell.

Fixes PR go/98496

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/283692
2021-01-14 09:57:04 -08:00
Thomas Schwinge
6106dfb9f7 [nvptx libgomp plugin] Build only in supported configurations
As recently again discussed in <https://gcc.gnu.org/PR97436> "[nvptx] -m32
support", nvptx offloading other than for 64-bit host has never been
implemented, tested, supported.  So we simply should buildn't the nvptx libgomp
plugin in this case.

This avoids build problems if, for example, in a (standard) bi-arch
x86_64-pc-linux-gnu '-m64'/'-m32' build, libcuda is available only in a 64-bit
variant but not in a 32-bit one, which, for example, is the case if you build
GCC against the CUDA toolkit's 'stubs/libcuda.so' (see
<https://stackoverflow.com/a/52784819>).

This amends PR65099 commit a92defdab7 (r225560)
"[nvptx offloading] Only 64-bit configurations are currently supported" to
match the way we're doing this for the HSA/GCN plugins.

	libgomp/
	PR libgomp/65099
	* plugin/configfrag.ac (PLUGIN_NVPTX): Restrict to supported
	configurations.
	* configure: Regenerate.
	* plugin/plugin-nvptx.c (nvptx_get_num_devices): Remove 64-bit
	check.
2021-01-14 18:48:00 +01:00
Jonathan Wakely
57a4f5e4ea libstdc++: Define function to throw filesystem_error [PR 98471]
Fix ordering problem on Windows targets where filesystem_error was used
before being defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/98471
	* include/bits/fs_path.h (__throw_conversion_error): New
	function to throw or abort on character conversion errors.
	(__wstr_from_utf8): Move definition after filesystem_error has
	been defined. Use __throw_conversion_error.
	(path::_S_convert<_EcharT>): Use __throw_conversion_error.
	(path::_S_str_convert<_CharT, _Traits, _Allocator>): Likewise.
	(path::u8string): Likewise.
2021-01-14 16:26:30 +00:00
Sebastian Huber
aa3d33dccb RTEMS: Fix Ada build for riscv
gcc/ada/

	PR ada/98595
	* Makefile.rtl (LIBGNAT_TARGET_PAIRS) <riscv*-*-rtems*>: Use
	wraplf version of Aux_Long_Long_Float.
2021-01-14 17:10:44 +01:00
Martin Liska
7624c58c6b gcov: add one more pytest
gcc/testsuite/ChangeLog:

	* g++.dg/gcov/gcov-17.C: New test.
	* g++.dg/gcov/test-gcov-17.py: New test.
2021-01-14 17:08:32 +01:00
Martin Liska
236d6a33ca mklog: skip unsupported files
This fixes an infinite loop one could see for:
git show b87ec922c4 | ./contrib/mklog.py

contrib/ChangeLog:

	* mklog.py: Fix infinite loop for unsupported files.
2021-01-14 17:06:08 +01:00
H.J. Lu
77d372abec x86: Error on -fcf-protection with incompatible target
-fcf-protection with CF_BRANCH inserts ENDBR32 at function entries.
ENDBR32 is NOP only on 64-bit processors and 32-bit TARGET_CMOV
processors.  Issue an error for -fcf-protection with CF_BRANCH when
compiling for 32-bit non-TARGET_CMOV targets.

gcc/

	PR target/98667
	* config/i386/i386-options.c (ix86_option_override_internal):
	Issue an error for -fcf-protection with CF_BRANCH when compiling
	for 32-bit non-TARGET_CMOV targets.

gcc/testsuite/

	PR target/98667
	* gcc.target/i386/pr98667-1.c: New file.
	* gcc.target/i386/pr98667-2.c: Likewise.
	* gcc.target/i386/pr98667-3.c: Likewise.
2021-01-14 07:42:47 -08:00
Uros Bizjak
5ebdd53534 i386: Resolve variable shadowing in i386-options.c [PR98671]
Also change global variable pta_size to unsigned.

2021-01-14  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/98671
	* config/i386/i386-options.c (ix86_valid_target_attribute_inner_p):
	Remove declaration and initialization of shadow variable "ret".
	(ix86_option_override_internal): Remove delcaration of
	shadow variable "i".  Redeclare shadowed variable to unsigned.
	* common/config/i386/i386-common.c (pta_size): Redeclare to unsigned.
	* config/i386/i386-builtins.c (get_builtin_code_for_version):
	Update for redeclaration.
	* config/i386/i386.h (pta_size): Ditto.
2021-01-14 16:29:21 +01:00
Richard Biener
2182274f51 tree-optimization/98674 - improve dependence analysis
This improves dependence analysis on refs that access the same
array but with different typed but same sized accesses.  That's
obviously safe for the case of types that cannot have any
access function based off them.  For the testcase this is
signed short vs. unsigned short.

2021-01-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98674
	* tree-data-ref.c (base_supports_access_fn_components_p): New.
	(initialize_data_dependence_relation): For two bases without
	possible access fns resort to type size equality when determining
	shape compatibility.

	* gcc.dg/vect/pr98674.c: New testcase.
2021-01-14 16:14:01 +01:00
H.J. Lu
a512079ef4 i386: Update PR target/95021 tests
Also pass -mpreferred-stack-boundary=4 -mno-stackrealign to avoid
disabling STV by:

  /* Disable STV if -mpreferred-stack-boundary={2,3} or
     -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
     stack realignment will be extra cost the pass doesn't take into
     account and the pass can't realign the stack.  */
  if (ix86_preferred_stack_boundary < 128
      || ix86_incoming_stack_boundary < 128
      || opts->x_ix86_force_align_arg_pointer)
    opts->x_target_flags &= ~MASK_STV;

	PR target/98676
	* gcc.target/i386/pr95021-1.c: Add -mpreferred-stack-boundary=4
	-mno-stackrealign.
	* gcc.target/i386/pr95021-3.c: Likewise.
2021-01-14 07:05:33 -08:00
Prathamesh Kulkarni
a802a2ef5f arm: Replace calls to __builtin_vcge* by <=,>= in arm_neon.h [PR66791]
gcc/
2021-01-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>

	PR target/66791
	* config/arm/arm_neon.h: Replace calls to __builtin_vcge* by
	<=, >= operators in vcle and vcge intrinsics respectively.
	* config/arm/arm_neon_builtins.def: Remove entry for
	vcge and vcgeu.
2021-01-14 19:59:03 +05:30
Jonathan Wakely
194a9d67be libstdc++: Update copyright dates on new files
The patch adding these files was approved in 2020 but it wasn't
committed until 2021, so the copyright years were not updated along with
the years in all the existing files.

libstdc++-v3/ChangeLog:

	* include/std/barrier: Update copyright years. Fix whitespace.
	* include/std/version: Fix whitespace.
	* testsuite/30_threads/barrier/1.cc: Update copyright years.
	* testsuite/30_threads/barrier/2.cc: Likewise.
	* testsuite/30_threads/barrier/arrive.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise.
	* testsuite/30_threads/barrier/completion.cc: Likewise.
2021-01-14 14:25:10 +00:00
Nathan Sidwell
d61d2a5f3c c++: Fix erroneous parm comparison logic [PR 98372]
I flubbed an application of De Morgan's law.  Let's just express the
logic directly and let the compiler figure it out.  This bug made it
look like pr52830 was fixed, but it is not.

	PR c++/98372
	gcc/cp/
	* tree.c (cp_tree_equal): Correct map_context logic.
	gcc/testsuite/
	* g++.dg/cpp0x/constexpr-52830.C: Restore dg-ice
	* g++.dg/template/pr98372.C: New.
2021-01-14 05:31:07 -08:00
Uros Bizjak
08a4adcf2b i386: Remove reduntand assignment in i386-options.c [PR98671]
Also rename x86_prefetch_sse to ix86_prefetch_sse.

2021-01-14  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/98671
	* config/i386/i386-options.c (ix86_function_specific_save):
	Remove redundant assignment to opts->x_ix86_branch_cost.
	* config/i386/i386.c (ix86_prefetch_sse):
	Rename from x86_prefetch_sse.  Update all uses.
	* config/i386/i386.h: Update for rename.
	* config/i386/i386-options.h: Ditto.
2021-01-14 13:23:13 +01:00
Jakub Jelinek
0efdc7b31c i386: Fix the pmovzx SSE4.1 define_insn_and_split patterns [PR98670]
I've made two mistakes in the *sse4_1_zero_extend* define_insn_and_split
patterns.  One is that when it uses vector_operand, it should use Bm rather
than m constraint, and the other one is that because it is a post-reload
splitter it needs isa attribute to select which alternatives are valid for
which ISAs.  Sorry for messing this up.

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

	PR target/98670
	* config/i386/sse.md (*sse4_1_zero_extendv8qiv8hi2_3,
	*sse4_1_zero_extendv4hiv4si2_3, *sse4_1_zero_extendv2siv2di2_3):
	Use Bm instead of m for non-avx.  Add isa attribute.

	* gcc.target/i386/pr98670.c: New test.
2021-01-14 12:56:18 +01:00
Jakub Jelinek
8f8762a2e8 match.pd: Optimize ~(X >> Y) to ~X >> Y if ~X can be simplified [PR96688]
This patch optimizes two GIMPLE operations into just one.
As mentioned in the PR, there is some risk this might create more expensive
constants, but sometimes it will make them on the other side less expensive,
it really depends on the exact value.
And if it is an important issue, we should do it in md or during expansion.

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

	PR tree-optimization/96688
	* match.pd (~(X >> Y) -> ~X >> Y): New simplification if
	~X can be simplified.

	* gcc.dg/tree-ssa/pr96688.c: New test.
	* gcc.dg/tree-ssa/reassoc-37.c: Adjust scan-tree-dump regex.
	* gcc.target/i386/pr66821.c: Likewise.
2021-01-14 12:50:33 +01:00
Richard Sandiford
e45c41988b vect: Account for unused IFN_LOAD_LANES results
At the moment, if we use only one vector of an LD4 result,
we'll treat the LD4 as having the cost of a single load.
But all 4 loads and any associated permutes take place
regardless of which results are actually used.

This patch therefore counts the cost of unused LOAD_LANES
results against the first statement in a group.  An alternative
would be to multiply the ncopies of the first stmt by the group
size and treat other stmts in the group as having zero cost,
but I thought that might be more surprising when reading dumps.

gcc/
	* tree-vect-stmts.c (vect_model_load_cost): Account for unused
	IFN_LOAD_LANES results.

gcc/testsuite/
	* gcc.target/aarch64/sve/cost_model_11.c: New test.
	* gcc.target/aarch64/sve/mask_struct_load_5.c: Use
	-fno-vect-cost-model.
2021-01-14 11:36:25 +00:00
Kyrylo Tkachov
48f8d1d48f aarch64: Reimplememnt vmovn/vmovl intrinsics with builtins instead
Turns out __builtin_convertvector is not as good a fit for the widening
and narrowing intrinsics as I had hoped.
During the veclower phase we lower most of it to bitfield operations and
hope DCE cleans it back up into
vector pack/unpack and extend operations. I received reports that in
more complex cases GCC fails to do that
and we're left with many vector extract operations that clutter the
output.

I think veclower can be improved on that front, but for GCC 10 I'd like
to just implement these builtins
with a good old RTL builtin rather than inline asm.

gcc/
	* config/aarch64/aarch64-simd.md (aarch64_<su>xtl<mode>):
	Define.
	(aarch64_xtn<mode>): Likewise.
	* config/aarch64/aarch64-simd-builtins.def (sxtl, uxtl, xtn):
	Define
	builtins.
	* config/aarch64/arm_neon.h (vmovl_s8): Reimplement using
	builtin.
	(vmovl_s16): Likewise.
	(vmovl_s32): Likewise.
	(vmovl_u8): Likewise.
	(vmovl_u16): Likewise.
	(vmovl_u32): Likewise.
	(vmovn_s16): Likewise.
	(vmovn_s32): Likewise.
	(vmovn_s64): Likewise.
	(vmovn_u16): Likewise.
	(vmovn_u32): Likewise.
	(vmovn_u64): Likewise.
2021-01-14 08:36:19 +00:00
Kyrylo Tkachov
52cd1cd1b6 aarch64: reimplement vqmovn_high* intrinsics using builtins
This patch reimplements the saturating-truncate-and-insert-into-high
intrinsics using the appropriate RTL codes and builtins.

gcc/
	* config/aarch64/aarch64-simd.md (aarch64_<su>qxtn2<mode>_le):
	Define.
	(aarch64_<su>qxtn2<mode>_be): Likewise.
	(aarch64_<su>qxtn2<mode>): Likewise.
	* config/aarch64/aarch64-simd-builtins.def (sqxtn2, uqxtn2):
	Define builtins.
	* config/aarch64/iterators.md (SAT_TRUNC): Define code_iterator.
	(su): Handle ss_truncate and us_truncate.
	* config/aarch64/arm_neon.h (vqmovn_high_s16): Reimplement using
	builtin.
	(vqmovn_high_s32): Likewise.
	(vqmovn_high_s64): Likewise.
	(vqmovn_high_u16): Likewise.
	(vqmovn_high_u32): Likewise.
	(vqmovn_high_u64): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/narrow_high-intrinsics.c: Update uqxtn2 and
	sqxtn2 scan-assembler-times.
2021-01-14 08:36:19 +00:00
Kyrylo Tkachov
c7f1ff01a2 aarch64: Reimplement vmovn_high_* intrinsics using builtins
The vmovn_high* intrinsics are supposed to map to XTN2 instructions that
narrow their source vector and instert it into the top half of the destination vector.
This patch reimplements them away from inline assembly to an RTL builtin
that performs a vec_concat with a truncate.

gcc/
	* config/aarch64/aarch64-simd.md (aarch64_xtn2<mode>_le):
	Define.
	(aarch64_xtn2<mode>_be): Likewise.
	(aarch64_xtn2<mode>): Likewise.
	* config/aarch64/aarch64-simd-builtins.def (xtn2): Define
	builtins.
	* config/aarch64/arm_neon.h (vmovn_high_s16): Reimplement using
	builtins.
	(vmovn_high_s32): Likewise.
	(vmovn_high_s64): Likewise.
	(vmovn_high_u16): Likewise.
	(vmovn_high_u32): Likewise.
	(vmovn_high_u64): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/narrow_high-intrinsics.c: Adjust
	scan-assembler-times for xtn2.
2021-01-14 08:36:19 +00:00
GCC Administrator
be0851b8e9 Daily bump. 2021-01-14 00:16:24 +00:00
Stafford Horne
e40fdcc4f4 or1k: Fixup exception header data encodings
While running glibc tests several *-textrel tests failed showing that
relocations remained against read only sections.  It turned out this was
related to exception headers data encoding being wrong.

By default pointer encoding will always use the DW_EH_PE_absptr format.

This patch uses format DW_EH_PE_pcrel and DW_EH_PE_sdata4.  Optionally
DW_EH_PE_indirect is included for global symbols.  This eliminates the
relocations.

gcc/ChangeLog:

	* config/or1k/or1k.h (ASM_PREFERRED_EH_DATA_FORMAT): New macro.
2021-01-14 08:45:01 +09:00
Stafford Horne
6ed637c585 or1k: Add note to indicate execstack
Define TARGET_ASM_FILE_END as file_end_indicate_exec_stack to allow
generation of the ".note.GNU-stack" section note.  This allows binutils
to properly set PT_GNU_STACK in the program header.

This fixes a glibc execstack testsuite test failure found while working
on the OpenRISC glibc port.

gcc/ChangeLog:

	* config/or1k/linux.h (TARGET_ASM_FILE_END): Define macro.
2021-01-14 08:45:01 +09:00
Stafford Horne
b77f6d2fa8 or1k: Support for softfloat to emulate hw exceptions
This allows the openrisc softfloat implementation to set exceptions.
This also sets the correct tininess after rounding value to be
consistent with hardware and simulator implementations.

libgcc/ChangeLog:

	* config/or1k/sfp-machine.h (FP_RND_NEAREST, FP_RND_ZERO,
	FP_RND_PINF, FP_RND_MINF, FP_RND_MASK, FP_EX_OVERFLOW,
	FP_EX_UNDERFLOW, FP_EX_INEXACT, FP_EX_INVALID, FP_EX_DIVZERO,
	FP_EX_ALL): New constant macros.
	(_FP_DECL_EX, FP_ROUNDMODE, FP_INIT_ROUNDMODE,
	FP_HANDLE_EXCEPTIONS): New macros.
	(_FP_TININESS_AFTER_ROUNDING): Change to 1.
2021-01-14 08:45:01 +09:00
Stafford Horne
e1171c3250 or1k: Add builtin define to detect hard float
This is used in libgcc and now glibc to detect when hardware floating
point operations are supported by the target.

gcc/ChangeLog:

	* config/or1k/or1k.h (TARGET_CPU_CPP_BUILTINS): Add builtin
	  define for __or1k_hard_float__.
2021-01-14 08:45:00 +09:00
Stafford Horne
8cba7cb320 or1k: Implement profile hook calling _mcount
Defining this to not abort as found when working on running tests in
the glibc test suite.

We implement this with a call to _mcount with no arguments.  The required
return address's will be pulled from the stack.  Passing the LR (r9) as
an argument had problems as sometimes r9 is clobbered by the GOT logic
in the prologue before the call to _mcount.

gcc/ChangeLog:

	* config/or1k/or1k.h (NO_PROFILE_COUNTERS): Define as 1.
	(PROFILE_HOOK): Define to call _mcount.
	(FUNCTION_PROFILER): Change from abort to no-op.
2021-01-14 08:45:00 +09:00
Marek Polacek
796ead19f8 c++: Failure to lookup using-decl name [PR98231]
In r11-4690 we removed the call to finish_nonmember_using_decl in
tsubst_expr/DECL_EXPR in the USING_DECL block.  This was done not
to perform name lookup twice for a non-dependent using-decl, which
sounds sensible.

However, finish_nonmember_using_decl also pushes the decl's bindings
which we still have to do so that we can find the USING_DECL's name
later.  In this case, we've got a USING_DECL N::operator<<  that we are
tsubstituting.  We already looked it up while parsing the template
"foo", and lookup_using_decl stashed the OVERLOAD it found into
USING_DECL_DECLS.  Now we just have to update the IDENTIFIER_BINDING of
the identifier for operator<< with the overload the name is bound to.

I didn't want to export push_local_binding so I've introduced a new
wrapper.

gcc/cp/ChangeLog:

	PR c++/98231
	* name-lookup.c (push_using_decl_bindings): New.
	* name-lookup.h (push_using_decl_bindings): Declare.
	* pt.c (tsubst_expr): Call push_using_decl_bindings.

gcc/testsuite/ChangeLog:

	PR c++/98231
	* g++.dg/lookup/using63.C: New test.
2021-01-13 17:16:30 -05:00
Jakub Jelinek
8fc183ccd0 match.pd: Fold (~X | C) ^ D into (X | C) ^ (~D ^ C) if (~D ^ C) can be simplified [PR96691]
These simplifications are only simplifications if the (~D ^ C) or (D ^ C)
expressions fold into gimple vals, but in that case they decrease number of
operations by 1.

2021-01-13  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96691
	* match.pd ((~X | C) ^ D -> (X | C) ^ (~D ^ C),
	(~X & C) ^ D -> (X & C) ^ (D ^ C)): New simplifications if
	(~D ^ C) or (D ^ C) can be simplified.

	* gcc.dg/tree-ssa/pr96691.c: New test.
2021-01-13 19:54:49 +01:00
Martin Liska
7d7ef413ef gcc-changelog: Support multiline parentheses wrapping
contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Support wrapping of functions
	in parentheses that can take multiple lines.
	* gcc-changelog/test_email.py: Add tests for it.
	* gcc-changelog/test_patches.txt: Add 2 patches.
2021-01-13 17:22:34 +01:00
Richard Biener
285fa338b0 tree-optimization/92645 - avoid harmful early BIT_FIELD_REF canonicalization
This avoids canonicalizing BIT_FIELD_REF <T1> (a, <sz>, 0) to
(T1)a on integer typed a.  This confuses the vectorizer SLP matching.

With this delayed to after vector lowering the testcase in PR92645
from Skia is now finally optimized to reasonable assembly.

2021-01-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/92645
	* match.pd (BIT_FIELD_REF to conversion): Delay canonicalization
	until after vector lowering.

	* gcc.target/i386/pr92645-7.c: New testcase.
	* gcc.dg/tree-ssa/ssa-fre-54.c: Adjust.
	* gcc.dg/pr69047.c: Likewise.
2021-01-13 14:51:08 +01:00
Martin Liska
a2d04f3d2c mklog: support define_insn_and_split format
contrib/ChangeLog:

	* mklog.py: Parse also define_insn_and_split and similar
	directives in .md files.
	* test_mklog.py: Test.
2021-01-13 14:34:08 +01:00
Nathan Sidwell
11cbea852b c++: Fix cp_build_function_call_vec [PR 98626]
I misunderstood the cp_build_function_call_vec API, thinking a NULL
vector was an acceptable way of passing no arguments.  You need to
pass a vector of no elements.

	PR c++/98626
	gcc/cp/
	* module.cc (module_add_import_initializers):  Pass a
	zero-element argument vector.
2021-01-13 05:18:23 -08:00
Richard Sandiford
264a1269b4 aarch64: Add support for unpacked SVE MLS and MSB
This patch extends the MLS/MSB patterns to support unpacked
integer vectors.  The type suffix could be either the element
size or the container size, but using the element size should
be more efficient.

gcc/
	* config/aarch64/aarch64-sve.md (fnma<mode>4): Extend from SVE_FULL_I
	to SVE_I.
	(@aarch64_pred_fnma<mode>, cond_fnma<mode>, *cond_fnma<mode>_2)
	(*cond_fnma<mode>_4, *cond_fnma<mode>_any): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/mls_2.c: New test.
	* g++.target/aarch64/sve/cond_mls_1.C: Likewise.
	* g++.target/aarch64/sve/cond_mls_2.C: Likewise.
	* g++.target/aarch64/sve/cond_mls_3.C: Likewise.
	* g++.target/aarch64/sve/cond_mls_4.C: Likewise.
	* g++.target/aarch64/sve/cond_mls_5.C: Likewise.
2021-01-13 13:00:13 +00:00
Richard Sandiford
cf7a335306 aarch64: Add support for unpacked SVE MLA and MAD
This patch extends the MLA/MAD patterns to support unpacked
integer vectors.  The type suffix could be either the element
size or the container size, but using the element size should
be more efficient.

gcc/
	* config/aarch64/aarch64-sve.md (fma<mode>4): Extend from SVE_FULL_I
	to SVE_I.
	(@aarch64_pred_fma<mode>, cond_fma<mode>, *cond_fma<mode>_2)
	(*cond_fma<mode>_4, *cond_fma<mode>_any): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/mla_2.c: New test.
	* g++.target/aarch64/sve/cond_mla_1.C: Likewise.
	* g++.target/aarch64/sve/cond_mla_2.C: Likewise.
	* g++.target/aarch64/sve/cond_mla_3.C: Likewise.
	* g++.target/aarch64/sve/cond_mla_4.C: Likewise.
	* g++.target/aarch64/sve/cond_mla_5.C: Likewise.
2021-01-13 13:00:12 +00:00
Richard Biener
3ddc18251a tree-optimization/92645 - improve SLP with existing vectors
This improves SLP discovery in the face of existing vectors allowing
punning of the vector shape (or even punning from an integer type).
For punning from integer types this does not yet handle lane zero
extraction being represented as conversion rather than BIT_FIELD_REF.

2021-01-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/92645
	* tree-vect-slp.c (vect_build_slp_tree_1): Relax supported
	BIT_FIELD_REF argument.
	(vect_build_slp_tree_2): Record the desired vector type
	on the external vector def.
	(vectorizable_slp_permutation): Handle required punning
	of existing vector defs.

	* gcc.target/i386/pr92645-6.c: New testcase.
2021-01-13 13:38:41 +01:00
Richard Sandiford
5ab67cdee6 aarch64: Tighten condition on sve/sel* tests
Noticed while testing on a different machine that the sve/sel_*.c
tests require .variant_pcs support but don't test for it.
.variant_pcs post-dates SVE so there shouldn't be a need to test
for both.

gcc/testsuite/
	* gcc.target/aarch64/sve/sel_1.c: Require aarch64_variant_pcs.
	* gcc.target/aarch64/sve/sel_2.c: Likewise.
	* gcc.target/aarch64/sve/sel_3.c: Likewise.
2021-01-13 11:49:45 +00:00
Richard Sandiford
6d75168146 rtl-ssa: Fix reversed comparisons in accesses.h comment
Noticed while looking at something else that the comment above
def_lookup got the description of the comparisons the wrong way
round.

gcc/
	* rtl-ssa/accesses.h (def_lookup): Fix order of comparison results.
2021-01-13 11:43:36 +00:00
Richard Sandiford
40b371a7c2 sh: Remove match_scratch operand test
This patch fixes a regression on sh4 introduced by the rtl-ssa stuff.
The port had a pattern:

(define_insn "movsf_ie"
  [(set (match_operand:SF 0 "general_movdst_operand"
			        "=f,r,f,f,fy, f,m, r, r,m,f,y,y,rf,r,y,<,y,y")
	(match_operand:SF 1 "general_movsrc_operand"
			        " f,r,G,H,FQ,mf,f,FQ,mr,r,y,f,>,fr,y,r,y,>,y"))
   (use (reg:SI FPSCR_MODES_REG))
   (clobber (match_scratch:SI 2 "=X,X,X,X,&z, X,X, X, X,X,X,X,X, y,X,X,X,X,X"))]
  "TARGET_SH2E
   && (arith_reg_operand (operands[0], SFmode)
       || fpul_operand (operands[0], SFmode)
       || arith_reg_operand (operands[1], SFmode)
       || fpul_operand (operands[1], SFmode)
       || arith_reg_operand (operands[2], SImode))"

But recog can generate this pattern from something that matches:

  [(set (match_operand:SF 0 "general_movdst_operand")
	(match_operand:SF 1 "general_movsrc_operand")
   (use (reg:SI FPSCR_MODES_REG))]

with recog adding the (clobber (match_scratch:SI)) automatically.
recog tests the C condition before adding the clobber, so there might
not be an operands[2] to test.

Similarly, gen_movsf_ie takes only two arguments, with operand 2
being filled in automatically.  The only way to create this pattern
with a REG operands[2] before RA would be to generate it directly
from RTL.  AFAICT the only things that do this are the secondary
reload patterns, which are generated during RA and come with
pre-vetted operands.

arith_reg_operand rejects 6 specific registers:

      return (regno != T_REG && regno != PR_REG
	      && regno != FPUL_REG && regno != FPSCR_REG
	      && regno != MACH_REG && regno != MACL_REG);

The fpul_operand tests allow FPUL_REG, leaving 5 invalid registers.
However, in all alternatives of movsf_ie, either operand 0 or
operand 1 is a register that belongs r, f or y, none of which
include any of the 5 rejected registers.  This means that any
post-RA pattern would satisfy the operands[0] or operands[1]
condition without the operands[2] test being necessary.

gcc/
	* config/sh/sh.md (movsf_ie): Remove operands[2] test.
2021-01-13 11:37:18 +00:00
Samuel Thibault
e9cb89b936 Hurd: Enable ifunc by default
The binutils bugs seem to have been fixed.

	gcc/
	* config.gcc [$target == *-*-gnu*]: Enable
	'default_gnu_indirect_function'.
2021-01-13 12:09:59 +01:00
Jonathan Wakely
f04e7e540e libstdc++: Fix typo in ChangeLog-2020 2021-01-13 11:02:13 +00:00
Martin Liska
c23aea6edc gcc-changelog: Allow modifications to old ChangeLogs without entry
contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Allow modifications of older
	ChangeLog (or specific) files without need to make a ChangeLog
	entry.
	* gcc-changelog/test_email.py: Test it.
	* gcc-changelog/test_patches.txt: Add new patch.
2021-01-13 11:57:14 +01:00
Samuel Thibault
2b356e689c hurd: libgcc unwinding over signal trampolines with SIGINFO
When the application sets SA_SIGINFO, the signal trampoline parameters
are different to follow POSIX.

	libgcc/
	* config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Add the
	posix siginfo case to struct handler_args. Detect between legacy
	and siginfo from the second parameter, which is a small sigcode in
	the legacy case, and a pointer in the siginfo case.
2021-01-13 11:54:54 +01:00
Jakub Jelinek
b1d1e2b54c i386, expand: Optimize also 256-bit and 512-bit permutatations as vpmovzx if possible [PR95905]
The following patch implements what I've talked about, i.e. to no longer
force operands of vec_perm_const into registers in the generic code, but let
each of the (currently 8) targets force it into registers individually,
giving the targets better control on if it does that and when and allowing
them to do something special with some particular operands.
And then defines the define_insn_and_split for the 256-bit and 512-bit
permutations into vpmovzx* (only the bw, wd and dq cases, in theory we could
add define_insn_and_split patterns also for the bd, bq and wq).

2021-01-13  Jakub Jelinek  <jakub@redhat.com>

	PR target/95905
	* optabs.c (expand_vec_perm_const): Don't force v0 and v1 into
	registers before calling targetm.vectorize.vec_perm_const, only after
	that.
	* config/i386/i386-expand.c (ix86_vectorize_vec_perm_const): Handle
	two argument permutation when one operand is zero vector and only
	after that force operands into registers.
	* config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_1): New
	define_insn_and_split pattern.
	(*avx512bw_zero_extendv32qiv32hi2_1): Likewise.
	(*avx512f_zero_extendv16hiv16si2_1): Likewise.
	(*avx2_zero_extendv8hiv8si2_1): Likewise.
	(*avx512f_zero_extendv8siv8di2_1): Likewise.
	(*avx2_zero_extendv4siv4di2_1): Likewise.
	* config/mips/mips.c (mips_vectorize_vec_perm_const): Force operands
	into registers.
	* config/arm/arm.c (arm_vectorize_vec_perm_const): Likewise.
	* config/sparc/sparc.c (sparc_vectorize_vec_perm_const): Likewise.
	* config/ia64/ia64.c (ia64_vectorize_vec_perm_const): Likewise.
	* config/aarch64/aarch64.c (aarch64_vectorize_vec_perm_const): Likewise.
	* config/rs6000/rs6000.c (rs6000_vectorize_vec_perm_const): Likewise.
	* config/gcn/gcn.c (gcn_vectorize_vec_perm_const): Likewise.  Use std::swap.

	* gcc.target/i386/pr95905-2.c: Use scan-assembler-times instead of
	scan-assembler.  Add tests with zero vector as first __builtin_shuffle
	operand.
	* gcc.target/i386/pr95905-3.c: New test.
	* gcc.target/i386/pr95905-4.c: New test.
2021-01-13 11:36:38 +01:00
Martin Liska
7875e8dc83 if-to-switch: fix also virtual phis
gcc/ChangeLog:

	PR tree-optimization/98455
	* gimple-if-to-switch.cc (condition_info::record_phi_mapping):
	Record also virtual PHIs.
	(pass_if_to_switch::execute): Return TODO_cleanup_cfg only
	conditionally.

gcc/testsuite/ChangeLog:

	PR tree-optimization/98455
	* gcc.dg/tree-ssa/pr98455.c: New test.
2021-01-13 11:33:28 +01:00
Jonathan Wakely
0db5f48848 libstdc++: Remove <debug/array> from Doxygen config
This header was removed recently, so Doxygen shouldn't try to process
it.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (INPUT): Remove include/debug/array.
2021-01-13 10:29:45 +00:00
Jonathan Wakely
4c598b038d doc: Fix typos in C++ Modules documentation
gcc/ChangeLog:

	* doc/invoke.texi (C++ Modules): Fix typos.
2021-01-13 10:29:00 +00:00
Richard Biener
ffd28c265e tree-optimization/98640 - fix bogus sign-extension with VN
VN tried to express a sign extension from int to long of
a trucated quantity with a plain conversion but that loses the
truncation.  Since there's no single operand doing truncate plus
sign extend (there was a proposed SEXT_EXPR to do that at some
point mapping to RTL sign_extract) don't bother to appropriately
model this with two ops (which the VN insert machinery doesn't
handle and which is unlikely to CSE fully).

2021-01-13  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98640
	* tree-ssa-sccvn.c (visit_nary_op): Do not try to
	handle plus or minus from a truncated operand to be
	sign-extended.

	* gcc.dg/torture/pr98640.c: New testcase.
2021-01-13 11:13:33 +01:00
Jakub Jelinek
5d057bfeff i386: Add define_insn_and_split patterns for btrl [PR96938]
In the following testcase we only optimize f2 and f7 to btrl, although we
should optimize that way all of the functions.  The problem is the type
demotion/narrowing (which is performed solely during the generic folding and
not later), without it we see the AND performed in SImode and match it as
btrl, but with it while the shifts are still performed in SImode, the
AND is already done in QImode or HImode low part of the shift.

2021-01-13  Jakub Jelinek  <jakub@redhat.com>

	PR target/96938
	* config/i386/i386.md (*btr<mode>_1, *btr<mode>_2): New
	define_insn_and_split patterns.
	(splitter after *btr<mode>_2): New splitter.

	* gcc.target/i386/pr96938.c: New test.
2021-01-13 10:15:13 +01:00
Martin Liska
6b70fa678b ipa: remove a dead code
gcc/ChangeLog:

	PR ipa/98652
	* cgraphunit.c (analyze_functions): Remove dead code.
2021-01-13 09:27:31 +01:00
Qian Jianhua
3f325179b3 [PATCH v2] aarch64: Add cpu cost tables for A64FX
This patch add cost tables for A64FX.

2021-01-13 Qian jianhua <qianjh@cn.fujitsu.com>

gcc/
	* config/aarch64/aarch64-cost-tables.h (a64fx_extra_costs): New.
	* config/aarch64/aarch64.c (a64fx_addrcost_table): New.
	(a64fx_regmove_cost, a64fx_vector_cost): New.
	(a64fx_tunings): Use the new added cost tables.
2021-01-13 15:22:09 +08:00
Jakub Jelinek
b668a06e37 i386: Optimize _mm_unpacklo_epi8 of 0 vector as second argument or similar VEC_PERM_EXPRs into pmovzx [PR95905]
The following patch adds patterns (so far 128-bit only) for permutations
like { 0 16 1 17 2 18 3 19 4 20 5 21 6 22 7 23 } where the second
operand is CONST0_RTX CONST_VECTOR to be emitted as pmovzx.

2021-01-13  Jakub Jelinek  <jakub@redhat.com>

	PR target/95905
	* config/i386/predicates.md (pmovzx_parallel): New predicate.
	* config/i386/sse.md (*sse4_1_zero_extendv8qiv8hi2_3): New
	define_insn_and_split pattern.
	(*sse4_1_zero_extendv4hiv4si2_3): Likewise.
	(*sse4_1_zero_extendv2siv2di2_3): Likewise.

	* gcc.target/i386/pr95905-1.c: New test.
	* gcc.target/i386/pr95905-2.c: New test.
2021-01-13 08:06:25 +01:00
Julian Brown
7993fe1877 amdgcn: Remove dead code for fixed v0 register
This patch removes code to fix the v0 register in
gcn_conditional_register_usage that was missed out of the previous patch
removing the need for that:

  https://gcc.gnu.org/pipermail/gcc-patches/2019-November/534284.html

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* config/gcn/gcn.c (gcn_conditional_register_usage): Remove dead code
	to fix v0 register.
2021-01-12 16:46:02 -08:00
Julian Brown
3df6fac008 amdgcn: Fix exec register live-on-entry to BB in md-reorg
This patch fixes a corner case in the AMD GCN md-reorg pass when the
EXEC register is live on entry to a BB, and could be clobbered by code
inserted by the pass before a use in (e.g.) a different BB.

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* config/gcn/gcn.c (gcn_md_reorg): Fix case where EXEC reg is live
	on entry to a BB.
2021-01-12 16:46:02 -08:00
Julian Brown
c8812bac8e amdgcn: Improve FP division accuracy
GCN has a reciprocal-approximation instruction but no
hardware divide. This patch adjusts the open-coded reciprocal
approximation/Newton-Raphson refinement steps to use fused multiply-add
instructions as is necessary to obtain a properly-rounded result, and
adds further refinement steps to correctly round the full division result.

The patterns in question are still guarded by a flag_reciprocal_math
condition, and do not yet support denormals.

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* config/gcn/gcn-valu.md (recip<mode>2<exec>, recip<mode>2): Use unspec
	for reciprocal-approximation instructions.
	(div<mode>3): Use fused multiply-accumulate operations for reciprocal
	refinement and division result.
	* config/gcn/gcn.md (UNSPEC_RCP): New unspec constant.

gcc/testsuite/
	* gcc.target/gcn/fpdiv.c: New test.
2021-01-12 16:46:01 -08:00
Julian Brown
abb3993e49 amdgcn: Fix subdf3 pattern
This patch fixes a typo in the subdf3 pattern that meant it had a
non-standard name and thus the compiler would emit a libcall rather than
the proper hardware instruction for DFmode subtraction.

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
	* config/gcn/gcn-valu.md (subdf): Rename to...
	(subdf3): This.
2021-01-12 16:46:01 -08:00
GCC Administrator
6851dda2e7 Daily bump. 2021-01-13 00:16:36 +00:00
Paul E. Murphy
cfaaa6a1ca syscall: ensure openat uses variadic libc wrapper
On powerpc64le, this caused a failure in TestUnshareUidGidMapping
due to stack corruption which resulted in a bogus execve syscall.

Use the existing c wrapper to ensure we respect the ppc abi for
variadic functions.

Fixes PR go/98610

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/282717
2021-01-12 13:21:09 -08:00
Martin Sebor
5a9cfad2de Avoid a couple more ICEs in print_mem_ref (PR c/98597).
Resolves:
PR c/98597 - ICE in -Wuninitialized printing a MEM_REF
PR c/98592 - ICE in gimple_canonical_types_compatible_p while formatting

gcc/c-family/ChangeLog:

	PR c/98597
	PR c/98592
	* c-pretty-print.c (print_mem_ref): Avoid assuming MEM_REF operand
	has pointer type.  Remove redundant code.  Avoid calling
	gimple_canonical_types_compatible_p.

gcc/testsuite/ChangeLog:

	PR c/98597
	PR c/98592
	* g++.dg/warn/Wuninitialized-13.C: New test.
	 gcc.dg/uninit-39.c: New test.

	#
2021-01-12 13:03:00 -07:00
Segher Boessenkool
728fee7a79 MAINTAINERS: Fix spacing
We indent with tabs, not spaces.  This fixes it.

2021-01-12  Segher Boessenkool  <segher@kernel.crashing.org>

	* MAINTAINERS: Fix spacing.
2021-01-12 18:41:43 +00:00
Nathan Sidwell
e2aa8a5f98 libcody: Simplify configure [PR 98414, 98509]
Libcody's configurey was overly 'clever'.  That didn't play well with
GCC's structure.  This removes lots of that overengineering, using
libcpp as an example.

	libcody/
	* Makefile.in: Remove auto parallelize, swallow Makesub.in. Don't
	check compiler name here.
	* Makesub.in: Delete.
	* build-aux/config.guess: Delete.
	* build-aux/config.sub: Delete.
	* build-aux/install-sh: Delete.
	* dox.cfg.in: Delete.
	* gdbinit.in: Delete.
	* internal.hh (BuildNote): Delete.
	* fatal.cc (BuildNote): Delete.
	* config.m4: Remove unneeded fns.
	* configure.ac: Remove unneccessary checks and configures.
	* configure: Rebuilt.
	* config.h.in: Rebuilt.
2021-01-12 10:32:27 -08:00
Martin Liska
248feb2fa2 gcov: fix printf format for 32-bit hosts
gcc/ChangeLog:

	* gcov.c (source_info::debug): Fix printf format for 32-bit hosts.
2021-01-12 18:16:05 +01:00
Andrea Corallo
1aff68d54c Fix typo in function-abi.h
gcc/Changelog

2021-01-12  Andrea Corallo  <andrea.corallo@arm.com>

	* function-abi.h: Fix typo.
2021-01-12 17:58:32 +01:00
Christophe Lyon
25bef68902 arm: Add movmisalign patterns for MVE (PR target/97875)
This patch adds new movmisalign<mode>_mve_load and store patterns for
MVE to help vectorization. They are very similar to their Neon
counterparts, but use different iterators and instructions.

Indeed MVE supports less vectors modes than Neon, so we use the
MVE_VLD_ST iterator where Neon uses VQX.

Since the supported modes are different from the ones valid for
arithmetic operators, we introduce two new sets of macros:

ARM_HAVE_NEON_<MODE>_LDST
  true if Neon has vector load/store instructions for <MODE>

ARM_HAVE_<MODE>_LDST
  true if any vector extension has vector load/store instructions for <MODE>

We move the movmisalign<mode> expander from neon.md to vec-commond.md, and
replace the TARGET_NEON enabler with ARM_HAVE_<MODE>_LDST.

The patch also updates the mve-vneg.c test to scan for the better code
generation when loading and storing the vectors involved: it checks
that no 'orr' instruction is generated to cope with misalignment at
runtime.
This test was chosen among the other mve tests, but any other should
be OK. Using a plain vector copy loop (dest[i] = a[i]) is not a good
test because the compiler chooses to use memcpy.

For instance we now generate:
test_vneg_s32x4:
	vldrw.32       q3, [r1]
	vneg.s32  q3, q3
	vstrw.32       q3, [r0]
	bx      lr

instead of:
test_vneg_s32x4:
	orr     r3, r1, r0
	lsls    r3, r3, #28
	bne     .L15
	vldrw.32	q3, [r1]
	vneg.s32  q3, q3
	vstrw.32	q3, [r0]
	bx      lr
	.L15:
	push    {r4, r5}
	ldrd    r2, r3, [r1, #8]
	ldrd    r5, r4, [r1]
	rsbs    r2, r2, #0
	rsbs    r5, r5, #0
	rsbs    r4, r4, #0
	rsbs    r3, r3, #0
	strd    r5, r4, [r0]
	pop     {r4, r5}
	strd    r2, r3, [r0, #8]
	bx      lr

2021-01-12  Christophe Lyon  <christophe.lyon@linaro.org>

	PR target/97875
	gcc/
	* config/arm/arm.h (ARM_HAVE_NEON_V8QI_LDST): New macro.
	(ARM_HAVE_NEON_V16QI_LDST, ARM_HAVE_NEON_V4HI_LDST): Likewise.
	(ARM_HAVE_NEON_V8HI_LDST, ARM_HAVE_NEON_V2SI_LDST): Likewise.
	(ARM_HAVE_NEON_V4SI_LDST, ARM_HAVE_NEON_V4HF_LDST): Likewise.
	(ARM_HAVE_NEON_V8HF_LDST, ARM_HAVE_NEON_V4BF_LDST): Likewise.
	(ARM_HAVE_NEON_V8BF_LDST, ARM_HAVE_NEON_V2SF_LDST): Likewise.
	(ARM_HAVE_NEON_V4SF_LDST, ARM_HAVE_NEON_DI_LDST): Likewise.
	(ARM_HAVE_NEON_V2DI_LDST): Likewise.
	(ARM_HAVE_V8QI_LDST, ARM_HAVE_V16QI_LDST): Likewise.
	(ARM_HAVE_V4HI_LDST, ARM_HAVE_V8HI_LDST): Likewise.
	(ARM_HAVE_V2SI_LDST, ARM_HAVE_V4SI_LDST, ARM_HAVE_V4HF_LDST): Likewise.
	(ARM_HAVE_V8HF_LDST, ARM_HAVE_V4BF_LDST, ARM_HAVE_V8BF_LDST): Likewise.
	(ARM_HAVE_V2SF_LDST, ARM_HAVE_V4SF_LDST, ARM_HAVE_DI_LDST): Likewise.
	(ARM_HAVE_V2DI_LDST): Likewise.
	* config/arm/mve.md (*movmisalign<mode>_mve_store): New pattern.
	(*movmisalign<mode>_mve_load): New pattern.
	* config/arm/neon.md (movmisalign<mode>): Move to ...
	* config/arm/vec-common.md: ... here.

	PR target/97875
	gcc/testsuite/
	* gcc.target/arm/simd/mve-vneg.c: Update test.
2021-01-12 16:51:05 +00:00
Vladimir N. Makarov
cf2ac1c30a [PR97969] LRA: Transform pattern plus (plus (hard reg, const), pseudo) after elimination
LRA can loop infinitely on targets without `reg + imm` insns.  Register elimination
on such targets can increase register pressure resulting in permanent
stack size increase and changing elimination offset.  To avoid such situation, a simple
transformation can be done to avoid register pressure increase after
generating reload insns containing eliminated hard regs.

gcc/ChangeLog:

	PR target/97969
	* lra-eliminations.c (eliminate_regs_in_insn): Add transformation
	of pattern 'plus (plus (hard reg, const), pseudo)'.

gcc/testsuite/ChangeLog:

	PR target/97969
	* gcc.target/arm/pr97969.c: New.
2021-01-12 11:27:29 -05:00
Patrick Palka
e0bec6ceac c++: Fix ICE with CTAD in concept [PR98611]
This patch teaches cp_walk_subtrees to visit the template represented
by a CTAD placeholder, which would otherwise be not visited during
find_template_parameters.  The template may be a template template
parameter (as in the first testcase), or it may implicitly use the
template parameters of an enclosing class template (as in the second
testcase), and in either case we need to visit this tree to record the
template parameters used therein for later satisfaction.

gcc/cp/ChangeLog:

	PR c++/98611
	* tree.c (cp_walk_subtrees) <case TEMPLATE_TYPE_PARM>: Visit
	the template of a CTAD placeholder.

gcc/testsuite/ChangeLog:

	PR c++/98611
	* g++.dg/cpp2a/concepts-ctad1.C: New test.
	* g++.dg/cpp2a/concepts-ctad2.C: New test.
2021-01-12 09:34:41 -05:00
Richard Biener
52a170b1a1 tree-optimization/98550 - fix BB vect unrolling check
This fixes the check that disqualifies BB vectorization because of
required unrolling to match up with the later exact_div we do.  To
not disable the ability to split groups that do not match up
exactly with a choosen vector type this also introduces a soft-fail
mechanism to vect_build_slp_tree_1 which delays failing to after
the matches[] array is populated from other checks and only then
determines the split point according to the vector type.

2021-01-12  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98550
	* tree-vect-slp.c (vect_record_max_nunits): Check whether
	the group size is a multiple of the vector element count.
	(vect_build_slp_tree_1): When we need to fail because
	the vector type choosen causes unrolling do so lazily
	without affecting matches only at the end to guide group splitting.

	* g++.dg/opt/pr98550.C: New testcase.
2021-01-12 15:17:24 +01:00
Martin Liska
e91910d357 options: properly compare string arguments
Similarly to 7f967bd2a7, we need to
compare string with strcmp.

gcc/ChangeLog:

	PR c++/97284
	* optc-save-gen.awk: Compare also n_target_save vars with
	strcmp.
2021-01-12 14:04:28 +01:00
Martin Liska
b2230210f1 gcov: add more debugging facility
gcc/ChangeLog:

	* gcov.c (source_info::debug): New.
	(print_usage): Add --debug (-D) option.
	(process_args): Likewise.
	(generate_results): Call src->debug after
	accumulate_line_counts.
	(read_graph_file): Properly assign id for EXIT_BLOCK.
	* profile.c (branch_prob): Dump function body before it is
	instrumented.
2021-01-12 12:55:17 +01:00
Jakub Jelinek
24ea113f75 widening_mul: Fix up ICE caused by my signed multiplication overflow pattern recognition changes [PR98629]
As the testcase shows, my latest changes caused ICE on that testcase.
The problem is that arith_overflow_check_p now can change the use_stmt
argument (has a reference), so that if it succeeds (returns non-zero),
it points it to the GIMPLE_COND or EQ/NE or COND_EXPR assignment from the
TRUNC_DIV_EXPR assignment.
The problem was that it would change use_stmt also if it returned 0 in some
cases, such as multiple imm uses of the division, and in one of the callers
if arith_overflow_check_p returns 0 it looks at use_stmt again and performs
other checks, which of course assumes that use_stmt is the one passed
to arith_overflow_check_p and not e.g. NULL instead or some other unrelated
stmt.

The following patch fixes that by only changing use_stmt when we are about
to return non-zero (for the MULT_EXPR case, which is the only one with the
need to use different use_stmt).

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

	PR tree-optimization/98629
	* tree-ssa-math-opts.c (arith_overflow_check_p): Don't update use_stmt
	unless returning non-zero.

	* gcc.c-torture/compile/pr98629.c: New test.
2021-01-12 11:04:46 +01:00
Jakub Jelinek
13d47c37a2 reassoc: Optimize in reassoc x < 0 && y < 0 to (x | y) < 0 etc. [PR95731]
We already had x != 0 && y != 0 to (x | y) != 0 and
x != -1 && y != -1 to (x & y) != -1 and
x < 32U && y < 32U to (x | y) < 32U, this patch adds signed
x < 0 && y < 0 to (x | y) < 0.  In that case, the low/high seem to be
always the same and just in_p indices whether it is >= 0 or < 0,
also, all types in the same bucket (same precision) should be type
compatible, but we can have some >= 0 and some < 0 comparison mixed,
so the patch handles that by using the right BIT_IOR_EXPR or BIT_AND_EXPR
and doing one set of < 0 or >= 0 first, then BIT_NOT_EXPR and then the other
one.  I had to move optimize_range_tests_var_bound before this optimization
because that one deals with signed a >= 0 && a < b, and limited it to the
last reassoc pass as reassoc itself can't virtually undo this optimization
yet (and not sure if vrp would be able to).

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

	PR tree-optimization/95731
	* tree-ssa-reassoc.c (optimize_range_tests_cmp_bitwise): Also optimize
	x < 0 && y < 0 && z < 0 into (x | y | z) < 0 for signed x, y, z.
	(optimize_range_tests): Call optimize_range_tests_cmp_bitwise
	only after optimize_range_tests_var_bound.

	* gcc.dg/tree-ssa/pr95731.c: New test.
	* gcc.c-torture/execute/pr95731.c: New test.
2021-01-12 11:03:40 +01:00
Jakub Jelinek
ff99d05f40 configure, make: Fix up --enable-link-serialization
As reported by Matthias, --enable-link-serialization=1 can currently start
two concurrent links first (e.g. gnat1 and cc1).
The problem is that make var = value values seem to work differently between
dependencies and actual rules (where it was tested).
As the language make fragments can be in different order, we can have:
ada.prev = ... magic that will become $(c.serial) under --enable-link-serialization=1
gnat1$(exe): ..... $(ada.prev)
	...
c.serial = cc1$(exe)
and while if I add echo $(ada.prev) in the gnat1 rule's command, it prints
cc1, the dependencies are actually evaluated during reading of the goal or
when.
The configure creates (and puts into Makefile) some serialization order of
the languages and in that order c always comes first, and the rest is
actually sorted the way the all_lang_makefrags are already sorted,
so just by forcing c/Make-lang.in first we achieve that X.serial variable
is always defined before some other Y.prev will use it in its goal
dependencies.

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

	* configure.ac: Ensure c/Make-lang.in comes first in @all_lang_makefrags@.
	* configure: Regenerated.
2021-01-12 11:02:16 +01:00
Qian Jianhua
ab96073df0 MAINTAINERS: Add myself for write after approval
ChangeLog:

2021-01-12  Qian Jianhua  <qianjh@cn.fujitsu.com>

	* MAINTAINERS (Write After Approval): Add myself
2021-01-12 15:32:43 +08:00
Marek Polacek
814299a9d4 c++: -Wmissing-field-initializers in unevaluated ctx [PR98620]
This PR wants us not to warn about missing field initializers when
the code in question takes places in decltype and similar.  Fixed
thus.

gcc/cp/ChangeLog:

	PR c++/98620
	* typeck2.c (process_init_constructor_record): Don't emit
	-Wmissing-field-initializers warnings in unevaluated contexts.

gcc/testsuite/ChangeLog:

	PR c++/98620
	* g++.dg/warn/Wmissing-field-initializers-2.C: New test.
2021-01-11 22:31:39 -05:00
liuhongt
240f0a490d Delete dead code in ix86_expand_sse_comi.
d->flag is always 0 for builtins located in
BDESC_FIRST (comi,COMI,...)
...
BDESC_END (COMI, PCMPESTR)

gcc/ChangeLog:
	PR target/98612
	* config/i386/i386-builtins.h (BUILTIN_DESC_SWAP_OPERANDS):
	Deleted.
	* config/i386/i386-expand.c (ix86_expand_sse_comi): Delete
	dead code.
2021-01-12 11:17:29 +08:00
Alexandre Oliva
640296c367 make FOR_EACH_IMM_USE_STMT safe for early exits
Use a dtor to automatically remove ITER from IMM_USE list in
FOR_EACH_IMM_USE_STMT.


for  gcc/ChangeLog

	* ssa-iterators.h (end_imm_use_stmt_traverse): Forward
	declare.
	(auto_end_imm_use_stmt_traverse): New struct.
	(FOR_EACH_IMM_USE_STMT): Use it.
	(BREAK_FROM_IMM_USE_STMT, RETURN_FROM_IMM_USE_STMT): Remove,
	along with uses...
	* gimple-ssa-strength-reduction.c: ... here, ...
	* graphite-scop-detection.c: ... here, ...
	* ipa-modref.c, ipa-pure-const.c, ipa-sra.c: ... here, ...
	* tree-predcom.c, tree-ssa-ccp.c: ... here, ...
	* tree-ssa-dce.c, tree-ssa-dse.c: ... here, ...
	* tree-ssa-loop-ivopts.c, tree-ssa-math-opts.c: ... here, ...
	* tree-ssa-phiprop.c, tree-ssa.c: ... here, ...
	* tree-vect-slp.c: ... and here, ...
	* doc/tree-ssa.texi: ... and the example here.
2021-01-11 23:37:59 -03:00
David Malcolm
ab88f36072 analyzer: fix ICE merging dereferencing unknown ptrs [PR98628]
gcc/analyzer/ChangeLog:
	PR analyzer/98628
	* store.cc (binding_cluster::make_unknown_relative_to): Don't mark
	dereferenced unknown pointers as having escaped.

gcc/testsuite/ChangeLog:
	PR analyzer/98628
	* gcc.dg/analyzer/pr98628.c: New test.
2021-01-11 20:23:41 -05:00
GCC Administrator
67fbb7f0fd Daily bump. 2021-01-12 00:16:22 +00:00
Richard Sandiford
a958b2fc6d aarch64: Add support for unpacked SVE ASRD
This patch adds support for both conditional and unconditional unpacked
ASRD.  This meant adding a new define_insn for the unconditional form,
instead of reusing the conditional instructions.  It also meant
extending the current conditional patterns to support merging with
any independent value, not just zero.

gcc/
	* config/aarch64/aarch64-sve.md (sdiv_pow2<mode>3): Extend from
	SVE_FULL_I to SVE_I.  Generate an UNSPEC_PRED_X.
	(*sdiv_pow2<mode>3): New pattern.
	(@cond_<sve_int_op><mode>): Extend from SVE_FULL_I to SVE_I.
	Wrap the ASRD in an UNSPEC_PRED_X.
	(*cond_<sve_int_op><mode>_2): Likewise.  Replace the UNSPEC_PRED_X
	predicate with a constant PTRUE, if it isn't already.
	(*cond_<sve_int_op><mode>_z): Replace with...
	(*cond_<sve_int_op><mode>_any): ...this new pattern.

gcc/testsuite/
	* gcc.target/aarch64/sve/asrdiv_4.c: New test.
	* gcc.target/aarch64/sve/cond_asrd_1.c: Likewise.
	* gcc.target/aarch64/sve/cond_asrd_1_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_asrd_2.c: Likewise.
	* gcc.target/aarch64/sve/cond_asrd_2_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_asrd_3.c: Likewise.
	* gcc.target/aarch64/sve/cond_asrd_3_run.c: Likewise.
2021-01-11 18:03:26 +00:00
Richard Sandiford
37426e0f06 aarch64: Add support for unpacked SVE conditional BIC
This patch adds support for unpacked conditional BIC.  The type suffix
could be taken from the element size or the container size, so the
patch continues to use the element size.  This is consistent with
the existing support for unconditional BIC.

gcc/
	* config/aarch64/aarch64-sve.md (*cond_bic<mode>_2): Extend from
	SVE_FULL_I to SVE_I.
	(*cond_bic<mode>_any): Likewise.

gcc/testsuite/
	* g++.target/aarch64/sve/cond_bic_1.C: New test.
	* g++.target/aarch64/sve/cond_bic_2.C: Likewise.
	* g++.target/aarch64/sve/cond_bic_3.C: Likewise.
	* g++.target/aarch64/sve/cond_bic_4.C: Likewise.
2021-01-11 18:03:25 +00:00
Richard Sandiford
7446de5a2a aarch64: Add support for unpacked SVE MULH
This patch extends the SMULH and UMULH support to unpacked vectors.
The type suffix must be taken from the element size rather than the
container size.

The main use of these patterns is to support division and modulus
by a constant.  The conditional forms would be hard to trigger from
non-ACLE code, and ACLE code needs fully-packed vectors only.

gcc/
	* config/aarch64/aarch64-sve.md (<su>mul<mode>3_highpart)
	(@aarch64_pred_<MUL_HIGHPART:optab><mode>): Extend from SVE_FULL_I
	to SVE_I.

gcc/testsuite/
	* gcc.target/aarch64/sve/mul_highpart_3.c: New test.
2021-01-11 18:03:24 +00:00
Richard Sandiford
907ea37955 aarch64: Add support for unpacked SVE ABD
This patch adds support for unpacked SVE SABD and UABD.
It also rewrites the patterns so that they match as combine
patterns without the need for REG_EQUAL notes.  Finally,
there was no pattern for merging with the second input,
which can be handled by reversing the operands.

The type suffix needs to be taken from the element size rather
than the container size.

gcc/
	* config/aarch64/aarch64-sve.md (<su>abd<mode>_3): Extend from
	SVE_FULL_I to SVE_I.
	(*aarch64_cond_<su>abd<mode>_2): Likewise.
	(*aarch64_cond_<su>abd<mode>_any): Likewise.
	(@aarch64_pred_<su>abd<mode>): Likewise.  Use UNSPEC_PRED_X
	for the max and min but not for the minus.
	(*aarch64_cond_<su>abd<mode>_3): New pattern.

gcc/testsuite/
	* g++.target/aarch64/sve/abd_1.C: New test.
	* g++.target/aarch64/sve/cond_abd_1.C: Likewise.
	* g++.target/aarch64/sve/cond_abd_2.C: Likewise.
	* g++.target/aarch64/sve/cond_abd_3.C: Likewise.
	* g++.target/aarch64/sve/cond_abd_4.C: Likewise.
2021-01-11 18:03:23 +00:00
Richard Sandiford
3f8b0bba03 aarch64: Add support for unpacked SVE ADR
This patch extends the ADR patterns to handle unpacked vectors.
They would work with both elements and containers, but since
the instructions only support .s and .d, we get more coverage
by using containers.

gcc/
	* config/aarch64/iterators.md (SVE_24I): New iterator.
	* config/aarch64/aarch64-sve.md (*aarch64_adr<mode>_shift): Extend from
	SVE_FULL_SDI to SVE_24I.  Use containers rather than elements.

gcc/testsuite/
	* gcc.target/aarch64/sve/adr_6.c: New test.
2021-01-11 18:03:23 +00:00
Richard Sandiford
ab76e3db6b aarch64: Add general unpacked SVE conditional binary arithmetic
This patch adds support for conditional binary ADD, SUB, MUL, SMAX,
UMAX, SMIN, UMIN, LSL, LSR, ASR, AND, ORR and EOR.  It's not really
possible to split it up further given how the patterns are written.

Min, max and right-shift need the element size rather than the container
size.  The others would work with both, although MUL should be more
efficient when applied to elements instead of containers.

gcc/
	* config/aarch64/aarch64-sve.md (@cond_<SVE_INT_BINARY:optab><mode>)
	(*cond_<SVE_INT_BINARY:optab><mode>_2): Extend from SVE_FULL_I
	to SVE_I.
	(*cond_<SVE_INT_BINARY:optab><mode>_3): Likewise.
	(*cond_<SVE_INT_BINARY:optab><mode>_any): Likewise.
	(*cond_<SVE_INT_BINARY:optab><mode>_2_const): Likewise.
	(*cond_<SVE_INT_BINARY:optab><mode>_any_const): Likewise.

gcc/testsuite/
	* g++.target/aarch64/sve/cond_arith_1.C: New test.
	* g++.target/aarch64/sve/cond_arith_2.C: Likewise.
	* g++.target/aarch64/sve/cond_arith_3.C: Likewise.
	* g++.target/aarch64/sve/cond_arith_4.C: Likewise.
	* g++.target/aarch64/sve/cond_shift_1.C: New test.
	* g++.target/aarch64/sve/cond_shift_2.C: Likewise.
	* g++.target/aarch64/sve/cond_shift_3.C: Likewise.
	* g++.target/aarch64/sve/cond_shift_4.C: Likewise.
2021-01-11 18:03:22 +00:00
Richard Sandiford
48c7f5b881 aarch64: Add support for unpacked SVE mult, max and min
This patch makes the SVE_INT_BINARY_IMM patterns support
unpacked arithmetic, covering MUL, SMAX, SMIN, UMAX and UMIN.
For min and max, the type suffix must be taken from the element
size rather than the container size.

The XFAILs are due to PR98602.

gcc/
	* config/aarch64/aarch64-sve.md (<SVE_INT_BINARY_IMM:optab><mode>3)
	(@aarch64_pred_<SVE_INT_BINARY_IMM:optab><mode>)
	(*post_ra_<SVE_INT_BINARY_IMM:optab><mode>3): Extend from SVE_FULL_I
	to SVE_I.

gcc/testsuite/
	PR testsuite/98602
	* g++.target/aarch64/sve/max_1.C: New test.
	* g++.target/aarch64/sve/min_1.C: Likewise.
	* gcc.target/aarch64/sve/mul_2.c: Likewise.
2021-01-11 18:03:21 +00:00
Richard Sandiford
b81fbfe1eb aarch64: Add support for unpacked SVE shifts
This patch adds support for unpacked SVE LSL, ASR and LSR.
For right shifts, the type suffix needs to be taken from the
element size rather than the container size.

gcc/
	* config/aarch64/aarch64-sve.md (<ASHIFT:optab><mode>3)
	(v<ASHIFT:optab><mode>3, @aarch64_pred_<optab><mode>)
	(*post_ra_v<ASHIFT:optab><mode>3): Extend from SVE_FULL_I to SVE_I.

gcc/testsuite/
	* gcc.target/aarch64/sve/shift_2.c: New test.
2021-01-11 18:03:20 +00:00
Martin Liska
cbe9758ff4 Properly release symtab::m_clones.
gcc/ChangeLog:

	PR jit/98615
	* symtab-clones.h (clone_info::release): Release
	symtab::m_clones with ggc_delete as it's a GGC memory.
2021-01-11 18:15:06 +01:00
Jakub Jelinek
3dd0d3ee1d c++, abi: Fix abi_tag attribute handling [PR98481]
In GCC10 cp_walk_subtrees has been changed to walk template arguments.
As the following testcase, that changed the mangling of some functions.
I believe the previous behavior that find_abi_tags_r doesn't recurse into
template args has been the correct one, but setting *walk_subtrees = 0
for the types and handling the types subtree walking manually in
find_abi_tags_r looks too hard, there are a lot of subtrees and details what
should and shouldn't be walked, both in tree.c (walk_type_fields there,
which is static) and in cp_walk_subtrees itself.

The following patch abuses the fact that *walk_subtrees is an int to
tell cp_walk_subtrees it shouldn't walk the template args.

Co-authored-by: Jason Merrill <jason@redhat.com>

gcc/cp/ChangeLog:

	PR c++/98481
	* class.c (find_abi_tags_r): Set *walk_subtrees to 2 instead of 1
	for types.
	(mark_abi_tags_r): Likewise.
	* decl2.c (min_vis_r): Likewise.
	* tree.c (cp_walk_subtrees): If *walk_subtrees_p is 2, look through
	typedefs.

gcc/testsuite/ChangeLog:

	PR c++/98481
	* g++.dg/abi/abi-tag24.C: New test.
2021-01-11 11:12:48 -05:00
Matthias Klose
8c09b788a9 Make the serialized link target more verbose
2020-12-07  Matthias Klose  <doko@ubuntu.com>

	* Makefile.in (LINK_PROGRESS): Show the link target.
2021-01-11 14:51:35 +00:00
Martin Liska
3b25e83536 Port update-copyright.py to Python3
contrib/ChangeLog:

	* update-copyright.py: Port to python3 by guessing encoding
	(first utf8, then iso8859). Add 2 more ignores: .png and .pyc.
2021-01-11 14:08:50 +01:00
Richard Biener
84684e0f78 tree-optimization/91403 - avoid excessive code-generation
The vectorizer, for large permuted grouped loads, generates
inefficient intermediate code (cleaned up only later) that runs
into complexity issues in SCEV analysis and elsewhere.  For the
non-single-element interleaving case we already put a hard limit
in place, this applies the same limit to the missing case.

2021-01-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91403
	* tree-vect-data-refs.c (vect_analyze_group_access_1): Cap
	single-element interleaving group size at 4096 elements.

	* gcc.dg/vect/pr91403.c: New testcase.
2021-01-11 13:38:18 +01:00
Bernd Edlinger
6ebf79fcd4 testsuite: Fix test failures from outputs.exp [PR98225]
The .ld1_args file is not created when HAVE_GNU_LD is false.
The ltrans0.ltrans_arg file is not created when the make jobserver
is available, so remove the MAKEFLAGS variable.
Add an exception for *.gcc_args files similar to the
exception for *.cdtor.* files.
Limit both exceptions to targets that define EH_FRAME_THROUGH_COLLECT2.
That means although the test case does not use C++ constructors
or destructors it is still using dwarf2 frame info.

2021-01-11  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR testsuite/98225
	* gcc.misc-tests/outputs.exp: Unset MAKEFLAGS.
	Expect .ld1_args only when GNU LD is used.
	Add an exception for *.gcc_args files.
2021-01-11 13:28:29 +01:00
Richard Biener
04bff1bbfc tree-optimization/98526 - fix vectorizer reduction cost
This fixes a double-counting in the reduction cost when vectorizing
the reduction through the regular vectorizable_* functions.

2021-01-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98526
	* tree-vect-loop.c (vect_model_reduction_cost): Remove costing
	of the actual reduction op for the regular case.
	(vectorizable_reduction): Cost the stmts
	vect_transform_reduction produces here.
2021-01-11 12:50:59 +01:00
Iain Buclaw
928e96bbe9 d: Remove visibility and lookup deprecation
The deprecation phase for access checks is finished.

The `-ftransition=import` and `-ftransition=checkimports` switches no
longer have an effect and are now removed.  Symbols that are not visible
in a particular scope will no longer be found by the compiler.

Reviewed-on: https://github.com/dlang/dmd/pull/12124

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 2d3d13748.
	* d-lang.cc (d_handle_option): Remove OPT_ftransition_checkimports and
	OPT_ftransition_import.
	* gdc.texi (Warnings): Remove documentation for -ftransition=import
	and -ftransition=checkimports.
	* lang.opt (ftransition=checkimports): Remove.
	(ftransition=import): Remove.
2021-01-11 12:21:03 +01:00
Andreas Krebbel
300a3ce5c5 tree-optimization/98221 - fix wrong unpack operation used for big-endian
The vec-abi-varargs-1.c testcase on IBM Z currently fails.

While adding an SI mode vector to a DI mode vector the first is unpacked using:

  _28 = BIT_INSERT_EXPR <{ 0, 0, 0, 0 }, _2, 0>;
  _34 = [vec_unpack_lo_expr] _28;

However, on big endian targets lo refers to the right hand side of the vector - in this case the zeroes.

2021-01-11  Andreas Krebbel  <krebbel@linux.ibm.com>

	* tree-ssa-forwprop.c (simplify_vector_constructor): For
	big-endian, use UNPACK[_FLOAT]_HI.
2021-01-11 11:46:31 +01:00
Tamar Christina
0c18faac3f slp: upgrade complex add to new format and fix memory leaks
This fixes a memory leak in complex_add_pattern because I was not calling
vect_free_slp_tree when dissolving one side of the TWO_OPERANDS nodes.

Secondly it also upgrades the class to the new inteface required by the other
patterns.

gcc/ChangeLog:

	* tree-vect-slp-patterns.c (class complex_pattern,
	class complex_add_pattern): Add parameters to matches.
	(complex_add_pattern::build): Free memory.
	(complex_add_pattern::matches): Move validation end of match.
	(complex_add_pattern::recognize): Likewise.
2021-01-11 09:58:36 +00:00
Tamar Christina
bd4298e192 slp: handle externals correctly in linear_loads_p
This fixes a bug with externals and linear_loads_p where I forgot to save the
value before returning.

It also fixes handling of nodes with multiple children on a non VEC_PERM node.
There the child iteration would already resolve the kind and the loads are All
expected to be the same if valid so just return one.

gcc/ChangeLog:

	* tree-vect-slp-patterns.c (linear_loads_p): Fix externals.
2021-01-11 09:57:41 +00:00
Tamar Christina
39666d2b88 slp: fix is_linear_load_p to prevent multiple answers
This fixes an issue where is_linear_load_p could return the incorrect
permutation kind because it is singe pass.

This arranges the candidates in such a way that there won't be any ambiguity so
that the function can still be linear but give correct values.

gcc/ChangeLog:

	* tree-vect-slp-patterns.c (is_linear_load_p): Fix ambiguity.
2021-01-11 09:56:44 +00:00
Jakub Jelinek
9a6c37e6ae reassoc: Reassociate integral multiplies [PR95867]
For floating point multiply, we have nice code in reassoc to reassociate
multiplications to almost optimal sequence of as few multiplications as
possible (or library call), but for integral types we just give up
because there is no __builtin_powi* for those types.

As there is no library routine we could use, instead of adding new internal
call just to hold it temporarily and then lower to multiplications again,
this patch for the integral types calls into the sincos pass routine that
expands it into multiplications right away.

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

	PR tree-optimization/95867
	* tree-ssa-math-opts.h: New header.
	* tree-ssa-math-opts.c: Include tree-ssa-math-opts.h.
	(powi_as_mults): No longer static.  Use build_one_cst instead of
	build_real.  Formatting fix.
	* tree-ssa-reassoc.c: Include tree-ssa-math-opts.h.
	(attempt_builtin_powi): Handle multiplication reassociation without
	powi_fndecl using powi_as_mults.
	(reassociate_bb): For integral types don't require
	-funsafe-math-optimizations to call attempt_builtin_powi.

	* gcc.dg/tree-ssa/pr95867.c: New test.
2021-01-11 10:36:24 +01:00
Jakub Jelinek
9febe9e4be widening_mul: Pattern recognize also signed multiplication with overflow check [PR95852]
On top of the previous widening_mul patch, this one recognizes also
(non-perfect) signed multiplication with overflow, like:
int
f5 (int x, int y, int *res)
{
  *res = (unsigned) x * y;
  return x && (*res / x) != y;
}
The problem with such checks is that they invoke UB if x is -1 and
y is INT_MIN during the division, but perhaps the code knows that
those values won't appear.  As that case is UB, we can do for that
case whatever we want and handling that case as signed overflow
is the best option.  If x is a constant not equal to -1, then the checks
are 100% correct though.
Haven't tried to pattern match bullet-proof checks, because I really don't
know if users would write it in real-world code like that,
perhaps
  *res = (unsigned) x * y;
  return x && (x == -1 ? (*res / y) != x : (*res / x) != y);
?

https://wiki.sei.cmu.edu/confluence/display/c/INT32-C.+Ensure+that+operations+on+signed+integers+do+not+result+in+overflow
suggests to use twice as wide multiplication (perhaps we should handle that
too, for both signed and unsigned), or some very large code
with 4 different divisions nested in many conditionals, no way one can
match all the possible variants thereof.

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

	PR tree-optimization/95852
	* tree-ssa-math-opts.c (maybe_optimize_guarding_check): Change
	mul_stmts parameter type to vec<gimple *> &.  Before cond_stmt
	allow in the bb any of the stmts in that vector, div_stmt and
	up to 3 cast stmts.
	(arith_cast_equal_p): New function.
	(arith_overflow_check_p): Add cast_stmt argument, handle signed
	multiply overflow checks.
	(match_arith_overflow): Adjust caller.  Handle signed multiply
	overflow checks.

	* gcc.target/i386/pr95852-3.c: New test.
	* gcc.target/i386/pr95852-4.c: New test.
2021-01-11 10:34:07 +01:00
Jakub Jelinek
a2106317cd widening_mul: Pattern recognize unsigned multiplication with overflow check [PR95852]
The following patch pattern recognizes some forms of multiplication followed
by overflow check through division by one of the operands compared to the
other one, with optional removal of guarding non-zero check for that operand
if possible.  The patterns are replaced with effectively
__builtin_mul_overflow or __builtin_mul_overflow_p.  The testcases cover 64
different forms of that.

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

	PR tree-optimization/95852
	* tree-ssa-math-opts.c (maybe_optimize_guarding_check): New function.
	(uaddsub_overflow_check_p): Renamed to ...
	(arith_overflow_check_p): ... this.  Handle also multiplication
	with overflow check.
	(match_uaddsub_overflow): Renamed to ...
	(match_arith_overflow): ... this.  Add cfg_changed argument.  Handle
	also multiplication with overflow check.  Adjust function comment.
	(math_opts_dom_walker::after_dom_children): Adjust callers.  Call
	match_arith_overflow also for MULT_EXPR.

	* gcc.target/i386/pr95852-1.c: New test.
	* gcc.target/i386/pr95852-2.c: New test.
2021-01-11 10:32:19 +01:00
Kyrylo Tkachov
64dc013853 aarch64: Reimplement vmovl*/vmovn* intrinsics using __builtin_convertvector
__builtin_convertvector seems well-suited to implementing the vmovl and
vmovn intrinsics that widen and narrow
the integer elements in a vector.

This removes some more inline assembly from the intrinsics.

gcc/
	* config/aarch64/arm_neon.h (vmovl_s8): Reimplement using
	__builtin_convertvector.
	(vmovl_s16): Likewise.
	(vmovl_s32): Likewise.
	(vmovl_u8): Likewise.
	(vmovl_u16): Likewise.
	(vmovl_u32): Likewise.
	(vmovn_s16): Likewise.
	(vmovn_s32): Likewise.
	(vmovn_s64): Likewise.
	(vmovn_u16): Likewise.
	(vmovn_u32): Likewise.
	(vmovn_u64): Likewise.
2021-01-11 09:12:22 +00:00
Martin Liska
4e275dccfc Add pytest for a GCOV test-case
gcc/testsuite/ChangeLog:

	PR gcov-profile/98273
	* lib/gcov.exp: Add run-gcov-pytest function which runs pytest.
	* g++.dg/gcov/pr98273.C: New test.
	* g++.dg/gcov/gcov.py: New test.
	* g++.dg/gcov/test-pr98273.py: New test.
2021-01-11 09:18:53 +01:00
Martin Liska
fa4586d854 if-to-switch: remove memory leaks
gcc/ChangeLog:

	* gimple-if-to-switch.cc (struct condition_info): Use auto_var.
	(if_chain::is_beneficial): Delete clusters
	(find_conditions): Make second argument of conditions_in_bbs a
	pointer so that we control over it's lifetime.
	(pass_if_to_switch::execute): Delete them.
2021-01-11 09:18:28 +01:00
Kewen Lin
bcb3065b2b ira: Skip some pseudos in move_unallocated_pseudos
This patch is to make move_unallocated_pseudos consistent
to what we have in function find_moveable_pseudos, where we
record the original pseudo into pseudo_replaced_reg only if
validate_change succeeds with newreg.  To ensure every
unallocated pseudo in move_unallocated_pseudos has expected
information, it's better to add a check and skip it if it's
unexpected.  This avoids possible ICEs in future.

gcc/ChangeLog:

	* ira.c (move_unallocated_pseudos): Check other_reg and skip if
	it isn't set.
2021-01-10 20:33:23 -06:00
GCC Administrator
366f86bd42 Daily bump. 2021-01-11 00:16:17 +00:00
David Edelsohn
4a1d7f7e20 libstdc++: Suppress more vstring testsuite warnings. [PR 98613]
PR c++/57111 - 57111 - Generalize -Wfree-nonheap-object to delete

can create false positive warnings for vstring _S_empty_rep.

This patch prunes the excess false positive warnings from two more
testcases.

libstdc++-v3/ChangeLog:

	PR libstdc++/98613
	* testsuite/ext/vstring/cons/moveable.cc: Suppress false positive
	warning.
	* testsuite/ext/vstring/modifiers/assign/move_assign.cc: Same.
2021-01-10 18:22:51 -05:00
GCC Administrator
872373360d Daily bump. 2021-01-10 00:16:20 +00:00
Iain Buclaw
7da827c99c d: Synchronize testsuite with upstream dmd
Adds TEST_OUTPUT directives and reduces the verbosity of many tests.

Reviewed-on: https://github.com/dlang/dmd/pull/12112

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd cb1106ad5.
2021-01-09 23:59:30 +01:00
Iain Buclaw
7a103daef7 d: Support deprecated, @disable, and user-defined attributes on enum members
Reviewed-on: https://github.com/dlang/dmd/pull/12108

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 9bba772fa.
2021-01-09 23:45:46 +01:00
Iain Buclaw
acae7b21bc d: Implement expression-based contract syntax
Expression-based contract syntax has been added.  Contracts that consist
of a single assertion can now be written more succinctly and multiple
`in` or `out` contracts can be specified for the same function.

Reviewed-on: https://github.com/dlang/dmd/pull/12106

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd e598f69c0.
2021-01-09 23:45:46 +01:00
Maciej W. Rozycki
f2a5346244 VAX/testsuite: Remove notsi comparison elimination regressions
Remove fallout from commit 0bd675183d ("match.pd: Add ~(X - Y) -> ~X
+ Y simplification [PR96685]") and paper over the regression caused as
it is not the matter of the test cases affected.

Previously assembly like this:

	.text
	.align 1
.globl eq_notsi
	.type	eq_notsi, @function
eq_notsi:
	.word 0	# 35	[c=0]  procedure_entry_mask
	subl2 $4,%sp	# 46	[c=32]  *addsi3
	mcoml 4(%ap),%r0	# 32	[c=16]  *one_cmplsi2_ccz
	jeql .L1		# 34	[c=26]  *branch_ccz
	addl2 $2,%r0	# 31	[c=32]  *addsi3
.L1:
	ret		# 40	[c=0]  return
	.size	eq_notsi, .-eq_notsi

was produced.  Now this:

	.text
	.align 1
.globl eq_notsi
	.type	eq_notsi, @function
eq_notsi:
	.word 0	# 36	[c=0]  procedure_entry_mask
	subl2 $4,%sp	# 48	[c=32]  *addsi3
	movl 4(%ap),%r0	# 33	[c=16]  *movsi_2
	cmpl %r0,$-1	# 34	[c=8]  *cmpsi_ccz/1
	jeql .L3		# 35	[c=26]  *branch_ccz
	subl3 %r0,$1,%r0	# 32	[c=32]  *subsi3/1
	ret		# 27	[c=0]  return
.L3:
	clrl %r0		# 31	[c=2]  *movsi_2
	ret		# 41	[c=0]  return
	.size	eq_notsi, .-eq_notsi

is, which cannot work with post-reload comparison elimination, due to
the comparison against -1 rather than 0.

Use subtraction from a constant then rather than addition as the former
operation is not transformed, removing these regressions:

FAIL: gcc.target/vax/cmpelim-eq-notsi.c   -O1   scan-rtl-dump-times cmpelim "deleting insn with uid" 1
FAIL: gcc.target/vax/cmpelim-eq-notsi.c   -O1   scan-assembler-not \t(bit|cmpz?|tst).
FAIL: gcc.target/vax/cmpelim-eq-notsi.c   -O1   scan-assembler one_cmplsi[^ ]*_ccz(/[0-9]+)?\n
FAIL: gcc.target/vax/cmpelim-lt-notsi.c   -O1   scan-rtl-dump-times cmpelim "deleting insn with uid" 1
FAIL: gcc.target/vax/cmpelim-lt-notsi.c   -O1   scan-assembler-not \t(bit|cmpz?|tst).
FAIL: gcc.target/vax/cmpelim-lt-notsi.c   -O1   scan-assembler one_cmplsi[^ ]*_ccn(/[0-9]+)?\n

and likewise across some of the other the optimization levels verified.

The LE variant appears unaffected as the new transformation produces
slightly different although still suboptimal code:

	.text
	.align 1
.globl le_notsi
	.type	le_notsi, @function
le_notsi:
	.word 0	# 27	[c=0]  procedure_entry_mask
	subl2 $4,%sp	# 34	[c=32]  *addsi3
	movl 4(%ap),%r1	# 23	[c=16]  *movsi_2
	mcoml %r1,%r0	# 24	[c=8]  *one_cmplsi2_ccnz
	jleq .L1		# 26	[c=26]  *branch_ccnz
	subl3 %r1,$1,%r0	# 22	[c=32]  *subsi3/1
.L1:
	ret		# 32	[c=0]  return
	.size	le_notsi, .-le_notsi

but update the test case too, for consistency with the other two.

	gcc/testsuite/
	* gcc.target/vax/cmpelim-eq-notsi.c: Use subtraction from a
	constant then rather than addition.
	* gcc.target/vax/cmpelim-le-notsi.c: Likewise.
	* gcc.target/vax/cmpelim-lt-notsi.c: Likewise.
2021-01-09 16:30:51 +00:00
Maciej W. Rozycki
7f5c4d23db VAX: Remove a duplicate `cc' mode attribute
Remove the `cc' mode attribute that duplicates the implicitly defined
`mode' attribute.  No change to semantics.

	gcc/
	* config/vax/vax.md (cc): Remove mode attribute.
	(subst_<cc>, subst_f<cc>): Rename to...
	(subst_<mode>, subst_f<VAXccnz:mode>): ... these respectively.
	(*cbranch<VAXint:mode>4_<VAXcc:mode>): Update for `cc' removal.
	(*cbranch<VAXfp:mode>4_<VAXccnz:mode>): Likewise.
	(*branch_<mode>, *branch_<mode>_reversed): Likewise.
2021-01-09 16:30:50 +00:00
Maciej W. Rozycki
c38bbf5eed VAX: Use a mode with `const_double_zero' expressions
For predictable semantics propagate the mode from operands referred by
the FP substitution to the `const_double_zero' expressions used with the
associated condition code calculation.  Use an iterator to make copies
of the FP substitution across the FP modes supported as the substitution
now has to match the mode of the operands.

	gcc/
	* config/vax/vax.md (subst_f<cc>): Add mode to operands and
	`const_double_zero'.
2021-01-09 16:30:25 +00:00
Maciej W. Rozycki
be7e807242 PDP11: Use a mode with `const_double_zero' expressions
For predictable semantics propagate the mode from operands referred by
FP substitutions to the `const_double_zero' expressions used with the
associated condition code calculation, resulting in the following update
to insn-emit.c code produced for the `pdp11-aout' target (with machine
description line numbering change noise removed):

@@ -1514,7 +1514,7 @@
 	gen_rtx_COMPARE (CCmode,
 	gen_rtx_ABS (DFmode,
 	operand1),
-	CONST_DOUBLE_ATOF ("0", VOIDmode))),
+	CONST_DOUBLE_ATOF ("0", DFmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_ABS (DFmode,
 	copy_rtx (operand1)))));
@@ -1555,7 +1555,7 @@
 	gen_rtx_COMPARE (CCmode,
 	gen_rtx_NEG (DFmode,
 	operand1),
-	CONST_DOUBLE_ATOF ("0", VOIDmode))),
+	CONST_DOUBLE_ATOF ("0", DFmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_NEG (DFmode,
 	copy_rtx (operand1)))));
@@ -1790,7 +1790,7 @@
 	gen_rtx_MULT (DFmode,
 	operand1,
 	operand2),
-	CONST_DOUBLE_ATOF ("0", VOIDmode))),
+	CONST_DOUBLE_ATOF ("0", DFmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_MULT (DFmode,
 	copy_rtx (operand1),
@@ -1942,7 +1942,7 @@
 	gen_rtx_DIV (DFmode,
 	operand1,
 	operand2),
-	CONST_DOUBLE_ATOF ("0", VOIDmode))),
+	CONST_DOUBLE_ATOF ("0", DFmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_DIV (DFmode,
 	copy_rtx (operand1),

Provide a new iterator to provide copies of FP substitutions across the
FP modes supported as the substitutions now need to match the mode of
the operands.

	gcc/
	* config/pdp11/pdp11.md (PDPfp): New mode iterator.
	(fcc_cc, fcc_ccnz): Use it.  Add mode to `const_double_zero' and
	operands.
2021-01-09 15:50:27 +00:00
Maciej W. Rozycki
859be2e44a RTL: Update `const_double_zero' handling for mode and callable insns
Handle machine mode specification with `const_double_zero' and handle
the rtx with callable code produced from named insns.  Complementing
commit 20ab43b5ca ("RTL: Add `const_double_zero' syntactic rtx") and
removing a commit c60d0736df ("PDP11: Use `const_double_zero' to
express double zero constant") build regression observed with the
`pdp11-aout' target:

genemit: Internal error: abort in gen_exp, at genemit.c:202
make[2]: *** [Makefile:2427: s-emit] Error 1

where a:

(const_double 0 [0] 0 [0] 0 [0] 0 [0])

rtx coming from:

(parallel [
        (set (reg:CC 16)
            (compare:CC (abs:DF (match_operand:DF 1 ("general_operand") ("0,0")))
                (const_double 0 [0] 0 [0] 0 [0] 0 [0])))
        (set (match_operand:DF 0 ("nonimmediate_operand") ("=fR,Q"))
            (abs:DF (match_dup 1)))
    ])

and ultimately `(const_double_zero)' referred in a named RTL insn cannot
be interpreted.  Handle the rtx then by supplying the constant 0 double
operand requested, resulting in the following update to insn-emit.c code
produced for the `pdp11-aout' target, relative to before the triggering
commit:

@@ -1514,7 +1514,7 @@ gen_absdf2_cc (rtx operand0 ATTRIBUTE_UN
 	gen_rtx_COMPARE (CCmode,
 	gen_rtx_ABS (DFmode,
 	operand1),
-	const0_rtx)),
+	CONST_DOUBLE_ATOF ("0", VOIDmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_ABS (DFmode,
 	copy_rtx (operand1)))));
@@ -1555,7 +1555,7 @@ gen_negdf2_cc (rtx operand0 ATTRIBUTE_UN
 	gen_rtx_COMPARE (CCmode,
 	gen_rtx_NEG (DFmode,
 	operand1),
-	const0_rtx)),
+	CONST_DOUBLE_ATOF ("0", VOIDmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_NEG (DFmode,
 	copy_rtx (operand1)))));
@@ -1790,7 +1790,7 @@ gen_muldf3_cc (rtx operand0 ATTRIBUTE_UN
 	gen_rtx_MULT (DFmode,
 	operand1,
 	operand2),
-	const0_rtx)),
+	CONST_DOUBLE_ATOF ("0", VOIDmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_MULT (DFmode,
 	copy_rtx (operand1),
@@ -1942,7 +1942,7 @@ gen_divdf3_cc (rtx operand0 ATTRIBUTE_UN
 	gen_rtx_DIV (DFmode,
 	operand1,
 	operand2),
-	const0_rtx)),
+	CONST_DOUBLE_ATOF ("0", VOIDmode))),
 		gen_rtx_SET (operand0,
 	gen_rtx_DIV (DFmode,
 	copy_rtx (operand1),

This does not (yet) remove VOIDmode CONST_DOUBLE use, as it is up to
individual machine descriptions to choose.

	gcc/
	* genemit.c (gen_exp) <CONST_DOUBLE>: Handle `const_double_zero'
	rtx.
	* read-rtl.c (rtx_reader::read_rtx_code): Handle machine mode
	with `const_double_zero'.
	* doc/rtl.texi (Constant Expression Types): Document it.
2021-01-09 15:46:02 +00:00
Jakub Jelinek
991656092f tree-cfg: Allow enum types as result of POINTER_DIFF_EXPR [PR98556]
As conversions between signed integers and signed enums with the same
precision are useless in GIMPLE, it seems strange that we require that
POINTER_DIFF_EXPR result must be INTEGER_TYPE.

If we really wanted to require that, we'd need to change the gimplifier
to ensure that, which it isn't the case on the following testcase.
What is going on during the gimplification is that when we have the
(enum T) (p - q) cast, it is stripped through
      /* Strip away as many useless type conversions as possible
         at the toplevel.  */
      STRIP_USELESS_TYPE_CONVERSION (*expr_p);
and when the MODIFY_EXPR is gimplified, the *to_p has enum T type,
while *from_p has intptr_t type and as there is no conversion in between,
we just create GIMPLE_ASSIGN from that.

2021-01-09  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98556
	* tree-cfg.c (verify_gimple_assign_binary): Allow lhs of
	POINTER_DIFF_EXPR to be any integral type.

	* c-c++-common/pr98556.c: New test.
2021-01-09 10:49:38 +01:00
Jakub Jelinek
16dae48e9c vregs: Fix up instantiate_virtual_regs_in_insn for asm goto with outputs [PR98603]
If an asm insn fails constraint checking during vregs, it is just deleted.
We don't delete asm goto though because of the edges to the labels, so
instantiate_virtual_regs_in_insn would just remove the inputs and their
constraints, the pattern etc.
This worked fine when asm goto couldn't have output operands, but causes
ICEs later on when it has more than one output (and furthermore doesn't
really remove the problematic outputs).  The problem is that
for multiple outputs we have a PARALLEL with multiple ASM_OPERANDS, but
those must use the same ASM_OPERANDS_INPUT_VEC etc., but the code was
adjusting just one.

The following patch turns invalid asm goto into a bare
asm goto ("" : : : : lab, lab2, lab3);
i.e. no inputs/outputs/clobbers, just the labels.

2021-01-09  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/98603
	* function.c (instantiate_virtual_regs_in_insn): For asm goto
	with impossible constraints, drop all SETs, CLOBBERs, drop PARALLEL
	if any, set ASM_OPERANDS mode to VOIDmode and change
	ASM_OPERANDS_OUTPUT_CONSTRAINT and ASM_OPERANDS_OUTPUT_IDX.

	* gcc.target/i386/pr98603.c: New test.
	* gcc.target/aarch64/pr98603.c: New test.
2021-01-09 10:48:20 +01:00
Alexandre Oliva
57450da2fe final: accept markers at line 0
Back when I introduced debug markers, I seem to have been under the
impression that location line 0 would only ever occur for unknown and
builtin locations.

Though line 0 never comes up in normal processing of source files, and
debug info formats often cannot represent them, I suppose there's no
need to preemptively discard them during final.


for  gcc/ChangeLog

	PR debug/97714
	* final.c (notice_source_line): Narrow down the condition to
	skip a line-0 marker.

for  gcc/testsuite/ChangeLog

	PR debug/97714
	* gcc.dg/debug/pr97714.c: New.
2021-01-09 00:09:02 -03:00
GCC Administrator
bf5cbb9edf Daily bump. 2021-01-09 00:16:22 +00:00
Sergei Trofimovich
0b874e0ffd ipa-modref: avoid linebreak split in debug print
* ipa-modref.c (merge_call_side_effects): Fix
	linebreak split by reordering two print calls.
2021-01-08 21:25:29 +00:00
Ilya Leoshkevich
0e47d6c808 IBM Z: Fix constraints in vpdi patterns
The destination register is only partially overwritten, so + should be
used instead of =.

gcc/ChangeLog:

2021-01-08  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/vector.md (*tf_to_fprx2_0): Rename from
	"*mov_tf_to_fprx2_0" for consistency, fix constraint.
	(*tf_to_fprx2_1): Rename from "*mov_tf_to_fprx2_1" for
	consistency, fix constraint.
2021-01-08 18:15:47 +01:00
H.J. Lu
745d04e796 x86-64: Require lp64 for PR target/98482 tests
Require lp64 for PR target/98482 tests since -mcmodel=large is isn't
supported for x32.

	PR target/98482
	* gcc.target/i386/pr98482-1.c: Require lp64.
	* gcc.target/i386/pr98482-2.c: Likewise.
2021-01-08 08:47:06 -08:00
Ilya Leoshkevich
f47df2af31 IBM Z: Introduce __LONG_DOUBLE_VX__ macro
Give end users the opportunity to find out whether long doubles are
stored in floating-point register pairs or in vector registers, so that
they could fine-tune their asm statements.

gcc/ChangeLog:

2020-12-14  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/s390-c.c (s390_def_or_undef_macro): Accept
	callables instead of mask values.
	(struct target_flag_set_p): New predicate.
	(s390_cpu_cpp_builtins_internal): Define or undefine
	__LONG_DOUBLE_VX__ macro.

2020-12-14  Ilya Leoshkevich  <iii@linux.ibm.com>

gcc/testsuite/ChangeLog:

	* gcc.target/s390/vector/long-double-vx-macro-off-on.c: New test.
	* gcc.target/s390/vector/long-double-vx-macro-on-off.c: New test.
2021-01-08 17:43:24 +01:00
Olivier Hainque
98546324c7 Tweak dg-prune-output regex for out-of-build-tree contexts
libstdc++-v3/

	* testsuite/20_util/bind/ref_neg.cc: Tweak the
	dg-prune-output regex for out-of-build-tree contexts.
2021-01-08 16:23:23 +00:00
Patrick Palka
bb1f0b50ab c++: ICE with constexpr call that returns a PMF [PR98551]
We shouldn't do replace_result_decl after evaluating a call that returns
a PMF because PMF temporaries aren't wrapped in a TARGET_EXPR (and so we
can't trust ctx->object), and PMF initializers can't be self-referential
anyway, so replace_result_decl would always be a no-op.

To that end, this patch changes the relevant AGGREGATE_TYPE_P test to
CLASS_TYPE_P, which should rule out PMFs (as well as arrays, which we
can't return and therefore won't see here).  This fixes an ICE from the
sanity check in replace_result_decl in the below testcase during
constexpr evaluation of the call f() in the initializer g(f()).

gcc/cp/ChangeLog:

	PR c++/98551
	* constexpr.c (cxx_eval_call_expression): Check CLASS_TYPE_P
	instead of AGGREGATE_TYPE_P before calling replace_result_decl.

gcc/testsuite/ChangeLog:

	PR c++/98551
	* g++.dg/cpp0x/constexpr-pmf2.C: New test.
2021-01-08 10:11:25 -05:00
Patrick Palka
98a1fb705e c++: Fix access checking of scoped non-static member [PR98515]
In the first testcase below, we incorrectly reject the use of the
protected non-static member A::var0 from C<int>::g() because
check_accessibility_of_qualified_id, at template parse time, determines
that the access doesn't go through 'this'.  (This happens because the
dependent base B<T> of C<T> doesn't have a binfo object, so it appears
to DERIVED_FROM_P that A is not an indirect base of C<T>.)  From there
we create the corresponding deferred access check, which we then
perform at instantiation time and which (expectedly) fails.

The problem ultimately seems to be that we can't in general determine
whether a use of a scoped non-static member goes through 'this' until
instantiation time, as the second testcase below illustrates.  So this
patch makes check_accessibility_of_qualified_id punt in such situations
to avoid creating a bogus deferred access check.

gcc/cp/ChangeLog:

	PR c++/98515
	* semantics.c (check_accessibility_of_qualified_id): Punt if
	we're checking access of a scoped non-static member inside a
	class template.

gcc/testsuite/ChangeLog:

	PR c++/98515
	* g++.dg/template/access32.C: New test.
	* g++.dg/template/access33.C: New test.
2021-01-08 10:02:04 -05:00
H.J. Lu
76be18f442 x86-64: Use R10 and R11 for profiling large model with PIC
For NO_PROFILE_COUNTERS targets, R11 is a scratch register.  We can use
R10 and R11 to call mcount in large model with PIC.

gcc/

	PR target/98482
	* config/i386/i386.c (x86_function_profiler): Use R10 and R11
	to call mcount in large model with PIC for NO_PROFILE_COUNTERS
	targets.

gcc/testsuite/

	PR target/98482
	* gcc.target/i386/pr98482-2.c: Updated.
2021-01-08 06:46:04 -08:00
Richard Biener
77a375a3eb reset the SCEV htab after FRE in loop pipeline
When running FRE in the loop pipeline (as part of the conditionally
scheduled scalar cleanups) we have to reset the SCEV hashtable as
otherwise we can end up with stale entries and all sorts of problems.

Catched by my out-of-tree verifier for this problem.

2021-01-08  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (pass_fre::execute): Reset the SCEV hash table.
2021-01-08 15:10:40 +01:00
Richard Biener
b407f233d7 fix vectorizer memleaks
This plugs two memleaks in the vectorizer.

2021-01-08  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (scalar_stmts_to_slp_tree_map_t): Fix.
	(vect_build_slp_tree): On cache hit release the matched
	scalar stmts vector.
	* tree-vect-stmts.c (vectorizable_store): Properly free
	vec_oprnds before possibly gathering them again.
2021-01-08 14:23:44 +01:00
Richard Biener
bdcde15045 tree-optimization/98544 - more permute optimization fixes
Permute nodes are not transparent to the permute of their children.
Instead we have to materialize child permutes always and in future
may treat permute nodes as the source of arbitrary permutes as
we can permute the lane permutation vector at will (as the target
supports in the end).

2021-01-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98544
	* tree-vect-slp.c (vect_optimize_slp): Always materialize
	permutes at a permute node.

	* gcc.dg/vect/bb-slp-pr98544.c: New testcase.
2021-01-08 14:08:10 +01:00
H.J. Lu
1b885264a4 x86-64: Use R10 for profiling large model
R10 is caller-saved.  Although it can be used as a static chain register,
it is preserved when calling mcount for nested functions.  Use R10 as a
scratch register to call mcount in large model.

gcc/

	PR target/98482
	* config/i386/i386.c (x86_function_profiler): Use R10 to call
	mcount in large model.  Sorry for large model with PIC.

gcc/testsuite/

	PR target/98482
	* gcc.target/i386/pr98482-1.c: New test.
	* gcc.target/i386/pr98482-1.c: Likewise.
2021-01-08 04:51:57 -08:00
Jakub Jelinek
8f1cb70d7c i386: Fix -mcmodel= vs. target attribute [PR98585]
My patch to save/restore opts_set rather than essentially treating
global_options_set as a logical or whether some option has ever been
explicitly set somewhere apparently broke -mcmodel= vs. target attribute
(and as the patch shows some other options too).
The thing is, at least for options for which we ever test opts_set->x_*
or global_options_set.x_*, we need to save/restore them next to the
saving/restoring of the actual option values.
If an option has Save keyword or in case of TargetVariable, it is the
generic code that handles the saving and restoring of both the option
and corresponding opts_set flag automatically, for other variables
(TargetSave, or Target without Save) the backend needs to do that in the
target hook manually and in that case should save/restore both the option
values (the hooks mostly did that) and opts_set (they didn't).

As it seems much easier to let the automatic saving/restoring do the work
for us unless the saving/restoring of the option needs some specific magic,
the following patch is a result of grepping through the backend for
opts_set->x_ and global_options_set.x_ and for all such referenced
variables, grepping whether it is saved/restored including opts_set properly
in the generated options-save.c or not.

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

	PR target/98585
	* config/i386/i386.opt (ix86_cmodel, ix86_incoming_stack_boundary_arg,
	ix86_pmode, ix86_preferred_stack_boundary_arg, ix86_regparm,
	ix86_veclibabi_type): Remove x_ prefix, use TargetVariable instead of
	TargetSave and initialize for variables with enum types.
	(mfentry, mstack-protector-guard-reg=, mstack-protector-guard-offset=,
	mstack-protector-guard-symbol=): Add Save.
	* config/i386/i386-options.c (ix86_function_specific_save,
	ix86_function_specific_restore): Don't save or restore x_ix86_cmodel,
	x_ix86_incoming_stack_boundary_arg, x_ix86_pmode,
	x_ix86_preferred_stack_boundary_arg, x_ix86_regparm,
	x_ix86_veclibabi_type.

	* gcc.target/i386/pr98585.c: New test.
2021-01-08 12:28:25 +01:00
Richard Sandiford
5fe3e6bf06 aarch64: Support unpacked CNOT on SVE
This patch adds unpacked support for unconditional and
conditional CNOT.  The type suffix has to be taken from
the element size rather than the container size.

gcc/
	* config/aarch64/aarch64-sve.md (*cnot<mode>): Extend from
	SVE_FULL_I to SVE_I.
	(*cond_cnot<mode>_2, *cond_cnot<mode>_any): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/cnot_2.c: New test.
	* gcc.target/aarch64/sve/cond_cnot_4.c: Likewise.
	* gcc.target/aarch64/sve/cond_cnot_4_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_cnot_5.c: Likewise.
	* gcc.target/aarch64/sve/cond_cnot_5_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_cnot_6.c: Likewise.
	* gcc.target/aarch64/sve/cond_cnot_6_run.c: Likewise.
2021-01-08 10:49:38 +00:00
Richard Sandiford
f3c5d1fa53 aarch64: Support conditional unpacked UXT on SVE
This patch extends the conditional UXT patterns from SVE_FULL_I
to SVE_I.  It doesn't matter in this case whether the type suffix
is taken from the element size or the container size.

gcc/
	* config/aarch64/aarch64-sve.md (*cond_uxt<mode>_2): Extend from
	SVE_FULL_I to SVE_I.
	(*cond_uxt<mode>_any): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/cond_uxt_5.c: New test.
	* gcc.target/aarch64/sve/cond_uxt_5_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_6.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_6_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_7.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_7_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_8.c: Likewise.
	* gcc.target/aarch64/sve/cond_uxt_8_run.c: Likewise.
2021-01-08 10:49:37 +00:00
Tamar Christina
07fb24a3da SVE2: Fix aarch64-sve2-acle-asm tests.
This fixes a logical inconsistency with the SVE2 ACLE tests where the SVE2 tests
are checking for SVE support in the assembler instead of SVE2.

This makes all these tests fail when the user has an SVE enabled assembler but
not an SVE2 one.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp
	(check_effective_target_aarch64_asm_sve2_ok): New.
	* g++.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp: Use it.
	* gcc.target/aarch64/sve2/acle/aarch64-sve2-acle-asm.exp: Likewise.
2021-01-08 10:45:23 +00:00
Kyrylo Tkachov
e811f10b61 aarch64: Reimplement most vpadal intrinsics using builtins
This patch reimplements most of the vpadal intrinsics to use RTL
builtins in the normal way.
The ones that aren't converted are the int32x2_t -> int64x1_t ones as
the RTL pattern doesn't currently handle
these modes. We don't have a V1DI mode so it would need to return a
DImode value or a V2DI one with the first lane
being the result. It's not hard to do, but it would require a bit more
refactoring so we can do it separately later.

This patch hopefully improves the status quo.

The new Vwhalf mode attribute is created because the existing Vwtype
attribute maps V8QI wrongly (for this pattern) to "8h" as the
suffix rather than "4h" as needed.

gcc/
	* config/aarch64/iterators.md (Vwhalf): New iterator.
	* config/aarch64/aarch64-simd.md (aarch64_<sur>adalp<mode>_3):
	Rename to...
	(aarch64_<sur>adalp<mode>): ... This.  Make more
	builtin-friendly.
	(<sur>sadv16qi): Adjust callsite of the above.
	* config/aarch64/aarch64-simd-builtins.def (sadalp, uadalp): New
	builtins.
	* config/aarch64/arm_neon.h (vpadal_s8): Reimplement using
	builtins.
	(vpadal_s16): Likewise.
	(vpadal_u8): Likewise.
	(vpadal_u16): Likewise.
	(vpadalq_s8): Likewise.
	(vpadalq_s16): Likewise.
	(vpadalq_s32): Likewise.
	(vpadalq_u8): Likewise.
	(vpadalq_u16): Likewise.
	(vpadalq_u32): Likewise.
2021-01-08 10:29:25 +00:00
Kyrylo Tkachov
79db5945ad aarch64: Reimplement vabd* intrinsics using builtins
This patch reimplements the vabd* intrinsics using RTL builtins.
It's fairly straightforward with new builtins + arm_neon.h changes.

gcc/
	* config/aarch64/aarch64-simd.md (aarch64_<su>abd<mode>_3):
	Rename to...
	(aarch64_<su>abd<mode>): ... This.
	(<sur>sadv16qi): Adjust callsite of the above.
	* config/aarch64/aarch64-simd-builtins.def (sabd, uabd): Define
	builtins.
	* config/aarch64/arm_neon.h (vabd_s8): Reimplement using
	builtin.
	(vabd_s16): Likewise.
	(vabd_s32): Likewise.
	(vabd_u8): Likewise.
	(vabd_u16): Likewise.
	(vabd_u32): Likewise.
	(vabdq_s8): Likewise.
	(vabdq_s16): Likewise.
	(vabdq_s32): Likewise.
	(vabdq_u8): Likewise.
	(vabdq_u16): Likewise.
	(vabdq_u32): Likewise.
2021-01-08 10:29:25 +00:00
Kyrylo Tkachov
cab822d4ea aarch64: Reimplement vaba* intrinsics using builtins
This patch reimplements the vaba* arm_neon.h intrinsics using RTL
builtins that expand to proper RTL patterns
rather than using inline asm.
The implementation is fairly straightforward by defining new builtins
and using them in the header.

gcc/
	* config/aarch64/aarch64-simd-builtins.def (saba, uaba): Define
	builtins.
	* config/aarch64/arm_neon.h (vaba_s8): Implement using builtin.
	(vaba_s16): Likewise.
	(vaba_s32): Likewise.
	(vaba_u8): Likewise.
	(vaba_u16): Likewise.
	(vaba_u32): Likewise.
	(vabaq_s8): Likewise.
	(vabaq_s16): Likewise.
	(vabaq_s32): Likewise.
	(vabaq_u8): Likewise.
	(vabaq_u16): Likewise.
	(vabaq_u32): Likewise.
2021-01-08 10:29:25 +00:00
Kyrylo Tkachov
c9d25aa748 aarch64: Fix RTL patterns for UABA/SABA
Sometime ago we changed the RTL representation of the (SU)ABD
instructions in RTL to a (MINUS (MAX) (MIN)) rather than a (MINUS (ABS) (ABS))
as it is more correctly models the semantics.
We should do the same for the accumulation forms of these instructions:
UABA/SABA.

This patch does that and allows the new pattern to generate the unsigned
UABA form as well.
The new form also allows it to more easily be re-used to implement the
relevant arm_neon.h intrinsics in the future.

The testcase takes an -fno-tree-reassoc to work around a side-effect of
PR98581.

gcc/
	* config/aarch64/aarch64-simd.md (aba<mode>_3): Rename to...
	(aarch64_<su>aba<mode>): ... This.  Handle uaba as well.
	Change RTL pattern to match.

gcc/testsuite/
	* gcc.target/aarch64/usaba_1.c: New test.
2021-01-08 10:29:25 +00:00
Paul Thomas
21c1a30fc7 Fortran: Allow pointer deferred length associate selectors. [PR93794]
2021-01-05  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/93794
	* trans-expr.c (gfc_conv_component_ref): Remove the condition
	that deferred character length components only be allocatable.

gcc/testsuite/
	PR fortran/93794
	* gfortran.dg/deferred_character_35.f90 : New test.
2021-01-08 10:15:22 +00:00
Paul Thomas
c231fca5de Fortran:Fix simplification of constructors with implied-do [PR98458]
2021-01-08  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/98458
	* simplify.c (is_constant_array_expr): If an array constructor
	expression has elements other than constants or structures, try
	fixing the expression with gfc_reduce_init_expr. Also, if shape
	is NULL, obtain the array size and set it.

gcc/testsuite/
	PR fortran/98458
	* gfortran.dg/implied_do_3.f90 : New test.
2021-01-08 10:11:00 +00:00
Kito Cheng
01d92cfd79 Fix array-quals-1.c for RISC-V
RISC-V will put those variable on srodata rather than rodata.

gcc/testsuite/ChangeLog:

	* gcc.dg/array-quals-1.c: Allow srodata.
2021-01-08 11:14:03 +08:00
Kito Cheng
e3354b6de7 RISC-V: Implement new style of architecture extension test macros.
- This patch introduce new set of architecture extension test macros
  which is accept on riscv-c-api-doc recently.
  - https://github.com/riscv/riscv-c-api-doc/blob/master/riscv-c-api.md#architecture-extension-test-macro

- We will also mark deprecated for legacy architecture extension test macros
  in GCC 11, but still support that for 1 or 2 release cycles.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.c (riscv_current_subset_list): New.
	* config/riscv/riscv-c.c (riscv-subset.h): New.
	(INCLUDE_STRING): Define.
	(riscv_cpu_cpp_builtins): Add new style architecture extension
	test macros.
	* config/riscv/riscv-subset.h (riscv_subset_list::begin): New.
	(riscv_subset_list::end): New.
	(riscv_current_subset_list): New.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/predef-10.c: New.
	* gcc.target/riscv/predef-11.c: New.
	* gcc.target/riscv/predef-12.c: New.
	* gcc.target/riscv/predef-13.c: New.
2021-01-08 11:14:02 +08:00
Kito Cheng
0b7b471011 RISC-V: Move class riscv_subset_list and riscv_subset_t to riscv-protos.h
Pre-work of new style of architecture extension test macros, we need the
list used in `config/riscv/riscv-c.c`, so those struct/class declaration
must move to header file rather than local C file.

gcc/ChangeLog

	* common/config/riscv/riscv-common.c (RISCV_DONT_CARE_VERSION):
	Move to riscv-subset.h.
	(struct riscv_subset_t): Ditto.
	(class riscv_subset_list): Ditto.
	* config/riscv/riscv-subset.h (RISCV_DONT_CARE_VERSION): Move
	from riscv-common.c.
	(struct riscv_subset_t): Ditto.
	(class riscv_subset_list): Ditto.
	* config/riscv/t-riscv ($(common_out_file)): Add file
	dependency.
2021-01-08 11:14:02 +08:00
GCC Administrator
7d187e4f6f Daily bump. 2021-01-08 00:16:23 +00:00
Jakub Jelinek
aa4db31dd2 c++: Fix up tsubst of BIT_CAST_EXPR [PR98329]
As the testcase shows, calling cp_build_bit_cast in tsubst_copy doesn't seem
to be a good idea, because tsubst_copy might not really make the operand
non-dependent, but as processing_template_decl can be 0,
type_dependent_expression_p will return false and then cp_build_bit_cast
assumes the type is non-NULL and non-dependent.
So, this patch just follows what is done e.g. for NOP_EXPR etc. and just
builds some tree in tsubst_copy, and only calls the semantics.c function
from tsubst_copy_and_build.

2021-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98329
	* pt.c (tsubst_copy) <case BIT_CAST_EXPR>: Don't call
	cp_build_bit_cast here, instead just build_min a BIT_CAST_EXPR and set
	its location.
	(tsubst_copy_and_build): Handle BIT_CAST_EXPR.

	* g++.dg/cpp2a/bit-cast10.C: New test.
2021-01-07 23:00:28 +01:00
Martin Sebor
178f0afce3 PR middle-end/98578 - ICE warning on uninitialized VLA access
gcc/c-family/ChangeLog:

	PR middle-end/98578
	* c-pretty-print.c (print_mem_ref): Strip array from access type.
	Avoid assuming acces type's size is constant.  Correct condition
	guarding the printing of a parenthesis.

gcc/testsuite/ChangeLog:

	PR middle-end/98578
	* gcc.dg/plugin/gil-1.c: Adjust expected output.
	* gcc.dg/uninit-pr98578.c: New test.
2021-01-07 14:22:28 -07:00
Marek Polacek
2f359597e4 c++: Fix thinko in auto return type checking [PR98441]
This fixes a thinko in my r11-2085 patch: when I said "But only give the
!late_return_type errors when funcdecl_p, to accept e.g. auto (*fp)() = f;
in C++11" I should've done this, otherwise we give bogus errors mentioning
"function with trailing return type" when there is none.

gcc/cp/ChangeLog:

	PR c++/98441
	* decl.c (grokdeclarator): Move the !funcdecl_p check inside the
	!late_return_type block.

gcc/testsuite/ChangeLog:

	PR c++/98441
	* g++.dg/cpp0x/auto55.C: New test.
2021-01-07 16:19:29 -05:00
Jason Merrill
6c59b8a93c c++: Add TARGET_EXPR comments
Discussing the 98469 patch and class prvalues with Jakub led me to
double-check our handling of TARGET_EXPR in constexpr.c, and add a note
about why we don't strip them in parameter initialization.  And another to
clarify that we're handling an INIT_EXPR in a place we do strip them.

gcc/cp/ChangeLog:

	* constexpr.c (cxx_bind_parameters_in_call): Add comment.
	(cxx_eval_store_expression): Add comment.
2021-01-07 16:09:11 -05:00
Jason Merrill
4d65a07d54 c++: Add some conversion sanity checking.
Another change I was working on revealed that for complex numbers we were
building a ck_identity with build_conv, leading to the wrong active member
in the union being set.  Rather than add another enumeration of the
appropriate conversion codes, I factored that out.

gcc/cp/ChangeLog:

	* call.c (has_next): Factor out from...
	(next_conversion): ...here.
	(strip_standard_conversion): And here.
	(is_subseq): And here.
	(build_conv): Check it.
	(standard_conversion): Don't call build_conv
	for ck_identity.
2021-01-07 16:05:09 -05:00
Thomas Rodgers
b7c3f201be libstdc++: Add support for C++20 barriers
Adds <barrier>

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Add new header.
	* include/Makefile.am (std_headers): likewise.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add new header.
	* include/std/barrier: New file.
	* include/std/version: Add __cpp_lib_barrier feature test macro.
	* testsuite/30_threads/barrier/1.cc: New test.
	* testsuite/30_threads/barrier/2.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_drop.cc: Likewise.
	* testsuite/30_threads/barrier/arrive_and_wait.cc: Likewise.
	* testsuite/30_threads/barrier/arrive.cc: Likewise.
	* testsuite/30_threads/barrier/completion.cc: Likewise.
2021-01-07 12:52:37 -08:00
David Malcolm
0677759f75 analyzer: fix ICE when DECL_INITIAL is error_mark_node [PR98580]
lto-streamer-out.c's get_symbol_initial_value can return error_mark_node
rather than DECL_INITIAL as an optimization to avoid extra sections for
simple scalar values.

Add a check to the analyzer to handle such cases gracefully.

gcc/analyzer/ChangeLog:
	PR analyzer/98580
	* region.cc (decl_region::get_svalue_for_initializer): Gracefully
	handle when LTO writes out DECL_INITIAL as error_mark_node.

gcc/testsuite/ChangeLog:
	PR analyzer/98580
	* gcc.dg/analyzer/pr98580-a.c: New test.
	* gcc.dg/analyzer/pr98580-b.c: New test.
2021-01-07 15:45:29 -05:00
Ian Lance Taylor
b87ec922c4 test: add new Go tests from source repo 2021-01-07 11:02:17 -08:00
Joseph Myers
c8d2ed112e Update cpplib es.po.
* es.po: Update.
2021-01-07 17:54:39 +00:00
Patrick Palka
19f3c433cd libstdc++: Fix long double to_chars testcase [PR98384]
The testcase was failing to compile on some targets due to its use of
the non-standard functions nextupl and nextdownl.  This patch makes the
testcase instead use the C99 function nexttowardl in an equivalent way.

libstdc++-v3/ChangeLog:

	PR libstdc++/98384
	* testsuite/20_util/to_chars/long_double.cc: Use nexttowardl
	instead of the non-standard nextupl and nextdownl.
2021-01-07 12:41:14 -05:00
Paul Thomas
85fb1d7d5f Fortran: Improve resolution of associate variables. [PR93701].
2021-01-07  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
	PR fortran/93701
	* resolve.c (find_array_spec): Put static prototype for
	resolve_assoc_var before this function and call for associate
	variables.

gcc/testsuite/
	PR fortran/93701
	* gfortran.dg/associate_54.f90: New test.
	* gfortran.dg/associate_55.f90: New test.
	* gfortran.dg/associate_56.f90: New test.
2021-01-07 17:34:49 +00:00
Iain Buclaw
dddea6d4d8 d: Merge upstream dmd 9038e64c5.
Adds support for using user-defined attributes on function arguments and
single-parameter alias declarations.  These attributes behave analogous
to existing UDAs.

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd 9038e64c5.
	* d-builtins.cc (build_frontend_type): Update call to
	Parameter::create.
2021-01-07 18:22:36 +01:00
Richard Biener
d54029179c fix GIMPLE parser for loops
We do not tolerate "growing" a vector to a lower size.

2021-01-07  Richard Biener  <rguenther@suse.de>

gcc/c/
	* gimple-parser.c (c_parser_gimple_compound_statement): Only
	reallocate loop array if it is too small.
2021-01-07 17:36:25 +01:00
Jakub Jelinek
6bca2ebf10 i386: Optimize blsi followed by comparison [PR98567]
The BLSI instruction sets SF and ZF based on the result and clears OF.
CF is set to something unrelated.

The following patch optimizes BLSI followed by comparison, so we don't need
to emit a TEST insn in between.

2021-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/98567
	* config/i386/i386.md (*bmi_blsi_<mode>_cmp, *bmi_blsi_<mode>_ccno):
	New define_insn patterns.

	* gcc.target/i386/pr98567-1.c: New test.
	* gcc.target/i386/pr98567-2.c: New test.
2021-01-07 17:18:58 +01:00
Richard Sandiford
0f9d2c1a31 aarch64: Support conditional unpacked integer unary arithmetic on SVE
This patch extends the conditional unary integer operations
from SVE_FULL_I to SVE_I.  In each case the type suffix is
taken from the element size rather than the container size:
this matters for ABS and NEG, but doesn't matter for NOT.

gcc/
	* config/aarch64/aarch64-sve.md (@cond_<SVE_INT_UNARY:optab><mode>)
	(*cond_<SVE_INT_UNARY:optab><mode>_2): Extend from SVE_FULL_I to SVE_I.
	(*cond_<SVE_INT_UNARY:optab><mode>_any): Likewise.

gcc/testsuite/
	* gcc.target/aarch64/sve/cond_unary_5.c: New test.
	* gcc.target/aarch64/sve/cond_unary_5_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_6.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_6_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_7.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_7_run.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_8.c: Likewise.
	* gcc.target/aarch64/sve/cond_unary_8_run.c: Likewise.
2021-01-07 15:00:39 +00:00
Richard Sandiford
298e76e656 gimple-isel: Check whether IFN_VCONDEQ is supported [PR98560]
This patch follows on from the previous one for the PR and
makes sure that we can handle == as well as <.  Previously
we assumed without checking that IFN_VCONDEQ was available
if IFN_VCOND or IFN_VCONDU wasn't.

The patch also fixes the definition of the IFN_VCOND* functions.
The optabs are convert optabs in which the first mode is the
data mode and the second mode is the comparison or mask mode.

gcc/
	PR tree-optimization/98560
	* internal-fn.def (IFN_VCONDU, IFN_VCONDEQ): Use type vec_cond.
	* internal-fn.c (vec_cond_mask_direct): Get the data mode from
	argument 1.
	(vec_cond_direct): Likewise argument 2.
	(vec_condu_direct, vec_condeq_direct): Delete.
	(expand_vect_cond_optab_fn): Rename to...
	(expand_vec_cond_optab_fn): ...this, replacing old macro.
	(expand_vec_condu_optab_fn, expand_vec_condeq_optab_fn): Delete.
	(expand_vect_cond_mask_optab_fn): Rename to...
	(expand_vec_cond_mask_optab_fn): ...this, replacing old macro.
	(direct_vec_cond_mask_optab_supported_p): Treat the optab as a
	convert optab.
	(direct_vec_cond_optab_supported_p): Likewise.
	(direct_vec_condu_optab_supported_p): Delete.
	(direct_vec_condeq_optab_supported_p): Delete.
	* gimple-isel.cc: Include internal-fn.h.
	(gimple_expand_vec_cond_expr): Check that IFN_VCONDEQ is supported
	before using it.

gcc/testsuite/
	PR tree-optimization/98560
	* gcc.dg/vect/pr98560-2.c: New test.
2021-01-07 15:00:39 +00:00
Richard Sandiford
78595e918e gimple-isel: Fall back to using vcond_mask [PR98560]
PR98560 is about a case in which the vectoriser initially generates:

  mask_1 = a < 0;
  mask_2 = mask_1 & ...;
  res = VEC_COND_EXPR <mask_2, b, c>;

The vectoriser thus expects res to be calculated using vcond_mask.
However, we later manage to fold mask_2 to mask_1, leaving:

  mask_1 = a < 0;
  res = VEC_COND_EXPR <mask_1, b, c>;

gimple-isel then required a combined vcond to exist.

On most targets, it's not too onerous to provide all possible
(compare x select) combinations.  For each data mode, you just
need to provide unsigned comparisons, signed comparisons, and
floating-point comparisons, with the data mode and type of
comparison uniquely determining the mode of the compared values.
But for targets like SVE that support “unpacked” vectors,
it's not that simple: the level of unpacking adds another
degree of freedom.

Rather than insist that the combined versions exist, I think
we should be prepared to fall back to using separate comparisons
and vcond_masks.  I think that makes more sense on targets like
AArch64 and AArch32 in which compares and selects are fundementally
separate operations anyway.

gcc/
	PR tree-optimization/98560
	* gimple-isel.cc (gimple_expand_vec_cond_expr): If we fail to use
	IFN_VCOND{,U,EQ}, fall back on IFN_VCOND_MASK.

gcc/testsuite/
	PR tree-optimization/98560
	* gcc.dg/vect/pr98560-1.c: New test.
2021-01-07 15:00:38 +00:00
Uros Bizjak
d54be5ad21 i386: Merge various insn name mapping code attributes
2021-01-07  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	* config/i386/i386.md (insn): Merge from plusminus_insn, shift_insn,
	rotate_insn and optab code attributes.
	Update all uses to merged code attribute.
	* config/i386/sse.md: Update all uses to merged code attribute.
	* config/i386/mmx.md: Update all uses to merged code attribute.
2021-01-07 14:39:55 +01:00
Jakub Jelinek
d02a8b63e5 bswap: Fix up recent vector CONSTRUCTOR optimization [PR98568]
As the testcase shows, bswap can match even byte-swapping or indentity
from low part of some wider SSA_NAME.
For bswap replacement other than for vector CONSTRUCTOR the code has been
using NOP_EXPR casts if the types weren't compatible, but for vectors
we need to use VIEW_CONVERT_EXPR.  The problem with the latter is that
we require that it has the same size, which isn't guaranteed, so this patch
in those cases first adds a narrowing NOP_EXPR cast and only afterwards
does a VIEW_CONVERT_EXPR.

2021-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98568
	* gimple-ssa-store-merging.c (bswap_view_convert): New function.
	(bswap_replace): Use it.

	* g++.dg/torture/pr98568.C: New test.
2021-01-07 09:57:40 +01:00
Hongyu Wang
1b56697524 Adjust testcase for PR 92658
gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr92658-avx512bw.c: Add
	-mprefer-vector-width=512 to avoid impact of different default
	mtune which gcc is built with.
	* gcc.target/i386/pr92658-avx512bw-2.c: Ditto.
2021-01-07 14:33:49 +08:00
David Malcolm
be6c485b24 analyzer: fix false leak reports when merging states [PR97074]
gcc/analyzer/ChangeLog:
	PR analyzer/97074
	* store.cc (binding_cluster::can_merge_p): Add "out_store" param
	and pass to calls to binding_cluster::make_unknown_relative_to.
	(binding_cluster::make_unknown_relative_to): Add "out_store"
	param.  Use it to mark base regions that are pointed to by
	pointers that become unknown as having escaped.
	(store::can_merge_p): Pass out_store to
	binding_cluster::can_merge_p.
	* store.h (binding_cluster::can_merge_p): Add "out_store" param.
	(binding_cluster::make_unknown_relative_to): Likewise.
	* svalue.cc (region_svalue::implicitly_live_p): New vfunc.
	* svalue.h (region_svalue::implicitly_live_p): New vfunc decl.

gcc/testsuite/ChangeLog:
	PR analyzer/97074
	* gcc.dg/analyzer/pr97074.c: New test.
2021-01-06 21:44:07 -05:00
David Malcolm
cffe6dd2ce analyzer: fix missing bitmap_clear [PR98564]
gcc/analyzer/ChangeLog:
	PR analyzer/98564
	* engine.cc (exploded_path::feasible_p): Add missing call to
	bitmap_clear.

gcc/testsuite/ChangeLog:
	PR analyzer/98564
	* gcc.dg/analyzer/pr98564.c: New test.
2021-01-06 21:42:56 -05:00
GCC Administrator
942ae5be66 Daily bump. 2021-01-07 00:16:19 +00:00
Nick Alcock
f05bbca3d9 sync libctf toplevel from binutils-gdb
This pulls in the toplevel portions of these binutils-gdb commits:

   1ff6de031241c59d0ff bfd, ld: add CTF section linking
   87279e3cef5b2c54f4a libctf: installable libctf as a shared library
   c59e30ed1727135f8ef libctf: new testsuite

	* Makefile.def: Sync with binutils-gdb:
	(dependencies): all-ld depends on all-libctf.
	(host_modules): libctf is no longer no_install.
	No longer no_check.  Checking depends on all-ld.
	* Makefile.in: Regenerated.
2021-01-07 09:28:58 +10:30
Vladimir N. Makarov
15a47f437d [PR97978] LRA: Permit temporary allocation incorrectness after hard reg split.
LRA can crash when a hard register was split and the same hard register
was assigned on the previous assignment sub-pass.  The following
patch fixes this problem.

gcc/ChangeLog:

	PR rtl-optimization/97978
	* lra-int.h (lra_hard_reg_split_p): New external.
	* lra.c (lra_hard_reg_split_p): New global.
	(lra): Set up lra_hard_reg_split_p after splitting a hard reg.
	* lra-assigns.c (lra_assign): Don't check allocation correctness
	after hard reg splitting.

gcc/testsuite/ChangeLog:

	PR rtl-optimization/97978
	* gcc.target/i386/pr97978.c: New.
2021-01-06 16:13:30 -05:00
Martin Sebor
abb1b6058c PR c++/95768 - pretty-printer ICE on -Wuninitialized with allocated storage
gcc/c-family/ChangeLog:

	PR c++/95768
	* c-pretty-print.c (c_pretty_printer::primary_expression): For
	SSA_NAMEs print VLA names and GIMPLE defining statements.
	(print_mem_ref): New function.
	(c_pretty_printer::unary_expression): Call it.

gcc/cp/ChangeLog:

	PR c++/95768
	* error.c (dump_expr): Call c_pretty_printer::unary_expression.

gcc/testsuite/ChangeLog:

	PR c++/95768
	* g++.dg/pr95768.C: New test.
	* g++.dg/warn/Wuninitialized-12.C: New test.
	* gcc.dg/uninit-38.c: New test.
2021-01-06 13:44:27 -07:00
Martin Sebor
fd64f348a6 PR c++/98305 spurious -Wmismatched-new-delete on template instance
gcc/ChangeLog:

	PR c++/98305
	* builtins.c (new_delete_mismatch_p): New overload.
	(new_delete_mismatch_p (tree, tree)): Call it.

gcc/testsuite/ChangeLog:

	PR c++/98305
	* g++.dg/warn/Wmismatched-new-delete-3.C: New test.
2021-01-06 13:36:18 -07:00
Iain Sandoe
334a295faf testsuite, coroutines : Fix a bad testcase [PR96504].
Where possible (i.e. where that doesn't alter the intent of a test) we
use a suspend_always as the final suspend and a test that the coroutine
was 'done' to check that the state machine had terminated correctly.

Sometimes, filed PRs have 'suspend_never' as the final suspend expression
and that needs to be changed to match the testsuite style.  This is one
I missed and means that the call to 'done()' on the handle is made to an
already-destructed coroutine.  Surprisngly, thAt  didn't actually trigger
a failure until glibc 2-32.

Fixed by changing the final suspend to be 'suspend_always'.

gcc/testsuite/ChangeLog:

	PR c++/96504
	* g++.dg/coroutines/torture/pr95519-05-gro.C: Use suspend_always
	as the final suspend point so that we can check that the state
	machine has reached the expected point.
2021-01-06 19:58:10 +00:00
Harald Anlauf
8b6f1e8f97 PR fortran/78746 - invalid access after error recovery
The error recovery after an invalid reference to an undefined CLASS
during a TYPE declaration lead to an invalid access.  Add a check.

gcc/fortran/ChangeLog:

	* resolve.c (resolve_component): Add check for valid CLASS
	reference before trying to access CLASS data.
2021-01-06 19:37:11 +01:00
Marek Polacek
e6a5daae7e c++: Fix g++.dg/warn/Wmismatched-dealloc.C for C++11 [PR98566]
C++ sized deallocation only came in C++14, so this test wasn't
working properly in C++11, which isn't tested by default.  Fixed
thus by constraining the dg-errors to C++14 only.

gcc/testsuite/ChangeLog:

	PR testsuite/98566
	* g++.dg/warn/Wmismatched-dealloc.C: Use target c++14 in
	dg-error.
2021-01-06 12:16:05 -05:00
John David Anglin
6d0b075d66 Fix libcody build on hppa*-*-hpux11.11.
2021-01-06  John David Anglin  <danglin@gcc.gnu.org>

libcody/ChangeLog:

	PR bootstrap/98506
	* resolver.cc: Only use fstatat when _POSIX_C_SOURCE >= 200809L.
2021-01-06 13:58:56 +00:00
Alexandre Oliva
758abf1ae3 add alignment to enable store merging in strict-alignment targets
In g++.dg/opt/store-merging-2.C, the natural alignment of types T and
S is a single byte, so we shouldn't expect store merging on
strict-alignment platforms.  Indeed, without something like the
adjust-alignment pass to bump up the alignment of the automatic
variable, as in GCC 10, the optimization does not occur.

This patch adjusts the test so that the required alignment is
expressly stated, and so we don't rely on its accidentally being there
to get the desired optimization.


for  gcc/testsuite/ChangeLog

	* g++.dg/opt/store-merging-2.C: Add the required alignment.
2021-01-06 08:05:40 -03:00
Alexandre Oliva
cecf8c662d robustify vxworks glimits.h overriding
The glimits.h overriding used in gcc/config/t-vxworks was fragile: the
intermediate file would already be there in a rebuild, and so the
adjustments would not be made, so the generated limits.h would miss
them, causing limits-width-[12] tests to fail on that target.

While changing it, I also replaced the modern $(cmd) shell syntax with
the more portable `cmd` construct.


for  gcc/ChangeLog

	* Makefile.in (T_GLIMITS_H): New.
	(stmp-int-hdrs): Depend on it, use it.
	* config/t-vxworks (T_GLIMITS_H): Override it.
	(vxw-glimits.h): New.
2021-01-06 08:05:35 -03:00
Richard Biener
c9ee9c1e35 add signed_bool_precision attribute for GIMPLE FE use
This adds __attribute__((signed_bool_precision(precision))) to be able
to construct nonstandard boolean types which for the included testcase
is needed to simulate Ada and LTO interaction (Ada uses a 8 bit
precision boolean_type_node).  This will also be useful for vector
unit testcases where we need to produce vector types with
non-standard precision signed boolean type components.

2021-01-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/95582
gcc/c-family/
	* c-attribs.c (c_common_attribute_table): Add entry for
	signed_bool_precision.
	(handle_signed_bool_precision_attribute): New.

gcc/testsuite/
	* gcc.dg/pr95582.c: New testcase.
2021-01-06 09:33:41 +01:00
Richard Biener
a05cc70a6c tree-optimization/98513 - fix bug in range intersection code
This fixes a premature optimization in the range intersection code
which assumes earlier branches have to be taken, not taking into
account that for symbolic ranges we cannot always compare endpoints.
The fix is to instantiate the compare deemed redundant (which then
fails as undecidable for the testcase).

2021-01-06  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98513
	* value-range.cc (intersect_ranges): Compare the upper bounds
	for the expected relation.

	* gcc.dg/tree-ssa/pr98513.c: New testcase.
2021-01-06 09:33:37 +01:00
Martin Liska
57706dd7e0 gcc-changelog: workaround for utf8 filenames
contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Add decode_path function.
	* gcc-changelog/git_email.py: Use it in order to solve
	utf8 encoding filename issues.
	* gcc-changelog/git_repository.py: Likewise.
	* gcc-changelog/test_email.py: Test it.
2021-01-06 08:26:10 +01:00
David Malcolm
ac3966e315 analyzer: fix false leaks when writing through unknown ptrs [PR97072]
gcc/analyzer/ChangeLog:
	PR analyzer/97072
	* region-model-reachability.cc (reachable_regions::init_cluster):
	Convert symbolic region handling to a switch statement.  Add cases
	to handle SK_UNKNOWN and SK_CONJURED.

gcc/testsuite/ChangeLog:
	PR analyzer/97072
	* gcc.dg/analyzer/pr97072.c: New test.
2021-01-05 20:54:50 -05:00
David Malcolm
23fc2be633 analyzer: add regression test for PR 98073
This ICE was fixed by r11-2694-g808f4dfeb3a95f50 (aka the big state
rewrite for GCC 11).

gcc/testsuite/ChangeLog:
	PR analyzer/98073
	* gcc.dg/analyzer/pr98073.c: New test.
2021-01-05 20:53:40 -05:00
David Malcolm
df1eba3cea analyzer: remove xfail [PR98223]
The bogus leak message went away after
fcae512115 (aka "Hybrid EVRP and
testcases") due to that patch improving a phi node in the gimple input
to the analyzer.

gcc/testsuite/ChangeLog:
	PR analyzer/98223
	* gcc.dg/analyzer/pr94851-1.c: Remove xfail.
2021-01-05 20:51:50 -05:00
GCC Administrator
651b8a50a6 Daily bump. 2021-01-06 00:16:55 +00:00
Gerald Pfeifer
ad92bf4b16 doc: Re-add HSAIL to Language Standards
The HSAIL web server has reappeared after weeks, so restore the standard
reference for now while we consider further deprecation.

This reverts commit 7e999bd84f.

gcc/
2021-01-06  Gerald Pfeifer  <gerald@pfeifer.com>

	Revert:
	2020-12-28  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/standards.texi (HSAIL): Remove section.
2021-01-06 01:01:41 +01:00
Samuel Thibault
f56de3557f Update GNU/Hurd configure support
ChangeLog:

	* libtool.m4: Match gnu* along other GNU systems.
	* libgo/config/libtool.m4: Match gnu* along other GNU systems.
	* libgo/configure: Re-generate.

libffi/
	* configure: Re-generate.

libgomp/
	* configure: Re-generate.

gcc/

	* configure: Re-generate.

libatomic/

	* configure: Re-generate.

libbacktrace/

	* configure: Re-generate.

libcc1/

	* configure: Re-generate.

libgfortran/

	* configure: Re-generate.

libgomp/

	* configure: Re-generate.

libhsail-rt/

	* configure: Re-generate.

libitm/

	* configure: Re-generate.

libobjc/

	* configure: Re-generate.

liboffloadmic/

	* configure: Re-generate.
	* plugin/configure: Re-generate.

libphobos/

	* configure: Re-generate.

libquadmath/

	* configure: Re-generate.

libsanitizer/

	* configure: Re-generate.

libssp/

	* configure: Re-generate.

libstdc++-v3/

	* configure: Re-generate.

libvtv/

	* configure: Re-generate.

lto-plugin/

	* configure: Re-generate.

zlib/

	* configure: Re-generate.
2021-01-05 16:04:14 -07:00
Ilya Leoshkevich
c21f47f401 IBM Z: Fix check_effective_target_s390_z14_hw
Commit 2f473f4b06 ("IBM Z: Do not run long double tests on old
machines") introduced a predicate for tests that must run only on z14+.
However, due to a syntax error, the predicate always returns false.

gcc/testsuite/ChangeLog:

2020-12-10  Ilya Leoshkevich  <iii@linux.ibm.com>

	* gcc.target/s390/s390.exp: Replace %% with %.
2021-01-05 23:53:20 +01:00
Steve Kargl
e591f18ff8 xfail test that will never pass on i?86 FreeBSD
gcc/testsuite
	* gfortran.dg/dec_math.f90: xfail on i?86-*-freebsd*
2021-01-05 15:43:23 -07:00
Ian Lance Taylor
f47c00cf95 syscall: don't define sys_SETREUID and friends
We don't use them, since we always call the C library functions which do
the right thing anyhow.  And they aren't defined on all GNU/Linux variants.

Fixes PR go/98510

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281473
2021-01-05 13:53:13 -08:00
Ian Lance Taylor
a9f76d03bb internal/cpu: more build fixes for Go1.16beta1 release
Some files were missing from the libgo copy of internal/cpu, because they
used to only declare CacheLinePadSize which libgo gets from goarch.sh.
Now they also declare doinit, so copy them over.  Adjust cpu_other.go.

Fix the amd64p32 build by adding a build constraint to cpu_no_name.go.

Fixes PR go/98493

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281472
2021-01-05 13:48:59 -08:00
Jakub Jelinek
db7ce388dc doc: reflect the publication of C++20 in invoke.texi and standards.texi
Jonathan mentioned on IRC that ISO/IEC 14882:2020 has been published
yesterday (and indeed it appears on www.iso.org for sale).
I think we should reflect that in our documentation and in cxx-status.html,
patches attached.
I understand we want to keep C++20 support experimental even in GCC 11,
though not sure if we should still talk about "almost certainly change in
incompatible ways" rather than that it might change in incompatible ways.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	* doc/invoke.texi (-std=c++20): Adjust for the publication of
	ISO 14882:2020 standard.
	* doc/standards.texi: Likewise.
2021-01-05 22:43:13 +01:00
Iain Buclaw
c5e94699ef d: Merge upstream dmd a5c86f5b9
Adds the following new `__traits' to the D language.

 - isDeprecated: used to detect if a function is deprecated.

 - isDisabled: used to detect if a function is marked with @disable.

 - isFuture: used to detect if a function is marked with @__future.

 - isModule: used to detect if a given symbol represents a module, this
   enhancement also adds support using `is(sym == module)'.

 - isPackage: used to detect if a given symbol represents a package,
   this enhancement also adds support using `is(sym == package)'.

 - child: takes two arguments.  The first must be a symbol or expression
   and the second must be a symbol, such as an alias to a member of the
   first 'parent' argument.  The result is the second 'member' argument
   interpreted with its 'this' context set to 'parent'.  This is the
   inverse of `__traits(parent, member)'.

 - isReturnOnStack: determines if a function's return value is placed on
   the stack, or is returned via registers.

 - isZeroInit: used to detect if a type's default initializer has no
   non-zero bits.

 - getTargetInfo: used to query features of the target being compiled
   for, the back-end can expand this to register any key to handle the
   given argument, however a reliable subset exists which includes
   "cppRuntimeLibrary", "cppStd", "floatAbi", and "objectFormat".

 - getLocation: returns a tuple whose entries correspond to the
   filename, line number, and column number of where the argument was
   declared.

 - hasPostblit: used to detect if a type is a struct with a postblit.

 - isCopyable: used to detect if a type allows copying its value.

 - getVisibility: an alias for the getProtection trait.

Reviewed-on: https://github.com/dlang/dmd/pull/12093

gcc/d/ChangeLog:

	* dmd/MERGE: Merge upstream dmd a5c86f5b9.
	* d-builtins.cc (d_eval_constant_expression): Handle ADDR_EXPR trees
	created by build_string_literal.
	* d-frontend.cc (retStyle): Remove function.
	* d-target.cc (d_language_target_info): New variable.
	(d_target_info_table): Likewise.
	(Target::_init): Initialize d_target_info_table.
	(Target::isReturnOnStack): New function.
	(d_add_target_info_handlers): Likewise.
	(d_handle_target_cpp_std): Likewise.
	(d_handle_target_cpp_runtime_library): Likewise.
	(Target::getTargetInfo): Likewise.
	* d-target.h (struct d_target_info_spec): New type.
	(d_add_target_info_handlers): Declare.
2021-01-05 22:09:10 +01:00
Ed Smith-Rowland
ae1ada95fe Add <source_location> to the precompiled header.
2021-01-05  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* include/precompiled/stdc++.h: Add <source_location> to C++20 section.
2021-01-05 15:50:06 -05:00
H.J. Lu
f6dd35cf93 x86: Use unsigned short to compute pextrw result
Use unsigned short to compute the zero-extended pextrw result.

	PR target/98495
	* gcc.target/i386/sse2-mmx-pextrw.c (compute_correct_result): Use
	unsigned short to compute pextrw result.
2021-01-05 11:03:38 -08:00
Patrick Palka
e2e2f3f2c9 c++: Fix deduction from the type of an NTTP
In the testcase nontype-auto17.C below, the calls to f and g are invalid
because neither deduction nor defaulting of the template parameter T
yields a valid specialization.  Deducing T doesn't work because T is
used only in a non-deduced context, and defaulting T doesn't work
because its default argument makes the type of M invalid.

But with -std=c++17 or later, we incorrectly accept both calls.
Starting with C++17 (specifically P0127R2), during deduction we're
allowed to try to deduce T from the argument '42' that's been
tentatively deduced for M.  The problem is that when unify walks into
the type of M (a TYPENAME_TYPE), it immediately gives up without
performing any new unifications (so the type of M is still unknown) --
and then we go on to unify M with '42' anyway.  Later in
type_unification_real, we complete the template argument vector using
T's default template argument, and end up forming the bogus
specializations f<void, 42> and g<S, 42>.

This patch fixes this issue by checking whether the type of an NTTP is
still dependent after walking into its type during unification.  If it
is, it means we couldn't deduce all the template parameters used in its
type, and so we shouldn't yet unify the NTTP.

(The new testcase ttp33.C demonstrates the need for the TEMPLATE_PARM_LEVEL
check; without it, we would ICE on this testcase from the call to tsubst.)

gcc/cp/ChangeLog:

	* pt.c (unify) <case TEMPLATE_PARM_INDEX>: After walking into
	the type of the NTTP, substitute into the type again.  If the
	type is still dependent, don't unify the NTTP.

gcc/testsuite/ChangeLog:

	* g++.dg/template/partial5.C: Adjust directives to expect the
	same errors across all dialects.
	* g++.dg/cpp1z/nontype-auto17.C: New test.
	* g++.dg/cpp1z/nontype-auto18.C: New test.
	* g++.dg/template/ttp33.C: New test.
2021-01-05 13:36:26 -05:00
Jakub Jelinek
5de7bf5bc9 expand: Fold x - y < 0 to x < y during expansion [PR94802]
My earlier patch to simplify x - y < 0 etc. for signed subtraction
with undefined overflow into x < y in match.pd regressed some tests,
even when it was guarded to be post-IPA, the following patch thus
attempts to optimize that during expansion instead (which is the last
time we can do it, afterwards we lose the information whether it was
x - y < 0 or (int) ((unsigned) x - y) < 0 for which we couldn't
optimize it.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/94802
	* expr.h (maybe_optimize_sub_cmp_0): Declare.
	* expr.c: Include tree-pretty-print.h and flags.h.
	(maybe_optimize_sub_cmp_0): New function.
	(do_store_flag): Use it.
	* cfgexpand.c (expand_gimple_cond): Likewise.

	* gcc.target/i386/pr94802.c: New test.
	* gcc.dg/Wstrict-overflow-25.c: Remove xfail.
2021-01-05 19:13:29 +01:00
Julian Brown
6b577a17b2 nvptx: Cache stacks block for OpenMP kernel launch
2021-01-05  Julian Brown  <julian@codesourcery.com>

libgomp/
	* plugin/plugin-nvptx.c (SOFTSTACK_CACHE_LIMIT): New define.
	(struct ptx_device): Add omp_stacks struct.
	(nvptx_open_device): Initialise cached-stacks housekeeping info.
	(nvptx_close_device): Free cached stacks block and mutex.
	(nvptx_stacks_free): New function.
	(nvptx_alloc): Add SUPPRESS_ERRORS parameter.
	(GOMP_OFFLOAD_alloc): Add strategies for freeing soft-stacks block.
	(nvptx_stacks_alloc): Rename to...
	(nvptx_stacks_acquire): This.  Cache stacks block between runs if same
	size or smaller is required.
	(nvptx_stacks_free): Remove.
	(GOMP_OFFLOAD_run): Call nvptx_stacks_acquire and lock stacks block
	during kernel execution.
2021-01-05 09:56:36 -08:00
Richard Sandiford
407bcf8e28 A couple of comment tweaks
Tweak a couple of comments added in the RTL-SSA series in response
to reviewer feedback.

gcc/
	* mux-utils.h (pointer_mux::m_ptr): Tweak description of contents.
	* rtlanal.c (simple_regno_set): Tweak description to clarify the
	RMW condition.
2021-01-05 17:43:27 +00:00
Jakub Jelinek
8ea81f5614 Don't link cc1 etc. against libcody.a
Richi complained on IRC that cc1 is linked against libcody.a.
From my understanding, it is just the cc1plus and cc1objplus binaries
that need it, so this patch links only those against it.

> this is already part of my Solaris libcody patch

The following updated patch are the incremental changes between what Rainer
has committed and what I've posted.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

gcc/cp/
	* Make-lang.in (cc1plus-checksum, cc1plus$(exeext): Add
	$(CODYLIB) after $(BACKEND).
gcc/objcp/
	* Make-lang.in (cc1objplus-checksum, cc1objplus$(exeext): Add
	$(CODYLIB) after $(BACKEND).
2021-01-05 17:46:56 +01:00
Richard Biener
33a6325770 tree-optimization/98516 - fix SLP permute opt materialization
When materializing on a VEC_PERM node we have to permute the
incoming vectors, not the outgoing one.

2021-01-05  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98516
	* tree-vect-slp.c (vect_optimize_slp): Permute the incoming
	lanes when materializing on a VEC_PERM node.
	(vectorizable_slp_permutation): Dump the permute properly.

	* gcc.dg/vect/bb-slp-pr98516-1.c: New testcase.
	* gcc.dg/vect/bb-slp-pr98516-2.c: Likewise.
2021-01-05 17:40:51 +01:00
Jakub Jelinek
606f2af197 c++: Fix ICE with __builtin_bit_cast [PR98469]
On the following testcase we ICE during constexpr evaluation (for warnings),
because the IL has ADDR_EXPR of BIT_CAST_EXPR and ADDR_EXPR case asserts
the result is not a CONSTRUCTOR.
The patch punts on lval BIT_CAST_EXPR folding.

> This change is OK, but part of the problem is that we're trying to do
> overload resolution for an S copy/move constructor, which we shouldn't be
> because bit_cast is a prvalue, so in C++17 and up we should use it to
> directly initialize the target without any implied constructor call.

This version therefore wraps it into a TARGET_EXPR then, it alone fixes
the bug, but I've kept the constexpr.c change too.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/98469
	* constexpr.c (cxx_eval_constant_expression) <case BIT_CAST_EXPR>:
	Punt if lval is true.
	* semantics.c (cp_build_bit_cast): Call get_target_expr_sfinae on
	the result if it has a class type.

	* g++.dg/cpp2a/bit-cast8.C: New test.
	* g++.dg/cpp2a/bit-cast9.C: New test.
2021-01-05 17:17:57 +01:00
Marek Polacek
af362af18f c++: ICE with deferred noexcept when deducing targs [PR82099]
In this test we ICE in type_throw_all_p because it got a deferred
noexcept which it shouldn't.  Here's the story:

In noexcept61.C, we call bar, so we perform overload resolution.  When
adding the (only) candidate, we need to deduce template arguments, so
call fn_type_unification as usually.  That deduces U to

  void (*) (int &, int &)

which is correct, but its noexcept-spec is deferred_noexcept.  Then
we call add_function_candidate (bar), wherein we try to create an
implicit conversion sequence for every argument.  Since baz<int> is
of unknown type, we instantiate_type it; it is a TEMPLATE_ID_EXPR
so that calls resolve_address_of_overloaded_function.  But we crash
there, because target_type contains the deferred_noexcept.

So we need to maybe_instantiate_noexcept before we can compare types.
resolve_overloaded_unification seemed like the appropriate spot, now
fn_type_unification produces the function type with its noexcept-spec
instantiated.  This shouldn't go against CWG 1330 because here we
really need to instantiate the noexcept-spec.

This also fixes class-deduction76.C, a dg-ice test I recently added,
therefore this fix also fixes c++/90799, yay.

gcc/cp/ChangeLog:

	PR c++/82099
	* pt.c (resolve_overloaded_unification): Call
	maybe_instantiate_noexcept after instantiating the function
	decl.

gcc/testsuite/ChangeLog:

	PR c++/82099
	* g++.dg/cpp1z/class-deduction76.C: Remove dg-ice.
	* g++.dg/cpp0x/noexcept61.C: New test.
2021-01-05 11:06:41 -05:00
Richard Biener
27aad52157 move SLP debug counter
This moves it to catch individual SLP subgraphs

2021-01-05  Richard Biener  <rguenther@suse.de>

	* tree-vect-slp.c (vect_slp_region): Move debug counter
	to cover individual subgraphs.
2021-01-05 16:43:39 +01:00
Richard Biener
26b5062be9 tree-optimization/98428 - avoid pre-existing vectors for loop SLP
It wasn't supposed to be enabled and appearantly copying around the
checking messed up the condition.

2021-01-05  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98428
	* tree-vect-slp.c (vect_build_slp_tree_1): Properly reject
	vector lane extracts for loop vectorization.
2021-01-05 16:43:39 +01:00
Jakub Jelinek
4ddee425b8 reassoc: Fix reassociation on 32-bit hosts with > 32767 bbs [PR98514]
Apparently reassoc ICEs on large functions (more than 32767 basic blocks
with something to reassociate in those).
The problem is that the pass uses long type to store the ranks, and
the bb ranks are (number of SSA_NAMEs with default defs + 2 + bb->index) << 16,
so with many basic blocks we overflow the ranks and we then have assertions
rank is not negative.

The following patch just uses int64_t instead of long in the pass,
yes, it means slightly higher memory consumption (one array indexed by
bb->index is twice as large, and one hash_map from trees to the ranks
will grow by 50%, but I think it is better than punting on large functions
the reassociation on 32-bit hosts and making it inconsistent e.g. when
cross-compiling.  Given vec.h uses unsigned for vect element counts,
we don't really support more than 4G of SSA_NAMEs or more than 2G of basic
blocks in a function, so even with the << 16 we can't really overflow the
int64_t rank counters.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98514
	* tree-ssa-reassoc.c (bb_rank): Change type from long * to
	int64_t *.
	(operand_rank): Change type from hash_map<tree, long> to
	hash_map<tree, int64_t>.
	(phi_rank): Change return type from long to int64_t.
	(loop_carried_phi): Change block_rank variable type from long to
	int64_t.
	(propagate_rank): Change return type, rank parameter type and
	op_rank variable type from long to int64_t.
	(find_operand_rank): Change return type from long to int64_t
	and change slot variable type from long * to int64_t *.
	(insert_operand_rank): Change rank parameter type from long to
	int64_t.
	(get_rank): Change return type and rank variable type from long to
	int64_t.  Use PRId64 instead of ld to print the rank.
	(init_reassoc): Change rank variable type from long to int64_t
	and adjust correspondingly bb_rank and operand_rank initialization.
2021-01-05 16:37:40 +01:00
Jakub Jelinek
576714b309 phiopt: Optimize x < 0 ? ~y : y to (x >> 31) ^ y [PR96928]
As requested in the PR, the one's complement abs can be done more
efficiently without cmov or branching.

Had to change the ifcvt-onecmpl-abs-1.c testcase, we no longer optimize
it in ifcvt, on x86_64 with -m32 we generate in the end the exact same
code, but with -m64:
        movl    %edi, %eax
-       notl    %eax
-       cmpl    %edi, %eax
-       cmovl   %edi, %eax
+       sarl    $31, %eax
+       xorl    %edi, %eax
        ret

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96928
	* tree-ssa-phiopt.c (xor_replacement): New function.
	(tree_ssa_phiopt_worker): Call it.

	* gcc.dg/tree-ssa/pr96928.c: New test.
	* gcc.target/i386/ifcvt-onecmpl-abs-1.c: Remove -fdump-rtl-ce1,
	instead of scanning rtl dump for ifcvt message check assembly
	for xor instruction.
2021-01-05 16:35:22 +01:00
Jakub Jelinek
5ca2400270 match.pd: Improve (A / (1 << B)) -> (A >> B) optimization [PR96930]
The following patch improves the A / (1 << B) -> A >> B simplification,
as seen in the testcase, if there is unnecessary widening for the division,
we just optimize it into a shift on the widened type, but if the lshift
is widened too, there is no reason to do that, we can just shift it in the
original type and convert after.  The tree_nonzero_bits & wi::mask check
already ensures it is fine even for signed values.

I've split the vr-values optimization into a separate patch as it causes
a small regression on two testcases, but this patch fixes what has been
reported in the PR alone.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96930
	* match.pd ((A / (1 << B)) -> (A >> B)): If A is extended
	from narrower value which has the same type as 1 << B, perform
	the right shift on the narrower value followed by extension.

	* g++.dg/tree-ssa/pr96930.C: New test.
2021-01-05 16:33:29 +01:00
Jakub Jelinek
a7553ad60b store-merging: Handle vector CONSTRUCTORs using bswap [PR96239]
I've tried to add such helper, but handling over just analysis and letting
each pass handle it differently seems complicated given the limitations of
the bswap infrastructure.

So, this patch just hooks the optimization also into store-merging so that
the original testcase from the PR can be fixed.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/96239
	* gimple-ssa-store-merging.c (maybe_optimize_vector_constructor): New
	function.
	(get_status_for_store_merging): Don't return BB_INVALID for blocks
	with potential bswap optimizable CONSTRUCTORs.
	(pass_store_merging::execute): Optimize vector CONSTRUCTORs with bswap
	if possible.

	* gcc.dg/tree-ssa/pr96239.c: New test.
2021-01-05 16:16:06 +01:00
Jakub Jelinek
f702893787 go: Fix -fgo-embedcfg= option description.
Description of options should be . terminated, the:
FAIL: compiler driver --help=go option(s): "^ +-.*[^:.]$" absent from output: "  -fgo-embedcfg=<file>        List embedded files via go:embed"
test even reports that.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	* lang.opt (fgo-embedcfg=): Add full stop at the end of description.
2021-01-05 16:13:20 +01:00
Richard Biener
01da03c915 tree-optimization/98381 - fix live bool vector extract
This fixes extraction of live bool vector results for the case of
integer mode vectors.

2021-01-05  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98381
	* tree.c (vector_element_bits): Properly compute bool vector
	element size.
	* tree-vect-loop.c (vectorizable_live_operation): Properly
	compute the last lane bit offset.
2021-01-05 15:54:42 +01:00
Uros Bizjak
1ff0ddcd8b i386: Prevent spurious FP exceptions with _mm_cvt{,t}ps_pi32 [PR98522]
Prevent spurious FP exceptions with _mm_cvt{,t}ps_pi32 for TARGET_MMX_WITH_SSE
by clearing the top 64 bytes of the input XMM register.

2021-01-05  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/98522
	* config/i386/sse.md (sse_cvtps2pi): Redefine as define_insn_and_split.
	Clear the top 64 bytes of the input XMM register.
	(sse_cvttps2pi): Ditto.

gcc/testsuite

	PR target/98522
	* gcc.target/i386/pr98522.c: New test.
2021-01-05 14:45:28 +01:00
Uros Bizjak
951bdbde6a i386: Add _mm256_cmov_si256 [PR98521]
Add missing _mm256_cmov_si256 intrinsic to xopintrin.h.

2021-01-05  Uroš Bizjak  <ubizjak@gmail.com>

gcc/
	PR target/98521
	* config/i386/xopintrin.h (_mm256_cmov_si256): New.
2021-01-05 14:45:27 +01:00
Nathan Sidwell
6ffaffd5d1 [c++]: Improve module-decl diagnostics [PR 98327]
The diagnostic for a misplaced module decl was essentially 'computer
says no', which isn't the most helpful.  This adjusts it to indicate
what would be acceptable.

	gcc/cp/
	* parser.c (cp_parser_module_declaration): Alter diagnostic
	text to say where is permissable.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/p0713-2.C: Adjust.
	* g++.dg/modules/p0713-3.C: Adjust.
2021-01-05 05:28:23 -08:00
H.J. Lu
af60b0ec79 x86: Cast to unsigned short first for _mm_extract_pi16
_mm_extract_pi16 is intrinsic for pextrw, which should be zero-extended,
not sign-extended.

gcc/

	PR target/98495
	* config/i386/xmmintrin.h (_mm_extract_pi16): Cast to unsigned
	short first.

gcc/testsuite/

	PR target/98495
	* gcc.target/i386/pr98495-1.c: New test.
	* gcc.target/i386/pr98495-2.c: New test.
	* gcc.target/i386/pr98495-3.c: New test.
	* gcc.target/i386/pr98495-4.c: New test.
	* gcc.target/i386/pr98495-5.c: New test.
2021-01-05 05:08:00 -08:00
Claudiu Zissulescu
b679559385 arc: fix accumulator first register.
gcc/
2021-01-05  Claudiu Zissulescu  <claziss@synopsys.com>

	* config/arc/arc.md (maddsidi4_split): Use ACC_REG_FIRST.
	(umaddsidi4_split): Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
2021-01-05 14:19:27 +02:00
liuhongt
bea984814c i386: Optimize pmovskb on zero_extend of subreg HI of pmovskb result [PR98461]
The following patch adds define_insn_and_split to optimize

       vpmovmskb       %xmm0, %eax
-       movzwl  %ax, %eax
        notl    %eax

and combine splitter to optimize

        pmovmskb        %xmm0, %eax
-       notl    %eax
-       movzwl  %ax, %eax
+       xorl    $65535, %eax

gcc/ChangeLog
	PR target/98461
	* config/i386/sse.md (*sse2_pmovskb_zexthisi): New
	define_insn_and_split for zero_extend of subreg HI of pmovskb
	result.
	(*sse2_pmovskb_zexthisi): Add new combine splitters for
	zero_extend of not of subreg HI of pmovskb result.

gcc/testsuite/ChangeLog
	* gcc.target/i386/sse2-pr98461-2.c: New test.
2021-01-05 19:39:46 +08:00
Richard Sandiford
e8beba1cfc explow, aarch64: Fix force-Pmode-to-mem for ILP32 [PR97269]
This patch fixes a mode/rtx mismatch for ILP32 targets in:

	  mem = force_const_mem (ptr_mode, imm);

where imm can be Pmode rather than ptr_mode.

The patch uses convert_memory_address to convert the Pmode address
to ptr_mode before the call.  However, immediate addresses can in
general contain unspecs, and convert_memory_address wasn't set up
to handle those.

The patch therefore adds some generic unspec handling to
convert_memory_address_addr_space_1.  As the comment says, we can add
a target hook if this behaviour turns out to be wrong for some targets.
But I think what the patch does is a strict improvement over the status
quo: without it, we would try to force the unspec into a register,
but nevertheless wrap the result in a (const ...).  That in turn
would be invalid rtl and seems bound to generate an ICE later.

I tested the explow.c part using -fstack-protector with local hacks
to force SYMBOL_FORCE_TO_MEM for UNSPEC_SALT_ADDR.

Fixes c-c++-common/torture/pr57945.c and various other tests.

gcc/
	PR target/97269
	* explow.c (convert_memory_address_addr_space_1): Handle UNSPECs
	nested in CONSTs.
	* config/aarch64/aarch64.c (aarch64_expand_mov_immediate): Use
	convert_memory_address to convert symbolic immediates to ptr_mode
	before forcing them to memory.
2021-01-05 11:29:10 +00:00
Richard Sandiford
eac8675225 recog: Fix a constrain_operands corner case [PR97144]
aarch64's *add<mode>3_poly_1 has a pattern with the constraints:

  "=...,r,&r"
  "...,0,rk"
  "...,Uai,Uat"

i.e. the penultimate alternative requires operands 0 and 1 to match,
but the final alternative does not allow them to match.

The register allocators dealt with this correctly, and so used
different input and output registers for instructions with Uat
operands.  However, constrain_operands carried the penultimate
alternative's matching rule over to the final alternative,
so it would essentially ignore the earlyclobber.  This in turn
allowed postreload to convert a correct Uat pairing into an
incorrect one.

The fix is simple: recompute the matching information for each
alternative.

gcc/
	PR rtl-optimization/97144
	* recog.c (constrain_operands): Initialize matching_operand
	for each alternative, rather than only doing it once.

gcc/testsuite/
	PR rtl-optimization/97144
	* gcc.c-torture/compile/pr97144.c: New test.
	* gcc.target/aarch64/sve/pr97144.c: Likewise.
2021-01-05 11:18:48 +00:00
Richard Sandiford
8a25be517f rtl-ssa: Fix updates to call clobbers [PR98403]
In the PR, fwprop was changing a call instruction and tripped
an assert when trying to update a list of call clobbers.
There are two ways we could handle this: remove the call clobber
and then add it back, or assume that the clobber will stay in its
current place.

At the moment we don't have enough information to safely move
calls around, so the second approach seems simpler and more
efficient.

gcc/
	PR rtl-optimization/98403
	* rtl-ssa/changes.cc (function_info::finalize_new_accesses): Explain
	why we don't remove call clobbers.
	(function_info::apply_changes_to_insn): Don't attempt to add
	call clobbers here.

gcc/testsuite/
	PR rtl-optimization/98403
	* g++.dg/opt/pr98403.C: New test.
2021-01-05 11:04:15 +00:00
Richard Sandiford
01be45ecce vect: Fix missing alias checks for 128-bit SVE [PR98371]
On AArch64, the vectoriser tries various ways of vectorising with both
SVE and Advanced SIMD and picks the best one.  All other things being
equal, it prefers earlier attempts over later attempts.

The way this works currently is that, once it has a successful
vectorisation attempt A, it analyses all other attempts as epilogue
loops of A:

      /* When pick_lowest_cost_p is true, we should in principle iterate
	 over all the loop_vec_infos that LOOP_VINFO could replace and
	 try to vectorize LOOP_VINFO under the same conditions.
	 E.g. when trying to replace an epilogue loop, we should vectorize
	 LOOP_VINFO as an epilogue loop with the same VF limit.  When trying
	 to replace the main loop, we should vectorize LOOP_VINFO as a main
	 loop too.

	 However, autovectorize_vector_modes is usually sorted as follows:

	 - Modes that naturally produce lower VFs usually follow modes that
	   naturally produce higher VFs.

	 - When modes naturally produce the same VF, maskable modes
	   usually follow unmaskable ones, so that the maskable mode
	   can be used to vectorize the epilogue of the unmaskable mode.

	 This order is preferred because it leads to the maximum
	 epilogue vectorization opportunities.  Targets should only use
	 a different order if they want to make wide modes available while
	 disparaging them relative to earlier, smaller modes.  The assumption
	 in that case is that the wider modes are more expensive in some
	 way that isn't reflected directly in the costs.

	 There should therefore be few interesting cases in which
	 LOOP_VINFO fails when treated as an epilogue loop, succeeds when
	 treated as a standalone loop, and ends up being genuinely cheaper
	 than FIRST_LOOP_VINFO.  */

However, the vectoriser can normally elide alias checks for epilogue
loops, on the basis that the main loop should do them instead.
Converting an epilogue loop to a main loop can therefore cause the alias
checks to be skipped.  (It probably also unfairly penalises the original
loop in the cost comparison, given that one loop will have alias checks
and the other won't.)

As the comment says, we should in principle analyse each vector mode
twice: once as a main loop and once as an epilogue.  However, doing
that up-front would be quite expensive.  This patch instead goes for a
compromise: if an epilogue loop for mode M2 seems better than a main
loop for mode M1, re-analyse with M2 as the main loop.

The patch fixes dg.torture.exp=pr69719.c when testing with
-msve-vector-bits=128.

gcc/
	PR tree-optimization/98371
	* tree-vect-loop.c (vect_reanalyze_as_main_loop): New function.
	(vect_analyze_loop): If an epilogue loop appears to be cheaper
	than the main loop, re-analyze it as a main loop before adopting
	it as a main loop.
2021-01-05 11:03:22 +00:00
Rainer Orth
a20893cf6b build: libcody: Link with -lsocket -lnsl if necessary [PR98316]
With the introduction of C++20 modules and libcody, cc1plus and
cc1objplus gained a dependency on the socket functions.  Before those
were merged into libc in Solaris 11.4, one needed to link with -lsocket -lnsl
on Solaris, so that merge broke the Solaris 11.3 build.

While we already have 4 different checks for those libraries in the
tree, I decided to import autoconf-archive's AX_LIB_SOCKET_NSL macro
instead.  At the same time, the patch only links libcody and the
networking libs where needed (cc1plus, cc1objplus).

Bootstrapped without regressions on i386-pc-solaris2.11 (Solaris 11.3
and 11.4), sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.

2020-12-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	c++tools:
	PR c++/98316
	* configure.ac: Include ../config/ax_lib_socket_nsl.m4.
	(NETLIBS): Determine using AX_LIB_SOCKET_NSL.
	* configure: Regenerate.
	* Makefile.in (NETLIBS): Define.
	(g++-mapper-server$(exeext)): Add $(NETLIBS).

	gcc/objcp:
	PR c++/98316
	* Make-lang.in (cc1objplus$(exeext)): Add $(CODYLIB), $(NETLIBS).

	gcc/cp:
	PR c++/98316
	* Make-lang.in (cc1plus$(exeext)): Add $(CODYLIB), $(NETLIBS).

	gcc:
	PR c++/98316
	* configure.ac (NETLIBS): Determine using AX_LIB_SOCKET_NSL.
	* aclocal.m4, configure: Regenerate.
	* Makefile.in (NETLIBS): Define.
	(BACKEND): Remove $(CODYLIB).

	config:
	PR c++/98316
	* ax_lib_socket_nsl.m4: Import from autoconf-archive.
2021-01-05 11:32:31 +01:00
Jakub Jelinek
4615cde5d7 simplify-rtx: Optimize (x - 1) * y + y [PR98334]
We don't try to optimize for signed x, y (int) (x - 1U) * y + y
into x * y, we can't do that with signed x * y, because the former
is well defined for INT_MIN and -1, while the latter is not.
We could perhaps optimize it during isel or some very late optimization
where we'd turn magically flag_wrapv, but we don't do that yet.

This patch optimizes it in simplify-rtx.c, such that we can optimize
it during combine.

2021-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/98334
	* simplify-rtx.c (simplify_context::simplify_binary_operation_1):
	Optimize (X - 1) * Y + Y to X * Y or (X + 1) * Y - Y to X * Y.

	* gcc.target/i386/pr98334.c: New test.
2021-01-05 10:59:00 +01:00
Bernd Edlinger
6b69738c1e Restore input_location after recursive expand_call_inline
This is just a precautionary fix.

2021-01-05  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* tree-inline.c (expand_call_inline): Restore input_location.
	Return result from recursive call.
2021-01-05 10:57:54 +01:00
Jerome Lambourg
560d991576 Fix testsuite/g++.dg/cpp1y/constexpr-66093.C execution failure...
The constexpr iteration dereferenced an array element past the end of
the array.


for  gcc/testsuite/ChangeLog

	* g++.dg/cpp1y/constexpr-66093.C: Fix bounds issue.
2021-01-05 04:47:41 -03:00
Ian Lance Taylor
bf183413c6 Go frontend: add -fgo-embedcfg option
This option will be used by the go command to implement go:embed directives,
which are new with the upcoming Go 1.16 release.

	* lang.opt (fgo-embedcfg): New option.
	* go-c.h (struct go_create_gogo_args): Add embedcfg field.
	* go-lang.c (go_embedcfg): New static variable.
	(go_langhook_init): Set go_create_gogo_args embedcfg field.
	(go_langhook_handle_option): Handle OPT_fgo_embedcfg_.
	* gccgo.texi (Invoking gccgo): Document -fgo-embedcfg.
2021-01-04 17:41:16 -08:00
David Malcolm
15af33a880 analyzer: fix ICE with -fsanitize=undefined [PR98293]
-fsanitize=undefined with calls to nonnull functions
creates struct __ubsan_nonnull_arg_data instances
with CONSTRUCTORs for RECORD_TYPEs with NULL index values.
The analyzer was mistakenly using INTEGER_CST for these
fields, leading to ICEs.

Fix the issue by iterating through the fields in the type
for such cases, imitating similar logic in varasm.c's
output_constructor.

gcc/analyzer/ChangeLog:
	PR analyzer/98293
	* store.cc (binding_map::apply_ctor_to_region): When "index" is
	NULL, iterate through the fields for RECORD_TYPEs, rather than
	creating an INTEGER_CST index.

gcc/testsuite/ChangeLog:
	PR analyzer/98293
	* gcc.dg/analyzer/pr98293.c: New test.
2021-01-04 19:20:32 -05:00
GCC Administrator
7e73f51157 Daily bump. 2021-01-05 00:16:42 +00:00
Martin Uecker
a000eb5918 C: Add test for incorrect warning for assignment of certain volatile expressions fixed by commit 58a45ce [PR98029]
2021-01-04  Martin Uecker  <muecker@gwdg.de>

gcc/testsuite/
	PR c/98029
	* gcc.dg/pr98029.c: New test.
2021-01-04 22:53:58 +01:00
Philipp Tomsich
f262a35188 MAINTAINERS: Update my email address.
2021-01-04  Philipp Tomsich  <philipp.tomsich@vrull.eu>

	* MAINTAINERS: Update my email address.
2021-01-04 17:37:54 +01:00
Nathan Sidwell
5938a61434 Th, th, th, that's all folks! 2021-01-04 07:59:53 -08:00
Nathan Sidwell
d8d2f7d752 Merge trunk a5469584f6 2021-01-04 07:53:37 -08:00
Nathan Sidwell
a5469584f6 c++: Add stdlib module test cases
The remaining modules tests use the std library.  These are those.

	gcc/testsuite/
	* g++.dg/modules/binding-1_a.H: New.
	* g++.dg/modules/binding-1_b.H: New.
	* g++.dg/modules/binding-1_c.C: New.
	* g++.dg/modules/binding-2.H: New.
	* g++.dg/modules/builtin-3_a.C: New.
	* g++.dg/modules/global-2_a.C: New.
	* g++.dg/modules/global-2_b.C: New.
	* g++.dg/modules/global-3_a.C: New.
	* g++.dg/modules/global-3_b.C: New.
	* g++.dg/modules/hello-1_a.C: New.
	* g++.dg/modules/hello-1_b.C: New.
	* g++.dg/modules/iostream-1_a.H: New.
	* g++.dg/modules/iostream-1_b.C: New.
	* g++.dg/modules/part-5_a.C: New.
	* g++.dg/modules/part-5_b.C: New.
	* g++.dg/modules/part-5_c.C: New.
	* g++.dg/modules/stdio-1_a.H: New.
	* g++.dg/modules/stdio-1_b.C: New.
	* g++.dg/modules/string-1_a.H: New.
	* g++.dg/modules/string-1_b.C: New.
	* g++.dg/modules/string-view1.C: New.
	* g++.dg/modules/string-view2.C: New.
	* g++.dg/modules/tinfo-1.C: New.
	* g++.dg/modules/tinfo-2_a.H: New.
	* g++.dg/modules/tinfo-2_b.C: New.
	* g++.dg/modules/tname-spec-1_a.H: New.
	* g++.dg/modules/tname-spec-1_b.C: New.
	* g++.dg/modules/xtreme-header-1.h: New.
	* g++.dg/modules/xtreme-header-1_a.H: New.
	* g++.dg/modules/xtreme-header-1_b.C: New.
	* g++.dg/modules/xtreme-header-1_c.C: New.
	* g++.dg/modules/xtreme-header-2.h: New.
	* g++.dg/modules/xtreme-header-2_a.H: New.
	* g++.dg/modules/xtreme-header-2_b.C: New.
	* g++.dg/modules/xtreme-header-2_c.C: New.
	* g++.dg/modules/xtreme-header-3.h: New.
	* g++.dg/modules/xtreme-header-3_a.H: New.
	* g++.dg/modules/xtreme-header-3_b.C: New.
	* g++.dg/modules/xtreme-header-3_c.C: New.
	* g++.dg/modules/xtreme-header-4.h: New.
	* g++.dg/modules/xtreme-header-4_a.H: New.
	* g++.dg/modules/xtreme-header-4_b.C: New.
	* g++.dg/modules/xtreme-header-4_c.C: New.
	* g++.dg/modules/xtreme-header-5.h: New.
	* g++.dg/modules/xtreme-header-5_a.H: New.
	* g++.dg/modules/xtreme-header-5_b.C: New.
	* g++.dg/modules/xtreme-header-5_c.C: New.
	* g++.dg/modules/xtreme-header-6.h: New.
	* g++.dg/modules/xtreme-header-6_a.H: New.
	* g++.dg/modules/xtreme-header-6_b.C: New.
	* g++.dg/modules/xtreme-header-6_c.C: New.
	* g++.dg/modules/xtreme-header.h: New.
	* g++.dg/modules/xtreme-header_a.H: New.
	* g++.dg/modules/xtreme-header_b.C: New.
	* g++.dg/modules/xtreme-tr1.h: New.
	* g++.dg/modules/xtreme-tr1_a.H: New.
	* g++.dg/modules/xtreme-tr1_b.C: New.
2021-01-04 07:52:21 -08:00
Nathan Sidwell
0325be5391 Merge trunk 6288183377 2021-01-04 07:21:50 -08:00
Richard Sandiford
aa204d5118 vect, aarch64: Fix alignment units for IFN_MASK* [PR95401]
The IFN_MASK* functions take two leading arguments: a load or
store pointer and a “cookie”.  The type of the cookie is the
type of the access for TBAA purposes (like for MEM_REFs)
while the value of the cookie is the alignment of the access.
This PR was caused by a disagreement about whether the alignment
is measured in bits or bytes.

It looks like this goes back to PR68786, which made the
vectoriser create its own cookie argument rather than reusing
the one created by ifcvt.  The alignment value of the new cookie
was measured in bytes (as needed by set_ptr_info_alignment)
while the existing code expected it to be measured in bits.
The folds I added for IFN_MASK_LOAD and STORE then made
things worse.

gcc/
	PR tree-optimization/95401
	* config/aarch64/aarch64-sve-builtins.cc
	(gimple_folder::load_store_cookie): Use bits rather than bytes
	for the alignment argument to IFN_MASK_LOAD and IFN_MASK_STORE.
	* gimple-fold.c (gimple_fold_mask_load_store_mem_ref): Likewise.
	* tree-vect-stmts.c (vectorizable_store): Likewise.
	(vectorizable_load): Likewise.

gcc/testsuite/
	PR tree-optimization/95401
	* g++.dg/vect/pr95401.cc: New test.
	* g++.dg/vect/pr95401a.cc: Likewise.
2021-01-04 14:44:21 +00:00
Nathan Sidwell
6288183377 [libcody] Remove some std::move [PR 98368]
Compiling on clang showed a couple of pessimizations.  Fixed thusly.

	libcody/
	* client.cc (Client::ProcessResponse): Remove std::move
	inside ?:
	c++tools/
	* resolver.cc (module_resolver::cmi_response): Remove
	std::move of temporary.
2021-01-04 06:38:52 -08:00
Mateusz Wajchęprzełóż
6bbc196c64 [libcody] Windows absdir fix
An obvious thinko in dirve name check :(

	libcody/
	* resolver.cc (IsAbsDir): Fix string indexing.

Signed-off-by: Nathan Sidwell <nathan@acm.org>
2021-01-04 08:59:10 -05:00
Richard Biener
9e79d76a16 tree-optimization/98308 - set vector type for mask of masked load
This makes sure to set the vector type on an invariant mask argument
for a masked load and SLP.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98308
	* tree-vect-stmts.c (vectorizable_load): Set invariant mask
	SLP vectype.

	* gcc.dg/vect/pr98308.c: New testcase.
2021-01-04 14:39:14 +01:00
Jakub Jelinek
24cd9afe61 loop-niter: Recognize popcount idioms even with char, short and __int128 [PR95771]
As the testcase shows, we punt unnecessarily on popcount loop idioms if
the type is smaller than int or larger than long long.
Smaller type than int can be handled by zero-extending the argument to
unsigned int, and types twice as long as long long by doing
__builtin_popcountll on both halves of the __int128.

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

	PR tree-optimization/95771
	* tree-ssa-loop-niter.c (number_of_iterations_popcount): Handle types
	with precision smaller than int's precision and types with precision
	twice as large as long long.  Formatting fixes.

	* gcc.target/i386/pr95771.c: New test.
2021-01-04 14:36:06 +01:00
Richard Biener
39bd65faee tree-optimization/98464 - replace loop info with avail at uses
This does VN replacement in loop nb_iterations consistent with
the rest of the IL by using availability at the definition site
of uses.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98464
	* tree-ssa-sccvn.c (vn_valueize_for_srt): Rename from ...
	(vn_valueize_wrapper): ... this.  Temporarily adjust vn_context_bb.
	(process_bb): Adjust.

	* g++.dg/opt/pr98464.C: New testcase.
2021-01-04 13:51:56 +01:00
Matthew Malcomson
7f2b731756 docs: Fix wording describing the hwaddress sanitizer
The original documentation added to mention the clash between
-fsanitize=address and -fsanitize=hwaddress used confusing wording trying
to say that -fsanitize=hwaddress is only available on AArch64.

It read as if -fsanitize=address were only supported on AArch64.

This patch fixes that wording by being more explicit.

gcc/ChangeLog:

	PR other/98437
	* doc/invoke.texi (-fsanitize=address): Fix wording describing
	clash with -fsanitize=hwaddress.
2021-01-04 12:06:27 +00:00
Richard Biener
13b80a7d1b tree-optimization/98282 - classify V_C_E<constant> as nary
This avoids running into memory reference code in compute_avail by
properly classifying unfolded reference trees on constants.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98282
	* tree-ssa-sccvn.c (vn_get_stmt_kind): Classify tcc_reference on
	invariants as VN_NARY.

	* g++.dg/opt/pr98282.C: New testcase.
2021-01-04 12:59:44 +01:00
Richard Sandiford
b41e6dd50f aarch64: Improve vcombine codegen [PR89057]
This patch fixes a codegen regression in the handling of things like:

  __temp.val[0]								     \
    = vcombine_##funcsuffix (__b.val[0],				     \
			     vcreate_##funcsuffix (__AARCH64_UINT64_C (0))); \

in the 64-bit vst[234] functions.  The zero was forced into a
register at expand time, and we relied on combine to fuse the
zero and combine back together into a single combinez pattern.
The problem is that the zero could be hoisted before combine
gets a chance to do its thing.

gcc/
	PR target/89057
	* config/aarch64/aarch64-simd.md (aarch64_combine<mode>): Accept
	aarch64_simd_reg_or_zero for operand 2.  Use the combinez patterns
	to handle zero operands.

gcc/testsuite/
	PR target/89057
	* gcc.target/aarch64/pr89057.c: New test.
2021-01-04 11:59:07 +00:00
Richard Sandiford
ba15b0fa0d aarch64: Use the MUL VL form of SVE PRF[BHWD]
The expansions of the svprf[bhwd] instructions weren't taking
advantage of the immediate addressing mode.

gcc/
	* config/aarch64/aarch64.c (offset_6bit_signed_scaled_p): New function.
	(offset_6bit_unsigned_scaled_p): Fix typo in comment.
	(aarch64_sve_prefetch_operand_p): Accept MUL VLs in the range
	[-32, 31].

gcc/testsuite/
	* gcc.target/aarch64/sve/acle/asm/prfb.c: Test for a MUL VL range of
	[-32, 31].
	* gcc.target/aarch64/sve/acle/asm/prfh.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/prfw.c: Likewise.
	* gcc.target/aarch64/sve/acle/asm/prfd.c: Likewise.
2021-01-04 11:56:19 +00:00
Richard Biener
0926259f9f tree-optimization/98393 - properly init matches when failing SLP
This zeroes matches when failing SLP discovery because of the
work limit.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98393
	* tree-vect-slp.c (vect_build_slp_tree): Properly zero matches
	when hitting the limit.
2021-01-04 12:13:44 +01:00
Martin Liska
a40718b5fc Convert 2 files to utf8.
libiberty/ChangeLog:

	* strverscmp.c: Convert to utf8 from iso8859.

gcc/testsuite/ChangeLog:

	* README: Convert to utf8 from iso8859.
2021-01-04 11:35:17 +01:00
Martin Liska
ff6b406247 avr.exp: convert Dos newlines to Unix ones
gcc/testsuite/ChangeLog:

	* gcc.target/avr/avr.exp: Run dos2unix on the file.
2021-01-04 11:21:20 +01:00
Richard Biener
8837f82e4b tree-optimization/98291 - allow SLP more vectorization of reductions
When the VF is one a SLP reduction is in-order and thus we can
vectorize even when the reduction op is not associative.

2021-01-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/98291
	* tree-vect-loop.c (vectorizable_reduction): Bypass
	associativity check for SLP reductions with VF 1.

	* gcc.dg/vect/slp-reduc-11.c: New testcase.
	* gcc.dg/vect/vect-reduc-in-order-4.c: Adjust.
2021-01-04 10:47:43 +01:00
Jakub Jelinek
ad64e807ff match.pd: Fold x == ~x to false [PR96782]
x is never equal to ~x, so we can fold such comparisons to constants.

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

	PR tree-optimization/96782
	* match.pd (x == ~x -> false, x != ~x -> true): New simplifications.

	* gcc.dg/tree-ssa/pr96782.c: New test.
2021-01-04 10:37:12 +01:00
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Jakub Jelinek
c00e2af363 Add AMD and Ulf Adams as external authors
* update-copyright.py: Add AMD and Ulf Adams as external authors.
2021-01-04 10:25:17 +01:00
Martin Liska
f96f664cf6 Remove duplicate ChangeLog entries.
gcc/fortran/ChangeLog:

	* ChangeLog-2018: Remove duplicate ChangeLog entries.
2021-01-04 10:18:18 +01:00
Jakub Jelinek
2a680610d1 Fix up indentation in update-copyright.py
* update-copyright.py: Use 8 spaces instead of tab to indent.
2021-01-04 10:16:13 +01:00
Martin Liska
cf76bbf8a8 mklog.py: add --update-copyright option
contrib/ChangeLog:

	* mklog.py: Add --update-copyright option which adds:
	"Update copyright years." to ChangeLog files belonging
	to a modified file.
2021-01-04 10:09:07 +01:00
Martin Liska
8869bd0efc gcc-changelog: Ignore copyright years commits.
contrib/ChangeLog:

	* gcc-changelog/git_commit.py: Skip Update copyright
	years commits.
2021-01-04 10:09:07 +01:00
Jakub Jelinek
b4cdbb9335 Remove duplicated ChangeLog entries from po/ChangeLog
to undo broken https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=gcc/po/ChangeLog;h=9f4bf9a8e3a34266e521e24be1adbba52f31e8d3;hp=5f5f8f70e44a374d3a8a615abc6cddc6642982a3;hb=818ab71a415cd234be092111a0aa5e812ec56434;hpb=21fa2a29dc265ab54c957c37d8a9e9ab07d7cd66
change.
2021-01-04 10:08:04 +01:00
Bernd Edlinger
e9f8a554ef Fix -save-temp leaking lto files in /tmp
When linking with -flto and -save-temps, various
temporary files are created in /tmp.
The same happens when invoking the driver with @file
parameter, and using -L or -I options.

gcc:
2021-01-04  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* collect-utils.c (collect_execute): Check dumppfx.
	* collect2.c (maybe_run_lto_and_relink, do_link): Pass atsuffix
	to collect_execute.
	(do_link): Add new parameter atsuffix.
	(main): Handle -dumpdir option.  Skip one argument for
	-o, -isystem and -B options.
	* gcc.c (make_at_file): New helper function.
	(close_at_file): Use it.

gcc/testsuite:
2021-01-04  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gcc.misc-tests/outputs.exp: Adjust testcase.
2021-01-04 10:03:19 +01:00
Jakub Jelinek
c48514bea6 Update Copyright in ChangeLog files
Do this separately from all other Copyright updates, as ChangeLog files
can be modified only separately.
2021-01-04 09:35:45 +01:00
GCC Administrator
2e96eec614 Daily bump. 2021-01-04 00:16:18 +00:00
Eric Botcazou
f14f89c5c4 Bump copyright year
gcc/ada/
	* gnatvsn.ads: Bump copyright year.
2021-01-03 13:43:01 +01:00
Mike Frysinger
3335c9f954 config: import pkg.m4 from pkg-config
We use this in the sim tree currently.  Rather than require people to
have pkg-config installed, include it in the config/ dir.

config/ChangeLog:

	* pkg.m4: New file from pkg-config-0.29.2.
2021-01-02 21:53:56 -05:00
Mike Frysinger
37d0bb1f5b libiberty.h: punt duplicate strverscmp prototype
SVN r216772 accidentally copied & pasted this prototype when adding
other ones nearby.

include/ChangeLog:

	* libiberty.h (strverscmp): Delete duplicate prototype.
2021-01-02 21:51:14 -05:00
GCC Administrator
2eacfdbd6a Daily bump. 2021-01-03 00:16:20 +00:00
Iain Sandoe
ef370f933c Darwin : Adjust defaults for the linker.
Ideally, the linker will be queried for its version and that will be
used to determine capabilities that cannot be discovered from
reasonable configuration testing.

When building cross tools, this might not be possible, and we have
strategies for providing useful defaults.  These are adjusted here to
refect current choices.

gcc/ChangeLog:

	* config/darwin.h (MIN_LD64_NO_COAL_SECTS): Adjust.
	Amend handling for LD64_VERSION fallback defaults.
2021-01-02 19:56:19 +00:00
Iain Sandoe
4a04f09dc7 Darwin, Simplify headers 4/5 : Remove redundant headers.
The darwinN.h headers (with the sole exception of darwin7.h,
which contains a target macro definition) now only contain
values that set fall-backs for cross-compilations, these can
be provided from the config.gcc script which means we no longer
need the darwinN.h - so delete them.

gcc/ChangeLog:

	* config.gcc: Compute default version information
	from the configured target.  Likewise defaults for
	ld64.
	* config/darwin10.h: Removed.
	* config/darwin12.h: Removed.
	* config/darwin9.h: Removed.
	* config/rs6000/darwin8.h: Removed.
2021-01-02 19:56:19 +00:00
Iain Sandoe
5282e22f0e Darwin, Simplify headers 3/5 : Delete dead code.
Darwin defines ASM_OUTPUT_ALIGNED_DECL_COMMON which is used in
preference to ASM_OUTPUT_ALIGNED_COMMON, which makes the latter
definition dead code.  Remove this.

gcc/ChangeLog:

	* config/darwin9.h (ASM_OUTPUT_ALIGNED_COMMON): Delete.
2021-01-02 19:56:19 +00:00
Iain Sandoe
ac6ecec4b3 Darwin, Simplify headers 2/5 : Move spec for STACK_CHECK_STATIC_BUILTIN.
We now need a modern (C++11) toolchain to bootstrap GCC, so there's no
need to skip the stack protect for Darwin < 9.

gcc/ChangeLog:

	* config/darwin9.h (STACK_CHECK_STATIC_BUILTIN): Move from here..
	* config/darwin.h (STACK_CHECK_STATIC_BUILTIN): .. to here.
2021-01-02 19:56:19 +00:00
Iain Sandoe
896607741f Darwin, Simplify headers 1/5 : Move LINK_GCC_C_SEQUENCE_SPEC [NFC].
There is no need to make the LINK_GCC_C_SEQUENCE_SPEC conditional on
configuration parameters, it is adequately conditionalized on the
macosx-version-min.

gcc/ChangeLog:

	* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move from
	here...
	* config/darwin.h (LINK_GCC_C_SEQUENCE_SPEC): ... to here.
2021-01-02 19:56:19 +00:00
Iain Sandoe
1dfeaca014 Darwin, Simplify headers 0/5 : Move spec for Darwin 10 unwind stub [NFC].
The darwinN.h headers were (presumably) introduced to allow specs to be
adjusted when there was no mmacosx-version-min handling, or that was
considered unreliable.

We have version-specific specs for the values that have configuration
data, and the version is set in the driver (so may be considered
reliably present).

Some of the 'darwinN.h' content has become dead code, and the reminder
is either conditionalised on version information (or is setting values
used as fall-backs in cross-compilations).

With the changes needed for Darwin20 / macOS 11 the 'darwnN.h' headers
are now too unwieldy to be useful - so this series moves the relevant
specs definitons to the common 'darwin.h' header and then finally uses
the config.gcc script to supply the fall-back defaults for cross-
compilations.

We can then delete all but the main header, since the darwinN.h are
unused.

This change moves a spec from darwin10.h to the main darwin.h
target header.

gcc/ChangeLog:

	* config/darwin10.h (LINK_GCC_C_SEQUENCE_SPEC): Move the spec
	for the Darwin10 unwinder stub from here ...
	* config/darwin.h (LINK_COMMAND_SPEC_A): ... to here.
2021-01-02 19:56:19 +00:00
Iain Sandoe
b2cee5e1e8 Darwin : Adjust defaults for current bootstrap constraints.
The toolchain now requires a C++11 compiler to bootstrap and
none of the older Darwin toolchains which were based on stabs
debugging are suitable.  We can simplify the debug setup now.

gcc/ChangeLog:

	* config/darwin.h (DSYMUTIL_SPEC): Default to DWARF
	(ASM_DEBUG_SPEC):Only define if the assembler supports
	stabs.
	(PREFERRED_DEBUGGING_TYPE): Default to DWARF.
	(DARWIN_PREFER_DWARF): Define.
	* config/darwin9.h (PREFERRED_DEBUGGING_TYPE): Remove.
	(DARWIN_PREFER_DWARF): Likewise
	(DSYMUTIL_SPEC): Likewise.
	(COLLECT_RUN_DSYMUTIL): Likewise.
	(ASM_DEBUG_SPEC): Likewise.
	(ASM_DEBUG_OPTION_SPEC): Likewise.
2021-01-02 19:56:19 +00:00
Jan Hubicka
ae99b315ba ggc_free basic blocks
* cfg.c (free_block): ggc_free bb.
2021-01-02 16:05:17 +01:00
Jan Hubicka
c304a68e41 Free datastructures pointing to CFG after parsing
* cp-tree.h (cp_tree_c_finish_parsing): Declare.
	* decl2.c (c_parse_final_cleanups): Call cp_tree_c_finish_parsing.
	* tree.c (cp_tree_c_finish_parsing): New function.
2021-01-02 16:04:24 +01:00
GCC Administrator
b6dd195aac Daily bump. 2021-01-02 00:16:24 +00:00
Ian Lance Taylor
5a4e0d121a internal/cpu: add aarch64 support functions
Patch from Andreas Schwab.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/281000
2021-01-01 15:13:50 -08:00
Ian Lance Taylor
0b9ef8be40 runtime: move startupRandomData back to runtime2.go
In libgo it's referenced from os_gccgo.go on all platforms.

Fixes go/98496

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/280999
2021-01-01 15:11:45 -08:00
Ian Lance Taylor
abca670596 internal/cpu, golang.org/x/sys/cpu: support other GOARCH values
Add support (mostly dummy support) for GOARCH values supported by
gofrontend but not gc.  Fix PPC handling.

Fixes https://gcc.gnu.org/PR98493

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/280932
2021-01-01 15:10:06 -08:00
Harald Anlauf
d816b0c144 PR fortran/96381 - invalid read in gfc_find_derived_vtab
An invalid declaration of a CLASS instance can lead to an internal state
with inconsistent attributes during parsing that needs to be handled with
sufficient care when processing subsequent statements.  Avoid a lookup of
the vtab entry for such cases.

gcc/fortran/ChangeLog:

	* class.c (gfc_find_vtab): Add check on attribute is_class.
2021-01-01 18:55:41 +01:00
Jakub Jelinek
4b24d500f4 Update copyright dates.
Manual part of copyright year updates.

2021-01-01  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* gcc.c (process_command): Update copyright notice dates.
	* gcov-dump.c (print_version): Ditto.
	* gcov.c (print_version): Ditto.
	* gcov-tool.c (print_version): Ditto.
	* gengtype.c (create_file): Ditto.
	* doc/cpp.texi: Bump @copying's copyright year.
	* doc/cppinternals.texi: Ditto.
	* doc/gcc.texi: Ditto.
	* doc/gccint.texi: Ditto.
	* doc/gcov.texi: Ditto.
	* doc/install.texi: Ditto.
	* doc/invoke.texi: Ditto.
gcc/ada/
	* gnat_ugn.texi: Bump @copying's copyright year.
	* gnat_rm.texi: Likewise.
gcc/d/
	* gdc.texi: Bump @copyrights-d year.
gcc/fortran/
	* gfortranspec.c (lang_specific_driver): Update copyright notice
	dates.
	* gfc-internals.texi: Bump @copying's copyright year.
	* gfortran.texi: Ditto.
	* intrinsic.texi: Ditto.
	* invoke.texi: Ditto.
gcc/go/
	* gccgo.texi: Bump @copyrights-go year.
libgomp/
	* libgomp.texi: Bump @copying's copyright year.
libitm/
	* libitm.texi: Bump @copying's copyright year.
libquadmath/
	* libquadmath.texi: Bump @copying's copyright year.
2021-01-01 17:45:07 +01:00
Jakub Jelinek
618e665a0f Rotate ChangeLog files - step 2 - remove 2020 entries from ChangeLog files.
Can't be committed together with the previous one due to the ChangeLog vs.
other files restrictions.
2021-01-01 17:30:04 +01:00
Jakub Jelinek
6e92696278 Rotate ChangeLog files - part 1 - add ChangeLog-2020.
2021-01-01  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/ada/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/cp/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/d/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/fortran/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
gcc/testsuite/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
libgfortran/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
libstdc++-v3/
	* ChangeLog-2020: Rotate ChangeLog.  New file.
2021-01-01 17:27:52 +01:00
Joel Brobecker
43dcbb07d2 disable some aapcs/vfp*.c test if not arm_fp16_alternative_ok
The tests use -mfp16-format=alternative, and so should not be run
if that option isn't supported.


for  gcc/testsuite/ChangeLog

	* lib/target-supports.exp
	(check_effective_target_arm_fp16_alternative_ok_nocache):
	Return zero for *-*-vxworks7r* targets.
	* gcc.target/arm/aapcs/vfp22.c: Require arm_fp16_alternative_ok.
	* gcc.target/arm/aapcs/vfp23.c: Likewise.
	* gcc.target/arm/aapcs/vfp24.c: Likewise.
	* gcc.target/arm/aapcs/vfp25.c: Likewise.
2021-01-01 02:13:20 -03:00
Jerome Lambourg
a210519cdd fix testsuite/g++.dg/init/new26.C for C++-14 and later
This test fails during the execution on VxWorks 7 when using
C++-14 and C++-17.


for  gcc/testsuite/ChangeLog

	* g++.dg/init/new26.C: Fix overriding of the delete operator
	for c++14 profile.
2021-01-01 02:12:06 -03:00
Jerome Lambourg
063bb8edbe g++.dg/tls/pr79288.C: Skip on vxworks_kernel (TLS model not supported)
The only TLS model supported in VxWorks kernel mode is local-exec.


for  gcc/testsuite/ChangeLog

	* g++.dg/tls/pr79288.C: Skip on vxworks_kernel (TLS model
	not supported).
2021-01-01 02:10:57 -03:00
Joel Brobecker
ba34b26564 compile gcc.target/arm/{pr78255-2.c,memset-inline-2.c} with -mno-long-calls
If the target is configured such that -mlong-call is passed
by default, the function calls these tests are trying to detect
by scanning the assembly file are performed using long calls,
like so:

    | foo:
    |     @ memset-inline-2.c:12:   memset (a, -1, 14);
    |         mov     r2, #14 @,
    |         mvn     r1, #0  @,
    |         ldr     r0, .L2 @,
    |         ldr     r3, .L2+4       @ tmp112,
    |         bx      r3              @ tmp112

Looking at .L2 (and in particular at .L2+4):

    | .L2:
    |         .word   a
    |         .word   memset   <<<---

This change adds -mno-long-calls to the list of compiler options
to make sure we generate short call code, allowing the assembly
matching to pass.

This is added unconditionally to the dg-options (as opposed to using
dg-additional-options) because this test is already specific to ARM
targets, and -mno-long-calls is available on all ARM targets.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/memset-inline-2.c: Add -mno-long-calls to
	the test's dg-options.
	* gcc.target/arm/pr78255-2.c: Likewise.
2021-01-01 02:07:16 -03:00
Jerome Lambourg
7ba5ce389c Fix testsuite/g++.old-deja/g++.mike/p658.C build failure on VxWorks RTP
The conflicting definition of OK is present in VxWorks RTP headers too.


for  gcc/testsuite/ChangeLog

	* g++.old-deja/g++.mike/p658.C: Also undefine OK on VxWorks RTP.
2021-01-01 02:06:42 -03:00
Jerome Lambourg
0bcaee87e8 Fix testsuite/g++.dg/opt/20050511-1.C compilation error on VxWorks 7
In VxWorks 7, UINT32 is defined in both modes, kernel and rtp.  Adjust
the work around accordingly.


for  gcc/testsuite/ChangeLog

	* g++.dg/opt/20050511-1.C: Work around UINT32 in vxworks rtp
	headers too.
2021-01-01 02:05:57 -03:00
Jerome Lambourg
59cd72afce Skip testsuite/g++.old-deja/g++.pt/const2.C on vxworks_kernel
Linking in vxworks kernel-mode is partial linking, so missing symbols
are not detected.


for  gcc/testsuite/ChangeLog

	* g++.old-deja/g++.pt/const2.C: Skip on vxworks kernel.
2021-01-01 02:00:55 -03:00
Jerome Lambourg
75df9435f3 Remove VxWorks-specific test directives in g++.dg/warn/miss-format-1.C
These are no longer applicable.


for  gcc/testsuite/ChangeLog

	* g++.dg/warn/miss-format-1.C: Remove vxworks-specific test
	directives.
2021-01-01 01:59:32 -03:00
Jerome Lambourg
8aba274de2 Undefine ERROR in g++.dg/tree-ssa/copyprop.C
VxWorks headers define ERROR as a macro, which conflicts with the use
in the test.


for  gcc/testsuite/ChangeLog

	* g++.dg/tree-ssa/copyprop.C: Undefine ERROR if defined.
2021-01-01 01:56:25 -03:00
Jerome Lambourg
af655dee79 skip testsuite/g++.dg/other/anon5.C on vxworks_kernel targets
The vxworks kernel-mode linking is partial linking, so it cannot
detect missing symbols.


for  gcc/testsuite/ChangeLog

	* g++.dg/other/anon5.C: Skip on vxworks kernel.
2021-01-01 01:56:25 -03:00
Jerome Lambourg
76d00e0045 Add conditions on VxWorks versions for gcc.dg/vxworks/initpri?.c
Adjust vxworks initpri expectations, given that vxworks7 has switched
to .init_array.


for  gcc/testsuite/ChangeLog

	* gcc.dg/vxworks/initpri1.c: Tigthen VxWorks version check.
	* gcc.dg/vxworks/initpri2.c: Likewise.
2021-01-01 01:56:25 -03:00
Joel Brobecker
06450993d4 gcc.dg/intmax_t-1.c compiles without error on VxWorks 7 SR06x0
This test currently fails on VxWorks 7 SR06x0 targets when in kernel
mode, because it expects a discrepancy between built-in and system
intmax_t for all VxWorks targets when in kernel mode.  Fortunately,
this has now been fixed when targetting VxWorks 7 SR06x0, so this
commit adjusts the "dg-error" condition to exclude newer versions of
VxWorks 7.

for  gcc/testsuite/ChangeLog

	* gcc.dg/intmax_t-1.c: Do not expect an error on *-*-vxworks7r*
	targets.
2021-01-01 01:54:58 -03:00
Olivier Hainque
6990be171f Fix VxWorks xfail filters on pthread-init-?.c
Match xfail on kernel instead of rtp mode.


for  gcc/testsuite/changeLog

	* gcc.dg/pthread-init-1.c: Fix the VxWorks xfail filters.
	* gcc.dg/pthread-init-2.c: Ditto.
2021-01-01 01:54:57 -03:00
Olivier Hainque
0292de4582 Add missing vxworks filters to lib/target-supports.exp functions
Explicitly disable some vxworks-missing features in the testsuite, that
the current feature tests detect as present.


for  gcc/testsuite/ChangeLog

	* lib/target-supports.exp (check_weak_available,
	check_fork_available, check_effective_target_lto,
	check_effective_target_mempcpy): Add vxworks filters.
2021-01-01 01:46:34 -03:00
Alexandre Oliva
8afe0911e0 -mno-long-calls for mve_libcall tests
The implicit -mlong-calls used in our vxworks configurations changes
the call sequences from those expected in the mve_libcall testcases.

This patch brings the test output in line with the expectations, with
an explicit -mno-long-calls.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/mve/intrinsics/mve_libcall1.c: Pass an
	explicit -mno-long-calls.
	* gcc.target/arm/mve/intrinsics/mve_libcall2.c: Likewise.
2021-01-01 01:46:34 -03:00
Alexandre Oliva
a9ff287b11 -mno-long-calls for arm/no_unique_address tests
The implicit -mlong-calls from our vxworks configurations makes the
tail-call instructions differ from those expected by the
no_unique_address tests in gcc.target/arm.

This patch adds -mno-long-calls to the compilation commands, so that
we generate the expected sequences.


for  gcc/testsuite/ChangeLog

	* g++.target/arm/no_unique_address_1.C: Add -mno-long-calls.
	* g++.target/arm/no_unique_address_2.C: Likewise.
2021-01-01 01:40:40 -03:00
Alexandre Oliva
02d2706db3 -mno-long-calls for arm/headmerge tests
The headmerge tests pass a constant to conditional calls, so that the
same constant is always passed to a function, though it's a different
function depending on which path is taken.

The test checks that the constant appears only once in the assembly
output, as a means to verify that the insns setting up the argument
are unified: they appear as separate insns up to jump2, where
crossjump identifies a common prefix to all conditional paths and
unifies them.

Alas, with -mlong-calls, that we enable in our arm-vxworks
configurations, the argument register is loaded after loading the
callee address into another register.  Since each path calls a
different function, there's no common initial code sequence for
crossjump to unify, and the argument register set up remains separate,
so the test fails.

Though it would surely be desirable for the compiler to perform the
unification of the argument register setting up, this patch merely
avoids the effects of -mlong-calls, with an explicit -mno-long-calls.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/headmerge-1.c: Add -mno-long-calls.
	* gcc.target/arm/headmerge-2.c: Likewise.
2021-01-01 01:39:49 -03:00
Alexandre Oliva
fe0e54c69f -mno-long-calls for expected regalloc in arm/fp16-aapcs-2.c test
The implicit -mlong-calls used in our arm-vxworks configurations
changes the register allocation patterns in the arm/fp16-aapcs-2.c
test: r3 ends up used in the long-call sequence, and we end up using
ip as a temporary, which doesn't match the expected mov patterns.

This patch adds an explicit -mno-long-calls for the generated code to
match the expectation.


for  gcc/testsuite/ChangeLog

	* gcc.target/arm/fp16-aapcs-2.c: Use -mno-long-calls.
2021-01-01 01:38:16 -03:00
GCC Administrator
53be78f071 Daily bump. 2021-01-01 00:16:20 +00:00
Jakub Jelinek
3ab7a91f36 testsuite: Fix up pr56719.c testcase [PR98489]
On some targets, there are no < 8191; and >= 8191; strings,
but < 8191) and >= 8191), so just remove the ; from the regexps.

2021-01-01  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/98489
	PR tree-optimization/56719
	* gcc.dg/tree-ssa/pr56719.c: Remove semicolon from
	scan-tree-dump-times regexps.
2021-01-01 00:03:35 +01:00
Richard Sandiford
58a12b0ead vect: Avoid generating out-of-range shifts [PR98302]
In this testcase we end up with:

  unsigned long long x = ...;
  char y = (char) (x << 37);

The overwidening pattern realised that only the low 8 bits
of x << 37 are needed, but then tried to turn that into:

  unsigned long long x = ...;
  char y = (char) x << 37;

which gives an out-of-range shift.  In this case y can simply
be replaced by zero, but as the comment in the patch says,
it's kind-of awkward to do that in the middle of vectorisation.

Most of the overwidening stuff is about keeping operations
as narrow as possible, which is important for vectorisation
but could be counter-productive for scalars (especially on
RISC targets).  In contrast, optimising y to zero in the above
feels like an independent optimisation that would benefit scalar
code and that should happen before vectorisation.

gcc/
	PR tree-optimization/98302
	* tree-vect-patterns.c (vect_determine_precisions_from_users): Make
	sure that the precision remains greater than the shift count.

gcc/testsuite/
	PR tree-optimization/98302
	* gcc.dg/vect/pr98302.c: New test.
2020-12-31 16:51:34 +00:00
Richard Sandiford
9fa5b473b5 vect: Fix bogus alignment assumption in alias checks [PR94994]
This PR is about a case in which the vectoriser was feeding
incorrect alignment information to tree-data-ref.c, leading
to incorrect runtime alias checks.  The alignment was taken
from the TREE_TYPE of the DR_REF, which in this case was a
COMPONENT_REF with a normally-aligned type.  However, the
underlying MEM_REF was only byte-aligned.

This patch uses dr_alignment to calculate the (byte) alignment
instead, just like we do when creating vector MEM_REFs.

gcc/
	PR tree-optimization/94994
	* tree-vect-data-refs.c (vect_vfa_align): Use dr_alignment.

gcc/testsuite/
	PR tree-optimization/94994
	* gcc.dg/vect/pr94994.c: New test.
2020-12-31 16:51:33 +00:00
Richard Sandiford
0411210fdd genmodes: Update GET_MODE_MASK when changing NUNITS [PR98214]
The static GET_MODE_MASKs for SVE vectors are based on the
static precisions, which in turn are based on 128-bit SVE.
The precisions are later updated based on -msve-vector-bits
(usually to become variable length), but the GET_MODE_MASK
stayed the same.  This caused combine to fold:

  (*_extract:DI (subreg:DI (reg:VNxMM R) 0) ...)

to zero because the extracted bits appeared to be insignificant.

gcc/
	PR rtl-optimization/98214
	* genmodes.c (emit_insn_modes_h): Emit a definition of CONST_MODE_MASK.
	(emit_mode_mask): Treat mode_mask_array as non-constant if adj_nunits.
	(emit_mode_adjustments): Update GET_MODE_MASK when updating
	GET_MODE_NUNITS.
	* machmode.h (mode_mask_array): Use CONST_MODE_MASK.
2020-12-31 16:10:47 +00:00
Nathan Sidwell
3c0ed58209 Merge trunk e798f08192 2020-12-21 12:21:11 -08:00
Nathan Sidwell
c3975ce1cc ICE in has_definition
gcc/cp/
	* module.cc (has_definition): Check VAR_DECL's LANG_SPECIFIC.
	gcc/testsuite/
	* g++.dg/modules/gvar_[ab].C: New.
2020-12-21 10:32:45 -08:00
Nathan Sidwell
d34124b256 Merge trunk 35b8d26874 2020-12-18 05:02:54 -08:00
Nathan Sidwell
0043138307 Merge trunk 433703843b 2020-12-15 11:26:27 -08:00
Nathan Sidwell
86c10ae324 Merge trunk 0feb237657 2020-12-15 09:36:55 -08:00
Nathan Sidwell
d01e5088e6 Remove comment
gcc/
	* diagnostic-core.h (progname): Remove comment.
2020-12-14 13:20:15 -08:00
Nathan Sidwell
4295fbcd7a Merge trunk 62c5ea5228 preprocessor: Deferred macro support 2020-12-14 08:28:12 -08:00
Nathan Sidwell
56318eb629 Named pipe support
gcc/cp
	* mapper-client.cc (module_client::open_module): Allow named pipes.
	gcc/
	* doc/invoke.texi (C++ Module Mapper): Document.
2020-12-14 08:14:43 -08:00
Nathan Sidwell
bfe96878c6 Update deferred macro fields
libcpp/
	* include/cpplib.h (struct cpp_macro): Rename imported field.
	(struct cpp_hashnode): Update deferred doc.
	* macro.c (_cpp_new_macro): Adjust.
	(cpp_get_deferred_macro, get_deferred_or_lazy_macro): Assert more.
	gcc/cp/
	* module.cc (module_state::read_define): Adjust.
	(module_state::install_macros): Likewise.
2020-12-14 08:14:43 -08:00
Nathan Sidwell
bb2e188ed7 Merge trunk 9324f7a25c c++: Avoid considering some conversion ops 2020-12-11 19:53:04 -05:00
Nathan Sidwell
68f0e5e053 Code cleanup
gcc/cp/
	* decl2.c (c_parse_final_cleanups): Refactor.
2020-12-11 09:22:34 -08:00
Nathan Sidwell
0b6270c1d0 Merge trunk 1c6b86b50d c++: module test harness 2020-12-11 08:45:02 -08:00
Nathan Sidwell
1a03a5316b Merge trunk e6e4b20de3 c++: name lookup API for modules 2020-12-10 13:28:23 -08:00
Nathan Sidwell
e6e4b20de3 c++: name lookup API for modules
This adds a set of calls to name lookup that are needed by modules.
Generally installing imported bindings, or walking the current TU's
bindings.  One note about template instantiations though.  When we're
about to instantiate a template we have to know about all the
maybe-partial specializations that exist.  These can be in any
imported module -- not necesarily the module defining the template.
Thus we key such foreign templates to the innermost namespace and
identifier of the containing entitity -- that's the only thing we have
a handle on.  That's why we note and load pending specializations here.

	gcc/cp/
	* module.cc (lazy_specializations_p): Stub.
	* name-lookup.h (append_imported_binding_slot)
	(mergeable_namespacE_slots, lookup_class_binding)
	(walk_module_binding, import_module_binding, set_module_binding)
	(note_pending_specializations, load_pending_specializations)
	(add_module_decl, add_imported_namespace): Declare.
	(get_cxx_dialect_name): Declare.
	(enum WMB_flags): New.
	* name-lookup.c (append_imported_binding_slot)
	(mergeable_namespacE_slots, lookup_class_binding)
	(walk_module_binding, import_module_binding, set_module_binding)
	(note_pending_specializations, load_pending_specializations)
	(add_module_decl, add_imported_namespace): New.
	(get_cxx_dialect_name): Make extern.
2020-12-10 13:10:25 -08:00
Nathan Sidwell
ca79818f73 Merge trunk 4f1d8bd509 c++: modules & using-decls 2020-12-10 12:18:26 -08:00
Nathan Sidwell
ff3f561afe Merge trunk afc14c8d0a c++: modularize spelling suggestions 2020-12-10 08:51:13 -08:00
Nathan Sidwell
5411a232ab Remove unneeded tweaks
gcc/cp/
	* name-lookup.c (member_vec_dedup): Remove gratuitous chaining.
	(check_local_shadow): No need to check for clone.
2020-12-09 12:55:07 -08:00
Nathan Sidwell
7aa1b6fd42 Merge trunk e4c3ec980f c++: Module-specific error and tree dumping 2020-12-09 12:33:55 -08:00
Nathan Sidwell
e4c3ec980f c++: Module-specific error and tree dumping
With modules, we need the ability to name 'foos' in different modules.
The idiom for that is a trailing '@modulename' suffix.  This adds that
to the error printing routines.  I also augment the tree dumping
machinery to show module-specific metadata.

	gcc/cp/
	* error.c (dump_module_suffix): New.
	(dump_aggr_type, dump_simple_decl, dump_function_name): Call it.
	* ptree.c (cxx_print_decl): Print module information.
	* module.cc (module_name, get_importing_module): Stubs.
2020-12-09 12:20:53 -08:00
Nathan Sidwell
f87b20c032 c++: name-lookup cleanups
Name-lookup is the most changed piece of the front end for modules.
Here are some preparatort cleanups and API extensions.

	gcc/cp/
	* name-lookup.h (set_class_bindings): Return vector, take signed
	'extra' parm.
	* name-lookup.c (maybe_lazily_declare): Break out ...
	(get_class_binding): .. of here, call it.
	(find_member_slot): Adjust get_class_bindings call.
	(set_class_bindings): Allow -ve extra.  Return the vector.
	(set_identifier_type_value_with_scope): Remove checking assert.
	(lookup_using_decl): Set decl's context.
	(do_pushtag): Adjust set_identifier_type_value_with_scope handling.
2020-12-09 12:20:53 -08:00
Nathan Sidwell
a873eca894 Pre-merge cleanups
gcc/cp/
	* module.cc (maybe_attach_decl): Use modules_p.
	(module_preprocess_options): Likewise.
	* pt.c (lookup_template_class_1)
	(instantiate_template_specializations): Likewise.
	* parser.c (cp_lexer_new_main): Rename confusing variable.
2020-12-09 05:54:10 -08:00
Nathan Sidwell
8cbe9fd263 Merge trunk cf97b970fe c++: Decl module-specific semantic processing 2020-12-09 05:01:29 -08:00
Nathan Sidwell
22dd3773a0 Merge trunk 570c312c03 c++: Originating and instantiating module 2020-12-08 12:42:48 -08:00
Nathan Sidwell
1de7ca5efe Merge trunk dded5f78cc c++: template and clone fns for modules 2020-12-08 11:48:10 -08:00
Nathan Sidwell
6fcee7f194 Merge trunk 0bd4fecbea c++: Fix MODULE_VERSION breakage 2020-12-08 11:30:45 -08:00
Nathan Sidwell
b0db6b0b5e Adjust duplicate checker
gcc/cp/
	* cp-tree.h (comparing_typenames): Replace with ...
	(map_context_from, map_context_to): ... this.
	* typeck.c (structural_comptypes): Adjust.
	* pt.c (comparing_typenames): Delete.
	(spec_hasher::equal): Adjust.
	* tree.c (cp_tree_equal): Check map_context_from & to for failed
	parameter context.
	* module.cc (map_context_from, map_context_to): Define.
	(check_mergeable_decl): Set & unset map_context vars.
	(trees_in::is_matching_decl): Likewise.
	(module_state::read_cluster): Set & unset
	comparing_specializations, not comparing_typenames.
2020-12-07 12:09:24 -08:00
Nathan Sidwell
f52faf7c78 Merge trunk ffb268ffcf c++: Adjust array type construction 2020-12-07 09:14:11 -08:00
Nathan Sidwell
e968f107df Merge trunk 5a26d4a204 c++: Revert dependent-array changes 2020-12-04 08:59:31 -08:00
Nathan Sidwell
f963b2b0b0 Merge trunk 97eaf8c92f c++: Module API declarations 2020-12-04 05:45:03 -08:00
Nathan Sidwell
a49c711e57 Merge trunk 62fb1b9e0d c++: Fix array type dependency [PR 98107] 2020-12-03 08:55:53 -08:00
Nathan Sidwell
d76a624571 Fix noncanonical_target
c++tools/
	* configure.ac: Need ACX_NONCANONICAL_TARGET
	* configure: Rebuilt.
2020-12-03 06:51:46 -08:00
Nathan Sidwell
8a9aaaf7c1 c++tools: fix typo
c++tools/
	* Makefile.in (libexecdir): Fix typo.
2020-12-03 06:17:49 -08:00
Nathan Sidwell
ead3c5394d More documentation
gcc/
	* doc/invoke.texi (C++ Modules): Add CMI section.
2020-12-02 15:06:45 -05:00
Nathan Sidwell
fd5e5a257b Merge some lang_decl flags
gcc/cp/
	* cp-tree.h (DECL_MODULE_PENDING_SPECIALIZATIONS_P)
	(DECL_MODULE_PENDING_MEMBERS_P): Use same module_pending_p field.
	(DECL_ATTACHED_DECLS_P): Rename to ...
	(DECL_MODULE_ATTACHEMENTS_P): ... this.  Use module_pending_p
	field.
	(struct lang_decl_base): Replace module_pending_specializations_p,
	module_pending_members_p, attached_decls_p fields with single
	module_pending_p field.
	* module.cc (trees_{in,out}::lang_decl_bools): Only stream
	module_pending_p for vars & fns.
	(trees_{in,out}::decl_value): Adjust DECL_MODULE_ATTACHMENTS_P
	changes.
	(trees_out::get_merge_kind): Likewise.
	(trees_in::key_mergeable, maybe_attach_decl): Likewise.
	* lex.c (cxx_dup_lang_specific_decl): Directly clear some module flags.
2020-12-02 11:28:51 -08:00
Nathan Sidwell
67c23df4fa Merge trunk 05f7a2afe8 C++ Module Binding Vector 2020-12-02 06:34:57 -08:00
Nathan Sidwell
6420399409 Merge trunk 41676a36a0 C++ Module keywords 2020-12-02 05:41:56 -08:00
Nathan Sidwell
89611c477c A Grand Renaming -- Crackin'!
gcc/cp/
	* name-lookup.h: Rename MODULE_VECTOR and associated structs &
	macros to BINDING_VECTOR.
	* cp-tree.h: Adjust.
	* cp-tree.def: Adjust.
	* decl.c: Adjust.
	* module.cc: Adjust.
	* name-lookup.c: Adjust.
	* ptree.c: Adjust.
	* decl.c: Adjust.
2020-12-02 05:25:26 -08:00
Nathan Sidwell
a2ece73254 Move struct module_vector
gcc/cp/
	* cp-tree.h (struct tree_module_vec): Move to ...
	* name-lookup.h (struct tree_module_vec): ... here.
2020-12-02 04:52:07 -08:00
Nathan Sidwell
12930302c2 Rename a struct
gcc/cp/
	* lex.c (struct token_coro): Rename to ...
	(struct module_token_filter): ... here.  Adjust through out.
2020-12-02 04:39:35 -08:00
Nathan Sidwell
dfdce31c9e libcody: Update from upstream, removing deprecated functions. 2020-12-01 10:40:38 -08:00
Nathan Sidwell
ee1460b684 Merge trunk 855bb43f6d 2020-12-01 09:18:56 -08:00
Nathan Sidwell
b1ee8f1468 Merge trunk eae68c434f testsuite: Adjust pruning 2020-12-01 08:33:45 -08:00
Nathan Sidwell
6e1fc16ff9 Merge trunk 83a1beee27 libstdc++: Add C++2a synchronization support 2020-12-01 07:54:15 -08:00
Nathan Sidwell
25ed79ba13 Fix noexcept circularity
gcc/cp/
	* module.cc (trees_{in,out}::decl_container): Stream template as
	well as container.  Do not strip (no nudity!)
	gcc/testsuite/
	* g++.dg/modules/noexcept-1{.h,_[ab].[HC]}: New.
2020-12-01 07:19:42 -08:00
Nathan Sidwell
7c6ac2a899 Documentation updates
gcc/
	* doc/invoke.texi: Updates from review.
2020-11-30 05:06:56 -08:00
Nathan Sidwell
e9bbe7ce0b Merge trunk 89d9c634dc 2020-11-24 05:36:59 -08:00
Nathan Sidwell
3453ca9c92 Note some potential issues
gcc/cp/
	* Make-lang.in: Don't depend VERSION on src dir.
	* module.cc: Note some potential issues.
2020-11-24 05:36:08 -08:00
Nathan Sidwell
505e63fe26 Add flang-include-translate-not
gcc/
	* doc/invoke.texi (-flang-include-translate-not): Document.
	gcc/cp/
	* module.cc (maybe_translate_include): Add not-translate noting.
	gcc/c-family/
	* c.opt (flang-include-translate-not): New.
2020-11-24 05:35:58 -08:00
Nathan Sidwell
0e9a89a169 Include translate finesse
libcody/
	Update from upstream, INCLUDE_TRANSLATE response meaning change
2020-11-23 04:51:57 -08:00
Nathan Sidwell
5a52a0a4a1 Doc fixes
gcc/
	* doc/invoke.texi: Fixes.
2020-11-20 12:10:16 -05:00
Nathan Sidwell
535f1eaf8d libcody: Update from upstream. 2020-11-20 07:37:20 -08:00
Nathan Sidwell
a089fe1fbb Adjust template spec accessor
gcc/cp/
	* cp-tree.h (match_mergeable_specialization): Take a spec_entry.
	* pt.c (match_mergeable_specialization): Likewise.
	* module.cc (trees_in::decl_value): Adjust.
	(trees_{in,out}::key_mergeable): Adjust.
	(specialization_add): Adjust.
2020-11-20 07:23:14 -08:00
Nathan Sidwell
e225fe8f4f Remove erraneous doc delete 2020-11-20 10:16:37 -05:00
Nathan Sidwell
eb6351eac9 Update docs
gcc/
	* doc/invoke.texi: Update
	* doc/cppopts.texi: Update
2020-11-20 10:11:14 -05:00
Nathan Sidwell
02d6056179 Merge trunk 5bba2215c2 c++: Template hash access 2020-11-20 04:30:57 -08:00
Nathan Sidwell
0ef7a82c24 Merge trunk bf425849f1 preprocessor: main-file cleanup 2020-11-19 04:59:15 -08:00
Nathan Sidwell
3e3a50eb0c Tidy up preprocess_undef lang_hook
gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_UNDEF): Do not override here.
	* cp-tree.h (module_cpp_undef): Do not declare.
	* module.cc (module_cpp_undef): Delete.
	(handle_module_option): Store cpp_main_search code in flag_header_unit.
	(module_preprocess_options): Set main_search option here.
	Conditionally set preprocess_undef lang hook here.
2020-11-18 13:13:32 -08:00
Nathan Sidwell
9a9d2e6556 Tidy up main_file detection
libcpp/
	* include/cpplib.h (enum cpp_main_search): Add CMS_header value.
	* internal.h (cpp_in_system_header): Rename to ...
	(_cpp_in_system_header): ... here.
	(cpp_in_primary_file): Rename to ...
	(_cpp_in_main_source_file): ... here.  Compare main_file equality
	and check main_search value.
	* lex.c (maybe_va_opt_error, _cpp_lex_direct): Adjust.
	* macro.c (_cpp_builtin_macro_text): Adjust.
	(replace_args): Likewise.
	* directives.c (do_include_next): Adjust.
	(do_pragma_once, do_pragma_system_header): Likewise.
	* files.c (struct _cpp_file): Delete main_file field.
	(pch_open): Check pfile->main_file equality.
	(make_cpp_file): Drop cpp_reader parm, don't set main_file.
	(_cpp_find_file): Adjust.
	(_cpp_stack_file): Check pfile->main_file equality.  Drop
	main_file clearing.
	(struct report_missing_guard_data): Add cpp_reader field.
	(report_missing_guard): Check pfile->main_file equality.
	(_cpp_report_missing_guards): Adjust.
2020-11-18 13:12:50 -08:00
Nathan Sidwell
49a91b6fe2 Merge trunk 92648faa1c
08-cpp-mkdeps.diff
	05-cpp-files.diff
	04a-cpp-lexer.diff
	32-aix-fixincl.diff
2020-11-18 11:55:38 -08:00
Nathan Sidwell
057222167c Merge trunk d3ae802402
01-langhooks.diff
	02-cpp-line-maps.diff
	03-cpp-callbacks.diff
	19-global-trees.diff
	21a-int-cst.diff
2020-11-18 04:50:39 -08:00
Nathan Sidwell
99c594dda5 Adjust lang hooks
gcc/c-family/
	* c-opts.c (c_common_init): Drop preprocess_undef
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_DEFERRED_MACRO): Delete.
	* cp-tree.h (module_cpp_deferred_macro): Do not declare.
	* module.cc (module_cpp_deferred_macro): Delete.
	(module_preprocess_options): Set deferred macro and undef
	callbacks here.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_UNDEF): Delete.
	* langhooks.h (struct lang_hooks): Delete
	preprocess_deferred_macro.
2020-11-16 10:34:25 -08:00
Nathan Sidwell
2d23df6e99 Constrained partial variable templates
gcc/cp/
	* module.cc (trees_{in,out}::key_mergeable): Variable templates
	can be partially specialized and constrained.
	(finish_module_processing): Point at module decl, so ICEs blame
	that.
	gcc/testsuite/
	* g++.dg/modules/var-tpl-concept-1{.h,_[ab].C}: New.
2020-11-16 09:36:47 -08:00
Nathan Sidwell
d3af74a5cf Merge trunk 63496cbea5 2020-11-16 05:14:36 -08:00
Nathan Sidwell
33ef7083da using enum support
gcc/cp/
	* module.cc (trees_out::mark_class_def): Mark cloned enum consts
	gcc/testsuite/
	* g++.dd/modules/using-enum-1_[ab].[HC]: New.
2020-11-16 04:53:47 -08:00
Nathan Sidwell
2711152d89 Merge trunk d50310408f c++: Implement C++20 'using enum' 2020-11-13 11:18:24 -08:00
Nathan Sidwell
aab3efb1b2 Merge trunk e3b3b59683 2020-11-13 10:56:59 -08:00
Nathan Sidwell
286a25f3b6 Fix libiberty linking
* g++tools/Makefile.in (LIBIBERTY): New.
2020-11-13 09:02:28 -08:00
Nathan Sidwell
6393b1f93a Merge trunk 5fa821bba73# 2020-11-13 05:20:55 -08:00
Nathan Sidwell
c265470c48 Merge trunk 7f851c3341 libstdc++: Fix __numeric_traits_integer<__int20> 2020-11-12 12:06:03 -08:00
Nathan Sidwell
f41bab85db Enum dedup ODR check fix
gcc/cp/
	* tree.c (cp_tree_equal): Allow NON_LVALUE_EXPR &
	VIEW_CONVERT_EXPR with NULL types.
	gcc/testsuite/
	* g++.dg/modules/loc-wrapper-1{.h,_a.H,_b.C}: New.
2020-11-12 11:44:15 -08:00
Nathan Sidwell
49305748e8 Fix some configure errors
* Makefile.def: Fix g++ check implications.
	* Makefile.in: Rebuilt.
	gcc/
	* config.in: Rebuilt.
	* configure: Rebuilt.
	* configure.ac: Remove unneeded checks
	gcc/cp/
2020-11-12 09:02:34 -08:00
Nathan Sidwell
3d7945021a Merge trunk 3c3beb1a81 2020-11-12 08:05:39 -08:00
Nathan Sidwell
db742646c1 Update to new Cody::Resolver API
c++tools/
	* resolver.h (module_resolver): Update to new API.
	* resolver.cc (module_resolver): Likewise.
2020-11-11 09:54:30 -08:00
Nathan Sidwell
257f541310 Adjust c++tools
* Makefile.def (c++tools): Depends on gcc
	* Makefile.in: Rebuilt
	c++tools/
	* mapper.h: Rename to ...
	* resolver.h: ... here.  Move mapper-client to
	gcc/cp/mapper-client.h
	* resolver.cc: Adjust.
	* configure.ac: Fix extraneous ]
	* configure: Rebuilt.
	gcc/cp/
	* mapper-client.h: New, split from c++tools/mapper.h.
	* mapper-client.cc: Adjust.
	* mapper-resolver.cc: Adjust.
	* module.cc: Adjust.
2020-11-11 06:25:33 -08:00
Nathan Sidwell
0835527413 Add mapper flags support
c++tools/
	* mapper.h (class mapper_client): Add flag support.
	gcc/cp/
	* mapper-client: Likewise.
	* module.cc (maybe_translate_include): Likewise.
	(preprocessed_module): Likewise.
2020-11-10 11:58:38 -08:00
Nathan Sidwell
6bfad31b62 Rebase libcody -- $flag support.
libcody/
	Rebase on upstream -- $flag support.
2020-11-10 11:54:25 -08:00
Nathan Sidwell
2e6ccb7833 Create c++tools dir
* Makefile.def: Add c++tools
	* Makefile.tpl: Likewise.
	* configure.ac: Likewise.
	* Makefile.in: Regenerated.
	* configure: Regenerated.
	c++tools/
	* Makefile.in: New.
	* configure.ac: New.
	* config.h.in: Generated
	* configure: Generated
	* mapper.h: Moved from gcc/cp.
	* resolver.cc: Moved from gcc/cp/mapper-resolver.cc
	* server.cc: Movedfrom gcc/cp/mapper-server.cc
	gcc/
	* configure.ac: Remove mapper-server-specific checks
	* config.in: Rebuilt.
	* configure: Rebuilt.
	gcc/cp/
	* Make-lang.in: Remove mapper-server.
	* mapper-client.cc: Adjusted.
	* mapper-resolver.cc: Moved to c++tools/resolver.cc, replaced with
	stub here.
	* mapper.h: Moved to c++tools, replaced with stub here.
	* module.cc: Adjust.
	gcc/testsuite/
	* g++.dg/modules/extern-tpl-1_b.C: Adjust invocation.
	* g++.dg/modules/inc-xlate-1_e.C: Likewise.
	* g++.dg/modules/legacy-2_b.H: Likewise.
	* g++.dg/modules/legacy-6_c.C: Likewise.
	* g++.dg/modules/legacy-6_d.C: Likewise.
2020-11-10 10:12:17 -08:00
Nathan Sidwell
47a70f40ef Merge trunk e38cd64ac6 c++: ADL refactor 2020-11-09 05:27:36 -08:00
Nathan Sidwell
3658892018 Address review comments
libcpp/
	* lex.c (cpp_maybe_module_directive): Add asserts and comments
	about initial and final state.  Remove __builtin_expects.
	(_cpp_lex_token): Remove __builtin_expect.
2020-11-09 04:51:00 -08:00
Nathan Sidwell
0986ce3ae9 Merge trunk 4b5f564a5d libcpp: Provide date routine 2020-11-06 10:27:15 -08:00
Nathan Sidwell
98186da5a2 Document cache_integer_cst
gcc/
	tree.c (cache_integer_cst): Document API.
2020-11-06 09:04:49 -08:00
Nathan Sidwell
130faab585 Alter revision setting
gcc/cp/
	* Make-lang.in: Drop git hash collection.
	gcc/
	* REVISION: New.
2020-11-06 05:55:31 -08:00
Nathan Sidwell
4a919dcc71 Revert some local changes
gcc/cp/
	* parser.c (cp_parser_diagnose_invalid_type_name): Revert local
	changes.
2020-11-06 05:28:11 -08:00
Nathan Sidwell
9582481c72 Genericize time API
libcpp/
	* include/cpplib.h (enum CPP_time_kind): New.
	(cpp_get_date): Declare.
	* internal.h (struct cpp_reader): Replace source_date_epoch with
	time_stamp and time_stamp_kind.
	* init.c (cpp_create_reader): Initialize them.
	* macro.c (_cpp_builtin_macro_text): Use cpp_get_date.
	(cpp_get_date): Broken out from _cpp_builtin_macro_text and
	genericize.
	gcc/cp/
	* module.cc (module_state_write_readme): Use new libcpp API.
2020-11-06 05:27:05 -08:00
Nathan Sidwell
484c64ebaf support SOURCE_DATE_EPOCH
gcc/cp/
	* module.cc (module_state::write_Readme): Add cpp_reader parm, use
	cb_get_source_data_epoch to see if the time is locked.
2020-11-05 12:53:23 -08:00
Nathan Sidwell
8ab6ed9c4f Fixup merge kind enum
gcc/cp/
	* module.cc (enum merge_kind): Minor remapping.
	(merge_kind_name): Adjust.
2020-11-05 12:28:17 -08:00
Nathan Sidwell
ddae3c4f2e Remove now-unreachable tmpl_partial handling
gcc/cp/
	* module.cc (depset::fini_partial_redirect): Delete.
	(depset::hash::add_partial_redirect): Delete.
	(depset::hash::init_partial_redirect): Delete.
	(enum merge_kind): Delete MK_tmpl_partial_mask,
	MK_type_partial_spec.
	(trees_out::get_merge_kind): Adjust.
	(trees_{in,out}::key_mergeable): Delete tmpl_partial case.
	(depset::hash::make_dependency): Directly create the redirect here.
	(depset::hash::add_specializations): Do not detect partial
	specializations here.
2020-11-05 12:06:33 -08:00
Nathan Sidwell
02dd63c9e6 Replace EK_DECL + DB_PARTIAL_BIT with EK_PARTIAL
gcc/cp/
	* module.cc (enum depset::entity_kind): Add EK_PARTIAL,
	EK_DIRECT_HWM.
	(enum depset::disc_bits): Delete DB_PARTIAL_BIT.
	(depset::is_partial): Delete.
	(depset::fini_partial_redirect): Assert EK_PARTIAL.
	(depset::entity_kind_name): Add EK_PARTIAL.
	(trees_out::decl_node): Adjust redirect asserts.
	(trees_out::get_merge_kind): No partial template.
	(depset::hash::make_dependency): Partials create EK_PARTIAL.
	(depset::hash::add_partial_entities): Adjust,
	(depset::hash::add_specializations): Adjust.
	(depset::hash::add_mergeable): Adjust.
	(sort_cluster, module_state::write_cluster): Likewise.
	(module_state::write_{entities,pendings}): Adjust.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-5_a.C: Adjust scan.
2020-11-05 11:32:10 -08:00
Nathan Sidwell
c6a08b99e7 Constrained partial specializations
gcc/cp/
	* module.cc (depset::hash::add_partial_redirect): Break out
	helpers ...
	(depset::fini_partial_redirect): ... this and ...
	(depset::hash::init_partial_redirect): ... this.  Call them.
	(partial_specializations): New vector.
	(depset::hash::make_dependency): Deal with partial
	specializations.
	(depset::hash::add_partial_entities): New.
	(deset::hash::add_specializations): We may have added a partial.
	(module_state::write_cluster): Count partials.
	(module_state::write_pendings): Likewise.
	(module_state::write): Add partials.
	(set_defining_module): Append explicit specializations.
	gcc/testsuite/
	* g++.dg/modules/constrained-partial-1_[ab].C: New.
2020-11-05 08:01:58 -08:00
Nathan Sidwell
4c56b02498 Adjust module-mapper path search behaviour
gcc/cp/
	* mapper-client.cc (spawn_mapper_program): Use @ to indicate
	looking in install dir.
	gcc/
	* doc/invoke.texi (fmodule-mapper): Document behaviour.
	gcc/testsuite/
	* g++.dg/modules/extern-tpl-1_b.C: Adjust options.
	* g++.dg/modules/inc-xlate-1_e.C: Adjust options.
	* g++.dg/modules/legacy-2_b.H: Adjust options.
	* g++.dg/modules/legacy-6_[cdef].C: Adjust options.
2020-11-05 05:33:47 -08:00
Nathan Sidwell
a331aa92fb fix scan for i686
gcc/testsuite/
	* g++.dg/modules/builtin-3_[ab].C: Adjust for i686
2020-11-04 07:19:34 -08:00
Nathan Sidwell
1c548a8f65 Fix i686 build failure
gcc/cp/
	* mapper-resolved.cc: define INCLUDE_ALGORITHM.
2020-11-04 06:55:37 -08:00
Nathan Sidwell
dbce8dbd1b Merge trunk a52bf01643 c++: using-decl instantiation 2020-11-03 10:36:50 -08:00
Nathan Sidwell
0ecda01a12 Cleanup unnecessary or stale changes
gcc/cp/
	* class.c (clone_cdtor): Fix erroneous comment.
	* decl.c (finish_enum_value_list): Revert local change.
	gcc/
	* doc/cppopts.texi (EE): Delete stale info.
	libcpp.
	* files.c (cpp_main_controlling_macro): Delete.
	* include/cpplibc.h (cpp_main_controlling_macro): Delete.
	* mkdeps.c: Rename bmi->cmi
2020-11-03 10:35:56 -08:00
Nathan Sidwell
cbf381f3e1 Merge trunk 444655b6f0 c++: cp_tree_equal cleanups 2020-11-03 06:40:09 -08:00
Nathan Sidwell
b269b6ce45 Remove unneeded fn
libcpp/
	* include/cpplib.h (cpp_enable_filename_token): Delete.
	* macro.c (cpp_enable_filename_token): Delete.
2020-11-03 05:56:17 -08:00
Nathan Sidwell
c385d545b0 Merge trunk b2a31e2c34 2020-11-02 06:28:38 -08:00
Nathan Sidwell
41710c43ad Kill obsolete FIXME
gcc/cp/
	* module.cc (module_state::write_elf): Remove obsolete FIXME.
2020-11-02 04:58:50 -08:00
Nathan Sidwell
bd3edcc6e0 Add DECL_ACCESS support
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream using_decl decls.
	(trees_out::lang_decl_vals): Do not stream DECL_ACCESS that is
	actually an access alterer.
	(trees_in::read_class_def): Reconstruct DECL_ACCESS.
	gcc/testsuite/
	* g++.dg/modules/access-1_[abc].C: New.
2020-10-30 10:35:50 -07:00
Nathan Sidwell
46337895de More FIXMEs 2020-10-30 09:09:25 -07:00
Nathan Sidwell
81b4ae98a7 More FIXMEs
gcc/cp/
	* cp-tree.h (maybe_check_all_macros): Declare.
	* module.cc (slurping::release_macros): New.
	(slurping::~slurping): Use it.
	(module_state::maybe_completed_reading): Use it.
	(maybe_check_all_macros): New, broken out of ...
	(finish_module_processing): ... here.  DO NOT CALL.
	* parser.c (cp_lexer_new_main): Call it here.
2020-10-30 07:55:24 -07:00
Nathan Sidwell
f3bd075e5b Cache Path-Of-Instantiation
gcc/cp/
	* cp-tree.h (struct tinst_level): Add path and visible bitmaps.
	* module.cc (path_of_instantiation): New recursive helper broken
	out of ...
	(module_visible_instantiation): ... here.  Call it.
	* pt.c (push_tinst_level_loc): Nullify path and visible bitmaps.
2020-10-30 06:19:20 -07:00
Nathan Sidwell
f129054735 Fixme addressing 2020-10-29 14:04:29 -07:00
Nathan Sidwell
db9d03292b Prague anon-enum keying by underlying type
gcc/cp/
	* module.cc (trees_{in,out}::key_mergeable): Stream MK_enum
	underlying type decl.
	(check_mergeable_decl): The enum itself is on the ovl list.
	* name-lookup.c (init_global_partition): Copy the enum for the
	first member of an anonymous enum.
	gcc/testsuite/
	* g++.dg/modules/enum-8_[abcd].[CH]: New.
2020-10-29 13:24:51 -07:00
Nathan Sidwell
1dd2d6c253 Fix FIXMEs
gcc/cp/
	* module.cc (trees_out::get_merge_kind): Resolve FIXMEs.
	(trees_out::key_mergeable): Likewise.
2020-10-29 10:24:34 -07:00
Nathan Sidwell
7e388a776a Check function-scope nameable decls are typedefs
gcc/cp/
	* module.cc (trees_out::get_merge_kind): Only function-scope
	entities we meet are implicit TYPE_DECLs.
2020-10-29 09:37:58 -07:00
Nathan Sidwell
1679952c7a Merge trunk 9703b8d98c c++: Stop (most) function-scope entities having a template header 2020-10-29 08:48:20 -07:00
Nathan Sidwell
6cf1a723f8 Merge trunk bafcf452c7 opts: Sanity check for param names.
gcc/
	* params.opt: Fixup lazy-load parm name.
	gcc/testsuite/
	* g++.dg/modules/freeze-1_d.C: Adjust.
	* g++.dg/modules/nest-1_c.C: Adjust.
2020-10-29 08:23:30 -07:00
Nathan Sidwell
7105aeb958 Merge trunk 53dede0f04 CSE conversions within sincos 2020-10-29 07:54:45 -07:00
Nathan Sidwell
e6a58c9189 Merge trunk 4289e488dd c++: Make OMP UDR DECL_LOCAL_DECL_P earlier 2020-10-28 11:49:19 -07:00
Nathan Sidwell
c7c4e6db5e Merge trunk 7d5f38e49e c++: Refactor push_template_decl 2020-10-28 08:26:32 -07:00
Nathan Sidwell
95ca0ee653 More FIXMEs
gcc/cp/
	* module.cc: More FIXME addressing.
	(trees_out::get_merge_kind): Assert function-scope entities are
	not unexpected.
2020-10-28 07:24:47 -07:00
Nathan Sidwell
6c2dc8d4a3 Address FIXMES
gcc/cp/
	* module.cc: More FIXME fixing.
2020-10-28 05:57:02 -07:00
Nathan Sidwell
c8125a20de Fix various -xc++-header flags
gcc/cp/
	* lang-specs.h: Fix -xc++-{,user-,system-}header.
2020-10-28 05:35:42 -07:00
Nathan Sidwell
c99d1f0b66 No special anon-namespace naming
gcc/cp/
	* name-lookup.h (add_imported_namespace): Drop anon name parm.
	* name-lookup.c (anon_name): Delete.
	(make_namespace): Nothing special for anonymous namespace.
	(add_imported_namespace): Likewise.
	* module.cc (module_state::{read,write}_namespaces): Anon
	namepspace does not need naming.
2020-10-27 12:59:06 -07:00
Nathan Sidwell
3443305d12 Add tr1 as header unit
gcc/testsuite/
	* g++.dg/modules/xtreme-tr1{.h,_a.H,_b.C}: New.
2020-10-27 12:38:33 -07:00
Nathan Sidwell
df57ef6f2e Anonymous members with typedef name
gcc/cp/
	* module.cc (trees_out::vec_chained_decls): Detect anonymous
	struct with typedef name.
	(trees_{in,out}::add_indirect): Assert TYPE_DECL is typedef or
	type's TYPE_NAME.
	(trees_{in,out}::{read,write}_class_def): Cope with anon-structs
	with typedef names.
	gcc/testsuite/
	* g++.dg/modules/tdef-8_[ab].C: New.
2020-10-27 12:29:42 -07:00
Nathan Sidwell
f5f2ca3000 Address a couple of FIXMEs
gcc/cp/
	* module.cc (depset_cmp): Decide strcmp question.
	(module_state::write_prepare_maps): Document pruning question.
2020-10-27 10:35:52 -07:00
Nathan Sidwell
a8f8a80306 nested udts are not a thing
gcc/cp/
	* module.cc (trees_{in,out}::{read,write}_class_def): Remove
	nested udt FIXMEs.  They are no longer a thing.
2020-10-27 10:24:02 -07:00
Nathan Sidwell
c06eb13861 Merge trunk 54380d42e6 c++: Kill nested_udts 2020-10-27 10:21:34 -07:00
Nathan Sidwell
1bcfe77203 Type attributes
gcc/cp/
	* module.cc (trees_{in,out{::type_node): Stream attribs.
2020-10-26 12:31:23 -07:00
Nathan Sidwell
2bd8a7ca3d Aligned type support
gcc/cp/
	* module.cc (trees_out::type_node): Stream alignment.
	(trees_in::type_node): Alignment is a log.
	gcc/testsuite/
	* g++.dg/modules/align-type-1_[ab].C: New.
2020-10-26 10:52:21 -07:00
Nathan Sidwell
cb8c13729c More FIXME resolution
gcc/cp/
	* module.cc (trees_{in,out}::tree_list): Address more Fixmes,
	either by obsoleting them, or coding around their confusion.
2020-10-26 10:26:14 -07:00
Nathan Sidwell
8cabe89e17 libcody rebase
libcody/
	Rebase on upstream, robustify enable-checking.
2020-10-26 09:51:40 -07:00
Nathan Sidwell
059a635068 Avoid nreverse on readback
gcc/cp/
	* module.cc (trees_{in,out}::tree_list): New streamers.
	(trees_{in,out}::{read,write}_class_def): Use them.
2020-10-26 06:41:50 -07:00
Nathan Sidwell
a63681e296 More FIXME resolving, mainly in documentation
gcc/cp/
	* module.cc: Remove or clarify more now-obsolete FIXMEs.
2020-10-26 05:55:25 -07:00
Nathan Sidwell
2d1e598895 Clarify FIXMES in documentation
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Document
	middle-endy/debugy BLOCK fields.  Document OPTIMIZATION_NODE &
	TARGET_OPTION_NODE issue.
2020-10-26 05:21:41 -07:00
Nathan Sidwell
a0d842c128 Fix RESULT_DECL streaming
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): RESULT_DECL is like PARM_DECL.
2020-10-26 05:21:22 -07:00
Nathan Sidwell
3931fe3d77 Rebase libcody, fix bootstrap
libcody/
	Rebase on upstream, fix enable-checking & bootstrap
2020-10-26 04:55:04 -07:00
Nathan Sidwell
11e0a02ed6 Suspicious FIXME is obsolete
gcc/cp/
	* module.cc (trees_in::chained_decls): Chain should always be null.
2020-10-26 04:54:00 -07:00
Nathan Sidwell
ac089f0a16 libcody rebase
libcody/
	Rebase on upstream, collect new autoconf bits.
2020-10-26 04:26:00 -07:00
Nathan Sidwell
9c31225a43 Address some FIXMEs
gcc/cp/
	* module.cc: Address 3 now-irrelevant FIXMES.
2020-10-23 12:26:24 -07:00
Nathan Sidwell
cf17ae6ada Reorder enum merge_kind
gcc/cp/
	* module.cc (enum merge_kind): Reorder.
	(merge_kind_name): Likewise.
2020-10-23 12:09:01 -07:00
Nathan Sidwell
e20d6929a6 Merge trunk cd8b7d7b24
Link with the configured net lib on vxworks7
2020-10-23 10:25:06 -07:00
Nathan Sidwell
2ef34e81b2 Merge trunk e957b86ca2
libstdc++: Rebase include/pstl to current upstream
	gcc/testsuite/
	PR 97549 workaround
	* g++.dg/modules/xtream-header{,-2}.h: Don't include <exception>.
2020-10-23 10:24:29 -07:00
Nathan Sidwell
bf53df8813 Merge trunk 310fe80bab
Fortran: class.c - update vtable comment
2020-10-23 07:38:33 -07:00
Nathan Sidwell
24501a7519 More windows host bits
gcc/cp/
	* mapper-server.cc: Disable networking when not available.
2020-10-23 07:03:37 -04:00
Nathan Sidwell
d963288e3a More windows defense
libcody/  9e71a7c Avoid fstatat when unavailable
	gcc/
	* configure.ac: Check for fstatat & O_CLOEXEC.
	* configure: Regenerated.
	* config.in: Regenerated.
	gcc/cp/
	* mapper-resolver.cc: Include config.h, system.h.  Cope with lack
	of fstatat.
	* module.cc: Workaround lack of O_CLOEXEC.
2020-10-22 18:37:07 -04:00
Nathan Sidwell
de3ad5aa97 Block-scope structures, like wow, why worked so far?
gcc/cp/
	* module.cc (trees_{in,out}::decl_value): Stream local struct
	definitions.
	gcc/testsuite/
	* g++.dg/modules/local-struct-1_[ab].C: New.
2020-10-22 11:53:02 -07:00
Nathan Sidwell
0cd3c276ab function arg contexts
gcc/cp/
	* module.cc (trees_in::is_matching_decl): Add builtin data
	copying.
	(trees_in::read_function_def): Recontextualize parms.
	* decl.c (duplicate_decls): Refactor builtin copying.
	gcc/testsuite/
	* g++.dg/modules/builtin-7_[ab].[HC]: New.
2020-10-22 08:57:44 -07:00
Nathan Sidwell
d028af9e5f libcody update
libcody/
	* fatal.cc: noexcept fix from Iain Sandoe.
2020-10-22 10:59:41 -04:00
Nathan Sidwell
215d369942 Anticipated builtin smashing
gcc/cp/
	* gcc/cp/decl.c (duplicate_decls_): Return error_mark_node for
	extern "C" collision.
	* gcc/cp/module.cc (check_mergeable_decl): Check extern "C"-ness.
	(trees_in::is_matching_decl): Check extern "C" builtin mismatch.
	Propagate flags on smashing a builtin.
	gcc/testsuite/
	* g++.dg/modules/builtin-6_[ab].[HC]: New.
2020-10-22 05:13:32 -07:00
Nathan Sidwell
6246418aa4 Module mapper networking enablement
gcc/cp/
	* mapper-client.cc: Enable networking only when CODY_NETWORKING
	* mapper-server.cc: Likewise.
	libcody/
	Rebase b26a54f | Enable networking only on known-good systems
2020-10-22 07:46:04 -04:00
Nathan Sidwell
ec6be390c6 Do not install libcody
* Makefile.def: Don't build libcody for build.  Do not install it
	either.
	* Makefile.in: Rebuilt.
2020-10-21 17:45:01 -04:00
Nathan Sidwell
f7bac0295d Vector bools
gcc/cp/
	* module.cc (trees_{in,out}::type_node): Deal with non-standard bools.
	gcc/testsuite/
	* g++.dg/modules/bool-1{,_[abc]}.[CHh]: New.
2020-10-21 11:02:47 -07:00
Nathan Sidwell
853067ac5e Trivial darwin test fix
gcc/testsuite/
	* g++.dg/modules/builtin-3_[ab].C: Scans for darwin, thanks Iain
2020-10-21 12:37:20 -04:00
Nathan Sidwell
385f83480f AIX fixinclude
fixincludes/
	* inclhack.def (aix_physadr_t): New.
	* fixincl.x: Regenerated.
2020-10-21 10:43:42 -04:00
Nathan Sidwell
62d7aae08f AIX test fix
gcc/testsuite/
	* g++.dg/modules/literals-1_[ab].C: Add -Wno-psabi
2020-10-21 06:14:43 -07:00
Nathan Sidwell
43d3295555 libcody fix
gcc/
	* Makefile.in (INCLUDES): Add $(CODYINC).
2020-10-20 12:23:55 -07:00
Nathan Sidwell
1a32988713 AIX sed fix
gcc/cp/
	* Make-lang.in (GIT_INFO): Support stricter seds.
2020-10-20 12:23:02 -07:00
Nathan Sidwell
cdaf02a04d Local-extern fix
gcc/cp
	* name-lookup.c (push_local_extern_decl_alias): Fix default arg bug.
2020-10-20 12:22:01 -07:00
Nathan Sidwell
225c2bdd6f Local-extern fix
gcc/cp
	* name-lookup.c (push_local_extern_decl_alias): Recontextualize
	alias' parms, drop any default args.
	gcc/testsuite/
	* g++.dg/modules/local-extern-2.H: New.
2020-10-20 11:04:25 -07:00
Nathan Sidwell
413b468076 Libcody by value
* Makefile.def: Add libcody as a component library.
	* Makefile.in: Change libcody from an external library to a
	component.
	* Makfile.tpl: Likewise.
	* configure.ac: Likewise.
	* configure: Regenerated.
	gcc/
	* Makefile.in: Likewise.
	* configure.ac: Likewise.
	* configure: Regenerated.
2020-10-20 09:34:10 -07:00
Nathan Sidwell
b97e108859 Add libcody source
* libcody/: Import by value.
2020-10-20 09:33:51 -07:00
Nathan Sidwell
ea1205e3bb AIX madvise fix
gcc/cp/
	* module.cc (elf_in::begin): Fix madvise on AIX.
2020-10-20 07:33:46 -07:00
Nathan Sidwell
d502e14d8f Fix non-mapped file io
gcc/cp/
	* module.cc: Add testing for non-mmapped access.
	(elf_out::grow): Assert aligned at start.
	(elf_out::write): Align afterwards.
2020-10-19 12:49:14 -07:00
Nathan Sidwell
f5a64e960c Fix arm test fail
gcc/testsuite/
	* g++.dg/modules/sym-subst-3_a.C: Some assemblers say .global.
2020-10-19 09:28:45 -07:00
Nathan Sidwell
cf8ab1c0a4 Fix macro locs on darwin and ppc-linux (and probably others)
gcc/cp/
	* module.cc (module_state::write_macro_locs): Macro loc count is a
	count.
	(module_state::read_prepare_maps): Adjust.
	gcc/testsuite/
	* g++.dg/modules/macloc-2_[ab].[HC]: New.
2020-10-19 09:18:43 -07:00
Nathan Sidwell
2ec0cbf131 Merge trunk ccb4f20cbe 2020-10-16 11:58:51 -07:00
Nathan Sidwell
4c19fa0e25 exporting using decl
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Fix duplication case.
2020-10-16 10:59:20 -07:00
Nathan Sidwell
ed9415022f Simplify binding callback API
gcc/cp/
	* name-lookup.h (enum WMB_Flags): New.
	(walk_module_binding): Adjust.
	* name-lookup.c (walk_module_binding): Replace callbacks, bool
	args by single flags arg.
	* module.cc (depset::hash::add_binding): Replace bool args by
	flags.
2020-10-15 12:11:07 -07:00
Nathan Sidwell
eb7a9f02da Header unit static inits
gcc/cp/
	* module.cc (trees_out::core_bools): Adjust initialized var
	handling.
	(has_definition): Likewise.
	(trees_{in,out}::{read,write}_var_def): Likewise.
	(module_state::{read,write}_inits): Just stream the decls.
	gcc/testsuite/
	* g++.dg/modules/hdr-init-1_[abc].[HC]: New.
2020-10-15 11:19:30 -07:00
Nathan Sidwell
62406deca5 Remove internal-linkage kludge
gcc/cp/
	* module.cc (depset::hash::finalize_dependencies): Remove
	pre-p2003 kludge.
2020-10-14 12:49:07 -07:00
Nathan Sidwell
9b71f432d2 p2003 internal linkage & header units
gcc/cp/
	* name-lookup.c (get_fixed_binding_slot): Promote internal GM
	entities to global slot.
	* module.cc (has_definition): Add internal linkage fns/vars in GM.
	(depset::hash::make_dependency): Internal linkage in GM is ok.
2020-10-14 12:15:57 -07:00
Nathan Sidwell
822d875cc5 Resolve pt.c FIXMEs
gcc/cp/
	* pt.c (lookup_template_class_1): Delete erroneous fixme.
	(tsubst_template_decl): Delete questioning fixme, problem, if any,
	is on trunk.
	(get_mergeable_specialization_flags): Optimize specialization scan.
2020-10-14 11:17:19 -07:00
Nathan Sidwell
b7c73fc949 Merge trunk 068644a149 (c++: DECL_FRIEND_P cleanup) 2020-10-14 10:49:20 -07:00
Nathan Sidwell
40513f1fb1 Merge trunk 06bec55e80 2020-10-14 10:31:47 -07:00
Nathan Sidwell
b4d0492028 Remove some obsolete fixmes
gcc/cp/
	* decl.c (duplicate_decls): Remove obsolete FIXME.
	* pt.c (push_template_decl): Remove about-to-be obsolete FIXME.
2020-10-14 10:06:36 -07:00
Nathan Sidwell
808df6317c Defining an import
gcc/cp/
	* decl.c (xref_tag_1): Refactor module handling. Push imported
	decl into TU's slot
	* name-lookup.c (lookup_elaborated_type_1): Fixme fixed.
	* module.cc (set_instantiating_module): Accept template_decls.
	gcc/testsuite/
	* g++.dg/modules/part-7_[abc].C: New.
	* g++.dg/modules/hdr-1_[abc].[HC]: New.
2020-10-14 10:05:20 -07:00
Nathan Sidwell
5730436827 Document unicode plan
libcpp/
	* lex.c (do_peek_module): Update plan for unicode.
2020-10-09 09:15:10 -07:00
Nathan Sidwell
b37aaf57ec fmodule-implicit-inline comment
gcc/cp/
	* decl.c (grokmethod): Remove comment about -fmodule-implicit-inline.
2020-10-09 08:30:07 -07:00
Nathan Sidwell
3152c118ca Block-scope externs disallowed
gcc/cp/
	* decl.c (start_decl): Reject block-scope extern in module
	purview.
	gcc/testsuite/
	* g++.dg/modules/local-extern-1.C: New.
2020-10-09 08:21:30 -07:00
Nathan Sidwell
363f58ec8b Remove unused code
gcc/cp/
	* friend.c (add_friend): Remove #if'd out code
2020-10-09 07:51:18 -07:00
Nathan Sidwell
aad9dacffc Cleanup name-lookup interface
gcc/cp/
	* name-lookup.h (get_field_ident, lookup_field_ident): Don't
	declare.
	(mergeable_class_entities): Rename to ...
	(lookup_class_binding): ... here.
	* name-lookup.c (mergeable_class_entities): Rename to ...
	(lookup_class_binding): ... here.
	(get_field_ident, lookup_field_ident): Move to module.cc
	* module.cc (get_field_ident, lookup_field_ident): Moved here.
	Only deal with anon fields.
	(trees_{in,out}::tree_node): Adjust.
	(trees_in::key_mergeable): Adjust.
2020-10-09 07:48:07 -07:00
Nathan Sidwell
98e9001194 Remove unneeded decls
gcc/cp/
	* name-lookup.c (lookup_class_member, void set_class_bindings)
	(tree lookup_all_conversions): Delete unused decls.
	(insert_late_enum_def_bindings): Delete duplicate decl.
2020-10-09 07:47:57 -07:00
Nathan Sidwell
8047291fa5 Clean up mangling documentation
gcc/cp/
	* mangle.c (write_module): Update grammar description.
	* module.cc (module_state::mangle): Clarify why partitions might
	be significant.
2020-10-09 06:44:25 -07:00
Nathan Sidwell
563a32906f Clean up some c-family pieces
gcc/
	* langhooks.h (struct lang_hooks): Replace
	preprocess_translate_include with preprocess_options.
	* langhooks-def.h: Replace LANG_HOOKS_PREPROCESS_INCLUDE_TRANSLATE
	with LANG_HOOKS_PREPROCESS_OPTIONS.
	gcc/c-family/
	* c-cppbuiltins.c (c_cpp_builtins): Comment __cpp_modules.
	* c-opts.c (c_common_post_options): Replace include_translate hook
	with more general preprocess_options hook.
	gcc/cp/
	* cp-lang.c: Replace LANG_HOOKS_PREPROCESS_TRANSLATE_INCLUDE with
	LANG_HOOKS_PREPROCESS_OPTIONS.
	* cp-tree.h (module_translate_include): Don't declare.
	(module_preprocess_options): Declare.
	* module.cc (module_translate_include): Rename to ..
	(maybe_translate_include): ... here.  Make static.
	(module_preprocess_options): New.
2020-10-09 06:06:25 -07:00
Nathan Sidwell
767eedddf4 Merge trunk d1c566d72d 2020-10-09 03:48:07 -07:00
Nathan Sidwell
a847e5c151 Undeclared builtin merging
gcc/cp/
	* module.cc (trees_in::is_matching_decl): Merge into undeclared
	builtin.
	* name-lookup.cc (check_module_override): Rename is_friend parm.
	(do_pushdecl): Ignore hidden imports.
	gcc/testsuite/
	* g++.dg/modules/builtin-5_[ab].[HC]: New.
2020-10-08 12:17:13 -07:00
Nathan Sidwell
3018e16e73 Undeclared builtin merging
gcc/cp/
	* module.cc (trees_in::is_matching_decl): Merge into undeclared
	builtin.
	* name-lookup.cc (check_module_override): Rename is_friend parm.
	(do_pushdecl): Ignore hidden imports.
	gcc/testsuite/
	* g++.dg/modules/builtin-5_[ab].[HC]: New.
2020-10-08 11:57:58 -07:00
Nathan Sidwell
d136cdaa41 Streamed classes always have a member vector
gcc/cp/
	* module.cc (trees_out::decl_value): Assert no pmfs.
	(trees_in::decl_value): Ensure existing duplicate class has member
	vector.
	(tree_out::write_class_def): Ensure there's a method vector.
	* name-lookup.c (set_class_bindings): Extra can be negative,
	meaning always.  Return the member vector.
	(mergeable_class_entities): Simplify.
	(lookup_field_ident): Simplify.
2020-10-08 09:59:20 -07:00
Nathan Sidwell
12234ffe6c Location shortage note
gcc/cp/
	* module.cc (module_state::read_prepare_maps): Only inform of
	location shortage once.
2020-10-08 05:20:27 -07:00
Nathan Sidwell
4e65e528f3 Fix -save-temps & header units
gcc/cp/
	* module.cc (loc_spans::maybe_init): New.
	(loc_spans::init): Allow NULL map.
	(preprocess_module, preprocessed_module): Call maybe_init.
	gcc/libcpp/
	* internal.h (enum include_type): Rename IT_MAIN_INJECT to IT_PRE_MAIN.
	* init.c (cpp_read_main): Adjust _cpp_stack_file call.  Adjust
	first line marker if no preprocessed marker found.
	(read_original_filename): Peek characters in buffer, not token.
	(read_original_directory): Likewise.
	* files.c (_cpp_stack_file): Adjst.
	gcc/testsuite/
	* g++.dg/modules/preproc-2_[ab].[HC]: New.
2020-10-08 04:55:24 -07:00
Nathan Sidwell
f5f9f2debe Merge trunk 4e62aca0e0 (c++: block-scope externs get an alias) 2020-10-07 08:33:31 -07:00
Nathan Sidwell
dc91b82fab Merge trunk e089e43365 2020-10-07 07:59:20 -07:00
Nathan Sidwell
7839315180 Merge trunk 255aa06d40 2020-10-07 07:25:05 -07:00
Nathan Sidwell
8150ef4e30 Merge trunk bf490f0636 2020-10-07 07:11:05 -07:00
Nathan Sidwell
1371d2fd7c c++: Make spell corrections consistent
My change to namespace-scope spell corrections ignored the issue that
different targets might have different builtins, and therefore perturb
iteration order.  This fixes it by using an intermediate array of
identifier, which we sort before considering.

	gcc/cp/
	* name-lookup.c (maybe_add_fuzzy_decl): New.
	(maybe_add_fuzzy_binding): New.
	(consider_binding_level): Use intermediate sortable vector for
	namespace bindings.
	gcc/testsuite/
	* c-c++-common/spellcheck-reserved.c: Restore diagnostic.
2020-10-05 07:00:58 -07:00
Nathan Sidwell
52ab3aea01 Merge trunk 679dbc9dce (c++: Kill DECL_ANTICIPATED) 2020-10-02 13:54:58 -07:00
Nathan Sidwell
c24f808c49 Merge trunk 7ee1c0413e (c++: Hash table iteration for namespace-member spelling)
gcc/cp/
	* name-lookup.c (consider_binding): New, broken out of ...
	(consider_binding_level): ... here.  Use it, add MODULE_VECTOR
	support.
2020-10-02 13:29:52 -07:00
Nathan Sidwell
494311c339 Merge trunk 9340d1c97b (c++: cleanup ctor_omit_inherited_parms) 2020-10-02 13:09:16 -07:00
Nathan Sidwell
bf62288a8b Merge trunk 3158482466 2020-10-02 12:50:50 -07:00
Nathan Sidwell
af5b22ea82 Merge trunk dfaa24c974 (c++: Kill DECL_HIDDEN_P) 2020-10-02 12:37:28 -07:00
Nathan Sidwell
6aff291867 Remove DECL_HIDDEN use from modules
gcc/cp/
	* name-lookup.c (walk_module_binding): Update for new HIDDEN markers.
2020-10-02 12:27:00 -07:00
Nathan Sidwell
33fd0e7ffb Merge trunk c2978b3405 2020-10-02 12:04:06 -07:00
Nathan Sidwell
baaabe0523 Merge trunk c2978b3405 2020-10-01 12:25:29 -07:00
Nathan Sidwell
437d6ec6cc Missed commit 2020-10-01 11:23:35 -07:00
Nathan Sidwell
2bb414bcb5 c++: Kill DECL_HIDDEN_FRIEND_P (trunk 734eed6853) 2020-10-01 09:58:20 -07:00
Nathan Sidwell
a329d25fb7 Merge trunk 65167982ef 2020-10-01 06:56:51 -07:00
Nathan Sidwell
81b83669df Merge trunk 7cbfe0894d 2020-10-01 06:27:10 -07:00
Nathan Sidwell
bc57d1f5d1 Merge trunk adcf8a11c7 2020-10-01 05:59:06 -07:00
Nathan Sidwell
bf42cd2284 Merge trunk cc61827b55 2020-10-01 05:32:26 -07:00
Nathan Sidwell
5e13acd2be Merge trunk 39a27bb01a 2020-09-30 19:16:03 -07:00
Nathan Sidwell
0d893c686e Merge trunk c74e6f7cfd 2020-09-30 14:44:01 -07:00
Nathan Sidwell
9dd9897ed3 c++: Hiddenness is a property of the symbol table (trunk 7cbfe0894d) 2020-09-30 13:26:08 -07:00
Nathan Sidwell
9be6759067 c++: Name lookup simplifications (trunk adcf8a11c7) 2020-09-30 12:00:54 -07:00
Nathan Sidwell
c109cb9336 c++: Identifier type value should not update binding (trunk cc61827b55) 2020-09-30 11:08:24 -07:00
Nathan Sidwell
23841c9ab8 c++: Adjust pushdecl/duplicate_decls API (merge c74e6f7cfd) 2020-09-30 10:40:50 -07:00
Nathan Sidwell
852d73592c Prepare ovl_using for merge
gcc/cp/
	* tree.h (ovl_insert): Make usingness unsigned.
	* tree.c (ovl_insert): Make usingness unsigned, change semantics.
	* name-lookup.c (do_nonmember_using_decl): Adjust ovl_insert call.
2020-09-30 09:35:15 -07:00
Nathan Sidwell
0106c98b91 c++: Replace tag_scope with TAG_how (merge 00aaae03db) 2020-09-30 07:30:51 -07:00
Nathan Sidwell
f5f068505a Merge trunk 0d8f3f612d 2020-09-30 07:09:30 -07:00
Nathan Sidwell
298eb88294 Merge trunk d13c0ae859 2020-09-24 20:43:55 -04:00
Nathan Sidwell
7a4d1524b3 Merge trunk cd6743e9c4 2020-09-14 12:21:08 -07:00
Nathan Sidwell
650163b267 Assert assumptions
gcc/cp/
	* module.cc (trees_out::get_merge_kind): Add asserts & FIXMEs.
2020-09-14 12:03:48 -07:00
Nathan Sidwell
ec1fefe043 Use VAR_OR_FUNCTION_DECL_P
gcc/cp/
	* pt.c (primary_template_specialization_p): Use
	VAR_OR_FUNCTION_DECL_P.
	(push_template_decl_real): Likewise.
	* module.cc (trees_out::chained_decls): Use
	VAR_OR_FUNCTION_DECL_P.
	(trees_out::get_merge_kind, trees_in::is_matching_decl)
	(depset::hash::make_dependency, depset::hash::add_binding_entity)
	(specialization_add): Likewise.
2020-09-14 10:34:45 -07:00
Nathan Sidwell
d02ded08f5 Merge trunk d106029c2a 2020-09-14 07:03:59 -07:00
Nathan Sidwell
7ffecad5c8 Merge trunk 10f51543bb
libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
2020-09-14 06:33:38 -07:00
Nathan Sidwell
a1fed5312e Concepts and local externs
gcc/cp/
	* decl.c (grokfndecl): Don't attach to local extern.
	gcc/testsuite/
	* concepts/local-extern.C: New.
2020-09-14 05:54:19 -07:00
Nathan Sidwell
33be02f918 Local extern fns do not get template header
gcc/cp/
	* module.cc (trees_out::chained_decls): Also mark local fns for
	by-value walking.
	(trees_out::decl_node): Assert we don't meet a local var or fn.
	(trees_out::get_merge_kind): Local fns are also unique.
	* pt.c (push_template_decl_real): Local fns also lack a header.
	(tsubst_function_decl): Cope with local fns.
	(tsubst_decl): Adjust VAR_DECL tsubsting.
	gcc/testsuite/
	* g++.dg/modules/tpl-extern-{var,fn}-1_{a.H,b.C}: New.
2020-09-14 05:54:18 -07:00
Nathan Sidwell
84f2dc7a13 Local extern vars do not get template header
gcc/cp/
	* cp-tree.h (TINFO_VAR_DECLARED_CONSTINIT): Replace with ...
	(DECL_DECLARED_CONSTINIT_P): ... here, decl_lang_flag 7.
	* decl.c (start_decl): Set DECL_DECLARED_CONSTINIT_P as necessary.
	(cp_finish_decl): Likewise.
	* pt.c (push_template_decl_real): Don't add a header for
	DECL_LOCAL_DECL_P VAR_DECLS.
	(tsubst_decl): Check for VAR_DECLS lacking template info are
	local.  No need to handle TINFO_VAR_DECLARED_CONSTINIT specially.
	(tsubst_expr): Likewise.
	(instantiate_decl): Likewise.
2020-09-14 05:54:18 -07:00
Nathan Sidwell
065650c9da Add DECL_LOCAL_DECL_P
gcc/cp/
	* cp-tree.h (DECL_LOCAL_FUNCTION_P): Rename to ...
	(DECL_LOCAL_DECL_P): ... here.  Apply to VAR_DECLS too.
	* decl.c (start_decl): Set DECL_LOCAL_DECL_P as approriate.
	(start_decl_1): Reformat.
	(omp_declare_variant_finalize_one): Use DECL_LOCAL_DECL_P.
	(local_variable_p): Simplify.
	* module.cc (trees_out::chained_decls): Stream DECL_LOCAL_DECL_P
	by value.
	(trees_out::get_merge_kind): DECL_LOCAL_DECL_P decls are unique.
	* name-lookup.c (set_decl_context_in_fn): Assert DECL_LOCAL_DECL_P
	as expected, don't set it here.
	(do_pushdecl): Don't call it for friends or dependent types.
	(is_local_extern): Simplify.
	* parser.c (cp_parser_postfix_expression): Use DECL_LOCAL_DECL_P.
	(cp_parser_omp_declare_reduction): Set DECL_LOCAL_DECL_P.
	Refactor.
	* pt.c (check_default_tmpl_args): Use DECL_LOCAL_DECL_P.
	(tsubst_expr): Adjust omp reduction case.
	(tsubst_omp_udr): Add comments.
	(type_dependent_expression_p): Adjust.
	* call.c (equal_functions): Adjust.
	* semantics.c (finish_call_expr): Adjust.
	libcc1/
	* libcp1plugin.cc (plugin_build_call_expr): Use DECL_LOCAL_DECL_P.
2020-09-14 05:54:07 -07:00
Nathan Sidwell
b63aa6567e Change cxx_int_tree_map to cxx_decl_tree_map
gcc/cp/
	* cp-tree.h (struct cxx_int_tree_map): Rename to ...
	(struct cxx_decl_tree_map): ... here.
	* cp-gimplify.c (cxx_int_tree_map_hasher): Rename to ...
	(cxx_decl_tree_map_hasher): ... here.  Update member fns
	(cp_genericize_r): Adjust extern_decl_map lookup.
	* name-lookup.c (set_local_extern_decl_linkage): Adjust
	extern_decl_map insertion.
2020-09-14 04:56:09 -07:00
Nathan Sidwell
4949a75130 FLAG DAY! Mapper reponse format change in LibCody
gcc/cp/
	* mapper-client.cc (module_client::open_module_client): Use
	Client::PC_PATHNAME.
	* mapper-resolver.cc (module_resolver::ModuleRepoRequest): Use
	PathnameResponse.
	(module_resolver::cmi_response): Likewise.
	(module_resolver::IncludeTranslateRequest): Use BoolResponse and
	PathnameResponse.
	* module.cc (module_state::set_filename): Use Client::PC_PATHNAME.
	(module_translate_include): Use Client::PC_BOOL and
	Client::PC_PATHNAME.
2020-09-12 10:58:03 -04:00
Nathan Sidwell
051f07cfa4 Merge trunk 8bc0f24d7a 2020-09-03 07:29:35 -07:00
Nathan Sidwell
3cb5b2bc2f Instantiation after extern instantiation
gcc/cp/
	* module.cc (trees_in::read_class_def): Maybe set
	CLASSTYPE_INTERFACE.
	gcc/testsuite/
	* g++.dg/modules/extern-tpl-2_[abc].[CH]: New.
2020-09-03 05:33:35 -07:00
Nathan Sidwell
3a846b5f96 include-next should not be xlated
libcpp/
	* files.c (_cpp_stack_file): Don't try and xlate include-next.
2020-09-02 12:06:39 -07:00
Nathan Sidwell
0a3599b598 Extern instantiations
gcc/cp/
	* module.cc (trees_{in,out}::core_bools): Drop duplicate comdat
	flag.
	(trees_in::is_matching_decl): Don't propagate not-really-extern
	here.
	(trees_{in,out}::{read,write}_function_def): Stream
	not-really-extern here.
	gcc/testsuite/
	* g++.dg/modules/extern-tpl-1_[abc].[CH]: New.
2020-09-02 12:05:45 -07:00
Nathan Sidwell
a73506a776 Rename -fnote-include-translate to -flang-info-include-translate
gcc/cp/
	* (module_translate_include): Check if matches trailing part of
	header name.
	(handle_module_option): Adjust.
	gcc/c-family/
	* c.opt (-fnote-include-translate{,=}): Rename to ...
	(-flang-info-include-translate{,=}): ... here.
	(-fnote-include-translate=query): Delete.
	gcc/
	* doc/invoke.texi: Update documentation.
2020-09-02 05:21:45 -07:00
Nathan Sidwell
7d342ac6fa C++ headers need directives-only preprocessing
gcc/cp/
	* lang-specs.h: c++headers always do directives-only preprocessing
	in modules mode.
2020-09-01 12:44:35 -07:00
Nathan Sidwell
4d4b2024b7 Deal with running out of locations
gcc/cp/
	* module.cc (module_state::read_prepare_maps): New.
	(module_state::write_{ordinary,macro}_maps): Adjust.
	(struct module_state_config): Record number of locations needed.
	(module_state::read_location): Deal with lack of locations.
	(module_state::{read,write}_config): Adjust.
	(module_state::read_initial): Adjust.
2020-09-01 12:43:41 -07:00
Nathan Sidwell
9ddb36a37c Zero length mapper files
gcc/cp/
	* mapper.h (module_resolver): Default to no xlation.
	* mapper-resolver.cc (module_resolver::read_tuple_file): Don't
	fail on zero-length files.
2020-08-31 11:51:26 -07:00
Nathan Sidwell
965e986d18 Add control for default header translation rules
gcc/cp/
	* mapper-client.cc (module_client::open_module_client): Better
	error reporting.
	* mapper-resolver.cc (module_resolver::module_resolver): Specify
	default translate behavior.
	(module_resolver::IncludeTranslateRequest): Check it.
	* mapper-server.cc (flag_xlate): New.
	(process_args): Rename -f->-m add -t
	(main): Adjust.
	* mapper.h (module_resolver): Add default_xlate field.
	gcc/testsuite/
	* g++.dg/modules/inc-xlate-1_e.C: Adjust.
	* g++.dg/modules/legacy-2_b.H: Adjust.
	* g++.dg/modules/legacy-6.map: Adjust.
	* g++.dg/modules/legacy-6_[cd].C: Adjust.
	* g++.dg/modules/map-2.C: Adjust.
2020-08-31 10:52:10 -07:00
Nathan Sidwell
3e615e8d56 GMF namespace fix
gcc/cp/
	* name-lookup.c (get_fixed_binding_slot): Don't stat-hack a
	namespace.
	* module.cc (trees_in::assert_definition): Header units are
	module_purview, but ok.
	gcc/testsuite/
	* g++.dg/modules/ns-dup-1_[ab].C: New.
2020-08-31 07:34:06 -07:00
Nathan Sidwell
6f28db12d7 Fix pushing imported namespaces
gcc/cp/
	* module.cc (depset::hash_add_namespace): Don't mark bindings
	special.
	(struct add_binding_data): Record finding a namespace.
	(depset::hash::add_binding_entity): Make namespaces idempotent.
	(depset::hash::add_namespace_entities): Clear met_namespace.
	(module_state::write): Zap partitions bitmap if empty.
	* name-lookup.c (push_namespace): Ensure namespace is in
	MODULE_SLOT_CURRENT.
	* ptree.c (cxx_print_xnode): Show more detail on MODULE_VECTOR.
	gcc/testsuite/
	* g++.dg/modules/ns-imp-1_[abc].C: New.
	* g++.dg/modules/ns-part-1_[abc].C: New.
2020-08-28 12:02:25 -07:00
Nathan Sidwell
c7c243c3ef Tweak ICE pruning
gcc/testsuite/
	* lib/prune.exp (prune_ices): Adjust regexp.
2020-08-28 06:19:29 -07:00
Nathan Sidwell
16f045d0e8 Merge trunk cb3c3d6331
Whee, all up to date!
2020-08-28 05:55:31 -07:00
Nathan Sidwell
c2285e6735 Merge trunk f1612b8ae8
c++: Check satisfaction before non-dep convs. [CWG2369]
	gcc/testsuite/
	* g++.dg/modules/concept-[13]_b.C: Adjust.
2020-08-28 05:32:05 -07:00
Nathan Sidwell
8d670e3e46 Merge trunk e6e01618e8. 2020-08-28 05:01:13 -07:00
Patrick Palka
82529869ce libstdc++: integer-class types as per [iterator.concept.winc]
This implements signed and unsigned integer-class types, whose width is
one bit larger than the widest supported signed and unsigned integral
type respectively.  In our case this is either __int128 and unsigned
__int128, or long long and unsigned long long.

Internally, the two integer-class types are represented as a largest
supported unsigned integral type plus one extra bit.  The signed
integer-class type is represented in two's complement form with the
extra bit acting as the sign bit.

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_headers): Add new header
	<bits/max_size_type.h>.
	* include/Makefile.in: Regenerate.
	* include/bits/iterator_concepts.h
	(ranges::__detail::__max_diff_type): Remove definition, replace
	with forward declaration of class __max_diff_type.
	(__detail::__max_size_type): Remove definition, replace with
	forward declaration of class __max_size_type.
	(__detail::__is_unsigned_int128, __is_signed_int128)
	(__is_int128): New concepts.
	(__detail::__is_integer_like): Accept __int128 and unsigned
	__int128.
	(__detail::__is_signed_integer_like): Accept __int128.
	* include/bits/max_size_type.h: New header.
	* include/bits/range_access.h: Include <bits/max_size_type.h>.
	(__detail::__to_unsigned_like): Two new overloads.
	* testsuite/std/ranges/iota/difference_type.cc: New test.
	* testsuite/std/ranges/iota/max_size_type.cc: New test.
2020-08-27 13:17:57 -07:00
Nathan Sidwell
28d02ccd11 Stream MEM_REFs, who knew?
gcc/cp/
	* module.cc (trees_{in,out}::start): Permit MEM_REFs.
	(trees_{in,out}::core_bools): Likewise.
	gcc/testsuite/
	* g++.dg/modules/memref-1_[ab].C: New.
2020-08-27 13:17:43 -07:00
Nathan Sidwell
0fe27d8441 Fix hash table breakage
gcc/cp/
	* name-lookup.c (push_namespace): Do not create slot on first
	lookup.
	gcc/testsuite/
	* g++.dg/modules/string-view1.C: New test.
	* g++.dg/modules/string-view2.C: Ditto.
2020-08-27 10:57:25 -07:00
Nathan Sidwell
95d673d68c Merge trunk 708b3600d0. 2020-08-27 07:22:14 -07:00
Nathan Sidwell
c858355c6a Merge trunk 17abcc7734
libstdc++: Replace operator>>(istream&, char*) [LWG 2499]
2020-08-26 13:02:58 -07:00
Nathan Sidwell
2383be81dd Fix type lang specific changing
gcc/cp/
	* lex.c (copy_lang_type): Split allocation & assignment to be
	conditional-breakpoint friendly.
	* module.cc (trees_in::read_class_def): Update variants if we
	alter TYPE_LANG_SPECIFIC.
	* name-lookup.c (maybe_lazily_declare): Look at main variant's
	decl.
	gcc/testsuite/
	* g++.dg/modules/tdef-inst-1{.h,_[ab].C}: New.
2020-08-26 12:09:54 -07:00
Nathan Sidwell
ee7260fe55 Fix int_cst caching
gcc/
	* tree.c (cache_integer_cst): Fix pointer type indices.
2020-08-26 08:49:04 -07:00
Nathan Sidwell
971750eab0 Cherry pick 794275711bd.
gcc/cp/
	* name-lookup.c (op_unqualified_lookup): Don't check if matches
	global lookup.
	gcc/testsuite/
	* g++.dg/lookup/operator-[12].C: New.
2020-08-26 06:18:41 -07:00
Nathan Sidwell
850418a6ed Operator function lookups in templates
gcc/cp/
	* decl.c (poplevel): A local-binding tree list holds the name in
	TREE_PURPOSE.
	* name-lookup.c (update_local_overload): Add id to TREE_PURPOSE.
	(lookup_name_1): Deal with local-binding error_mark_node marker.
	(op_unqualified_lookup): Return error_mark_node for 'nothing
	found'.  Do other short circuiting here.
	(maybe_save_operator_binding): Reimplement to always cache a
	result.
	(push_operator_bindings): Deal with 'ignore' marker.
	gcc/testsuite/
	* g++.dg/modules/operator-1_[ab].C: New.
2020-08-25 06:42:16 -07:00
Nathan Sidwell
425d7384b5 Friend specialization overhaul part 1
gcc/cp/
	* module.cc
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-[12]_a.C: Adjust scan.
	* g++.dg/modules/tpl-friend-merge-1*: New.
2020-08-20 13:00:12 -07:00
Nathan Sidwell
71e19827e4 Do not stream hidden_friend_p
gcc/cp/
	* module.cc (trees_{in,out}::lang_decl_bools): Do not stream
	anticipated_p or hidden_friend_p.
	* name-lookup.c (name_lookup::adl_class_fns): DECL_ANTICIPATED is
	not informative.
2020-08-20 10:49:49 -07:00
Nathan Sidwell
eb8dd5a3a3 Reimplement module binding extraction
gcc/cp/
	* module.cc (depset::clear_hidden_binding): New.
	(depset::hash::add_binding): Delete.
	(struct add_binding_data): New.
	(depset::hash::add_binding_entity): New.
	(writable_cmp): Delete.
	(depset::hash::add_namespace_entities): Reimplement.
	(module_state::write_cluster): Adjust for unscoped enums.
	* name-lookup.h (extract_module_binding): Replace with ...
	(walk_module_binding): ... this.
	* name-lookup.c (STAT_TYPE_HIDDEN): New.
	(extract_module_binding): Replace with ...
	(walk_module_binding): ... this.
2020-08-20 10:25:24 -07:00
Nathan Sidwell
7023d170c7 ODR-check enums!
gcc/cp/
	* module.cc (trees_in::maybe_duplicate): New.
	(trees_in::read_enum_def): ODR check duplicate.
	gcc/testsuite/
	* g++.dg/modules/enum-bad-1_[ab].[HC]: New.
2020-08-19 17:10:55 -04:00
Nathan Sidwell
639941e922 c++: Move hidden-lambda entity lookup checking
Hidden lambda entities only occur in block and class scopes.  There's
no need to check for them on every lookup.  So moving that particular
piece of validation to lookup_name_1, which cares.  Also reordered the
namespace and type checking, as that is also simpler.

	gcc/cp/
	* name-lookup.c (qualify_lookup): Drop lambda checking here.
	Reorder namespace & type checking.
	(lookup_name_1): Do hidden lambda checking here.
2020-08-18 06:22:18 -07:00
Nathan Sidwell
485e29be36 Fix -save-temps issue
libcpp/
	* lex.c (cpp_maybe_module_directive): Increment prevent_expansion
	if not expanding.
2020-08-18 09:00:19 -04:00
Nathan Sidwell
6ac22fbbde Update module mapper documentation
gcc/
	* doc/invoke.texi (C++ Module Mapper): Update documentation.
2020-08-17 20:18:07 -04:00
Nathan Sidwell
f198081bb5 Fix disable checking build
gcc/cp
	* module.cc (note_def_cache_hasher): GTY needs this even when
	unused.
	(not_defs_table_t, note_defs): Likewise.
	gcc/
	* gcc.c (driver::maybe_print_and_exit): Warn about disable-checking.
2020-08-17 15:26:08 -04:00
Nathan Sidwell
485bf433e2 c++: Final bit of name-lookup api simplification
We no longer need to give name_lookup_real not name_lookup_nonclass
different names to the name_lookup functions.  This renames the lookup
functions thusly.

	gcc/cp/
	* name-lookup.h (lookup_name_real, lookup_name_nonclass): Rename
	to ...
	(lookup_name): ... these new overloads.
	* name-lookup.c (identifier_type_value_1): Rename lookup_name_real
	call.
	(lookup_name_real_1): Rename to ...
	(lookup_name_1): ... here.
	(lookup_name_real): Rename to ...
	(lookup_name): ... here.  Rename lookup_name_real_1 call.
	(lookup_name_nonclass): Delete.
	* call.c (build_operator_new_call): Rename lookup_name_real call.
	(add_operator_candidates): Likewise.
	(build_op_delete_call): Rename lookup_name_nonclass call.
	* parser.c (cp_parser_lookup_name): Likewise.
	* pt.c (tsubst_friend_class, lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise.
	* semantics.c (capture_decltype): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Rename
	lookup_name_real call.
2020-08-14 17:11:01 -07:00
Nathan Sidwell
b5db575f59 c++: Yet more name-lookup api simplification
This patch deals with LOOKUP_HIDDEN, which originally meant 'find
hidden friends', but it's being pressed into service for not ignoring
lambda-relevant internals.  However these two functions are different.
(a) hidden friends can occur in block scope (very uncommon) and (b) it
had the semantics of stopping after the innermost enclosing
namepspace.  That's really suspect for the lambda case, but not
relevant there because we never get to namespace scope (I think).
Anyway, I've split the flag into two and adjusted the lambda callers
to just search block scope.  These two flags are added to the
LOOK_want enum class, which allows dropping another parameter from the
name lookup routines.

The remaining LOOKUP_$FOO flags in cp-tree.h are, I think, now all
related to features of overload resolution, conversion operators and
reference binding.  Nothing to do with /name/ lookup.

	gcc/cp/
	* cp-tree.h (LOOKUP_HIDDEN): Delete.
	(LOOKUP_PREFER_RVALUE): Adjust initializer.
	* name-lookup.h (enum class LOOK_want): Add HIDDEN_FRIEND and
	HIDDEN_LAMBDA flags.
	(lookup_name_real): Drop flags parm.
	(lookup_qualified_name): Drop find_hidden parm.
	* name-lookup.c (class name_lookup): Drop hidden field, adjust
	ctors.
	(name_lookup::add_overload): Check want for hiddenness.
	(name_lookup::process_binding): Likewise.
	(name_lookup::search_unqualified): Likewise.
	(identifier_type_value_1): Adjust lookup_name_real call.
	(set_decl_namespace): Adjust name_lookup ctor.
	(qualify_lookup): Drop flags parm, use want for hiddenness.
	(lookup_qualified_name): Drop find_hidden parm.
	(lookup_name_real_1): Drop flags parm, adjust qualify_lookup
	calls.
	(lookup_name_real): Drop flags parm.
	(lookup_name_nonclass, lookup_name): Adjust lookup_name_real
	calls.
	(lookup_type_scope_1): Adjust qualify_lookup calls.
	* call.c (build_operator_new_call): Adjust lookup_name_real call.
	(add_operator_candidates): Likewise.
	* coroutines.cc (morph_fn_to_coro): Adjust lookup_qualified_name
	call.
	* parser.c (cp_parser_lookup_name): Adjust lookup_name_real calls.
	* pt.c (check_explicit_specialization): Adjust
	lookup_qualified_name call.
	(deduction_guides_for): Likewise.
	(tsubst_friend_class): Adjust lookup_name_real call.
	(lookup_init_capture_pack): Likewise.
	(tsubst_expr): Likewise, don't look in namespaces.
	* semantics.c (capture_decltype): Adjust lookup_name_real.  Don't
	look in namespaces.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_exp): Adjust
	lookup_name_real call.
2020-08-14 15:56:18 -07:00
Nathan Sidwell
a6c852f4fc more name-lookup api cleanups
Cherry pick c38f8785205.
	gcc/cp/
	* cp-tree.h (LOOKUP_PREFER_TYPES, LOOKUP_PREFER_NAMESPACES)
	(LOOKUP_NAMESPACES_ONLY, LOOKUP_TYPES_ONLY)
	(LOOKUP_QUALIFIERS_ONL): Delete.
	(LOOKUP_HIDDEN): Adjust.
	* name-lookup.h (enum class LOOK_want): New.
	(operator|, operator&): Overloads for it.
	(lookup_name_real): Replace prefer_type & namespaces_only with
	LOOK_want parm.
	(lookup_qualified_name): Replace prefer_type with LOOK_want.
	(lookup_name_prefer_type): Replace with ...
	(lookup_name): ... this.  New overload with LOOK_want parm.
	* name-lookup.c (struct name_lookup): Replace flags with want and
	hidden fields.  Adjust constructors.
	(name_lookyp::add_overload): Correct hidden stripping test.  Update
	for new LOOK_want type.
	(name_lookup::process_binding): Likewise.
	(name_lookup::search_unqualified): Use hidden flag.
	(identifier_type_value_1): Adjust lookup_name_real call.
	(set_decl_namespace): Adjust name_lookup ctor.
	(lookup_flags): Delete.
	(qualify_lookup): Add LOOK_want parm, adjust.
	(lookup_qualified_name): Replace prefer_type parm with LOOK_want.
	(lookup_name_real_1): Replace prefer_type and namespaces_only with
	LOOK_want parm.
	(lookup_name_real): Likewise.
	(lookup_name_nonclass, lookup_name): Adjust lookup_name_real call.
	(lookup_name_prefer_type): Rename to ...
	(lookup_name): ... here.  New overload with LOOK_want parm.
	(lookup_type_scope_1): Adjust qualify_lookup calls.
	* call.c (build_operator_new_call)
	(add_operator_candidates): Adjust lookup_name_real calls.
	* coroutines.cc (find_coro_traits_template_decl)
	(find_coro_handle_template_decl, morph_fn_to_coro): Adjust
	lookup_qualified_name calls.
	* cp-objcp-common.c (identifier_global_tag): Likewise.
	* decl.c (get_tuple_size, get_tuple_decomp_init): Likewise.
	(lookup_and_check_tag): Use lookup_name overload.
	* parser.c (cp_parser_userdef_numeric_literal): Adjust
	lookup_qualified_name call.
	(prefer_arg_type): Drop template_mem_access parm, return LOOK_want
	value.
	(cp_parser_lookup_name): Adjust lookup_member, lookup_name_real
	calls.
	* pt.c (check_explicit_specialization): Adjust lookup_qualified_name
	call.
	(tsubst_copy_and_build, tsubst_qualified_name): Likewise
	(deduction_guides_for): Likewise.
	(tsubst_friend_class): Adjust lookup_name_real call.
	(lookup_init_capture, tsubst_expr): Likewise.
	* rtti.c (emit_support_tinfos): Adjust lookup_qualified_name call.
	* semantics.c (omp_reduction_lookup): Likewise.
	(capture_decltype): Adjust lookup_name_real call.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Adjust
	lookup_name_real & lookup_qualified_name calls.
2020-08-14 08:24:34 -07:00
Nathan Sidwell
60356152cb Unconfuse lookup_name_real API a bit
gcc/cp/
	* name-lookup.h (enum class LOOK_where): New.
	(operator|, operator&): Overloads for it.
	(lookup_name_real): Replace NONCLASS & BLOCK_P parms with WHERE.
	* name-lookup.c (identifier_type_value_w): Adjust
	lookup_name_real call.
	(lookup_name_real_1): Replace NONCLASS and BLOCK_P parameters
	with WHERE bitmask. Don't search namespaces if not asked to.
	(lookup_name_real): Adjust lookup_name_real_1 call.
	(lookup_name_nonclass, lookup_name)
	(lookup_name_prefer_type): Likewise.
	* call.c (build_operator_new_call)
	(add_operator_candidates): Adjust lookup_name_real calls.
	* parser.c (cp_parser_lookup_name): Likewise.
	* pt.c (tsubst_friend_class, lookup_init_capture_pack)
	(tsubst_expr): Likewise.
	* semantics.c (capture_decltype): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_dependent_expr): Likewise.
2020-08-13 11:23:11 -07:00
Nathan Sidwell
6302da22e9 Merge trunk d21252de6c 2020-08-07 15:37:36 -07:00
Nathan Sidwell
87f1ccd4c5 Address 2 FIXMEs
gcc/cp/
	* name-lookup.c (finish_nonmember_using_decl): Here.
	(lookup_type_scope_1): Here.
2020-08-07 08:45:06 -07:00
Nathan Sidwell
d5750e3cba Global decls
gcc/cp/
	* name-lookup.c (get_fixed_binding_slot): Skip internal decls when
	creating vector.
	(record_mergeable_decl): Replace with ...
	(maybe_record_mergeable_decl): Skip internal decls.
	(do_pushdecl): Adjust.
	* decl.c (start_decl): Templated vars are not
	internal. (Incomplete fix of PR 96523)
2020-08-07 08:45:06 -07:00
Nathan Sidwell
5b13659247 Shadowed type
gcc/cp/
	* name-lookup.c (check_module_override): No need to deal with
	shadowed type here.
	gcc/testsuite/
	* g++.dg/modules/shadowed-1_[ab].C: New.
2020-08-07 08:45:05 -07:00
Nathan Sidwell
7ad53d850a Simplify binding extraction
gcc/cp/
	* name-lookup.h (extract_module_binding): Drop NS arg.
	* name-lookup.c (extract_module_binding): Reimplement.
	* module.cc (depset::hash::add_namespace_entities): Adjust.
2020-08-07 08:44:50 -07:00
Nathan Sidwell
42461b826d Remove now-unneeded dedup bits
gcc/cp/
	* module.cc (module_state::read_cluster): Don't set dedup for
	partition or header unit.
2020-08-06 09:01:44 -07:00
Nathan Sidwell
931286309b Determine deduplication via slot flags.
gcc/cp/
	* module.cc (module_state::read_cluster): Disable dedup here.
	* name-lookup.cc (get_fixed_binding_slot): Set
	MODULE_BINDING_GLOBAL_P if necessary.
	(name_lookup::search_bitmap_only): Inspect MODULE_BINDING_$foo_P.
	(name_lookup::adl_namespace_fns): Likewise.
	(set_module_binding): Always stat hack if mod_glob.
2020-08-06 07:52:59 -07:00
Nathan Sidwell
f2656a9abf fix some lookup issues
gcc/cp/
	* module.cc (module_state::read_cluster): Pay attention to hidden
	decls even in same module.
	* name-lookup.c (name_lookup:adl_namespace_fns): Drop unused parm.
2020-08-06 07:41:14 -07:00
Nathan Sidwell
69adffa147 Note binding slot origin
gcc/cp/
	* cp-tree.h (MODULE_BINDING_{GLOBAL,PARTITION}_P): New.
	* module_cc (module_state::read_cluster): Adjust
	set_module_binding call.
	* name-lookup.c (set_module_binding): Replace inter_p with
	mod_glob parm.  Adjust and set origin.
	* name-lookup.h (set_module_binding): Adjust prototype.
2020-08-05 11:04:11 -07:00
Nathan Sidwell
cff03d76c2 Note duplicates on symbol vector
gcc/cp/
	* cp-tree.h (MODULE_VECTOR_GLOBAL_DUPS_P)
	(MODULE_VECTOR_PARTITION_DUPS_P): New.
	* name-lookup.h (mergeable_namespace_entities): Replace with ...
	(mergeable_namespace_slots): ... this.
	* module.cc (trees_in::key_mergeable): Set dups flag when alread
	existing.
	* name-lookup.c (mergeable_namespace_entities): Replace with ...
	(mergeable_namespace_slots): ... this.  Return the vector too.
2020-08-05 10:35:21 -07:00
Nathan Sidwell
6f9c8865b7 Fix alias templates
gcc/cp/
	* pt.c (lookup_template_class_1): Fix alias resetting of
	ti_template.
	gcc/testsuite/
	* g++.dg/template/pr95263.C: Re-enable.
2020-08-04 13:03:23 -07:00
Nathan Sidwell
03e33763bb Merge trunk 1790d13dc8 2020-08-04 10:34:39 -07:00
Nathan Sidwell
9c6fc6da56 Revert local paranoid change
gcc/cp/
	* cp-tree.h (build_cdtor_clones, clone_cdtor): Drop via_using parm.
	* class.c (build_cdtor_clones): Drop via_using parm.
	(clone_cdtor): Likewise.
	(clone_constructors_and_destructors): Adjust.
	* module.cc (trees_in::decl_value): Adjust build_cdtor_clones parms.
2020-08-03 12:57:50 -07:00
Nathan Sidwell
717a53b832 Add private module fragment parsing (only)
gcc/cp/
	* parser.c (enum module_preamble): Replace with ...
	(enum module_parse): Update all uses.  Add PMF values.
	(cp_parser_module_declaration): Add private-module-fragment grammar.
	gcc/testsuite/
	* g++.dg/modules/pmp-[123]{,_[ab]}.C: New.
2020-08-03 12:29:45 -07:00
Nathan Sidwell
eb9698edfa Fix save-temps & header-units
gcc/cp/
	* lang-specs.h (@c++-{,system-,user-}header): Directives-only
	preprocessing for saving temps with modules.
2020-08-03 09:02:52 -07:00
Nathan Sidwell
583d5560c8 Merge trunk d1773f58f3 2020-08-03 08:21:10 -07:00
Nathan Sidwell
06dd8695ed Add c++-user-header c++-system-header languages
gcc/cp/
	* lang-specs.h (@c++-header): Map -fmodules-ts to -fmodule-header,
	inhibit PCH.
	(@c++-user-header, @c++-system-header): New.
	gcc/
	* doc/invoke.texi (C++ Modules): Document.
2020-08-03 07:01:08 -07:00
Nathan Sidwell
1d95622996 Preserve reserved locations
gcc/cp/
	* module.cc (enum loc_kind): Add LK_RESERVED.
	(module_state::{read,write}_location): Preserve reserved
	locations.
	(module_State::{read,write}_macro_maps): Default to
	UNKNOWN_LOCATION.
	gcc/testsuite/
	* g++.dg/modules/part-mac-1_[abc].[CH]: New.
2020-07-31 11:08:02 -07:00
Nathan Sidwell
04a301cb10 Fix location of imports of partitions.
* module.cc (loc_spans::maybe_propagate): New.
	(module_state::read_{ordinary,macro}_maps): Use it.
	gcc/testsuite/
	* g++.dg/modules/part-hdr-1_[abc].[CH]: New.
2020-07-31 10:21:27 -07:00
Nathan Sidwell
3910d132ca Fix import location reparenting.
gcc/cp/
	* module.cc (preprocess_module): Reparent here, if we're already
	imported.
	gcc/testsuite/
	* g++.dg/modules/reparent-1_[abc].C: New.
2020-07-31 06:30:22 -07:00
Nathan Sidwell
a30ceda5cb Unspellable module control-line tokens
libcpp/
	* internal.h (struct spec_nodes): Add M__IMPORT.
	* init.c (post_options): Adjust module token spelling.
	* lex.c (cpp_maybe_module_directive): Adjust.
	* macro.c (cpp_get_token_1): Reset to zero.
	gcc/c-family/
	* c-common.c (c_common_reswords): Adjust module token spelling.
	gcc/testsuite/
	* g++.dg/modules/dir-recovery.C: New.
	* g++.dg/modules/cpp-[25]_c.C: Adjust.
	* g++.dg/modules/dep-2.C: Adjust.
	* g++.dg/modules/dir-only-[234]{,_b}.C: Adjust.
	* g++.dg/modules/inc-xlate-1_b.H: Adjust.
	* g++.dg/modules/legacy-[36]_[bcd].[HC]: Adjust.
2020-07-30 11:24:01 -07:00
Nathan Sidwell
a894fa90d9 Fix implicit fns from modules.
gcc/cp/
	* cp-tree.h (build_cdtor_clones): Add parms.
	* class.c (build_cdtor_clones): Swallow clone_cdtor's member insertion.
	(clone_cdtor): Move member insertion to build_cdtor_clones.
	* module.cc (trees_in::decl_value): Insert clones, if there's
	already a member vec.
	gcc/testsuite/
	* g++.dg/modules/sv-1{.h,_[ab].C}: New.
2020-07-30 07:36:15 -07:00
Nathan Sidwell
403213844e Merge trunk f3665bd111 2020-07-28 09:53:46 -07:00
Nathan Sidwell
c3e54977d6 Restore a bunch of trunk behaviour
gcc/cp/
	* class.c (layout_class_type): Restore trunk for unnamed classes.
	* cp-tree.h (lang_tree_node): Retore trunk GTY.
	(cp_tree_node_structure): Restore trunk API.
	* decl.c (cp_tree_node_structure): Restore trunk API.
	* diagnostic.c (progname): Restore trunk comment.
	gcc/
	* doc/invoke.texi (Precompiled Headers): Restore trunk index
	capitalization.
	(C++ Modules): Adjust to match.
2020-07-28 09:23:33 -07:00
Nathan Sidwell
bc70c94655 Merge trunk 134051f16b 2020-07-28 06:42:22 -07:00
Nathan Sidwell
b573170cdc line zero rewind fix
libcpp/
	* directives.c (_cpp_do_file_change): Check we're moving to line
	zero of the same file.
2020-07-28 06:15:10 -07:00
Nathan Sidwell
3c843d8968 Revert ada to trunk
gcc/c-family/
	* c-ada-spec.c (decl_sloc): Revert to trunk.
2020-07-22 14:58:13 -04:00
Nathan Sidwell
20eb7c128f Merge trunk 6e1e0decc9 2020-07-22 09:13:53 -07:00
Nathan Sidwell
82250e6409 Unbreak Ada
gcc/
	* gcc.c (execute): Disable argv[0] munging.
2020-07-22 10:47:50 -04:00
Nathan Sidwell
24fcaf7cad Sadly Ada still broken :(
gcc/c-family/
	* c-ada-spec.c (decl_sloc): Actually return the field's loc.
2020-07-21 09:49:13 -04:00
Nathan Sidwell
bcbd792383 Unbreak bootstrap
gcc/cp/
	* rtti.c (init_rtti_processing): Unbreak bootstrap.
2020-07-20 07:14:58 -07:00
Nathan Sidwell
be9f7b2b0b Merge trunk a926eeedf4 2020-07-20 05:59:07 -07:00
Nathan Sidwell
77bd6fc0ed Source main location
libcpp/
	* files.c (_cpp_stack_file): Remove FIXME.
	* include/cpplib.h (cpp_main_loc): Declare.
	* init.c (cpp_read_main_file): Set main loc.
	(cpp_main_loc): New.
	* internal.h (struct cpp_reader): Add main_loc.
	gcc/cp/
	* module.cc (main_source_loc): Delete.
	(module_translate_include): Use cpp_main_loc.
	(begin_header_unit, preprocess_module, preprocessed_module)
	(init_modules, finish_module_processing): Likewise.
	(fini_modules): Adjust.
2020-07-17 12:30:41 -07:00
Nathan Sidwell
ca814b3322 Declaring a builtin in a header unit
gcc/cp/
	* module.cc (module_may_redeclare): Deal with declaring a builtin
	in a header unit.
	* rtti.c (init_rtti_processing): The type is not exported.
2020-07-16 14:39:38 -07:00
Nathan Sidwell
aa9f1d9155 More FIXME resolution
libcpp/
	* directives.c (do_include_common): Drop FIXME question.
	* lex.c (cpp_maybe_module_directive): C++ keywords are not a thing
	here.
	(cpp_directive_only_process): Add assert.
2020-07-16 14:00:51 -07:00
Nathan Sidwell
7f3bd0c72e include xlate callback
libcpp/
	* include/cpplib.h (struct cpp_callbacks): Adjust
	translate_include's return type.
	* files.c (_cpp_stack_file): Push the buffer returned by the hook.
	* lex.c (_cpp_clean_line): Fix buffer overrun.
	gcc/
	* langhooks.h (struct lang_hooks): Change
	preprocess_translate_include's return type.
	gcc/cp/
	* cp-tree.h (module_translate_include): Change return type.
	* module.cc (module_translate_include): Return a buffer, don't
	push it.
2020-07-16 13:39:08 -07:00
Nathan Sidwell
09e0d79249 enum for main search mechanism
libcpp/
	* include/cpplib.h (enum cpp_main_search): New.
	(struct cpp_options): Adjust.
	* init.c (cpp_read_main_file): Adjust.
	* macro.c (cpp_get_token_1): Remove FIXME.
	gcc/cp/
	* module.cc (handle_module_option): Adjust.
2020-07-16 13:38:40 -07:00
Nathan Sidwell
41d88a6c8f Function-scope using-decls
gcc/cp/
	* pt.c (tsubst_expr): Do not process using decls again.
	gcc/testsuite/
	* g++.dg/modules/using-6_a.C: Enable elided code.
	* g++.dg/modules/using-8_[ab].C: New.
2020-07-16 13:38:13 -07:00
Nathan Sidwell
4556080e3c Merge trunk 765fbbf9bb 2020-07-15 11:43:59 -07:00
Nathan Sidwell
7eae4731c9 Merge trunk 5f809982e8 2020-07-14 09:11:51 -07:00
Nathan Sidwell
1edf8b5ed9 Delete now-unused new pieces
gcc/
	* toplev.h (original_argc, original_argv): Delete.
	* toplev.c (original_argc, original_argv): Delete.
	gcc/cp/
	* cp-tree.h (DECL_CHECK): Delete.
	gcc/c-family
	* c-pragma.h (C_LEX_STRING_IS_HEADER): Delete.
2020-07-13 12:49:36 -07:00
Nathan Sidwell
903dcdf0b0 Address more FIXMEs
gcc/cp/
	* module.cc (module_state::set_filename): New.
	(module_state::do_import): Drop fname arg.
	(module_state::read_imports): Set filename here.
	(module_state::write_locations): Drop duplicate FIXME.
	(module_state::read_macros): Drop out of date FIXME.
	(direct_import): Adjust.
	(module_translate): Set filename if we're told it.
	(preprocess_module): Copy if filename already known.
	(preprocessed_module, init_modules): Adjust.
2020-07-13 10:33:03 -07:00
Nathan Sidwell
9c75aba591 Remove some FIXMEs
gcc/cp/
	* module.cc (module_state::read_cluster): Add FIXME about
	unnecessary deduping.
	* name-lookup.c (name_lookup::process_module_binding): Remove
	FIXME.
	(name_lookup::adl_namespace_fns): Likewise.
	(name_lookup::search_adl): Likewise.
	(do_push_nested_namespace): Likewise.
2020-07-13 08:48:20 -07:00
Nathan Sidwell
65e3cb488b Fix scan-lang-dump-not
gcc/testsuite/
	* lib/scanlang.exp (scan-lang-dump-not): Fix 3-arg case.
	* g++.dg/modules/builtin-3_a.C: Remove unnecessary bracing.
2020-07-13 07:52:19 -07:00
Nathan Sidwell
094b09111a Merge trunk a1faa8e247 2020-07-13 07:50:49 -07:00
Nathan Sidwell
156e909b63 Fix polymorphic type info emission and key-function confusion
gcc/cp/
	* module.cc (trees_out::core_bools): Calculate externalness from
	POV of importer.
	(trees_{in,out{::lang_decl_bools): Do not stream
	not_really_extern.
	(trees_in::read_{var,function}_def): Recalculate
	not_really_extern.
	(trees_in::read_class_def): The key_method might become non-key.
	gcc/testsuite/
	* g++.dg/modules/sym-subst-3_a.C: Adjust regexp.
	* g++.dg/modules/virt-1_[ab].C: Adjust.
	* g++.dg/modules/virt-2_[abc].C: New.
2020-07-13 06:30:55 -07:00
Nathan Sidwell
7cce1e321d Copy with ARM's poly ints
gcc/cp/
	* modules.cc (trees_out::type_node [VECTOR_TYPE]): poly_int's
	to_constant already does the checking we need.
2020-07-09 10:58:56 -07:00
Nathan Sidwell
7fd73b12b7 Generalize assembly scan
gcc/testsuite/
	* g++.dg/modules/sym-subst-3_a.C: Adjust scan for other ABIs
2020-07-09 10:28:19 -07:00
Nathan Sidwell
8314e36e0d aarch64 and powerpc va_lists look different
gcc/testuite/
	* g++.dg/modules/builtin-3_[ab].C: Add va_list scans for
	aarch64 and ppowerpc ABIs.
2020-07-09 09:54:51 -07:00
Nathan Sidwell
7b4cb88d27 Remove tcl 8.6ism 2020-07-08 21:06:08 +00:00
Nathan Sidwell
ccbcd56f41 Merge trunk 6bf2ff0d52 2020-07-08 11:52:01 -07:00
Nathan Sidwell
396655c25a Merge trunk ce0f842492 2020-07-03 19:22:12 -04:00
Nathan Sidwell
60a30d9566 Fix bootstrap
gcc/cp/
	* name-lookup.c (name_lookup::adl_namespace_fns): Last param is
	unused, and bootstrap complains :( [Nathan left it like that so
	he'd be reminded to remove it if it really turned out not needed]
2020-07-03 10:43:56 -04:00
Nathan Sidwell
c4b3a5c64f p1779 ABI isolation
gcc/cp/
	* cp-tree.h (named_module_purview_p): New.
	* decl.c (grokmethod): Don't always implicitly inline.
	* module.cc (module_state_config::get_dialect): Add
	module_implicit_inline.
	gcc/
	* doc/invoke.texi (fmodule-implicit-inline): Document.
	gcc/c-family/
	* c.opt (-fmodule-implicit-inline): New.
	gcc/testsuite/
	* g++.dg/modules/imp-member-[12]_b.C: Add some inlines.
	* g++.dg/modules/vmort-1_a.C: Likewise.
	* g++.dg/modules/imp-inline-1_[ab].C: New.
2020-07-02 13:22:21 -07:00
Nathan Sidwell
142418ef83 GMF entities are not findable by name
gcc/cp/
	* modules.cc (enum depset::disc_bits): Remove DB_GLOBAL_BIT.
	(depset::is_global): Delete
	(depset::hash::make_dependency): Drop reachable GMF binding
	insertion.
	gcc/testsuite/
	* g++.dg/modules/builtin-[13]_[ab].C: Adjust scans.
	* g++.dg/modules/mod-sym-2.C: Adjust scans.
2020-07-01 09:55:19 -07:00
Nathan Sidwell
2a81714823 Implement FR039 -- dependent ADL and friend fns
gcc/cp/
	* name-lookup.c (name_lookup::adl_namespace): Instantiation path
	is not important here.
	(name_lookup::search_adl): Reimplement dependent adl for modules.
	gcc/testsuite/
	* g++.dg/modules/adl-[12]_b.C: export.
	* g++.dg/modules/adl-[45]_[abcd].C: New.
2020-07-01 09:20:48 -07:00
Nathan Sidwell
c6f2727d02 A couple of function cloning tweaks
gcc/cp/
	* class.c (copyfndecl_with_name): Drop inadvertent
	DECL_CLONED_FUNCTION setting.  Pass 0 for top_level to
	rest_of_decl_compiulation.
2020-06-30 12:11:59 -07:00
Nathan Sidwell
fb0bb1c31d Internal api tweak
gcc/cp/
	* class.c (copy_fndecl_with_name): Add tree code parm.  Adjust
	callers.
2020-06-30 10:22:36 -07:00
Nathan Sidwell
dd50d60d60 Missed a rename
libcc1/
	* libcp1plugin.cc (plugin_build_decl): Adjust.
2020-06-30 09:38:53 -07:00
Nathan Sidwell
84d3a3a985 Unify copy_fndecl_with_name and clone_decls.
gcc/cp/
	* class.c (DECL_NEEDS_VTT_PARM_P): Delete.
	(copy_fndecl_with_name): Add ctor booleans, use them.  Make static.
	(copy_operator_fn): New wrapper.
	(build_clone): Adjust to use copy_fndecl_with_name.
	(build_clones): Rename to ...
	(build_cdtor_clones): ... here.
	(clone_function_decl): Rename to ...
	(clone_cdtor): ... here.
	(clone_constructors_and_destructors): Adjust.
	* cp-tree.h (build_clones): Rename to build_cdtor_clones.
	(clone_function_decl): Rename to clone_cdtor.
	(copy_fndecl_with_name): Rename to copy_operator_fn.  Change arg
	type.
	* method.c (implicitly_declare_fn): Adjust.
	(lazily_declare_fn): Likewise.
	* module.c (trees_in::decl_value): Adjust.
	* pt.c (tsubst_function_Decl, instantiate_template_1): Adjust.
2020-06-30 08:59:44 -07:00
Nathan Sidwell
c34de11201 Merge master 9a33c41fe4 2020-06-29 14:00:35 -07:00
Nathan Sidwell
bfc221bd1a Merge master 44492e248c
c++: implicit operator== adjustments from P2002. [Jason Merrill]
	gcc/cp/
	* class.c (build_clone): Retain old version for the moment.
	(DECL_NEETS_VTT_PARM_P): Resurrect, before we kill it again.
2020-06-29 11:19:56 -07:00
Nathan Sidwell
a534cd6685 Fix stupid communicating server bugs.
gcc/cp/
	* mapper-server.cc (process_server): We should Write when writing.
	(server): Fix off-by-one error.
2020-06-25 20:30:29 -04:00
Nathan Sidwell
d07d094efd Merge master 68df8e8c34 2020-06-25 13:22:51 -07:00
Nathan Sidwell
869158f027 Merge master 502d63b6d6
Lower VEC_COND_EXPR into internal functions. [Martin Liska]
	Apply d11c9841d5 Add missing check for gassign.  [Martin Liska]
	Apply 9435fb9668 Fix typo in tree-ssa-reassoc.c. [Martin Liska]
2020-06-25 13:11:38 -07:00
Nathan Sidwell
0862b62421 Merge master 2021af0c23 2020-06-25 12:16:04 -07:00
Nathan Sidwell
8ad50d2855 Merge masrer 668ef28fbb.
c++: Clean up previous change [PR41437] [Patrick Palka]
	gcc/cp/
	* module.cc (trees_{in,out}::code_vals [TEMPLATE_INFO]): Adjust
	access checking streaming.
2020-06-25 08:27:45 -07:00
Nathan Sidwell
390ab9b8bc Merge master 92bed03609
c++: Improve access checking inside templates [PR41437]
2020-06-25 07:39:56 -07:00
Nathan Sidwell
6665d04697 Merge master a97e49a89d 2020-06-25 07:11:31 -07:00
Nathan Sidwell
6d8fa55b64 Merge master f2242ec0d3
Over the hump!
2020-06-24 13:43:53 -07:00
Nathan Sidwell
eb150e498d Constrained partial specializations
gcc/cp/
	* module.cc (depset::hash::add_partial_redirect): Add slot parm.
	(enum merge_kind): Add MK_partial.
	(merge_kind_name): Likewise.
	(trees_out::decl_node): A redirect may be for an EK_DECL.
	(trees_out::get_merge_kind): Determine MK_partial.
	(trees_{in,out}::key_mergeable): Deal with MK_partial.
	(depset::hash::make_dependency): Deal with discovering a partial
	specialization.
	* pt.c (maybe_new_partial_specialization): Add module bits to the
	new typedef.
	(tsubst_template_decl): Relax module import assert.
	(tsubst_template_decl): Refactor, add fixme to check.
	gcc/testsuite/
	* g++.dg/modules/nested-constr-1.h: New.
	* g++.dg/modules/nested-constr-1_a.H: New.
	* g++.dg/modules/nested-constr-1_b.C: New.
	* g++.dg/modules/nested-constr-2_a.C: New.
	* g++.dg/modules/nested-constr-2_b.C: New.
	* g++.dg/modules/nested-constr-2_c.C: New.
	* g++.dg/modules/tmpl-part-req-1.h: New.
	* g++.dg/modules/tmpl-part-req-1_a.H: New.
	* g++.dg/modules/tmpl-part-req-1_b.C: New.
	* g++.dg/modules/tmpl-part-req-2.h: New.
	* g++.dg/modules/tmpl-part-req-2_a.H: New.
	* g++.dg/modules/tmpl-part-req-2_b.C: New.
2020-06-24 13:35:06 -07:00
Nathan Sidwell
b27bcc6c83 Merge master b825a22890 2020-06-11 05:51:26 -07:00
Nathan Sidwell
26fd9ef073 Merge master ac9face8d2
PR c++/95263
	gcc/cp/
	* pt.c (lookup_template_class_1): Do not apply reversion
	gcc/testsuite/
	* g++.dg/template/pr95263.C: New (XFAIL)
2020-06-10 12:15:12 -07:00
Nathan Sidwell
3021b1cbb3 Merge master 6c8e16aea8 2020-06-10 09:39:20 -07:00
Nathan Sidwell
2d79fc0f6e Fixes for darwin
gcc/cp/
	* mapper-server.cc: Reorder includes.
	(server): Block scope potentially empty if clause.
	* module.cc (get_mapper): Don't use C++14.
	gcc/testsuite/
	* g++.dg/modules/bad-mapper-3: Adjust error.
2020-06-10 06:16:45 -07:00
Nathan Sidwell
9a42c3334f Install V1 module protocol goop
gcc/cp/
	* Make-lang.in: Remove mapper-server2 hack.
	* mapper-client.cc: Add additional mechanisms to get a server.
	* mapper-client.h: Delete.
	* mapper-resolver.cc: Fix file reading bugs
	* mapper-server.cc: Original deleted.
	* mapper-server2.cc: Renamed to mapper-server.cc.
	* mapper.h: Adjust.
	* module.cc: Adjust.
	gcc/testsuite/
	* g++.dg/modules/bad-mapper-1.C: Adjust expected errors.
	* g++.dg/modules/bad-mapper-2.C: Likewise.
	* g++.dg/modules/bad-mapper-3.C: Likewise.
	* g++.dg/modules/map-2.C: Likewise.
2020-06-05 15:37:00 -04:00
Nathan Sidwell
7400add66f Add libcody as an external library
* libcody: Delete
	* Makefile.def: Revert.
	* configure.ac: Revert. Add --with-libcody.
	* Makefile.tpl: Add CODYLIB, CODYLIBINC, HOST_CODYLIB, HOST_CODYLIBINC.
	* Makefile.in: Rebuilt.
	* configure: Rebuilt.
	gcc/
	* Makefile.in: Revert.  Add CODYLIB, CODYLIBINC.
	* configure.ac: Add CODYLIB, CODYLIBINC.
	* configure: Rebuilt.
	gcc/cp
	* Make-lang.in: Revert.
2020-06-05 09:18:22 -04:00
Nathan Sidwell
d34b6baae9 Add libcody with stub users
* libcody: New.  Currently a symlink to cody repo.
	* Makefile.def: Add libcody.
	* configure.ac: Add libcody.
	* Makefile.in: Rebuilt.
	* configure: Rebuilt.
	gcc/
	* Makefile.in: Add libcody.
	gcc/cp/
	* Make-lang.in: Add libcody
	* mapper.h: New stub/
	* mapper-resolver.cc: New stub.
	* mapper-server2.cc: New stub.
2020-06-02 07:32:58 -07:00
Nathan Sidwell
6036eaa98a Merge master 149c8c7c27 2020-05-21 11:30:31 -07:00
Nathan Sidwell
ac2e10e261 Premerging Patrick's c++/95223 fix.
gcc/cp/
	* cp-tree.h (comparing_typenames): Declare.
	(module_streaming): Delete.
	* modules.cc (module_streaming): Delete.
	(module_state::read_cluster): Increment comparing_typenames, not
	module_streaming.
	* pt.c (comparing_typenames): Define.
	(spec_hasher::equal): Increment it.
	* typeck.c (structural_comptypes): Check it here for typedefs.
2020-05-21 10:46:47 -07:00
Nathan Sidwell
6b9d7a4679 Update file_find_kind names
libcpp/
	* files.c, init.c, internal.h: Adjust file_find_kind names from trunk.
2020-05-21 09:48:57 -07:00
Nathan Sidwell
e16798eea3 Fix linemap range breakage 2020-05-21 09:19:59 -07:00
Nathan Sidwell
a2b1c78c1e Renam cpp_read_main_file's have_preamble parm
libcpp/
	* include/cpplib.h (cpp_read_main): Document preamble arg.
	* internal.h (IT_MAIN_{ZERO,REAL}): Rename to ...
	(IT_MAIN_PREAMBLE, IT_MAIN): ... these.
	* files.c (_cpp_stack_file): Adjust.
	* init.c (cpp_read_main_file): Adjust.
2020-05-20 13:04:01 -07:00
Nathan Sidwell
d714603ced Line zero optimizing
libcpp/
	* directives.c (_cpp_do_file_change): Optimize rewinding one line
	to line zero.
	gcc/c-family/
	* c-opts.c (c_finish_options): Set locations to zero.
	* c-ppoutput.c (cb_define): Always advance line number.
2020-05-20 12:44:42 -07:00
Nathan Sidwell
74963283ed Location setting fixes
libcpp/
	* files.c (cpp_push_include): Pass highest_line for loc.
	(cpp_push_default): Likewise.
	* line-map.c (linemap_add): Set range and column bits to what we
	used to figure start location.
2020-05-20 09:47:15 -07:00
Nathan Sidwell
8159d8db05 Use enumeration type for cpp file kind
libcpp/
	* internal.h (enum _find_file_kind): New.
	(_cpp_find_file): Use it, not 3 bools.
	* files.c (_cpp_find_file): Use _find_file_kind enum, not bools.
	(_cpp_stack_include, cpp_find_header_unit, _cpp_fake_include)
	(_cpp_do_file_change, _cpp_compare_file_date): Adjust.
	* init.c (cpp_read_main): Adjust _cpp_find_file call.
2020-05-19 13:46:19 -07:00
Nathan Sidwell
1e7d6cc63e Darwin test fixes
gcc/testsuite/
	* g++.dg/modules/sym-subst-3_a.C: Adjust scan asm for Darwin.
	* g++.dg/modules/init-2_b.C: Adjust scan-asms for Darwin.
	* g++.dg/modules/init-2_c.C: Likewise.
2020-05-19 12:13:57 -07:00
Nathan Sidwell
6bf96b1809 Darwin sighandler_t fix
gcc/cp/
	* mapper-client.cc: Move fallback typedef for sighandler_t
	from here ...
	* mapper-client.h: ... to here.
2020-05-19 12:06:06 -07:00
Nathan Sidwell
61f1501886 Merge master ed63c387aa 2020-05-19 12:04:08 -07:00
Nathan Sidwell
4e0bf9b5d3 Clarify error message
gcc/cp/
	* name-lookup.c (add_imported_namespace): Clarify
	inline/non-inline error message.

	libcpp/
	* lex.c (do_peek_module): Permit non-ascii char sets.
2020-05-19 09:58:50 -07:00
Nathan Sidwell
6761f494c3 Enumerate load states.
gcc/cp/
	* module.cc (enum module_loadedness): New.
	(module_state::load_state): Rename to ..
	(module_state::loadedness): ... this, change type.
	(module_state::read_{imports,preprocessor,language}): Adjust,
	(module_State::{load_section,do_mport}): Likewise,
	(direct_import, {import,declare,preprocess}_module): Likewise.
2020-05-15 08:41:47 -07:00
Nathan Sidwell
236e93e733 Remove {,purview_,partition_}direct_p flags.
gcc/cp/
	* module.cc (module_state::{,purview_,partition_}_direct_p):
	Remove flags.
	(module_state::is{,purview_,partition_}direct_p}): Adjust.
	(module_state::{read,write}_imports): Remove direct flag handling.
	(module_state::write): Likewise.
	(direct_import, process_module): Likewise.
2020-05-15 08:29:17 -07:00
Nathan Sidwell
09f3831f55 Duplicate {,purview_,partition_}direct_p flags in an enum.
gcc/cp/
	* module.cc (enum module_directness): New.
	(module_state): Add it.
	(module_state::is{,purview_,partition_}direct_p}): Consistency
	asserts.
	(module_state::{read,write}_imports): Adjust and add Consistency
	asserts.
	(module_state::write): Likewise.
	(direct_import, preprocess_module): Likewise.
2020-05-15 08:18:58 -07:00
Nathan Sidwell
79cacccce2 Stop GMF leakage from interface to implementation
gcc/cp/
	* cp-tree.h (preprocess_module): Add in_purview param.
	* lex.c (token_coro::resume): Adjust.
	* module.cc (module_state::purview_direct_p): New flag.
	(module_state::{read,write}_imports): Pay attention to it for
	invisible imports.
	(begin_header_unit): Adjust preprocess_module call.
	(preprocess_module): Set purview_direct_p as appropriate.
	gcc/testsuite/
	* g++.dg/modules/gmf-2_[abcd].[CH]: New.
2020-05-14 11:59:19 -07:00
Nathan Sidwell
4813653043 Merge master f497e36ae5 2020-05-14 08:13:54 -07:00
Nathan Sidwell
922db2851e Remove FIXME 2020-05-14 07:37:39 -07:00
Nathan Sidwell
cf28ae3008 Implement P1874 Dynamic Initialization Order
gcc/cp/
	* cp-tree.h (module_initializer_kind)
	(module_add_import_initializers): Declare.
	(mangle_module): Add include_partition parm.
	(init_module_processing): Rename to init_modules.
	(fini_modules): Declare.
	(mangle_identifier): Add prefix char.
	(mangle_module_global_init): Declare.
	* decl.c (cxx_init_decl_processing): Adjust for module init
	rename.
	* decl2.c (start_objects): Maybe mangle module initializer name.
	Add module initializers.
	(generate_ctor_or_dtor_function): Add module init support.
	(c_parse_final_cleanups): Likewise, adjust for module fini
	addition.
	* mangle.c (mangle_identifier): Add prefix char.
	(write_module): New, broken out of ...
	(maybe_write_module): ... here.  Call it.
	(mangle_module_global_init): New.
	* module.cc (module_state): Add call_init_p flag.
	(num_init_calls_needed): New global.
	(module_state::mangle): Add include_partition parm.
	(mangle_module): Likewise.
	(module_initializer_kind): New.
	(module_add_import_initializers): New.
	(init_module_processing): Rename to ...
	(init_modules): ... here.
	(finish_module_processing): Calculate call_init_p.
	(fini_modules): New, broken out of finish_module_processing.
	gcc/testsuite/
	* g++.dg/modules/init-[12]_[abc].C: New.
2020-05-13 10:49:49 -07:00
Nathan Sidwell
40f639a309 Merge master 2a0225e478 2020-05-12 14:01:34 -07:00
Nathan Sidwell
354fc550ee Merge master b224c3763e 2020-05-08 11:58:09 -07:00
Nathan Sidwell
b721297b71 EOF has a location
gcc/cp/
	* parser.c (cp_lexer_set_source_position_from_token): Don't
	special-case EOF.
	gcc/testsuite/
	* c-c++-common/raw-string-6.c: Adjust expected locations:
	* g++.dg/cpp0x/decltype63.C: Likewise.
	* g++.dg/cpp0x/gen-attrs-64.C
	* g++.dg/cpp0x/pr68726.C: Likewise.
	* g++.dg/cpp0x/pr78341.C: Likewise.
	* g++.dg/cpp1y/pr65202.C: Likewise.
	* g++.dg/cpp1z/class-deduction44.C: Likewise.
	* g++.dg/diagnostic/unclosed-extern-c.C: Likewise.
	* g++.dg/diagnostic/unclosed-function.C: Likewise.
	* g++.dg/diagnostic/unclosed-namespace.C: Likewise.
	* g++.dg/diagnostic/unclosed-struct.C: Likewise.
	* g++.dg/ext/pr84598.C: Likewise.
	* g++.dg/other/switch4.C: Likewise.
	* g++.dg/parse/crash10.C: Likewise.
	* g++.dg/parse/crash18.C: Likewise.
	* g++.dg/parse/crash35.C: Likewise.
	* g++.dg/parse/crash59.C: Likewise.
	* g++.dg/parse/crash61.C: Likewise.
	* g++.dg/parse/crash67.C: Likewise.
	* g++.dg/parse/ctor3.C: Likewise.
	* g++.dg/parse/error14.C: Likewise.
	* g++.dg/parse/error5.C: Likewise.
	* g++.dg/parse/error56.C: Likewise.
	* g++.dg/parse/invalid1.C: Likewise.
	* g++.dg/parse/parameter-declaration-1.C: Likewise.
	* g++.dg/parse/parser-pr28152-2.C: Likewise.
	* g++.dg/parse/parser-pr28152.C: Likewise.
	* g++.dg/parse/pr68722.C: Likewise.
	* g++.dg/pr46852.C: Likewise.
	* g++.dg/pr46868.C: Likewise.
	* g++.dg/template/crash115.C: Likewise.
	* g++.dg/template/crash43.C: Likewise.
	* g++.dg/template/error-recovery1.C: Likewise.
	* g++.dg/template/error57.C: Likewise.
	* g++.old-deja/g++.other/crash31.C: Likewise.
2020-05-08 06:33:04 -07:00
Nathan Sidwell
1fadf34081 Merge master ab2952c77d 2020-05-07 09:21:21 -07:00
Nathan Sidwell
136f279e5e Just push the eh decls.
gcc/cp/
	* except.c (declare_library_fn_1): Don't look at current binding.
	Just make the decl and push it.
	* name-lookup.h (get_global_module_decls): Delete decl.
	* name-lookup.c (get_global_module_decls): Delete defn.
2020-05-05 12:38:29 -07:00
Nathan Sidwell
c7c2447545 Fix eh specs
gcc/testsuite/
	* g++.dg/eh/builtin{5,7,9,10,11}.C: Fix eh specs on __cxa fn decls.
2020-05-05 12:36:25 -07:00
Nathan Sidwell
f894ccd5cb Fix libitm's decls
libitm/
	* eh_cpp.cc (__cxa_allocate_exception, __cxa_free_exception)
	(__cxa_begin_catch, __cxa_tm_cleanup, __cxa_eh_globals): Fix
	exception specification.
	(_ITM_cxa_allocate_exception, _ITM_cxa_free_exception)
	(_ITM_cxa_begin_catch): Likewise.
	* libitm.h (_ITM_NOTHROW): New define.
	(_ITM_cxa_allocate_exception, _ITM_cxa_free_exception)
	(_ITM_cxa_begin_catch): Use it.
	* testsuite/lib/libitm.exp (libitm_init): Add
	-fdiagnostics-color=never.
2020-05-05 12:34:45 -07:00
Nathan Sidwell
64b8060630 Simplify except fn helper pushing part 1
gcc/cp/
	* decl.c (push_library_fn): Return the decl pushdecl_toplevel returns.
	* except.c (verify_library_fn): Replace with ...
	(declare_library_fn_1): ... this fn.
	(declare_library_fn): Call it.
	(build_throw): Call declare_library_fn_1.
	* name-lookup.h (get_global_module_decls): Declare.
	* name-lookup.c (get_namespace_binding): Return this TU's
	bindings.
	(get_global_module_decls): New.
	gcc/testsuite/
	* g++.dg/eh/builtin10.C: Adjust expected errors.
	* g++.dg/eh/builtin11.C: Likewise.
	* g++.dg/eh/builtin6.C: Likewise.
	* g++.dg/eh/builtin7.C: Likewise.
	* g++.dg/eh/builtin9.C: Likewise.
	* g++.dg/parse/crash55.C: Likewise.
2020-05-04 12:37:42 -07:00
Nathan Sidwell
cb365f78e0 Fix macro expansion of header-unit names
libcpp/
	* macro.c (cpp_get_token_1): Pay attention to arg parsing mode,
	and the existence of padding/comment tokens.
	gcc/testsuite/
	* g++.dg/modules/cpp-6_[abc].[CH]: New.
2020-05-01 08:55:32 -07:00
Nathan Sidwell
6636864314 Set TREE_USED on stream in.
gcc/cp/
	* module.cc (trees_in::unused): New field.
	(trees_in::tree_node): Add defaulted off is_use arg, set TREE_USED
	on streamed in obect.  Adjust callers to set it.
	(trees_{in,out}::core_bools): Do not stream base.used_flag.
	(trees_{in,out}::core_vals): Reorder BINFO fields.  Increment
	unused around vtbl pieces.
	(trees_in::decl_value): Save and reset unused field.
	(trees_in::read_var_def): Increment unsused for vtbl initializers.
	gcc/testsuite/
	* g++.dg/modules/used-1_[abc].C: New.
2020-04-30 13:05:36 -07:00
Nathan Sidwell
8ba36396a8 Tweak buultin fn hack
gcc/cp/
	* name-lookup.c (get_namespace_binding): Strip singleton overloads.
2020-04-30 13:00:52 -07:00
Nathan Sidwell
01ae956170 Partition pending indirection fixes
gcc/cp/
	* module.cc (trees_in::install_entity): Treat pending flags
	independently, adjust indirection installation.
	(pendset_lazy_load): Add specialization_p arg.  Use for
	indirection adjustment.
	(get_primary_module): Look at implementation unit's parent.
	(lazy_load_{specializations,members}): Adjust.
	gcc/testsuite/
	* g++.dg/modules/part-6_[abcde].C: New.
2020-04-28 06:29:07 -07:00
Nathan Sidwell
6fded9a059 Stream definitions after decls.
gcc/cp
	* module.cc (module_state::write_cluster): Break out definition
	streaming to separate loop.
	gcc/testsuite/
	* g++.dg/modules/member-def-[12]_c.C: Adjust scans, oh for CHECK-DAG.
2020-04-23 10:05:31 -07:00
Nathan Sidwell
ed1fb0809b Stream node types last
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Move type streaming to
	end.
	gcc/testsuite/
	* g++.dg/modules/indirect-4_c.C: Adjust scan.
2020-04-23 09:38:08 -07:00
Nathan Sidwell
27909a10f2 Stream imports at start of cluster
gcc/cp/
	* module.cc (trees_out::importedness): New checker.
	(depset::hash::add_dependency): Add imports.
	(depset::tarjan::connect): Skip imports.
	(module_state::{read,write}_cluster): Seed imports before the
	cluster itself.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust scans.
	* g++.dg/modules/imp-member-[12]_[ce].C: Adjust scans.
	* g++.dg/modules/member-def-2_c.C: Adjust scans.
	* g++.dg/modules/vmort-2_c.C: Adjust scans.
2020-04-22 11:46:10 -07:00
Nathan Sidwell
1f49f4236e Don't stream DECL_ODR_USED or TREE_ASM_WRITTEN
gcc/cp/
	* module.cc (trees_{in,out}::core_values): Don't stream
	base.asm_written_flag.
	(trees_{in,out}::lang_decl_bools): Don't stream u.base.odr_used.
2020-04-21 12:19:50 -07:00
Nathan Sidwell
65a93bcc55 Remove DECL_MODULE_PARTITION_P, it is not needed
gcc/cp/
	* cp-tree.h (DECL_MODULE_PARTITION_P): Delete.
	(lang_decl_base): Remove module_partition_p bitfield.
	* decl.c (duplicate_decls): No need to check or reset it.
	* lex.c (cxx_dup_lang_specific): No need to reset it.
	* pt.c (build_template_decl): No need to check it.
	(tsubst_template_decl): Likewise, or reset it.
	* module.cc (trees_in::decl_value): No need to set it.
	(trees_out::decl_node): No need to check it.
	(depset::hash::make_dependency): Likewise, Adjust import marking
	code.
	(set_instantiating_module): No need to reset it.
2020-04-21 09:33:12 -07:00
Nathan Sidwell
88b13798f2 Merge master a28edad3da 2020-04-17 13:41:36 -07:00
Nathan Sidwell
f7908a8c38 Rename cxx-mapper
gcc/cp/
	* cxx-mapper.cc: Rename to ...
	* mapper-server.cc: ... here.
	* Make-lang.in: Adjust.
	* module.cc (make_mapper): Adjust.
	gcc/testsuite/
	* g++.dg/modulex/inc-xlate-1_e.C: Adjust.
	* g++.dg/modulex/legacy-[26]_[bcdef].[CH]: Likewise.
2020-04-17 12:33:14 -07:00
Nathan Sidwell
91041d612f Revert some abstractification
gcc/cp/
	* module.cc (mapper_{import_export,export_done}): Revert
	2020-04-13 change/
2020-04-17 12:17:34 -07:00
Nathan Sidwell
d37d255981 Break out module-mapper to separate file
gcc/cp/
	* mapper-client.{h,cc}: New, broken out of ...
	* module.cc: ... here.
	* Make-lang.in: Add mapper-client.
2020-04-17 12:10:09 -07:00
Nathan Sidwell
7f9b821b82 More abstractification
gcc/cp/
	* module.cc (module_mapper::{get,make}): Replace with ...
	(get_mapper, make_mapper): ... these.
	(module_mapper:(kill,fini): Delete.
	(module_mapper::{import_export,export_done}): Replace with ...
	(module_import_export, module_export_done): ... these.
2020-04-17 11:16:51 -07:00
Nathan Sidwell
946875ee91 module_mapper field-ectomy
gcc/cp/
	* module.cc (module_mapper::to): Drop unneeded field.
2020-04-17 09:19:24 -07:00
Nathan Sidwell
e424718753 mapper open & close
gcc/cp/
	* module.cc (module_mapper::{open,close}): New methods, use them.
2020-04-17 08:46:24 -07:00
Nathan Sidwell
93b930f137 More mapper abstractification
gcc/cp/
	* module.cc (module_mapper): Break more stuff out of ctor.
2020-04-17 08:46:06 -07:00
Nathan Sidwell
92649b212a Start abstracting module mapper
gcc/cp/
	* module.cc (module_mapper): Remove knowledge of module_state,
	update all callers.
2020-04-13 10:55:15 -07:00
Nathan Sidwell
9563d7f98a New hello-world testcase
gcc/testsuite/
	* g++.dg/modules/hello-1_[ab].C: New.
2020-04-08 12:09:54 -07:00
Nathan Sidwell
32dc3719d7 TYPE_DECLS don't necessarily have a D_L_S
gcc/cp/
	* module.cc (trees_in::decl_value): Need to retrofit lang for
	inner.
	gcc/testsuite/
	* g++.dg/modules/gmf-1_[ab].C: New.
2020-04-08 12:03:52 -07:00
Nathan Sidwell
5c4ec4a8f9 More header unit checking
gcc/testsuite/
	* g++.dg/modules/xtreme-header-[1-6]_c.C: New.
2020-04-08 09:55:34 -07:00
Nathan Sidwell
66892d570b Avoid null derefs
gcc/cp/
	* module.cc (trees_in::key_mergeable): Avoid null deref.
	(direct_import): Create attachment table.
	gcc/testsuite/
	* g++.dg/modules/lambds-[23]_c.C: New.
2020-04-08 09:54:27 -07:00
Nathan Sidwell
314832b80f Merge master 50c7853216 2020-04-08 06:43:03 -07:00
Nathan Sidwell
5e938e7912 C++20 Ranges!
gcc/testsuite/
	* g++.dg/modules/xtreme-header-2.h: Enable in c++20 mode.
2020-04-07 12:04:07 -07:00
Nathan Sidwell
c511123b6d Placeholder & constrained auto
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parm_value): Stream auto
	placeholder & constraints.
	gcc/testsuite/
	* g++.dg/modules/lambda-4{,_[ab]}.[hHC]: New.
2020-04-07 11:55:58 -07:00
Nathan Sidwell
639ade0145 Lambda _FUN with recursive types
gcc/cp/
	* module.cc (trees_out::key_mergeable): A lambda's static _FUN has
	a recursive return type.
	(trees_in::is_matching_decl): Likewise.
	* g++.dg/modules/lambda-4{,_[ab]}.[hHC]: New.
	* g++.dg/modules/concept-6_b.C: Remove xfail.
2020-04-07 08:32:23 -07:00
Nathan Sidwell
db37280772 Show NULL call arguments
gcc/
	* print-tree.c (print_node): Explicitly show CALL_EXPR null arguments.
2020-04-07 08:28:49 -07:00
Nathan Sidwell
acda0716f3 Instantiations with requires
gcc/cp/
	* module.cc (trees_out::key_mergeable): Instantiations can have
	requires.  Not just the template.
	gcc/testsuite/
	* g++.dg/modules/concept-6{,_[ab]}.[hHC]: New.
2020-04-07 05:47:08 -07:00
Nathan Sidwell
836856bef4 Refactor call-expr & decltype-type comparison
gcc/cp/
	* tree.c (cp_tree_equal): [CALL_EXPR] Directly check number of
	arguments to a call.  Assert they exist.
	* typeck.c (structural_comptypes): [DECLTYPE_TYPE] Break apart if
	conditional.
2020-04-07 05:27:33 -07:00
Nathan Sidwell
1fc1eeb085 Namespaces from partitions don't advertise that
gcc/cp
	* module.cc (depset::hash::make_dependency): Imported namespaces
	from a partition don't have PARTITION_P set.
	(module_state::write): Likewise.
	gcc/testsuite/
	* g++.dg/modules/part-5_[abc].C: New.
2020-04-06 08:28:47 -07:00
Nathan Sidwell
2c6b4bd9ab Zap NSDMIS on as_base fields [PR94476]
PR c++/94476
	gcc/cp/
	* class.c (layout_class_type): Zap NSDMI of as_base fields.
	gcc/testsuite/
	* g++.dg/modules/nsdmi-2.C: New.
2020-04-03 12:38:25 -07:00
Nathan Sidwell
2188cea2c6 Merge master bcafd8748c 2020-04-03 12:16:06 -07:00
Nathan Sidwell
776fd9cc4a Non Static Data Member Initializers (happy now githook?)
WARNING causes ICES in the STL header tests.  There's a trunk
	NSDMI parsing bug (pr94476)
	gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Write FIELD_DECL initial
	value.
	gcc/testsuite/
	* g++.dg/modules/nsdmi-1_[ab].C: New.
2020-04-03 10:40:00 -07:00
Nathan Sidwell
3043c9fed9 Partition up stl header inclusion
gcc/testsuite/
	* g++.dg/modules/xtreme-header-[123456]{,_[ab]}.[hHC]: New.
2020-04-03 09:51:50 -07:00
Nathan Sidwell
9a114dd344 Experimental shouting, perhaps it'll work?
gcc/
	* gcc.c (driver::maybe_print_and_exit): Shout about
	experimentalness.
	(driver::final_actions): Likewise.
	* diagnostic.c (diagnostic_action_after_output): Likewise.
	gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Prune the shouting.
2020-04-03 08:35:16 -07:00
Nathan Sidwell
3de8f3fe67 Template vars inited to lambdas
gcc/cp/
	* module.cc (depset::hash::find_dependencies): Adjust dump
	predicate.
	gcc/testsuite/
	* g++.dg/modules/lambda-3{,_[ab]}.[hHC]: New.
2020-04-03 08:12:01 -07:00
Nathan Sidwell
f3b2cf6b68 Resurrect topological key-order sort for clusters
gcc/cp/
	* module.cc (depset::hash): Add chain, is_key_order.
	(trees_out::is_key_order): New.
	(trees_out::decl_value): Adjust for key-order walk.
	(trees_out::{get_merge_kind,key_mergeable}): Likewise.
	(depset::hash::add_dependency): Deal with key-order dependency.
	(depset::hash::add_mergeable): New.
	(depset::hash::find_dependencies): Adjust for key-order walk.
	(cluster_cmp): Delete.
	(sort_cluster): New.
	(module_state::write): Call sort_cluster, not qsort (cluster_cmp).
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_b.C: Adjust final scan.
	* g++.dg/modules/late-ret-3_a.H: Likewise.
	* g++.dg/modules/member-def-[12]_c.C: Likewise.
	* g++.dg/modules/tpl-alias-1_a.H: Likewise.
	* g++.dg/modules/tpl-friend-1_a.C: Likewise.
	* g++.dg/modules/tpl-spec-3_[ab].C: Likewise.
	* g++.dg/modules/using-7.C: Likewise.
2020-04-03 07:46:55 -07:00
Nathan Sidwell
2a98bb1b44 namespace decl cleanup
gcc/cp/
	* modules.cc (trees_out::decl_node): Treat namespaces like other
	decls.
	(module_state::write): When checking, insert non-imported
	namespace-decls into the entity map here
2020-04-02 09:59:31 -07:00
Nathan Sidwell
dcd1233dc6 Deal with namespace dependencies separately
gcc/cp/
	* modules.cc (trees_out::decl_value): Public.
	(trees_out::decl_node): Do not expect by-value namespaces.
	(depset::hash::find_dependencies): Deal with namespaces here.
2020-04-02 09:15:39 -07:00
Nathan Sidwell
61e93aebe9 Fix broken tests
gcc/testsuite/
	* g++.dg/modules/tpl-alias-1_[ab].[HC]: Fix unresolved tests.
	* g++.dg/modules/vtt-2_b.C: Likewise.
2020-04-01 07:05:31 -07:00
Nathan Sidwell
fc7e31482b Lambdas attached to namespace-scope non-template vars
gcc/cp/
	* cp-tree.h (DECL_ATTACHED_DECLS_P): New.
	(struct lang_decl_base): Add attached_decls_p.
	(maybe_attach_decl): Declare.
	* lambda.c (record_lambda_scope): Call maybe_attach_decl.
	* lex.c (cxx_dup_lang_specific): Clear DECL_ATTACHED_DECLS_P.
	* module.c (uintset<T>::hash::create): New member function.
	(attachset, attached_tables): Declare.
	(enum merge_kind): Add MK_attached.  Adjust.
	(trees_{in,out}::lang_decl_bools): Stream attached_decls_p.
	(trees_{in,out}::decl_value): Stream attached decls.
	(trees_out::get_merge_kind): Determine if MK_attached.
	(trees_{in,out}::key_mergeable): Stream MK_attached.
	(depset::hash::make_dependency): You can get anonymous templatey
	things (lambdas).
	(maybe_attach_decl): New.
	(finish_module_processing): Delete attached_table.
	gcc/testsuite/
	* g++.dg/modules/lambda-2_[ab].[HC]: Remove xfail, add dump scans.
2020-04-01 06:42:14 -07:00
Nathan Sidwell
577388e0c4 Inhibit typename resolution when streaming
gcc/cp/
	* cp-tree.h (module_streaming): Declare.
	* module.cc (module_streaming): Define.
	(cluster_cmp): Do not strip template off an alias instantiation.
	(module_state::read_cluster): Increment module_streaming around
	the loading.
	* typeck.c (structural_comptypes): Do not resolve typename types
	when module_streaming.
2020-03-31 12:42:21 -07:00
Nathan Sidwell
9f857401a2 Create extra scope later
gcc/cp/
	* pt.c (tsubst_lambda_expr): Set extra scope after creating the
	lambda struct.
2020-03-31 10:02:38 -07:00
Nathan Sidwell
f93e7ba1b1 Templatify pendset
gcc/cp/
	* modules.cc (template<T> uintset): New template created from ...
	(pendset): ... this.  Use it.  Adjust all uses.
2020-03-30 08:27:12 -07:00
Nathan Sidwell
d18ba80f09 Merge master 62ede14d30 2020-03-27 06:43:17 -07:00
Nathan Sidwell
07c934bb9d STL headers header-unity (except C++ 20 ranges)
gcc/testsuite/
	* g++.dg/modules/xtreme-header-{,_[ab]}.[hHC]: New.
2020-03-26 13:35:50 -07:00
Nathan Sidwell
bc90e9fa5a Alias templates working (properly)
gcc/cp/
	* modules.cc (enum depset::disc_bits): Add DB_ALIAS_TMPL_INST_BIT,
	Replace DB_BOTH_SPEC_BIT with DB_ALIAS_SPEC_BIT.
	(enum merge_kind): Replace MK_tmpl_both_mask with
	MK_tmpl_alias_mask.  Add MK_alias_spec.
	(merge_kind_name): Adjust.
	(trees_out::core_vals): DECL_TEMPLATE_RESULT might not be visited.
	(trees_{in,out}::decl_value): Cope with alias template
	instantiations.
	(trees_out::get_merge_kind): Add alias support.
	(trees_{in,out}::ket_mergeable): Add alias support.
	(check_mergeable_decl): Likewise.
	(trees_in::is_matching_decl): Drop inner parm, adjust.
	(depset::hash::make_dependency): Add alias suport.
	(depset::hash::add_specializations): Detect and mark aliases.
	gcc/testsuite/
	* g++.dg/modules/tpl-alias-1{,_[ab]}.[hHC]: New.
2020-03-26 13:15:40 -07:00
Nathan Sidwell
8ca572dccd Avoid is_mergeable streaming for instantiations
gcc/cp/
	* module.cc (trees_{in,out}::decl_value): Instantiations are
	merged things too.
2020-03-26 08:39:49 -07:00
Nathan Sidwell
45fba619d5 Refactor entity installing
gcc/cp/
	* module.cc (trees_{in,out}::install_entity): New, broken out of ...
	(trees_{in,out}::decl_value): ... here.  Call them.
2020-03-26 08:24:29 -07:00
Nathan Sidwell
6a2bc22d0a Stop morphing alias instantiation template info
WARNING: This breaks lots of modules tests because an inconsistent
	invariant is now consistently different.  This is intended.
	gcc/cp/
	* cp-tree.h (SET_TYPE_TEMPLATE_INFO): Not for aliases.
	* pt.c (lookup_template_class_1): Type alias's template info
	should already be correct.
	(tsubst_template_decl): Don't reset TI_TEMPLATE of an alias.
2020-03-25 10:22:36 -07:00
Nathan Sidwell
389fa4edcb Avoid unnecessary work in loop.
gcc/cp/
	* cp-tree.h (SET_TYPE_TEMPLATE_INFO): Only expand VAL once.
	* pt.c (perform_typedefs_access_check)
	(append_type_to_template_for_access_check): Move G_T_N_A_C call
	out of loop.
	(get_types_needing_access_check): Simplify.
2020-03-24 10:18:55 -07:00
Nathan Sidwell
3e550ed675 no need to stream tpl-tpl-parm-contextness
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms_fini): Determine
	contextness requirement from TPI.
2020-03-23 07:36:36 -07:00
Nathan Sidwell
abd986fa1d Merge master a3586eeb88. 2020-03-23 07:29:21 -07:00
Nathan Sidwell
47bb5db5ab template template parm context
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms_fini): Flag whether
	tpl-tpl-parm context is non-null.
2020-03-20 10:43:38 -07:00
Nathan Sidwell
71493edf6a Avoid instantiation when comparing duplicates
gcc/cp/
	* module.cc (trees_in::decl_value): No need to install constraints
	for duplicate.
	(trees_in::is_matching_decl): Open code comparison, don't use
	decls_match.
2020-03-19 12:08:19 -07:00
Nathan Sidwell
d8d1efe361 constexprs can have error_mark_node result
gcc/cp/
	* module.cc (trees_{in,out}::{read,write}_function_def): Potential
	cexprs have result == error_mark_node.
2020-03-19 11:09:00 -07:00
Nathan Sidwell
b56ea93d7c Inheriting template ctors
gcc/cp/
	* module.cc (trees_in::decl_value): Template instantiations are
	never implicit member fns.
	(module_state_config::get_dialect): Check exceptions, rtti,
	inheriting ctors.
	gcc/testsuite/
	* g++.dg/modules/inh-tmpl-ctor-1{,_[ab]}.[hHC]: New.
2020-03-19 08:04:46 -07:00
Nathan Sidwell
a3718bc6ca Merge master 3512dc0108 2020-03-19 07:02:28 -07:00
Nathan Sidwell
1b786b3c5d Merge master 3512dc0108 2020-03-19 07:00:39 -07:00
Nathan Sidwell
232abc99a0 Merge master 3512dc0108 2020-03-19 05:36:51 -07:00
Nathan Sidwell
2d5f96b294 pmf typedefs are different to bare pmfs
gcc/cp/
	* module.cc (trees_out::type_node): Do ptr-mem-fns after typedef
	detection.
	gcc/testsuite/
	* g++.dg/modules/pmf-2{,_[ab]}.[hHC]: New.
2020-03-18 11:18:41 -07:00
Nathan Sidwell
ccf1d588d4 Remove gratuitous substitition
gcc/cp/
	* module.cc (trees_out::key_mergeable): Do not perform
	requirements stubstutition.
	(check_mergeable_decl): Likewise.
2020-03-18 10:07:14 -07:00
Nathan Sidwell
d54101b57a auto return type
gcc/cp/
	* decl.c (decls_match): Use fndecl_declared_return_type for
	newdecl too.
	* module.cc (trees_out::key_mergeable): Use
	fndecl_declared_return_type.
	(check_mergeable_decl): Likewise.
	gcc/testsuite/
	* g++.dg/modules/auto-1{,_[ab]}.[hHC]: New.
2020-03-18 07:26:49 -07:00
Nathan Sidwell
736b82e061 Instantiated noexcept specifications
gcc/cp/
	* module.cc (trees_in::is_matching_decl): Propagate instantiated
	noexcept specifications.
	gcc/testsuite/
	* g++.dg/modules/except-3{,_[ab]}.[hHC]: New.
2020-03-17 13:13:31 -07:00
Nathan Sidwell
71af6e7ca3 Check recursive laziness
gcc/cp/
	* module.cc (lazy_snum, recursive_lazy): New.
	(module_state::read_language): Set lazy_snum.
	(lazy_load_{binding,specializations}): Call recursive_lazy.
2020-03-17 05:59:03 -07:00
Nathan Sidwell
decb4b2c81 Adjust read error detection & messages
gcc/cp/
	* module.cc (elf_in::defrost): Return bool.
	(module_state::from): May return NULL.
	(module_state::maybe_completed_reading): New, broken out of
	check_read.
	(pendset::lazy_load): Likewise.
	(module_state::write): Do not read partitions here.
	(module_state::read_initial): Do not create slurp or elf_in here.
	(module_state::load_{preprocessor,language}): Return bool, add
	outermost flag.  Adjust check_read calls.
	(module_state::load_section): Reimplement, check mc_slot, issue
	errors here.
	(module_state::check_read): Reimplement for use by config loaders.
	(module_state::do_import): Add outermost flag, alloc slurping
	here.  Adjust check_read call.
	(module_state::lazy_load): Thin wrapper on load_section.
	(module_state::lazy_load_binding): Check error emission here and
	diagnose.
	(module_state::lazy_load_specializations): Likewise.
	(direct_import, preprocess_module): Adjust.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-4_c.C: Adjust regexp matching
2020-03-16 13:50:08 -07:00
Nathan Sidwell
67c341a073 Clarify a couple of newbie questions
gcc/cp/
	* doc/invoke.texi (C++ Modules): Clarify a couple of things.
2020-03-16 05:25:39 -07:00
Nathan Sidwell
e3613c51d1 Merging pointers to member fn initializers
gcc/cp/
	* name-lookup.c (lookup_field_ident): Check TYPE_LANG_SPECIFIC
	before getting the member vector.
	gcc/testsuite/
	* g++.dg/modules/pmf-1{,_[ab]}.[hHC]: New.
2020-03-13 13:14:31 -07:00
Nathan Sidwell
37baf522a1 Some cleanups
gcc/cp/
	* pt.c (template_args_equal): Slight refactor to clarify control
	flow.
	* tree.c (cp_tree_equal): Use comp_template_args for TREE_VEC.
	* typeck.c (structural_comptypes): Comment about exception specs.
2020-03-13 12:22:18 -07:00
Nathan Sidwell
b7834f4aa8 Ranges, you were right, have a biscuit!
gcc/testsuite/
	* g++.dg/modules/odr-1{,_[ab]}.[hHC]: Moved to ..
	* g++.dg/modules/lambda-2{,_[ab]}.[hHC]: ... here.  Xfailed
2020-03-13 12:12:39 -07:00
Nathan Sidwell
1d379b66a7 deferredness of noexcept can differ, as can builtins
gcc/cp/
	* module.cc (trees_in::decl_value): Set and reset constraints on
	duplicate decl.
	(trees_in::is_matching_decl): Use decls_match to compare decls.
	gcc/testsuite/
	* g++.dg/modules/except-2{,_[ab]}.[hHC]: New.
	* g++.dg/modules/builtin-4_[ab].[HC]: New.
2020-03-13 12:05:44 -07:00
Nathan Sidwell
2ee25bcbd7 PR94027 Fixette
gcc/cp/
	* mangle.c (find_substitution): Cleanup for c++/94027 fix.
2020-03-13 08:31:00 -07:00
Nathan Sidwell
c39c0440da New -fmodule-version-ignore option
gcc/cp/
	* module.cc (module_state::read_config): Allow overriding the
	version check.
	gcc/c-family/
	* c.opt (fmodule-version-ignore): New undocumented option.
2020-03-13 08:23:55 -07:00
Nathan Sidwell
a34216a048 Bad ranges, no biscuit!
gcc/testsuite/
	* g++.dg/modules/odr-1{,_[ab]}.[hHC]: New.
2020-03-11 04:10:17 -07:00
Nathan Sidwell
7c891deba8 Reconstruct deferred exception spec types
gcc/cp/
	* cp-tree.h (fixup_deferred_exception_variants): Declare.
	* tree.c (fixup_deferred_exception_variants): New.
	* parser.c (cp_parser_member_declaration): Comment about friends.
	(cp_parser_class_specifier_1): Call it, don't generate a new type.
	(cp_parser_noexcept_specification_opt): Reorder if conditional.
	gcc/testsuite/
	* g++.dg/modules/deferred-1{,_[ab]}.[hHC]: New.
2020-03-10 12:29:10 -07:00
Nathan Sidwell
55faf3ea77 Merge master 3654d49d0f 2020-03-10 08:59:42 -04:00
Nathan Sidwell
9c9254107f Function-scope using directives
gcc/cp/
	* cp-gimplify.c (cp_genericize_r): Set DECL_CONTEXT of
	IMPORTED_DECL.
	* module.cc (trees_{in.out}::core_vals): Stream IMPORTED_DECL's
	initial.
	(trees_out::decl_node): IMPORTED_DECLs are always by value.
2020-03-09 11:53:08 -07:00
Nathan Sidwell
d90b14bbba Namespace aliases
gcc/cp/
	* name-lookup.c (do_namespace_alias): Set originating module.
	* module.cc (trees_out::tree_node_bools): Allow namespace aliases.
	(depset::hash::make_dependency): Likewise.
	(depset_hash::add_namespace_entities): Likewise.
	(set_instantiating_module): Likewise.
	gcc/testsuite/
	* g++.dg/modules/ns-alias-1_[abc].C: New.
2020-03-09 10:25:53 -07:00
Nathan Sidwell
7cee441935 Chained decls read to vector
gcc/cp/
	* module.cc (trees_{in,out}::vec_chained_decls): New.
	(trees_{in,out}::{read,write}_class_def): Use for fields and vtables.
	gcc/testsuite/
	* g++.dg/modules/vtt-2{,_[ab]}.[hHC]: New.
2020-03-09 08:40:12 -07:00
Nathan Sidwell
1990415ae4 Partial specializations only added once
gcc/cp/
	* cp-tree.h (get_mergeable_specialization_flags)
	(add_mergeable_specialization): Declare.
	* module.cc (trees_{in,out}::key_mergeable): Stream specialization
	flags and add them as necessary.
	(enum ct_decl_flags): Delete.
	(module_state::{read,write}_cluster): No decl flags.
	(install_specialization): Delete.
	* pt.c (get_mergeable_specialization_flags): New.
	(add_mergeable_specialization): New.
	gcc/testsuite/
	* g++.dg/modules/partial-1{,_[ab]}.[hHC]: New.
	* g++.dg/modules/tpl-spec-5_b.C: Adjust scan.
2020-03-09 06:45:12 -07:00
Nathan Sidwell
6c40b552f7 Qualified depdent array types
gcc/cp/
	* tree.c (set_array_type_canon): Add dependent parm.
	(build_cplus_array_type, cp_build_qualified_type_real)
	(strip_typedefs): Pass dependent_p on.
	gcc/testsuite/
	* g++.dg/modules/tpl-ary-1.h: Try constifying.
2020-03-05 04:54:21 -08:00
Nathan Sidwell
a00ae23ed4 Dependent array types
gcc/cp/
	* cp-tree.h (cplus_build_array_type): Add known-dependent default arg.
	* tree.c (cplus_build_array_type): Only calculate dependent if
	unknown.  Set TYPE_DEPENDENT_P on dependent arys.
	* module.cc (trees_{in,out}::type_node): Serialize dependentness
	of array types.
	gcc/testsuite/
	* g++.dg/modules/tpl-ary-1{,_[ab]}.[hHC]: New.
2020-03-05 04:45:06 -08:00
Nathan Sidwell
17f0f914b1 Check TYPE_LANG_SPECIFIC
gcc/cp/
	* name-lookup.c (mergeable_class_entities): Check TYPE_LANG_SPECIFIC.
2020-03-04 12:49:29 -08:00
Nathan Sidwell
a3708e8852 using decls in different namespaces
gcc/cp/
	* module.cc (depset::hash::add_dependency): Only unscoped enum
	usings from the enum itself are mutual dependencies.
	(cluster_cmp): Cope with using decls for the same entity.
	gcc/testsuite/
	* g++.dg/modules/using-7.C: New.
2020-03-04 10:59:17 -08:00
Nathan Sidwell
ce9d948fe3 typedefs in cloned functions do not smell like typedefs
gcc/cp/
	* module.cc (trees_out::core_vals): Adjust typedef detection.
	(trees_{in,out}::decl_value): Likewise.
	gcc/testsuite/
	* g++.dg/modules/tdef-7{,_[ab]}.[hHC]: New.
2020-03-04 08:29:08 -08:00
Nathan Sidwell
2d6fad9f61 More NULL names
gcc/cp/
	* module.cc (trees__out::key_mergeable): NULL name more often.
	(enum merge_match): Delete.
	(check_mergeable_decl): Use merge_kind instead.
	(trees_in::key_mergeable): Adjust.
	gcc/testsuite/
	* g++.dg/modules/merge-6_b.C: Adjust scan.
2020-03-04 05:02:06 -08:00
Nathan Sidwell
a0ed30aea5 Elide merge_key streaming when possible
gcc/cp/
	* module.cc (struct merge_key): simplify.
	(trees_{in,out}::key_mergeable): Optimize merge_key streaming.
2020-03-04 04:38:17 -08:00
Nathan Sidwell
329b9d79fa More explicit merge kind discriminators
gcc/cp/
	* module.cc (enum merge_kind): Add more discriminators.
	(merge_kind_name): Adjust.
	(trees_{in,out}::key_mergeable): Partition via new discriminators.
	(trees_in::decl_value): Remove bad formatting.
	(trees_out::get_merge_kind): Select new discriminators.
	(mergeable_namespace_entity, mergeable_class_member): Fold into
	reimplemented key_mergeable.
	gcc/testsuite/
	* g++.dg/modules/merge-[56]_b.C: Adjust scans.
2020-03-03 14:42:21 -08:00
Nathan Sidwell
298855e460 Remove merge_key index as tree hack
gcc/cp/
	* module.cc (struct merge_key): Remove index as tree hack ...
	(merge_key::{read,write}): ... here.
	(trees_{in,out}::key_mergeable): Adjust.
2020-03-03 10:56:11 -08:00
Nathan Sidwell
5e53a8262a Pass merge_key around, not explicit parms
gcc/cp/
	* module.cc (merge_key::read): Remove req qualifier hack.
	(check_mergeable_decl): Use merge_key, not explicit args.
	(mergeable_namespace_entity, mergeable_class_member): Likewise.
	(trees_in::key_mergeable): Adjust.
2020-03-03 10:48:08 -08:00
Nathan Sidwell
e28d2a0f2e Move merging to key_mergeable
gcc/cp/
	* module.cc (trees_{in,out}::decl_container): New.
	(trees_in::key_mergeable): Reimplement, swallowing the merging
	logic of ...
	(trees_in::decl_value): ... this.
	gcc/testsuite/
	* g++.dg/modules/builtin-[13]_a.C: Adjust scans.
	* g++.dg/modules/indirect-[234]_b.C: Likewise.
	* g++.dg/modules/inst-[23]_a.C: Likewise.
2020-03-03 09:30:01 -08:00
Nathan Sidwell
e0db44ca34 Encapsulate merge key data in a struct
gcc/cp/
	* module.cc (trees_{in,out}::fn_arg_types): Delete.
	(struct merge_key): New.
	(trees_out::key_mergeable): Use merge_key.
	(trees_out::key_mergeable): #ifdef out.
	(trees_in::decl_value): Adjust key handling.
2020-03-03 08:06:08 -08:00
Nathan Sidwell
e08748a07a Move mergeable getters to module.cc
gcc/cp/
	* name-lookup.h (mergeable_namespace_entity)
	(mergeable_class_member): Don't declare.
	* name-lookup.c (check_mergeable_decl, mergeable_namespace_entity)
	(mergeable_class_member):  Move to ...
	* module.cc (check_mergeable_decl, mergeable_namespace_entity)
	(mergeable_class_member): ... here.
2020-03-02 12:34:38 -08:00
Nathan Sidwell
a640ac86d4 Start moving mergeable checking out of name-lookup
gcc/cp/
	* decl2.c (c_parse_final_cleanups): Revert previous change.
	* name-lookup.h (mergeable_{namespace,class}_entities): Declare.
	(add_mergeable_namespace_entity): Declare.
	* name-lookup.c (member_vec_dedup): Link stat_hack chain.
	(check_module_override): Do not use check_mergeable_decl.
	(mergeable_{namespace,class}_entities): New.
	(add_mergeable): Rename to ...
	(add_mergeable_namespace_entitity): ... here.
	(mergeable_{namespace,class}_entity): Use new accessors.
2020-03-02 10:11:22 -08:00
Nathan Sidwell
613ecabf40 The note_defs hash needs to be a cache
gcc/cp/
	* module.cc (struct note_def_cache_hasher): New type.
	(note_defs): Use it, set GTY((cache)).
	(trees_{in,out}::assert_definition): Adjust.
	(module_state::write, init_module_processing): Adjust note_defs
	construction.
2020-02-28 12:23:55 -08:00
Nathan Sidwell
0a10347d04 Don'c complain about unsynthesized defaulted members
gcc/cp/
	* module.cc (c_parse_final_c_cleanups): Don't complain about
	unsynthesized defaulted members in a header unit, and pick a
	privileged clone to complain about when we do.
	gcc/testsuite/
	* g++.dg/modules/imp-member-3.H: New.
2020-02-28 09:44:50 -08:00
Nathan Sidwell
53b027b734 Members can be overloaded on ref qualifierness
gcc/cp/
	* module.cc (trees_(in,out)::fn_arg_types): Serialize ref
	parmness.
	(trees_out::key_mergeable): Adjust.
	* name-lookup.c (check_mergeable_decl): Check ref parmness.
	(mergeable_class_member): __as_base not found via name lookup.
	gcc/testsuite/
	* g++.dg/modules/merge-15{,_[ab]}.[hHC]: New.
2020-02-28 07:36:58 -08:00
Nathan Sidwell
68d6c3e2eb Merge master 9d2d283367 2020-02-28 05:23:07 -08:00
Nathan Sidwell
037aca5849 FIELD_DCLs with template info
gcc/cp/
	* module.cc (trees_out::decl_value): FIELD_DECLS can have
	template_info.
	(member_owned_by_class): Likewise.
	gcc/testsuite/
	* g++.dg/modules/merge-14{,_[ab]}.[hHC]: New.
2020-02-27 11:18:07 -08:00
Nathan Sidwell
310ae53d8e Class-scope using-decls and dependent typename-types
gcc/cp/
	* decl.c (build_typename_type): Refactor.
	* module.cc (trees_out::decl_value): Class-scope using-decls are
	like fields.
	(trees_out::key_mergeable): Using-decls are like anonymous fields.
	(trees_{in,out}::{read,write}_class_def): Beware of
	typename_type's TYPE_DECL in the member vec.
	(trees_out::mark_class_def): Mark using-decls.
	(depset::hash::make_dependency): Assert not a class-scope
	using-decl.
	* name-lookup.c (mergeable_class_member): Using-decls can be
	indexed.
	({get,lookup}_field_ident): Using-decls are like fields.
	gcc/testsuite/
	* g++.dg/modules/indirect-2_c.C: Adjust scans.
	* g++.dg/modules/merge-13{,_[ab]}.[hHC]: New.
2020-02-26 12:47:20 -08:00
Nathan Sidwell
e6c0cbec94 <string> now buildable as a c++20 header unit
gcc/testsuite/
	* g++.dg/modules/string-1_[ab].[CH]: Enable in c++20 mode.
2020-02-25 13:11:15 -08:00
Nathan Sidwell
cb887e2fb7 Merge with variadic template concept
gcc/testsuite/
	* g++.dg/modules/merge-12{,_[ab]}.[hHC]: New.
2020-02-25 11:33:05 -08:00
Nathan Sidwell
7c20089e8f Concept with argument pack
gcc/cp/
	* typeck.c (structural_comptypes): Deal with TYPE_ARGUMENT_PACK.
	gcc/testsuite/
	* g++.dg/concepts/pack-1.C: New.
2020-02-25 11:13:29 -08:00
Nathan Sidwell
934fe9a30d ICE with preprocessed header unit [93761]
PR c++/93761
	gcc/cp/
	* module.cc (begin_header_unit): New, broken out of ...
	(module_begin_main_file): ... here.  Call it when not
	preprocessed.
	(init_module_processing): Call it when preprocessed.
	gcc/testsuite/
	* g++.dg/modules/preproc-1.C: New.
2020-02-25 08:08:23 -08:00
Nathan Sidwell
637df2e24f Small testcase cleanups
* g++.dg/modules/atom-decl-2.C: Use dg-prune.
	* g++.dg/modules/atom-pragma-3.C: Likewise.
	* g++.dg/modules/mod-decl-1.C: Likewise.
	* g++.dg/modules/mod-decl-3.C: Likewise.
	* g++.dg/modules/indirect-1_c.C: Remove dg-bogii.
	* g++.dg/modules/part-3_c.C: Likewise.
2020-02-25 06:37:17 -08:00
Nathan Sidwell
3b8d5c896f Global module constraint merging
gcc/cp/
	* module.cc (trees_out::decl_value): Always stream constraints.
	(trees_in::decl_value): Likewise, deal with requires in merge key.
	(trees_{in,out}::key_mergeable): Stream requires.
	* name-lookup.c (check_mergeable_decl): Add & check requires.
	(check_module_override): Get requires.
	(mergeable_namespace_entity): Add requires.
	(mergeable_class_member): Likewise.
	(make_namespace_finish): Adjust.
	* name-lookup.h (mergeable_namespace_entity): Add requires.
	(mergeable_class_member): Likewise.
	gcc/testsuite/
	* g++.dg/modules/concept-5{,_[ab]}.[hHC]: New.
2020-02-25 06:22:21 -08:00
Nathan Sidwell
be0d02e585 Implement US033
gcc/cp/
	* module.cc (import_module): Check language-linkage depth.
	* parser.c (cp_parser_import_declaration): Check if direct
	language linkage.
	gcc/testsuite/
	* g++.dg/modules/inc-xlate-1_d.C: Delete.
	* g++.dg/modules/lang-1_[abc].[HC]: New.
	* g++.dg/modules/lang-2_[ab].C: New.
2020-02-24 09:51:55 -08:00
Nathan Sidwell
27fea4cf5a Merge master 3841739c29 2020-02-24 08:13:45 -08:00
Nathan Sidwell
bfaad7a57e Commonize ' & " directives-only peeking
libcpp/
	* lex.c (cpp_directives_only): Commonize ' & " peeking, add
	cpp-number vs raw-string detection.
	gcc/testsuite/
	* c-c++-common/cpp/dir-only-7.c: Add test.
2020-02-22 18:36:46 -05:00
Nathan Sidwell
3f77ffc066 Backscanning for raw string literals
libcpp/
	* lex.c (cp_directive_only_process): Deal with raw strings by
	backtracking.
2020-02-19 21:36:49 +01:00
Nathan Sidwell
50974764f8 Support number-punctuator in directives-only
libcpp/
	* lex.c (cpp_directive_only_process): Cope with number
	punctuators.
	gcc/testsuite/
	* c-c++-common/cpp/dir-only-8.c: New.
2020-02-14 20:12:07 +01:00
Nathan Sidwell
fe76dae46c Show branch name in version info
gcc/cp/
	* Make-lang.in (MODULE_REVISION): Add branch name.
2020-02-12 09:43:24 +01:00
Nathan Sidwell
be16e6ca90 Fixup preprocessed main start
gcc/c-family/
	* c-opts.c (c_finish_options): Builtins & command-line starts at
	1.
	(cb_file_change): Alter detection of main file start.
	* c-ppoutput.c (print_line_1): Don't nadger line zero.
	gcc/testsuite/
	* g++.dg/modules/dir-only-3.C: Update line nos
	* g++.dg/modules/dir-only-4.C: New.
2020-02-11 14:57:53 +01:00
Nathan Sidwell
93a35bb732 Fix preprocessed module directives
gcc/c-family/
	* c-optsc (c_common_post_options): Set module_directives
	regardless of preprocessed state.
	gcc/cp/
	* parser.c (cp_parser_skip_to_pragma_eol): Don't explode on
	meeting actual EOF.
	gcc/testsuite/
	* g++.dg/modules/dir-only-3.C: New.
2020-02-11 13:11:17 +01:00
Nathan Sidwell
6d5fdedadb Merge master a6ee556c76 2020-02-11 12:29:55 +01:00
Nathan Sidwell
e812b46fa9 Better raw strings in directives-only mode
libcpp/
	lex.c (do_peek_prev): New.
	(cpp_directive_only_process): Peek backwards from 'R' to check it
	is a raw literal.
	gcc/testsuite/
	* c-c++-common/cpp/dir-only-7.c: Extend.
2020-02-10 19:59:55 +01:00
Nathan Sidwell
ecea46a64e Fix broken module control-lines
libcpp/
	lex.c (_cpp_lex_direct): PRAGMA_EOL is never pre-padded.
	(cpp_directive_only_process): Emit line marker after module
	control-line.
	gcc/
	* langhooks.h (struct lang_hooks): Add PT_flags enum.
	gcc/c-family/
	* c-ppoutput.c (token_streamer): Add begin_pragma.
	(token_streamer::stream): Remove out-of-pragma EOL procesing.
	Ignore pragma_eol location.
	(scan_translation_unit): Pay attention to filter return flags.
	(directives_only_cb): Likewise.
	gcc/cp/
	* lex.c: Inlude langhooks.
	(coro::resume): Return pragma begin flag.
	gcc/testsuite/
	* g++.dg/modules/dir-only-2_b.c: Add broken line check.
2020-02-09 06:59:03 +01:00
Nathan Sidwell
b099bdbf51 change preprocess_token langhook cookie type
gcc/
	* langhooks (struct lang_hooks): preprocess_token takes and
	returns a uintptr_t.
	gcc/cp/
	* cp-tree.h (module_token_{pre,cdtor,lang}): Change cookie type.
	* lex.c  (module_token_{pre,cdtor,lang}): Change cookie type.
	* parser.c (cp_lexer_new): Likewise.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Adjust lang hook use.
	(class do_streamer): Likewise.
	(scan_translation_unit_directives_only): Likewise.
2020-02-09 00:24:14 -05:00
Nathan Sidwell
bff1dce200 Relax raw string detection
libcpp/
	* lex.c (cpp_directive_only_process): Relax raw string detection.
2020-02-08 15:48:01 -05:00
Nathan Sidwell
ab75be3d7d More robust raw string literals and user-defined literals
libcpp/
	* lex.c (cpp_directive_only_process): Re-reimplement.
2020-02-07 14:31:41 -08:00
Nathan Sidwell
51e4956fd9 Use 'module control-line' terminology
libcpp/
	* lex.c (cpp_maybe_module_directive): Use 'module control-line'
	here ...
	gcc/cp/
	* parser.c (cp_parser_diagnose_invalid_type_name): ... here ...
	(cp_parser_import_declaration): ... and here.
2020-02-07 08:48:34 -08:00
Nathan Sidwell
cb5a780f16 Remove now-unused cpp_clear_if_stack
libcpp/
	* internal/cpplib.h (cpp_clear_if_stack): Don't declare.
	* directives.c (cpp_clear_if_stack): Delete.
2020-02-07 08:01:39 -08:00
Nathan Sidwell
91b4b5d6b4 Merge master 82aee6dd61 2020-02-07 07:36:56 -08:00
Nathan Sidwell
cc018da11e Initial -fdirectives-only support
gcc/c-family/
	* c-ppoutput.c (token_streamer::stream): Adust PRAGMA_EOL.
	(class_do_streamer): New.
	(directives_only_cb): Extend for token streaming.
	(scan_translation_unit_directives_only): Pay attention to
	preprocess lang_hook.
	(print_line_1): Ignore UNKNOWN_LOCATIONs.
	libcpp/
	* include/cpplib.h (cpp_directives_only): Add cpp_reader to
	callback.
	* lex.c (do_peek_{backslash,next,ident,module): New.
	(cpp_directive_only_preprocess): Add module peeking.
	gcc/testsuite/
	* g++.dg/modules/dir-only-2_[ab].[CH]: New.
2020-02-07 06:04:49 -08:00
Nathan Sidwell
a88e54535f A token streamer
gcc/c-family/
	* c-ppoutput.c (class token_streamer): New class, swallow guts of
	...
	(scan_translation_unit): ... this.  Use it.
2020-02-07 04:49:22 -08:00
Nathan Sidwell
328c45e8f6 A single generic callback for directives-only processing
libcpp/
	* include/cpplib.h (enum CPP_DO_task): New.
	(cpp_directive_only_process): Adjust prototype.
	* lex.c (cpp_directives_only_process): Take data pointer and
	generic callback, adjust.
	gcc/c-family/
	* c-ppoutput.c (print_lines_directives_only): Replace with ...
	(directives_only_cb): ... this new function.
	(scan_directive_only_preprocess): Adjust call.
2020-02-06 09:33:57 -08:00
Nathan Sidwell
8657d180fb Simplify raw string lexing
libcpp/
	* lex.c (cpp_directive_only_process): Simplify raw string lexing.
2020-02-06 05:42:14 -08:00
Nathan Sidwell
2d3fcfb453 Add raw string support [PR93606]
libcpp/
	* lex.c (cpp_directive_only_process): Add raw string lexing.
	gcc/testsuite/
	* c-c++-common/cpp/dir-only-7.c: New.
2020-02-06 04:37:50 -08:00
Nathan Sidwell
ca448c6510 Merge master fa0c6e297b 2020-02-05 12:24:20 -08:00
Nathan Sidwell
a42e73f54d Clarify comment 2020-02-05 12:04:28 -08:00
Nathan Sidwell
591f66adda Reimplement directive-only scanning
libcpp/
	* directives-only.c: Delete.
	* Makefile.in: Remove it.
	* include/cpplib.h (cpp_directives_only_process): Declare.
	* internal.h (struct _cpp_dir_only): Delete.
	(_cpp_preprocess_dir_only): Delete.
	* lex.c (cpp_directive_only_process): New implementation.
	gcc/c-family/
	* c-ppoutput.c (print_lines_directive_only): lines is unsigned.
	(scan_translation_unit_directives_only): Reimplement.
	gcc/testsuite/
	* gcc.dg/cpp: Move directives-only tests to ...
	* c-c++-common/cpp: ... here.
2020-02-05 12:03:47 -08:00
Nathan Sidwell
d6260ed612 Enforce preamble import restrictions
gcc/cp/
	* parser.c (cp_parser_import_declaration): Be stricter about preamble.
	gcc/testsuite/
	g++.dg/modules/atom-decl-2.C: Adjust diagnostics.
	g++.dg/modules/atom-pragma-3.C: Likewise.
	g++.dg/modules/exp-xlate-1_b.C: Likewise.
	g++.dg/modules/inc-xlate-1_e.C: Likewise.
	g++.dg/modules/atom-preamble-2_f.C: New.
2020-02-04 19:00:48 -05:00
Nathan Sidwell
348cfb09c6 Skip header macros when not preprocessing
gcc/cp/
	* module.cc (preprocess_module): Don't load header unit if not
	preprocessing.  Always close and reopen the line map spans.
	libcpp/
	* include/cpplib.h (cpp_get_options, cpp_get_callbacks)
	(cpp_get_deps): Mark as PURE.
2020-02-04 13:16:05 -08:00
Nathan Sidwell
3dd4f9cc2c Fix dependency generation
gcc/cp/
	* module.cc (module_state::do_import): Drop deps handling here.
	(preprocess_module): Mark interface.
	(preprocessed_module): Correct dependency generation.
	(finish_module_processing): Drop deps handling here.
	libcpp/
	* mkdeps.c (make_write): Note Make 4.3's &: targets
2020-02-04 12:58:17 -08:00
Nathan Sidwell
83cc972b42 MODULE_UNKNOWN_PARTITION is unneeded
gcc/cp/
	* module.cc (MODULE_UNKNOWN_PARTITION): Delete.
	(module_state::read_imports): Drop special partition detection.
	(module_state::read_partitions): Drop special partition setting.
	(module_translate_include): Use main_source_loc for mapper.
	({init,fini}_module_processing): Likewise.
2020-02-04 12:07:45 -08:00
Nathan Sidwell
97b25844b2 Remove module_state::from_loc
gcc/cp/
	* lex.c (module_token_cdtor): Call preprocessed_module on
	teardown here ...
	* parser.c (cp_lexer_new_main): ... not here.
	* module.cc (struct module_state): Drop from_loc.  Use loc in most
	places.
	(module_state::{maybe_create_loc,attach,is_detached): Delete.
	(module_state::is_rooted): New.  Use it in place of is_detached.
	(module_state::imported_from): New.
	(module_state::do_import): Create module loc here ...
	(direct_import): ... not here ...
	(preprocess_module): ... or here.
	(import_module): Reparent here.
	(module_cpp_undef): Check flag_header_unit.
	(module_begin_main_file): Do not declare_module here ...
	(preprocessed_module): ... do it here.
2020-02-04 11:54:01 -08:00
Nathan Sidwell
79135d7b59 Break apart direct_import
gcc/cp/
	* module.cc (module_state::direct_import): Delete.
	(module_state::do_import): Only ever do initial read.
	(direct_import): New non-member fn.
	({import,declare}_module): Call it.
	(preprocess_module): Call do_import.
2020-02-04 08:44:57 -08:00
Nathan Sidwell
661203d785 Final module state flag cleanup
gcc/cp/
	* module.cc (struct module_state): Cleanly separate module kind
	flags from module use flags.
2020-02-04 06:11:19 -08:00
Nathan Sidwell
a7f7873982 primary_p & from_partition_p bite the dust
gcc/cp/
	* module.cc (struct module_state): Drop primary_p &
	from_partition_p.  Map uses to module_p and partition_direct_p.
2020-02-03 13:34:42 -08:00
Nathan Sidwell
3f0e7d8510 Use a load state enumeration
gcc/cp/
	* module.cc (struct module_state): Add load_state, not flags.
	Remove imported_p, lazy_{preprocessor,language}_p.
	(module_state::read_{imports,preprocessor,language}): Adjust.
	(module_state::{check_read,{do,direct}_import}): Adjust.
	({declare,preprocess}_module): Adjust.
2020-02-03 13:12:36 -08:00
Nathan Sidwell
208db70e10 Start rationalizing module_state flags
gcc/cp/
	* cp-tree.h (module_normal_import_p): Delete.
	* module.cc (struct module_state): Rationalize flags.
	(module_normal_import_p): Delete.
	(module_state::direct_import): Don't save and restore line state
	here.
	(import_module): Just for language.
	(preprocess_module): Save line state here.
	* parser.c (cp_parser_import_declaration): Adjust.
	(cp_parser_declaration_seq_opt): Drop superflous pragma parsing.
2020-02-03 12:22:52 -08:00
Nathan Sidwell
badcc6b438 Diagnose poor include translation
gcc/cp/
	* parser.c (cp_parser_import_declaration): Diagnose include
	translation in purview.  Emit not about module-directive control lines.
	gcc/testsuite/
	* g++.dg/modules/inc-xlate-1_e.C: New.
2020-02-03 05:57:11 -08:00
Nathan Sidwell
11c82aea67 include translation fixups
libcpp/
	* internal.h (struct spec_nodes): Transpose n_modules array.
	* init.c (post_options): Adjust n_modules array access.
	* lex.c (cpp_maybe_module_directive): Remove supurfluous state and
	laziness.
	gcc/
	* module.cc (module_translate_include): Add __translated attribute.
	* parser.c (cp_parser_translation_unit): Move translated
	diagnostic to ...
	(cp_parser_import_declaration): ... here.  Still disabled.
	(cp_parser_module_export): Check for following module directive.
	gcc/testsuite/
	* g++.dg/modules/exp-xlate-1_b.C: Remove xfail, adjust errors.
	* g++.dg/modules/inc-xlate-1_b.H: Adjust final scans.
	* g++.dg/modules/legacy-[35]_[bcd].[CH]: Adjust final scans.
2020-02-02 19:12:44 -05:00
Nathan Sidwell
3c45cc6664 Reimplement module-directive mode peeking
libcpp/
	* include/cpplib.h (NODE_MODULE): New.
	(struct cpp_hashnode): Reserve another flag bit.
	* internal.h (struct spec_nodes): Replace separate module spec
	nodes by array.
	(_cpp_setup_module_directive): Delete.
	* init (post_options): Adjust module node initialization.
	* directives.c (_cpp_setup_module_directive): Delete, move into ...
	* lex.c (cpp_maybe_module_directive): ... here.  New, absorb
	peeking from ...
	(_cpp_lex_token): ... here.  Call it.
2020-01-31 11:08:15 -08:00
Nathan Sidwell
eaa6e833f8 Merge master b92709388b 2020-01-31 09:37:08 -08:00
Nathan Sidwell
da94c667ad Fixup pragma error recovery
gcc/cp/
	* parser.c (cp_parser_skip_to_end_of_statement): Adjust pragma
	skipping.
	(cp_parser_skip_to_end_of_block_or_statement): Likewise.
2020-01-31 08:36:46 -08:00
Nathan Sidwell
581aa8f952 PRAGMA_EOL needs a location at the end of pragma line
Fix PRAGMA_EOL location
	libcpp/
	* lex.c (_cpp_lex_direct): Return CPP_PRAGMA_EOL at end of line.
	gcc/cp/
	* lex.c (token_coro::resume): No need to handle in-pragma EOF.
	* parser.c (cp_parser_skip_to_pragma_eol): Likewise.
	(cp_parser_omp_declare_simd, cp_parser_omp_declare_reduction)
	(cp_parser_oacc_routine, cp_parser_initial_pragma, pragma_lex): Likewise.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Ignore CPP_PRAGMA_EOL in
	not a pragma.
	gcc/testsuite/
	* c-c++-common/cpp/pragma-eof.c: New.
2020-01-31 07:23:06 -08:00
Nathan Sidwell
9412c7e007 Restore batched mapper communication
Implement p1857, part 3
	gcc/cp/
	* cp-tree.h (module_preprocess, import_module_pre): Replace with ...
	(preprocess_module): ... this.
	(import_module_lang): Replace with ...
	(import_module): ... this.
	(preprocessed_module): Declare.
	(process_deferred_imports): Delete.
	* lex.c (struct token_coro): Report via preprocess_module.
	(module_token_pre): Call preprocessed_module on teardown.
	* module.cc (module_state::module_p): New flag.
	(main_source_loc): New.
	(pending_imports): Delete.
	(module_state::direct_import): Do not get filename here.
	(import_module_lang): Replace with ...
	(import_module): Drop attach logic.
	(declare_module): Adjust.
	(module_preprocess, import_module_pre): Replace with ...
	(preprocess_module): ... this.  Do attach logic here.
	(preprocessed_module): New.  Do deps and module server name comms.
	(process_deferred_imports): Delete.
	* parser.c (cp_lexer_new_main): Call preprocessed_module when
	done.
	(cp_parser_translation_unit): Drop deferred imports logic.
	(cp_parser_import_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-2_d.C: Remove xfail.
	* g++.dg/modules/bad-mapper-1.C: Adjust diagnostic loc.
	* g++.dg/modules/bad-mapper-2.C: Likewise.
	* g++.dg/modules/bad-mapper-3.C: Likewise.
	* g++.dg/modules/map-2.C: Likewise.
2020-01-31 04:29:07 -08:00
Nathan Sidwell
59068038ea p1857 parser parts
Implement p1857, part 2
	libcpp/
	* include/line-map.h (linemap_module_reparent): Declare.
	* line-map.c (linemap_module_reparent): New.
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_TOKEN): Adjust.
	* cp-tree.h (module_preprocess_token): Rename to ...
	(module_token_pre): ... here.
	(module_token_{cdtor,lang}): Declare.
	(module_map_header): Delete.
	(module_preprocess): Adjust parameters.
	(import_module): Delete, replace with ...
	(import_modile_{pre,lang}): ... these.
	(declare_module): Return void.
	* lex.c (struct token_coro): New, broken out of ...
	(module_preprocess_token): ... here.  Replace with ...
	(module_token_{pre,lang,cdtor}): ... these.
	* module.cc (module_state::read_location): Deal with early-read
	partition locations.
	(module_state::direct_import): Always preserve line map.  Take
	for_cpp arg.
	(import_module): Break into ...
	(import_module_{pre,lang}): ... these.  Disable pending imports.
	(declare_module): Adjust.
	(module_map_header): Delete.
	(module_preprocess): Do not change module array.  Return primary
	module.
	* parser.c (cp_lexer_tokenize): Delete.
	(cp_lexer_new_main): New, resurrected from trunk.  Tokenize the
	whole buffer.  Call the token coro.
	(cp_parser_skip_to_closing_parenthesis_1): Deal with falling into
	a module pseudo-pragma.
	(cp_parser_skip_to_end_of_{,block_or_}statement): Likewise.
	(cp_parser_translation_unit): Drop the incremental tokenization.
	(cp_parser_module_name): Drop KIND parameter.
	(cp_parser_module_directive_end): New.
	(cp_parser_{import,module}_declaration): Adjust.
	(cp_parser_declaration): Deal with (badly placed) import or module
	declarations.
	(cp_parser_toplevel_declaration): Restore PRAGMA parsing.
	(c_parse_file): PCHness handled in cp_lexer_new_main, use it.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-2.C: Adjust expected error
	* g++.dg/modules/atom-pragma-3.C: Likewise.
	* g++.dg/modules/exp-xlate-1_b.C: Likewise.
	* g++.dg/modules/mod-decl-1.C: Likewise.
	* g++.dg/modules/p0713-2.C: Likewise.
	* g++.dg/modules/p0713-3.C: Likewise.
	* g++.dg/modules/atom-preamble-2_d.C: Temporary XFAIL
	* g++.dg/modules/unnamed-1_b.C: Adjust output scan
2020-01-30 08:45:53 -08:00
Nathan Sidwell
55695b9451 A few parser cleanups
gcc/cp/
	* parser.c (cp_lexer_alloc): Remove pch finalizing.
	(cp_parser_skip_to_closing_parenthesis_1): Deal with falling into
	a CPP_PRAGMA.
	(cp_parser_skip_to_end_of_{,block_or_}statement): Likewise.
	(cp_parser_skip_to_pragma_eol): Don't consume CPP_EOF.
	(cp_parser_new): Take a lexer, don't create it here.
	(cp_parser_declaration): Just point at peeked tokens, don't copy.
	(cp_parser_block_declaration): Likewise.
	(cp_parser_initial_pragma): Don't get the first token.
	(c_parse_file): Do it here, and finalize pch.
2020-01-30 08:33:53 -08:00
Nathan Sidwell
1fa99997b3 Fix PRAGMA_EOL location
libcpp/
	* lex.c (_cpp_lex_direct): Set location of PRAGMA_EOL.
	gcc/testsuite/
	* g++.dg/modules/exp-xlate-1_b.C: Add xfailed bogus-error.
	* g++.dg/modules/cpp-2_c.C: Adjust output scan.
	* g++.dg/modules/cpp-5_c.C: Likewise.
	* g++.dg/modules/legacy-3_b.H: Likewise.
	* g++.dg/modules/legacy-3_c.H: Likewise.
	* g++.dg/modules/legacy-6_c.C: Likewise.
	* g++.dg/modules/legacy-6_d.C: likewise.
2020-01-30 08:04:02 -08:00
Nathan Sidwell
134f3dc4ce Constify preprocess_token langhook
gcc/
	* langhooks.h (preprocess_token): Take a const cpp_token pointer.
	gcc/c-family/
	* (c-ppoutput.c (scan_translation_unit): Preprocess lang hook
	doesn't alter the token.
2020-01-27 09:57:26 -08:00
Nathan Sidwell
c8e7875bdc Merge master a1f6eff20e 2020-01-24 06:32:18 -08:00
Nathan Sidwell
c594dbeb15 Module keywords are keywords
gcc/c-family/
	* c-common.h (enum rid): Remove non-underbarred module RIDs.
	* c-common.c (c_common_reswords): Remove non-underbarred module keywords.
	gcc/cp/
	* lex.c (init_reswords): Module keywords are keywords.
	* parser.c (cp_lexer_tokenize): Look for keywords.
	(cp_parser_translation_unit): Likewise.
	gcc/testsuite/
	* g++.dg/modules/exp-xlate-1_b.C: Remove bogus xfail.
2020-01-24 04:59:04 -08:00
Nathan Sidwell
e3346f355d preprocessor defined & has_include fixes
libcpp/
	* expr.c (parse_defined): Fixup for modules.
	(parse_has_include): Remove controlling macro nonsense.
2020-01-23 13:53:18 -08:00
Nathan Sidwell
885527c002 Implement p1857, part 1
Preprocessor lexes module directives as deferred pragmas.  Minimal changes elsewhere.

	libcpp/
	* internal.h (struct lexer_state): Add directive_file_token field.
	(struct spec_nodes): Add module directive nodes.
	(_cpp_setup_module_directive): Declare.
	* include/cpplib.h (struct cpp_options): Add module_directives field.
	* directives.c (_cpp_setup_module_directive): New.
	* init.c (post_options): Provess module_directives option.
	* lex.c (_cpp_lex_token): Add module directive handling.
	* macro.c (cpp_get_token_1): Add directive_file_token handling.
	gcc/cp/
	* lex.c (module_preprocess_token): Reimplement.
	* parser.c (cp_lexer_tokenize): Module lines end in
	CPP_PRAGMA_EOL.
	(cp_lexer_not_macro): Delete.
	(cp_parser_module_directive_end): New.
	(cp_parser_diagnose_invalid_typename): Adjust.
	(cp_parser_translation_unit): Adjust.
	(cp_parser_{module,import}_declaration): Adjust.
	gcc/c-family/
	* c-common.h (enum rid): Add RID__MODULE and co.
	* c-common.c (c_common_reswords): Add __module and co.
	* c-lex.c (c_lex_with_flags): Adjust CPP_HEADER_NAME handling.
	* c-opts.c (c_common_post_options): Set module_directives option.
	gcc/testsuite/
	* g++.dg/modules/anon-2_b.C: Adjust error/scans.
	* g++.dg/modules/atom-preamble-1.C: Likewise.
	* g++.dg/modules/atom-preamble-3.C: Likewise.
	* g++.dg/modules/cpp-2_c.C: Likewise.
	* g++.dg/modules/cpp-5_b.C: Likewise.
	* g++.dg/modules/cpp-5_c.C: Likewise.
	* g++.dg/modules/dep-2.C: Likewise.
	* g++.dg/modules/keyword-1_b.C: Likewise.
	* g++.dg/modules/legacy-3_b.H: Likewise.
	* g++.dg/modules/legacy-3_c.H: Likewise.
	* g++.dg/modules/legacy-6_c.C: Likewise.
	* g++.dg/modules/legacy-6_d.C: Likewise.
	* g++.dg/modules/mod-decl-0-2a.C: Likewise.
	* g++.dg/modules/mod-decl-0.C: Likewise.
	* g++.dg/modules/mod-decl-1.C: Likewise.
	* g++.dg/modules/mod-decl-3.C: Likewise.
	* g++.dg/modules/token-1.C: Likewise.
	* g++.dg/modules/token-2_b.C: Likewise.
	* g++.dg/modules/token-3.C: Likewise.
	* g++.dg/modules/token-4.C: Likewise.
	* g++.dg/modules/exp-xlate-1_b.C: XFAIL
	* g++.dg/modules/inc-xlate-1_d.C: XFAIL
2020-01-23 13:49:45 -08:00
Nathan Sidwell
d2e55cb5ec Simplify remap_module
gcc/cp/
	* modules.cc (slurping::remap_module): Return unsigned, use zero
	for error case.
	(trees_in::tree_node): Adjust.
	(module_state::read_{namespace,pendings}): Likewise.
	(module_state::read_{preprocessor,language}): Likewise.
2020-01-21 12:09:26 -08:00
Nathan Sidwell
841308c4c5 Separate & delay cpp and c++ state reading
gcc/cp/
	* modules.cc (struct module_state): Add
	lazy_{preprocessor,language}_p fields.
	(module_state::read): Delete, move into do_import.
	(module_state::read_preprocessor): Be idempotent. Read direct
	imports here.  Set header bitmap bits.
	(module_state::read_language): Likwise, set import/export bits.
	(module_state::check_read): Adjust file closing condition.
	(module_state::set_import): Do not deal with header bitmaps here.
	(module_state::do_import): Do the initial read (only) here.
	(module_state::direct_import): Do the preprocessor and language
	reading here.
2020-01-21 11:47:04 -08:00
Nathan Sidwell
f96e41419b Encode directness in remap array
gcc/cp/
	* modules.cc (slurping::remap_module): Encode import directness in
	remap array.
	(module_state::read_imports): Adjust.
	(module_state::read_initial): Likewise.
2020-01-21 07:14:55 -08:00
Nathan Sidwell
db89f94f8a Merge master 3a43459715.
Coroutines committed.
2020-01-20 12:37:12 -08:00
Nathan Sidwell
e2b8d17009 Merge master bf09d886a4. 2020-01-17 11:13:06 -08:00
Nathan Sidwell
a50fabeabb Macros only for header units
gcc/cp/
	* module.cc (module_state::write_macros): Always write a set of
	defs.
	(module_state::read_macros): Adjust.
	(module_state::read): Only read preprocessor for header unit.
	(module_state::read_preprocessor): Assert am header.
2020-01-16 13:24:59 -08:00
Nathan Sidwell
6fc5548356 Separate counts from config
gcc/cp/
	* module.cc (module_state::{read,write}_counts): New.  Broken out
	of ...
	(module_state::{read,write}_config): ... here.
	(enum module_state_counts): New.
	(module_state::write_cluster): Take lwm,hwm pair.
	(module_state::read_{bindings,entities,inits}): Adjust.
	(module_state::write): Write counts.
	(module_state::read_{preprocessor,language}): Read counts.
2020-01-16 12:42:40 -08:00
Nathan Sidwell
6d8ba29487 Start separating preprocessor and language reading
gcc/cp/
	* (slurping::slurping): Set current to ~0u.
	(module_state::read_{initial,preprocessor,language}): New, broken
	out of ...
	(module_state::read): ... here.  Call them.
2020-01-16 08:25:46 -08:00
Nathan Sidwell
e7a97f52d7 Merge master.
gcc/cp/
	* module.cc (depset::traits): Add empty_zero_p.
2020-01-15 06:28:30 -08:00
Nathan Sidwell
52ccbf1b00 Here goes nothing ...
gcc/cp/
	* Make-lang.in (MODULE_REVISION): SVN's dead, man.
2020-01-13 05:59:09 -08:00
Nathan Sidwell
336ad859dd Merge trunk r280131.
Bye bye SVN, I'm sure the farm upstate will be fine.

From-SVN: r280139
2020-01-10 20:49:35 +00:00
Nathan Sidwell
7e33753892 re PR c++/79592 (incomplete diagnostic "is not usable as a constexpr function because:")
PR c++/79592

	* g++.dg/ubsan/vptr-4.C: Add expected error.

From-SVN: r279903
2020-01-06 15:22:54 +00:00
Nathan Sidwell
6b8c226714 Merge trunk r279868
From-SVN: r279901
2020-01-06 13:55:06 +00:00
Nathan Sidwell
f4dac8a04d Header unit deduplication milestone
gcc/testsuite/
	* g++.dg/modules/string-1_{a.H,b.C}: New.

From-SVN: r279868
2020-01-03 20:21:48 +00:00
Nathan Sidwell
1eaa0a5422 module.cc (trees_in::decl_value): Disambiguate entity_ary slots from entuty_hash slots.
gcc/cp/
	* module.cc (trees_in::decl_value): Disambiguate entity_ary slots
	from entuty_hash slots.
	(trees_out::get_merge_kind): Check of
	uninstantiated_template_friend even when there's a depset.

From-SVN: r279867
2020-01-03 19:56:32 +00:00
Nathan Sidwell
ff3b72cde7 Return the deduped binfo
gcc/cp/
	* module.cc (trees_in::tree_value): Return existing.
	gcc/testsuite/
	* g++.dg/modules/merge-11{.h,_a.H,_b.C}: New.

From-SVN: r279865
2020-01-03 18:22:19 +00:00
Nathan Sidwell
fa2b4dcf66 anonymous bitfield merging
gcc/cp/
	* module.cc (trees_out::get_merge_kind): Detect bitfield storage
	unit.
	(trees_out::key_mergeable): Deal with anonymous bitfields.
	* name-lookup.c (mergeable_class_member): Likewise.
	gcc/testsuite/
	* g++.dg/modules/merge-10{.h,_a.H,_b.C}: New.

From-SVN: r279864
2020-01-03 17:52:44 +00:00
Nathan Sidwell
030308ea7a tree.h (DECL_ALIGN_RAW): New, use it in accessors.
gcc/
	* tree.h (DECL_ALIGN_RAW): New, use it in accessors.
	(DCL_WARN_IF_NOT_ALIGN): Likewise.
	gcc/cp/
	* cp-tree.h (CPTI_CONST_TYPE_INFO_TYPE,CPTI_TYPE_INFO_PTR_TYPE):
	Move to after module hwm.
	* module.cc (trees_out::write_class_def): Don't write empty thunk
	lists.
	(trees_in::read_class_def): Merge fields from a duplicate.
	gcc/testsuite/
	* g++.dg/modules/tinfo-2_{a.h,b.C}: New.
	* g++.dg/modules/member-def-1_c.C: Adjust scan.
	* g++.dg/modules/merge-9.h: Add another builtin.

From-SVN: r279863
2020-01-03 15:47:33 +00:00
Nathan Sidwell
dada502000 Set returns_struct
gcc/cp/
	* module.cc (module_state::read_cluster): Set cfun->returns_struct
	approprately.

From-SVN: r279862
2020-01-03 15:08:13 +00:00
Nathan Sidwell
df1a84d95f Allow post-streamed export lookup
gcc/cp/
	* module.cc (import_entity_module): Cope with exported entities.

From-SVN: r279860
2020-01-03 14:30:52 +00:00
Nathan Sidwell
0a74b817a2 Fix std::align_val_t
gcc/cp/
	* cp-tree.h (CPTI_ALIGN_TYPE): Not a global tree.
	gcc/testsuite/
	* g++.dg/modules/merge-9{.h,_a.H,_b.C}: New.

From-SVN: r279844
2020-01-02 19:59:20 +00:00
Nathan Sidwell
4920d278da Binfo deduplication
gcc/cp/
	* module.cc (nodel_decl_has): Rename to ...
	(duplicate_hash): ... here.  Allow binfos.
	(trees_{in,out}::binfo_mergeable): New.
	(trees_{in,out}::tree_node): Use it for tt_binfo.
	(trees_{in,out}::tree_value): Use to dedup binfos.
	gcc/testsuite/
	* g++.dg/modules/merge-8{.h,_a.H,_b.C}: New.

From-SVN: r279843
2020-01-02 19:26:10 +00:00
Nathan Sidwell
bd0115f848 Simplify binfo streaming.
gcc/cp/
	* module.cc (trees_{in,out}::tree_binfo): Delete.
	(trees_{in,out}::tree_node): Use binfo chain to find binfo.

From-SVN: r279842
2020-01-02 17:41:44 +00:00
Nathan Sidwell
eb690f1302 Merge trunk r279811.
Update all the years!

From-SVN: r279838
2020-01-02 16:33:29 +00:00
Nathan Sidwell
5ca4b1c654 Merge trunk r279809
That's 2019 done.

From-SVN: r279836
2020-01-02 16:07:44 +00:00
Nathan Sidwell
812831ae7b Merge trunk r279556
gcc/
	* diagnostic-core.h (progname): Resolve conflict.

From-SVN: r279834
2020-01-02 15:11:15 +00:00
Nathan Sidwell
b12b6c2ffe Merge trunk r279555
From-SVN: r279833
2020-01-02 14:36:27 +00:00
Nathan Sidwell
df55ee6828 Merge trunk r279473
From-SVN: r279832
2020-01-02 14:10:09 +00:00
Nathan Sidwell
1d3fa2d6fa Apply trunk r279473
gcc/cp/
	* constexpr.cc (check_constexpr_fundef): Clear non-potential
	result before registering.

From-SVN: r279831
2020-01-02 14:03:54 +00:00
Nathan Sidwell
8e60cdb35f Merge trunk r279472
From-SVN: r279830
2020-01-02 13:06:44 +00:00
Nathan Sidwell
4cf6ceeeaa Typeof merging
gcc/cp/
	* ptree.c (cxx_print_type): Print TYPEOF_TYPE & BASES types.
	* typeck.c (structural_comptypes): Add TYPEOF_TYPE.
	gcc/testsuite/
	* g++.dg/modules/merge-7{.h,_a.H,_b.C}: New.

From-SVN: r279590
2019-12-19 18:41:56 +00:00
Nathan Sidwell
72172d601a Anonymous templates are a thing.
gcc/cp/
	* module.cc (trees_out::key_mergeable): Deal with anon templatey
	members.
	* name-lookup.c (mergeable_class_member): Likewise.
	gcc/testsuite/
	* g++.dg/modules/merge-6{.h,_a.H,_b.C}: New.

From-SVN: r279589
2019-12-19 18:03:11 +00:00
Nathan Sidwell
7ce4ff2a1c module.cc (trees_in::decl_value): Fix enum-context merging.
gcc/cp/
	* module.cc (trees_in::decl_value): Fix enum-context merging.
	gcc/testsuite/
	* g++.dg/modules/merge-5{.h,_a.H,_b.C}: New.

From-SVN: r279586
2019-12-19 16:41:13 +00:00
Nathan Sidwell
2fed242a98 Formatting fix
gcc/cp/
	* module.cc (trees_out::key_mergeable): Fix indentation.

From-SVN: r279585
2019-12-19 16:15:29 +00:00
Nathan Sidwell
059dbd509d Fix ICE with merging template class member classes.
gcc/cp/
	* name-lookup.c (mergeable_class_member): Get to class template
	correctly.
	gcc/testsuite/
	* g++.dg/modules/merge-4{.h,_a.H,_b.C}: New.

From-SVN: r279578
2019-12-19 14:14:43 +00:00
Nathan Sidwell
7a1feda6a2 Fix implicit member parm-type thinko.
gcc/cp/
	* module.cc (trees_in::install_implicit_member): Fix parm type thinko.
	gcc/testsuite/
	* g++.dg/modules/imp-member-1_a.C: Fix scan.
	* g++.dg/modules/imp-member-2_[abc].C: New.

From-SVN: r279568
2019-12-19 12:44:02 +00:00
Nathan Sidwell
05fac9fb6e Installation of implicit member fns.
gcc/cp/
	* module.cc (trees_in::install_implicit_member): New.
	(trees_in::decl_value): Implicit member functions may be dups.
	Call install_implicit_member.
	gcc/testsuite/
	* g++.dg/modules/imp-memner-1_[abcde].C: New.

From-SVN: r279545
2019-12-18 21:37:39 +00:00
Nathan Sidwell
9db52afe3f Out-of-class member function definitions
gcc/cp/
	* decl.c (begin_function_body): RAII.
	* lex.c (cxx_dup_lang_specific): Clear IMPORT_P and PARTITION_P.
	* module.cc (module_state::is_matching_decl): Add inner parm.
	Propagate inline & externalness.
	(module_state::write): Read all partition entities.
	* parser.c (cp_parser_function_definition_after_decl): Set
	defining module as appropriate.
	gcc/testsuite/
	* g++.dg/modules/member-def-2_[abcd].C: New.

From-SVN: r279469
2019-12-17 20:46:11 +00:00
Nathan Sidwell
24f471755a Out-of-class member class definitions
gcc/cp/
	* cp-tree.h (DECL_MODULE_PENDING_MEMBERS_P): New.
	(lang_decl_base): Add module_pending_members_p.
	(lazy_load_members): Declare.
	* module.cc (depset::entity_kind): Add EK_INNER_DECL.
	(depset::disc_bits): Add DB_IS_MEMBER_BIT.
	(depset::is_member): New.
	(module_state::write_cluster): Take ref to module_state_config.
	Adjust.
	(module_state::{read,write}_specializations): Rename to ...
	(module_stte::{read,write}_pendings): Generalize to pending
	members.
	(trees_in::decl_val): Deal with pending members.
	(depset::hash::make_dependency): Adjust for EK_INNER_DECL.
	(depset::hash::add_class_entities): Add them.
	(struct module_state_config): Rename num_specializations ->
	num_pendings.  Adjust throughout.
	(module_state::read_entities): Shift snum another bit.
	(module_sttate::lazy_load): Likewise.
	(lazy_load_members): New.
	* name-lookup.c (maybe_lazily_declare): Load pending members.
	gcc/testsuite/
	* g++.dg/modules/member-def-1_[abcd].C: New.

From-SVN: r279467
2019-12-17 16:55:26 +00:00
Nathan Sidwell
3ee7ff8511 More cross-module redeclaration checks
gcc/cp/
	* cp-tree.h (set_defining_module): New.
	* decl.c (xref_tag_1): Check can redeclare, set instantiating
	module.
	(start_enum): Likewise.
	* module.c: Update doc preamble.
	(module_may_redeclare): Get to the template.
	(set_defining_module): New, broken out of ...
	(set_instantiating_module): ... here.  DO NOT CALL IT.
	* rtti.c (init_rtti_processing): "type_info" has exportedness.
	* semantics.c (begin_class_definition): Check can redeclare.  Set
	defining & instantiating.
	gcc/testsuite/
	* g++.dg/modules/friend-5_[ab].C: New.
	* g++.dg/modules/tdef-4_[bc].C: Add comments.

From-SVN: r279457
2019-12-17 12:32:57 +00:00
Nathan Sidwell
3d07d0302f Merge trunk r279384.
From-SVN: r279386
2019-12-13 21:54:40 +00:00
Nathan Sidwell
c2ac89e1a0 Rename specset to pendset
gcc/cp/
	* module.cc: Rename specset to pendset.  Document.

From-SVN: r279384
2019-12-13 21:21:42 +00:00
Nathan Sidwell
4a3a6f6079 Pending specializations keyed by ident
gcc/cp/
	* cp-tree.h (DECL_TEMPLATE_LAZY_SPECIALIZATIONS_P): Delete.
	(MODULE_VECTOR_LAZY_SPEC_P): Delete.
	(MODULE_VECTOR_PENDING_{SPECIALIZATIONS,IS_HEADER,IS_PARTITION}_P): New.
	(DECL_MODULE_PENDINGSPECIALIZATIONS_P): New.
	(lang_decl_base): Add module_specializations_p.
	(lazy_specializations_p): Declare.
	* name-lookup.h (note_pending_specializations): No return value.
	(load_pending_specializations): Declare.
	(note_loaded_specializations): Delete.
	* module.cc (specset): Key is entity ident.  Adjust throughout.
	(trees_in::decl_value): Deal with pending specializations.
	(specset::lazy_load): Deal with indirections.
	(module_state::{read,write}_specializations): Reimplement.
	(lazy_specializations_p): New.
	(lazy_load_specializations): Reimplement.
	* name-lookup.c (mark_pending_on_{decl,binding}): Delete.
	(set_module_binding): Drop lazy specialization tagging here.
	(note_pending_specializations): Reimplement.
	(load_pending_specializations): New.
	(note_loaded_specializations): Delete.
	* pt.c (lookup_template_class_1): Reimplement lazy specialization
	loading.
	(instantiate_template_1): Likewise.
	gcc/testsuite/
	* g++.dg/modules/inst-4_[ab].C: Adjust scans.
	* g++.dg/modules/tpl-spec-[12345]_[abcd].C: Likewise.

From-SVN: r279382
2019-12-13 21:15:05 +00:00
Nathan Sidwell
48beb65a20 Add DECL_MODULE_ENTITY_P
gcc/cp/
	* cp-tree.h (DECL_MODULE_ENTITY_P): New.
	(lang_decl_bas): Add module_entity_p flag.
	* module.cc (trees_in::decl_value): Insert according to
	DECL_MODULE_ENTITY_P.
	* lex.c (cxx_dup_lang_specific): Clear DECL_MODULE_ENTITY_P.

From-SVN: r279371
2019-12-13 13:20:33 +00:00
Nathan Sidwell
194cc57d53 Reserve an extra lazy index bit.
gcc/cp/
	* module.cc (class specset): Make ns an mc_slot.
	(specset::hash::add): Adjust.
	(specset::hash::lookup): Rename to ...
	(specset::hash::extract): ... here.  Adjust.
	(specset::lazy_load): New.
	(module_state::read_entities): Adjust lazy setting.
	(module_state::read_specializations): Adjust hash table adding.
	(lazy_load_binding): Reorder dump stacking.
	(lazy_load_specializations): Likewise, call specset::lazy_load.

From-SVN: r279313
2019-12-12 20:23:10 +00:00
Nathan Sidwell
23a0606245 cp-tree.h (DECL_MODULE_PARTITION_P): Update doc.
gcc/cp/
	* cp-tree.h (DECL_MODULE_PARTITION_P): Update doc.
	* module.cc (trees_in::decl_value): Only set
	DECL_MODULE_PARTITION_P when primary interface.

From-SVN: r279312
2019-12-12 20:15:41 +00:00
Nathan Sidwell
0c359f2f35 Refactor tag checking function
gcc/cp/
	* decl.c (lookup_and_check_tag): Refactor.

From-SVN: r279311
2019-12-12 20:12:09 +00:00
Nathan Sidwell
86fafd4935 ICE when dumping
gcc/cp/
	* module.cc (import_entity_index): Use different fail value.
	(dumper::impl::nested_name): Don't explode on bad import indices.
	(module_state::write): Adjust.
	gcc/testsuite/
	* g++.dg/modules/part-4_[abc].C: New.

From-SVN: r279308
2019-12-12 15:39:45 +00:00
Nathan Sidwell
664f600d74 Simplify maybe_strip_cmi_prefix
gcc/cp/
	* module.cc (maybe_strip_cmi_prefix): Simplify.

From-SVN: r279057
2019-12-06 18:04:05 +00:00
Nathan Sidwell
7bf2f5b0e4 Remove #ifdef'd code
gcc/cp/
	* module.cc (trees_out::key_mergeable): Remove unreachable code.

From-SVN: r279056
2019-12-06 17:52:39 +00:00
Nathan Sidwell
3b1b8f59f3 Uninstantiated template friends are not special
gcc/cp/
	* module.cc (enum tree_tag): Delete tt_friend_template.
	(trees_out::decl_node): Uninstantiated template friends are not
	special.
	(trees_in::tree_node): Delete tt_friend_template handling.
	(trees_{in,out}::{read,write}_class_def): No need to stream
	template friends specially.
	(trees_out::mark_class_def): No need to mark class_def members.
	(depset::hash::make_dependency): Do not confuse uninstantiated
	template friends with scope members.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-2_a.C: Adjust scan.

From-SVN: r279054
2019-12-06 17:48:35 +00:00
Nathan Sidwell
b32d9665c0 Don't mark friend specializations
gcc/cp/
	* module.cc (trees_out::mark_class_def): No need to mark friend
	specializations.

From-SVN: r279052
2019-12-06 16:56:13 +00:00
Nathan Sidwell
d5cd8e21e7 Zap copied template module info.
gcc/cp/
	* decl.c (duplicate_decls): Just zap the template's module info.
	* pt.c (build_template_decl): No need to copy false module info.
	(tsubst_tenplate_decl): Just zap the template's module info.

From-SVN: r279051
2019-12-06 16:10:31 +00:00
Nathan Sidwell
c218eb74ee Cluster no longer stores biased index
gcc/cp/
	* module.cc (trees_out::decl_{node,value}): Remove cluster biasing.
	(depset::hash::make_dependency): Likewise.
	(module_state::write_{cluster,{namespace{,s}}): Likewise.
	(module_state::write_{entities,specializations}): Likewise.
	(module_state::write): Likewise.

From-SVN: r279048
2019-12-06 14:10:14 +00:00
Nathan Sidwell
43135f359d module.cc (trees_out::decl_value): No need to look for dep again.
gcc/cp/
	* module.cc (trees_out::decl_value): No need to look for dep again.

From-SVN: r279047
2019-12-06 13:49:06 +00:00
Nathan Sidwell
60e94fb89a Cache importing indices in depset
gcc/cp/
	* module.cc (trees_out::decl_node): Get entity index & origin from
	the depset.
	(depset::hash::make_dependency): Stash the importing index &
	origin in the depset.
	(module_state::write_namespace): Get index & origin from the depset.

From-SVN: r279044
2019-12-06 13:18:35 +00:00
Nathan Sidwell
0f4a4a2e1d Structured bindings, c++2a libstdc++ is back working
gcc/cp/
	* module.cc (trees_{in,out}::lang_decl_{bools,vals}): Handle
	lds_decomp.
	gcc/testsuite/
	* g++.dg/modules/decomp-1_[ab].C: New.

From-SVN: r279042
2019-12-06 12:31:13 +00:00
Nathan Sidwell
5033b29ca9 Merge trunk r279023.
libstdc++ c++2a is now using structured bindings, and those don't
	work :(

From-SVN: r279041
2019-12-06 12:09:28 +00:00
Nathan Sidwell
0f849e09dc module.cc (depset::hash::add_namespace_context): New.
gcc/cp/
	* module.cc (depset::hash::add_namespace_context): New.
	(trees_out::decl_node): Use it for namespace.
	(depset::hash::make_dependency): Likewise for discovered GMF.
	(depset::hash::add_binding): Use it.
	(depset::tarjan::connect): Make sure we don't wander into imports.
	(depset::hash::connect): Don't add imports to the graph.
	(module_state::write_namespace{,s}): Never meet global namespace.
	(module_state::write_entries): Handle namespace entries
	separately.
	(module_state::write): Reorganize cluster traversals.

From-SVN: r279022
2019-12-05 21:31:03 +00:00
Nathan Sidwell
12043116d9 module.cc (depset::hash::add_dependency): Do not depend on imports.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Do not depend on
	imports.
	(depset::tarjen::connect): Assert more.
	(depset::hash::connect): Add less.
	(module_state::write): Fewer cases.
	gcc/testsuite/
	* g++.dg/modules/vmort-2_b.C: Invert scan test.

From-SVN: r279016
2019-12-05 19:22:58 +00:00
Nathan Sidwell
67c1da61c3 module.cc (depset::{make,add}_dependency): Drop is_import parm, update all callers.
gcc/cp/
	* module.cc (depset::{make,add}_dependency): Drop is_import parm,
	update all callers.
	(will_be_import): Delete.
	(trees_out::decl_node): Determine will be import locally.
	(depset::make_dependency): Likewise.

From-SVN: r279015
2019-12-05 18:47:53 +00:00
Nathan Sidwell
87c4e50b0c cp-tree.h (DECL_MODULE_PARTITION_P): New.
gcc/cp/
	* cp-tree.h (DECL_MODULE_PARTITION_P): New.
	(lang_decl_base): Add module_partition_p.
	* decl.c (duplicate_decls): Adjust.
	* pt.c (build_template_decl, tsubst_template_decl): Adjust.
	* module.cc (will_be_import): Assert consistency.
	(trees_in::decl_value): Set module_partition_p.
	(depset::hash::make_dependency): Assert consistency.
	(set_instantiating_module): Clear it.

From-SVN: r279014
2019-12-05 18:33:17 +00:00
Nathan Sidwell
f2ddde3922 One Beellion Modules!
gcc/cp/
	* cp-tree.h (lang_decl_base): Replace module_origin field with
	module_import_p flag.
	* modules.cc (MODULE_UNKNOWN{,_PARTITION}): Adjust.
	(MODULE_LIMIT): Delete.
	(module_state): Make mod & remap unsigneds.
	(module_state::read): No need to check module overflow.

From-SVN: r279011
2019-12-05 17:59:06 +00:00
Nathan Sidwell
285cf50d89 module.cc (macro_import::slot): Adjust encoding to use fewer bits.
gcc/cp/
	* module.cc (macro_import::slot) Adjust encoding to use fewer
	bits.
	(macro_import::append): Add defness parm.
	(macro_import::exported): Always make definition.
	(maybe_add_macro): Adjust.
	(module_state::{write,install}_macros): Likewise.
	(module_state::deferred_macro): Likewise.

From-SVN: r279009
2019-12-05 17:49:07 +00:00
Nathan Sidwell
e2ec5e6536 Module index no longer on the decl itself.
From-SVN: r279008
2019-12-05 16:21:46 +00:00
Nathan Sidwell
80f8e7ebe8 name-lookup.h (add_imported_namespace): Origin is unsigned.
gcc/cp/
	* name-lookup.h (add_imported_namespace): Origin is unsigned.
	* name-lookup.c (add_imported_namespace): Origin is unsigned and
	non-zero.  Elide unreachable code.

From-SVN: r279007
2019-12-05 16:01:27 +00:00
Nathan Sidwell
9619d17ff4 cp-tree.h (get_instantiating_module_decl): Delete.
gcc/cp/
	* cp-tree.h (get_instantiating_module_decl): Delete.
	(get_instantiating_module): Delete.
	* module.cc (depset::hash::add_specialization): Remove assert.
	(get_instantiating_module_decl): Delete.
	(get_instantiating_module): Delete.

From-SVN: r279006
2019-12-05 15:40:49 +00:00
Nathan Sidwell
d1b62c763d module.cc (trees_in::{enum ,get_}{dup,ord}ness): Delete.
gcc/cp/
	* module.cc (trees_in::{enum ,get_}{dup,ord}ness): Delete.
	(trees_in::{odr,is}_duplicate): New.
	(trees_in::read_{function,var,class,enum}_def): Adjust.
	(module_state::read_cluster): Adjust.

From-SVN: r279005
2019-12-05 15:36:12 +00:00
Nathan Sidwell
35fb5ddc69 decl.c (duplicate_decls): Pass the old decl to module_may_redeclare.
gcc/cp/
	* decl.c (duplicate_decls): Pass the old decl to
	module_may_redeclare.
	* module.cc (module_may_redeclare): Expect the decl, not its
	owner.

From-SVN: r278999
2019-12-05 13:16:24 +00:00
Nathan Sidwell
e9708070db module.cc (trees_out::decl_node): Move is_import test into non-streaming block.
gcc/cp/
	* module.cc (trees_out::decl_node): Move is_import test into
	non-streaming block.  Check the decl, not the instantiator.

From-SVN: r278997
2019-12-05 12:52:18 +00:00
Nathan Sidwell
4ce9f6875c Elrond is dead, long live Elrond!
From-SVN: r278972
2019-12-04 16:51:46 +00:00
Nathan Sidwell
dff733d12f module.cc (trees_out::decl_node): Refactor, removing duplicate code blocks.
gcc/cp/
	* module.cc (trees_out::decl_node): Refactor, removing duplicate
	code blocks.

From-SVN: r278971
2019-12-04 16:49:58 +00:00
Nathan Sidwell
0a6063ba94 Delete unreachable code
Delete unreachable code
	gcc/cp/
	* module.cc (enum tree_tag): Delete tt_named,
	tt_implicit_template.
	(trees_out::decl_node): Remove #if'd out code.
	(trees_in::tree_node): Remove tt_named, tt_implicit_template
	handling.
	(trees_out::key_mergeable): Remove unreachable anon-type case.
	(trees_out::{write,mark}_class_def)  Removed #if'd out code.
	(trees_in::read_class_def): Likewise.
	* name-lookup.c (get_binding_or_decl): Delete.
	(lookup_by_type, lookup_ident, get_lookup_ident): Delete.
	* name-lookup.h (lookup_by_type, lookup_ident, get_lookup_ident):
	Don't declare.

From-SVN: r278970
2019-12-04 16:31:44 +00:00
Nathan Sidwell
b762d23483 Class members by index.
gcc/cp/
	* decl.c (duplicate_decls): Repropagate module origin & purview.
	* friend.c (add_friend): Potential code, so I don't forget it.
	* module.cc (depset): Delete DB_MERGEABLE_BIT.
	(find_enum_member): New.
	(trees_out::decl_value): Separate different mergeable matching
	cases.  Add new ones.
	(trees_out::decl_node): Stream class members by index.  Adjust
	identifier streaming.
	(trees_in::decl_node): Deal with conv_op_identifier.  Use
	find_enum_member.
	(trees_out::get_merge_kind): Add DECL parm, deal with via_ctx and
	local_friends.
	(trees_out::key_mergeable): Swap parms, deal with new kinds.
	(trees_in::key_mergeable): Deal with new kinds.
	(trees_{in,out}::{read,write}_class_def): Don't stream member
	definitions.
	(trees_out::mark_class_def): Don't mark members.
	(depset::hash::make_dependency): Don't mark as mergeable.
	(cluster_cmp): Compare by stripped UID.
	(get_{instantiating,originating}_module_decl): Deal with fields,
	usings and local friends.
	* name-lookup.c (enum merge_match): New.
	(check_mergeable_decl): Add match kind parm.
	(match_mergeable_decl): Rename to ...
	(mergeable_namespace_entity): ... here.  Deal with namespace scope
	entities.
	(mergeable_class_member): New.
	(make_namespace_finish): Adjust.
	* name-lookup.h (match_mergeable_decl): Rename to ...
	(mergeable_namespace_entity): ... here.
	(mergeable_class_member): Declare.
	gcc/testsuite/
	* g++.dg/modules/friend-1_a.C: Adjust scans.
	* g++.dg/modules/indirect-[1234]_[bc].C: Likewise.
	* g++.dg/modules/inst-3_a.C: Likewise.
	* g++.dg/modules/tpl-friend-[12]_a.C: Likewise.
	* g++.dg/modules/tpl-spec-[45]_a.C: Likewise.
	* g++.dg/modules/vmort-2_a.C: Likewise.
	* g++.dg/modules/internal-1.C: Add xfailed dg-bogus
	* g++.dg/modules/thunk-1_a.C: Avoid implicit member problem.

From-SVN: r278969
2019-12-04 16:11:01 +00:00
Nathan Sidwell
3661a4c90d module.cc (dumper::impl::nested_name): Add 'template ' disambiguator.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Add 'template '
	disambiguator.
	(trees_out::add_indirect_tpl_parms): Check if streaming before
	dumping.
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_[bc].C: Adjust scans.
	* g++.dg/modules/inst-3_b.C: Likewise.
	* g++.dg/modules/late-ret-[23]_[ac].[HC]: Likewise.
	* g++.dg/modules/tpl-friend-[12]_a.C: Likewise.
	* g++.dg/modules/tpl-spec-[1245]_[abcd].C: Likewise.

From-SVN: r278906
2019-12-02 17:26:56 +00:00
Nathan Sidwell
770808de05 module.cc (will_be_import): New.
gcc/cp/
	* module.cc (will_be_import): New.
	(depset::hash::make_dependency): Add is_import parm, rather than
	calculate. Update all callers.
	(depset::hash::add_dependency): Likewise.

From-SVN: r278772
2019-11-27 15:05:27 +00:00
Nathan Sidwell
b97d6bcf41 module.cc (trees_out::decl_node): Untangle namespace-scope emission from class-scope.
gcc/cp/
	* module.cc (trees_out::decl_node): Untangle namespace-scope
	emission from class-scope.
	(trees_in::tree_node): Fix tt_entity ident signedness.
	(depset::hash::make_dependency): Check is_import before checking
	GMF reachability.

From-SVN: r278771
2019-11-27 14:41:00 +00:00
Nathan Sidwell
e151a14da3 module.cc (trees_out::decl_node): Refactor function scope & specialization emission.
gcc/cp/
	* module.cc (trees_out::decl_node): Refactor function scope
	& specialization emission.

From-SVN: r278769
2019-11-27 14:15:42 +00:00
Nathan Sidwell
5e5f56e05f module.cc (trees_out::decl_node): Deal with function scope before instantiations.
gcc/cp/
	* module.cc (trees_out::decl_node): Deal with function scope
	before instantiations.

From-SVN: r278766
2019-11-27 12:25:09 +00:00
Nathan Sidwell
edfffe2c61 module.cc (trees_out::decl_node): Tag and add indirects for uninstantiated template friend.
gcc/cp/
	* module.cc (trees_out::decl_node): Tag and add indirects for
	uninstantiated template friend.
	(trees_in::tree_node): Likewise.

From-SVN: r278741
2019-11-26 23:02:52 +00:00
Nathan Sidwell
d7d4ae1910 module.cc (trees_out::decl_node): Remove a scope.
gcc/cp/
	* module.cc (trees_out::decl_node): Remove a scope.

From-SVN: r278739
2019-11-26 22:21:08 +00:00
Nathan Sidwell
6a32241a8d module.cc (depset): Delete EK_UNNAMED, EK_MAYBE_SPEC.
gcc/cp/
	* module.cc (depset): Delete EK_UNNAMED, EK_MAYBE_SPEC.
	(trees_out::decl_node): Use EK_DECL for those.
	(depset::hash::make_dependency): Likewise.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-[12]_a.C: Adjust scans.
	* g++.dg/modules/tpl-spec-5_a.C: Likewise.
	* g++.dg/modules/vmort-2_a.C: Likewise.

From-SVN: r278733
2019-11-26 20:17:18 +00:00
Nathan Sidwell
b044d1d554 module.cc (trees_out::decl_node): Assert more.
gcc/cp/
	* module.cc (trees_out::decl_node): Assert more.

From-SVN: r278730
2019-11-26 18:44:20 +00:00
Nathan Sidwell
0652e05476 module.cc (module_state::check_read): Simplify to print once per import.
gcc/cp/
	* module.cc (module_state::check_read): Simplify to print once per
	import.

From-SVN: r278729
2019-11-26 18:05:45 +00:00
Nathan Sidwell
198469b348 module.cc (trees_{in,out}::core_vals): Stream _EXPR operands in forward order.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream _EXPR operands in
	forward order.
	(trees_out::decl_node): Move NULL DECL_CONTEXT handling to ...
	(trees_out::tree_node): ... here.

From-SVN: r278727
2019-11-26 15:44:06 +00:00
Nathan Sidwell
9a9e2ff889 module.cc (struct unnamed_entity): Delete.
gcc/cp/
	* module.cc (struct unnamed_entity): Delete.

From-SVN: r278706
2019-11-25 21:20:59 +00:00
Nathan Sidwell
5180db9ae1 name-lookup.h (get_imported_namespace): Don't delare.
gcc/cp/
	* name-lookup.h (get_imported_namespace): Don't delare.
	* name-lookup.c (get_imported_namespace): Delete.

From-SVN: r278705
2019-11-25 21:17:33 +00:00
Nathan Sidwell
5fabdd2c96 Namespaces are in the entity_ary
Namespaces are in the entity_ary
	gcc/cp/
	* module.cc (trees_out::decl_node): Namespace may be imported.
	(depset::hash::make_dependency): Permit imported namespaces.
	(module_state::{read,write}_namespace): New.
	(module_state::{read,write}_namespaces): Adjust.
	(module_state::{read,write]_bindings): Adjust.
	(module_state::write): Don't count imported namespaces.
	* name-lookup.c (add_imported_namespace): Mark namespace as
	imported, if we made it.
	gcc/testsuite/
	* g++.dg/modules/indirect-[1234]_[bc].C: Adjust scans.
	* g++.dg/modules/namespace-2_a.C: Likewise.

From-SVN: r278704
2019-11-25 21:12:06 +00:00
Nathan Sidwell
4771d44b98 module.cc (tree_tag): Delete tt_namespace.
gcc/cp/
	* module.cc (tree_tag): Delete tt_namespace.
	(trees_in::tree_node): Delete tt_namespace handling.
	(module_state::{read,write}_namespaces): Adjust.
	(module_state::write_entities): Delete TABLE parm.

From-SVN: r278696
2019-11-25 18:56:13 +00:00
Nathan Sidwell
4c07c7435b module.cc (trees_out::tree_decl): Write namespaces as tt_entity.
gcc/cp/
	* module.cc (trees_out::tree_decl): Write namespaces as tt_entity.
	(module_state::write_namespaces): Adjust.
	(module_state::read_namespaces): Likewise, don't return a
	namespace vector.
	(module_state::{read,write}_bindings): Adjust.
	(module_state::{read,write}_entities): Allow namespaces.
	(module_state::{read,write}): Adjust.
	gcc/testsuite/
	* g++.dg/modules/indirect-[1234]_c.C: Adjust scans.

From-SVN: r278695
2019-11-25 18:49:53 +00:00
Nathan Sidwell
7a68fb011c module.cc (module_state::write_namespaces): Delete TABLE arg, look at the dep[0]
gcc/cp/
	* module.cc (module_state::write_namespaces): Delete TABLE arg,
	look at the dep[0]
	(module_state::read_namespaces): Add num_spaces parm.  Use it to
	count iterations.
	(module_State::write_bindings): Drop TABLE arg, look at dep[0].
	(struct module_state_config): Add num_namespaces field, stream it.
	(module_state::{read,write}): Don't count global namespace. adjust
	namespace streaming calls.

From-SVN: r278694
2019-11-25 18:26:19 +00:00
Nathan Sidwell
b25fe6214b module.cc (trees_out::decl_node): Add namespace dependency here.
gcc/cp/
	* module.cc (trees_out::decl_node): Add namespace dependency here.
	(depset::hash::add_dependency): And here.
	(space_cmp): Delete.
	(module_state::write): No need to sort namespaces anymore.

From-SVN: r278693
2019-11-25 17:53:44 +00:00
Nathan Sidwell
5e947e4935 missed scan updates
From-SVN: r278691
2019-11-25 14:43:00 +00:00
Nathan Sidwell
815177fb2b module.cc (depset::hash::make_dependency): Add context dependency when discovering a new GMF binding.
gcc/cp/
	* module.cc (depset::hash::make_dependency): Add context
	dependency when discovering a new GMF binding.
	(depset::hash::add_binding): Likewise when discoving a non-empty binding.
	(depset::hash::finalize_dependencies): Leave binding's namespace
	dependency untouched.
	(module_state::write_cluster): Assert binding's namespace in in
	slot zero.  Adjust binding scan.

From-SVN: r278690
2019-11-25 14:37:58 +00:00
Nathan Sidwell
bed5662d49 cxx-mapper.cc (DOT_REPLACE, [...]): New.
gcc/cp/
	* cxx-mapper.cc (DOT_REPLACE, COLON_REPLACE): New.
	(module2bmi): Use them.
	gcc/testsuite/
	* g++.dg/modues/modules.exp (dg-module-cmi): Update default mapping.

From-SVN: r278646
2019-11-23 13:44:57 +00:00
Nathan Sidwell
b0e16bbf73 module.cc (depset::EK_FOR_BINDING): New.
gcc/cp/
	* module.cc (depset::EK_FOR_BINDING): New.
	(depset::hash::make_dependency): Don't look at current.  Adjust.
	(depset::hash::add_dependency): Current is always live.
	(depset::hash::add_binding): Don't set current.  Directly depend
	the binding.
	(depset::hash::add_namespace_entities): Use make_dependency.
	(depset::hash::add_specializations): Likewise.

From-SVN: r278632
2019-11-22 21:11:12 +00:00
Nathan Sidwell
3c6ca32410 module.cc (depset::hash::find_entity): Rename to ...
gcc/cp/
	* module.cc (depset::hash::find_entity): Rename to ...
	(depset::hash::find_dependency): ... here.  Update callers.
	(depset::hash::add_dependency): Break apart to ...
	(depset::hash::make_dependency): ... this, and ...
	(depset::hash::add_dependency): ... this, adder.
	(depset::hash::add_dependency): Do both.

From-SVN: r278629
2019-11-22 20:06:43 +00:00
Nathan Sidwell
d957fd24d5 module.cc (depset::DB_PSEUDO_SPEC_BIT): Delete.
gcc/cp/
	* module.cc (depset::DB_PSEUDO_SPEC_BIT): Delete.
	(depset::is_pseudo_spec): Delete.
	(depset::add_dependency): Don't set it.

From-SVN: r278627
2019-11-22 19:39:04 +00:00
Nathan Sidwell
c07ccf3e0c module.cc (trees_out::decl_node): We should not meet imported internal namespaces.
gcc/cp/
	* module.cc (trees_out::decl_node): We should not meet imported
	internal namespaces.
	(module_state::{read,write}): Stream entities before namespaces.
	* name-lookup.c (add_imported_namespace): Module number must not
	be negative.

From-SVN: r278625
2019-11-22 17:54:18 +00:00
Nathan Sidwell
6a335f4b5c module.cc (trees_in::lang_decl_bools): Don't set module_origin here.
gcc/cp/
	* module.cc (trees_in::lang_decl_bools): Don't set module_origin
	here.
	(trees_out::decl_value): Stream out entity index.  Install into
	entity_map.
	(trees_in::decl_value): Stream in entity index.  Install into
	entity ary, and map (if new)
	(module_state::write_cluster): Do not install into map here.
	(module_state::read_cluster): ... or here. And not ary either.
	gcc/testsuite/
	* g++.dg/modules/builtin-[13]_b.C: Adjust scans.
	* g++.dg/modules/indirect-[123]_[bc].C: Likewise.
	* g++.dg/modules/inst-[1234]_b.C: Likewise.
	* g++.dg/modules/late-ret-[23]_c.C: Likewise.
	* g++.dg/modules/part-3_[cd].C: Likewise.
	* g++.dg/modules/tdef-6_b.C: Likewise.

From-SVN: r278620
2019-11-22 15:31:37 +00:00
Nathan Sidwell
833c8c1099 cp-tree.h (DECL_MODULE_IMPORT_P): #ifdef out, not yet ready
gcc/cp/
	* cp-tree.h (DECL_MODULE_IMPORT_P): #ifdef out, not yet ready
	* module.cc (dumper::impl::nested_name): Don't use it.
	(module_state::read_cluster): Likewise.

From-SVN: r278618
2019-11-22 15:08:45 +00:00
Nathan Sidwell
9a6989cef8 module.cc (trees_out::decl_value): Ensure we stay in the section.
gcc/cp/
	* module.cc (trees_out::decl_value): Ensure we stay in the
	section.
	(trees_out::mark_class_def): Do not mark non-friends on
	CLASSTYPE_DECL_LIST.

From-SVN: r278615
2019-11-22 13:33:02 +00:00
Nathan Sidwell
7acbe3c96d name-lookup.c (lookup_enum_member): Delete.
gcc/cp/
	* name-lookup.c (lookup_enum_member): Delete.
	(get_binding_or_decl): Add missing return.

From-SVN: r278603
2019-11-21 20:55:31 +00:00
Nathan Sidwell
7f546842b1 name-lookup.c (get_binding_or_decl): Only class contexts.
gcc/cp/
	* name-lookup.c (get_binding_or_decl): Only class contexts.
	* module.cc (trees_out::decl_node): Possible fixme.

From-SVN: r278602
2019-11-21 20:52:35 +00:00
Nathan Sidwell
95c50ef084 module.cc (depset::hash): Add sections member.
gcc/cp/
	* module.cc (depset::hash): Add sections member.
	(module_state::write_cluster): Use it.
	(module_state::write): Set it.

From-SVN: r278601
2019-11-21 20:37:02 +00:00
Nathan Sidwell
0406d3382c module.cc (trees_out::decl_node): Don't strip_template checking instantiation consistency.
gcc/cp/
	* module.cc (trees_out::decl_node): Don't strip_template checking
	instantiation consistency.
	(depset::hash::add_{dependency,specializations}): Likewise.
	(get_originating_module_decl): Cope with template friends.  Get to
	the template_decl.
	(get_instantiating_module_decl): Cope with template friends.  Keep
	the template_decl.
	gcc/testsuite/
	* g++.dg/modules/pl-spec-[1245]_[abcd].C: Adjust scans.

From-SVN: r278600
2019-11-21 20:32:51 +00:00
Nathan Sidwell
48a1e3062e name-lookup.c (check_local_shadow): Bail out for clones.
gcc/cp/
	* name-lookup.c (check_local_shadow): Bail out for clones.

From-SVN: r278597
2019-11-21 20:11:11 +00:00
Nathan Sidwell
b3b3453afa module.cc (dumper::impl:nested_name): Obnly show module on imports.
gcc/cp/
	* module.cc (dumper::impl:nested_name): Obnly show module on imports.
	gcc/testsuite/
	* g++dg.modules: Anjust many scans.

From-SVN: r278595
2019-11-21 20:07:44 +00:00
Nathan Sidwell
cb93a5205e module.cc (tree_tag): Rename tt_enum_int, add tt_enum_decl.
gcc/cp/
	* module.cc (tree_tag): Rename tt_enum_int, add tt_enum_decl.
	(trees_out::tree_decl): Write enum consts as tt_enum_decl, not
	tt_data_member.
	(trees_in::tree_node): Add tt_enum_decl handling, adjust
	tt_data_member handling.

From-SVN: r278524
2019-11-20 20:02:25 +00:00
Nathan Sidwell
97865b85fb module.cc (module_state::lazy_load): Add diags arg, make index unsigned.
gcc/cp/
	* module.cc (module_state::lazy_load): Add diags arg, make index
	unsigned.
	(lazy_load_specializations): Use lazy_load.

From-SVN: r278522
2019-11-20 19:15:46 +00:00
Nathan Sidwell
b6b416e217 module.cc (module_state:write_cluster): Minor cleanups
gcc/cp/
	* module.cc (module_state:write_cluster): Minor cleanups
	gcc/testsuite/
	* g++.dg/modules/indirect-2_b.C: Adjust scans.
	* g++.dg/modules/inst-3_a.C: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.

From-SVN: r278521
2019-11-20 19:00:44 +00:00
Nathan Sidwell
6df613e319 module.cc (depset:entity_kind): Reorder.
gcc/cp/
	* module.cc (depset:entity_kind): Reorder.
	(depset::DB_REFS_UNNAMED_BIT): Delete. Remove accessor & setter.
	(cluster_cmp): Order by entity_kind.
	(module_state::write_cluster): A single write pass is sufficient.
	gcc/testsuite/
	* g++.dg/modules/indirect-3_b.C: Adjust cluster order scan.
	* g++.dg/modules/late-ret-[23]_a.H: Likewise.

From-SVN: r278520
2019-11-20 18:44:27 +00:00
Nathan Sidwell
47f598b396 (class depset): Drop entity_num field.
gcc/cp/
	* (class depset): Drop entity_num field.  Adjust all users to use
	cluster.
	(module_state::write_cluster): Merge counting and marking loops.

From-SVN: r278508
2019-11-20 16:29:02 +00:00
Nathan Sidwell
e957eadc18 module.cc (module_state): Delete unnamed_{lwm,num}.
Expelliarmus!
	gcc/cp/
	* module.cc (module_state): Delete unnamed_{lwm,num}.
	(enum ct_decl_flags): Delete cdf_is_voldemort.
	(module_state::write_cluster): Don't set cluster number.  Drop
	voldemort handling.
	(module_state::read_cluster): Drop voldemort handling.
	(module_state::write_specializations): Drop cluster consistency
	check.
	gcc/testsuite/
	* g++.dg/modules/indirect-2_b.C: Adjust scans.
	* g++.dg/modules/inst-[23]_a.C: Likewise.

From-SVN: r278507
2019-11-20 16:18:42 +00:00
Nathan Sidwell
040cd3beae Remove more unnamed remnants.
gcc/cp/
	* module.cc (module_state::write_cluster): Count specializations.
	(module_state::{read,write}_unnamed): Rename to ...
	(module_state::{read,write}_specializations): ... here. Drop
	section numbers.  Adjust calls.
	(struct module_state_config): Rename num_unnamed to
	num_specializations, adjust all uses.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-[12345]_[ab].C: Adjust scans.

From-SVN: r278506
2019-11-20 15:56:26 +00:00
Nathan Sidwell
d264896667 Remove unnamed ary etc.
gcc/cp/
	* module.cc (unnamed_ary, unnamed_map_t, unnamed_map): Delete.
	(module_state::read_cluster): Do not insert into unnamed_ary or
	map.
	(module_state::read_unnamed): Do not extend unnamed_ary.
	(module_state::read): Do not set unnamed_lwm.
	(module_for_unnamed): Delete.
	({init,finish}_module_processing): Do not create/destroy unnamed
	ary & map.
	gcc/testsuite/
	* g++.dg/modules/indirect-[23]_c.C: Adjust scans.
	* g++.dg/modules/inst-[124]_b.C: Likewise.
	* g++.dg/modules/late-ret-2_c.C: Likewise.

From-SVN: r278503
2019-11-20 15:34:03 +00:00
Nathan Sidwell
7d00700c29 module.cc (module_state::{read,write}_unnamed): Specializations store entity index.
gcc/cp/
	* module.cc (module_state::{read,write}_unnamed): Specializations
	store entity index.
	(lazy_load_specializations): Use the entity index.

From-SVN: r278502
2019-11-20 15:13:47 +00:00
Nathan Sidwell
4500cde80b No more horcruxes.
gcc/cp/
	* module.cc (trees_out::decl_node): Specializations are tt_entity.
	(enum cluster_tag): Delete ct_horcrux.
	(module_state::write_cluster): No need to create horcruxes.
	(module_state::read_cluster): No need to resurrect horcruxes.
	gcc/testsuite/
	* g++.dg/modules/indirect-[24]_b.C: Adjust scans.
	* g++.dg/modules/inst-[123]_[ab].C: Likewise.
	* g++.dg/modules/late-ret-2_c.C: Likewise.
	* g++.dg/modules/tpl-friend-5_b.C: Likewise.

From-SVN: r278499
2019-11-20 14:18:35 +00:00
Nathan Sidwell
f1aef0ccd0 module.cc (trees_out::decl_node): Process unnamed decls directly here.
gcc/cp/
	* module.cc (trees_out::decl_node): Process unnamed decls directly
	here.
	(depset::hash::add_dependency): EK_UNNAMED doesn't reference
	unnamed (really).
	(module_state::write_cluster): Do not preseed horcruxes for
	EK_UNNAMED.  Add unnamed and specializations into the entity_map.
	gcc/testsuite/
	* g++.dg/modules/vmort-2_[abc].C: Adjust scans

From-SVN: r278466
2019-11-19 20:45:41 +00:00
Nathan Sidwell
a038e51369 module.cc (enum tree_tag): Kill tt_anon.
gcc/cp/
	* module.cc (enum tree_tag): Kill tt_anon.  No longer emitted.
	(import_entity_index): Do not assert imported.
	(trees_out::decl_node): Always get the import_entity_index for
	tt_entity.
	(trees_in::tree_node): Drop tt_anon.
	(module_state::write_cluster): Add the EK_DECLs to the entity_map.

From-SVN: r278462
2019-11-19 19:14:39 +00:00
Nathan Sidwell
f22aa9d814 cp-tree.h (lazy_load_binding): Drop final parm.
gcc/cp/
	* cp-tree.h (lazy_load_binding): Drop final parm.
	* module.cc (module_state::lazy_load): Drop ns, id & outermost
	parms.
	(trees_in::tree_node, module_state::read_cluster): Adjust
	lazy_load calls.
	(module_state::read): Inhibit GC here.
	(lazy_load_binding): Deal with binding dumps here.
	(lazy_load_specializations): Use lazy_load_binding.
	* name-lookup.c: Adjust lazy_load_binding calls.
	(get_binding_or_decl): No namespace handling here.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-5_b.C: Adjust scans
	* g++.dg/modules/vmort-2_c.C: Likewise.

From-SVN: r278456
2019-11-19 17:10:28 +00:00
Nathan Sidwell
8e952ad0b9 Entities are numbered (part 1)
Entities are numbered (part 1)
	gcc/cp/
	* cp-tree.h (DECL_MODULE_IMPORT_P): New.
	* module.cc (depset::entity_kind): Add EK_ENTITIES.
	(depset::entity_num): New (temporary) field.
	(enum tree_tag): Add tt_entity.
	(module_state): Add entity_lwm & entity_num fields.
	(module_state::lazy_load): Add index, use it.
	(module_state::{read,write}_entities): New.
	(module_state::{read,write}_cluster): Number the entities.
	(entity_map_t, entity_map, entity_ary) New.
	(import_entity_index, import_entity_module): New.
	(trees_out::decl_node): Write tt_entity for namespace decls.
	(trees_in::tree_node): Add tt_entity handling.
	(struct module_state_config): Add num_entities field.
	(module_state::{read,write}_config): Stream it.
	(module_state::{read,write}: Adjust.
	({init,fini}_module_processing): Deal with entity map and ary.
	* name-lookup.c (get_binding_or_decl): Mark NAMESPACE unreachable.
	gcc/testsuite/
	* g++.dg/modules/{builtin,indirect}-1_b.C: Adjust scans.
	* g++.dg/modules/indirect-[1234]_c.C: Likewise.
	* g++.dg/modules/tpl-friend-5_b.C: Likewise.
	* g++.dg/modules/unnamed-1_b.C: Likewise.

From-SVN: r278454
2019-11-19 16:09:58 +00:00
Nathan Sidwell
48decd0dfc cp-tree.h (check_mergeable_specialization): Take spec_entry arg.
gcc/cp/
	* cp-tree.h (check_mergeable_specialization): Take spec_entry arg.
	* module.cc (trees_out::decl_node): Allow CONCEPT_DECL.
	(trees_out::key_mergeable): Use check_mergeable_specialization).
	(specialization_add): Adjust check_mergeable_specialization call.
	* pt.c (register_specialization): Remove casts.
	(check_mergeable_specialization): Take spec_entry arg.
	(match_mergeable_specialization): Add the specialization early.
	gcc/testsuite/
	* g++.dg/modules/concept-4.H: New.

From-SVN: r278263
2019-11-14 19:34:33 +00:00
Nathan Sidwell
dcde38d532 cp-tree.h (lang_decl_base): Note 8-bits.
gcc/cp/
	* cp-tree.h (lang_decl_base): Note 8-bits.
	* error.c (dump_module_suffix): Bail on no DECL_CONTEXT.
	* module.cc (trees_{in,out}::lang_decl_bools): Update for new
	fields.
	(has_definition): Deal with CONCEPT_DECL.
	(trees_out::{mark,write}_definition): Concepts are like vars.
	(trees_in::read_definition): Likewise.
	({get,set}_originating_module{,_decl}): Deal with CONCEPT_DECL.
	* pt.c (finish_concept_definition): Set orginating module.
	gcc/testsuite/
	* g++.dg/modules/concept-3_[ab].C: New.

From-SVN: r278257
2019-11-14 17:48:29 +00:00
Nathan Sidwell
95e90a6f5a Merge trunk r278228.
From-SVN: r278241
2019-11-14 15:14:08 +00:00
Nathan Sidwell
33d139a4bd rtti.c ({push,pop}_abi_namespace): Save and restore module state.
gcc/cp/
	* rtti.c ({push,pop}_abi_namespace): Save and restore module
	state.
	(build_dynamic_cast_1, tinfo_base_init): Adjust.

From-SVN: r277712
2019-11-01 15:42:36 +00:00
Nathan Sidwell
b414b63eec module.cc (depset::hash::find_dependencies): Reach unreached specializations.
gcc/cp/
	* module.cc (depset::hash::find_dependencies): Reach unreached
	specializations.

From-SVN: r277710
2019-11-01 15:04:03 +00:00
Nathan Sidwell
a02fbe1f76 module.cc (module_state::read_cluster): Hack around cfun.
gcc/cp/
	* module.cc (module_state::read_cluster): Hack around cfun.

From-SVN: r277665
2019-10-31 11:23:38 +00:00
Nathan Sidwell
6a7526f276 module.cc (trees_out): Clean up dead code, update instrumentation.
gcc/cp/
	* module.cc (trees_out): Clean up dead code, update instrumentation.
	(class_members): New global.
	(depset::hash::add_writables): Rename to ...
	(depset::hash::add_namespace_entities): ... this.
	(depset::hash::add_class_entities): New, incomplete.
	(module_state::write): Add class entities.
	(set_instantiating_module): Record on the class_member list if
	necessary.

From-SVN: r277574
2019-10-29 14:52:55 +00:00
Nathan Sidwell
704e330d9c module.cc (trees_out::core_vals): Audit VAR_DECL, removing fixme.
gcc/cp/
	* module.cc (trees_out::core_vals): Audit VAR_DECL, removing fixme.

From-SVN: r277570
2019-10-29 13:31:15 +00:00
Nathan Sidwell
6662f7e1b4 module.cc (trees_{in,out}::core_vals): Stream more block fields.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream more block fields.

From-SVN: r277538
2019-10-28 19:33:57 +00:00
Nathan Sidwell
eda238fc4b module.cc (trees_{in,out}::core_vals): Stream template info's typedefs needing access checks.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream template info's
	typedefs needing access checks.

From-SVN: r277536
2019-10-28 19:17:10 +00:00
Nathan Sidwell
e5900036fe module.cc (depset): Correct documentation.
gcc/cp/
	* module.cc (depset): Correct documentation.
	(walk_kind_name): Delete unused.
	(trees_out::get_container): Lookup for redirect.

From-SVN: r277532
2019-10-28 19:01:51 +00:00
Nathan Sidwell
07572f3cdf module.cc (node_template_info): Type cannot be NULL.
gcc/cp/
	* module.cc (node_template_info): Type cannot be NULL.

From-SVN: r277529
2019-10-28 17:06:09 +00:00
Nathan Sidwell
b102dc42c7 module.cc (trees_out::{fn_parms_ini,tpl_header}): Privatize, resolving fixme.
gcc/cp/
	* module.cc (trees_out::{fn_parms_ini,tpl_header}): Privatize,
	resolving fixme.
	(trees_out::core_vals): Resolve TEMPLATE_DECL &
	TEMPLATE_PARM_INDEX fixmes.
	(trees_out::tpl_parm_value): Resolve template template parm fixme.

From-SVN: r277522
2019-10-28 14:29:07 +00:00
Nathan Sidwell
9f9a88de54 Merge trunk r277514.
From-SVN: r277519
2019-10-28 14:06:26 +00:00
Nathan Sidwell
184cb6c77b module.cc (trees_out::type_node): Move typdef printing after variant printing.
gcc/cp/
	* module.cc (trees_out::type_node): Move typdef printing after
	variant printing.
	(trees_in::tree_node): Simplity tt_typedef_type.

From-SVN: r277460
2019-10-25 17:14:36 +00:00
Nathan Sidwell
2db7663f58 module.cc (trees_out::core_vals): Check if template parm has a canonical type before processing it.
gcc/cp/
	* module.cc (trees_out::core_vals): Check if template parm has a
	canonical type before processing it.
	(trees_in::tpl_parm_value): Likewise.

From-SVN: r277457
2019-10-25 16:44:44 +00:00
Nathan Sidwell
71605a44ef module.cc (enum tree_tag): Delete tt_typename_decl.
gcc/cp/
	* module.cc (enum tree_tag): Delete tt_typename_decl.
	(trees_out::decl_node): Do not handle TYPENAME_TYPE here ...
	(trees_out::type_node): ... handle them here instead.
	(trees_in::tree_node): Delete tt_typename_decl, handle
	TYPENAME_TYPE as a derived_type.

From-SVN: r277456
2019-10-25 15:35:18 +00:00
Nathan Sidwell
4cfb372295 module.cc (trees_out::decl_node): Fixup anonymous case.
gcc/cp/
	* module.cc (trees_out::decl_node): Fixup anonymous case.

From-SVN: r277447
2019-10-25 12:52:37 +00:00
Nathan Sidwell
e0208fe787 Remove mergeable sorting code.
gcc/cp/
	* module.cc (depset::hash): Delete for_mergeable,
	is_for_mergeable.
	(depset::hash::add_mergeable{,_horcrux}): Delete.
	(trees_out::get_merge_kind): Remove for_mergeable indirection.
	(trees_out::key_mergeable): Likewise.
	(depset::hash::add_dependency): Remove mergeable handling.
	(depset::hash::find_dependencies): Likewise.  Remove #if'd out code.
	(sort_mergeables): Delete.
	(module_state::write_cluster): Remove #if'd out code.

From-SVN: r277444
2019-10-25 12:01:54 +00:00
Nathan Sidwell
717b4e3302 Turn off mergeable ordering.
gcc/cp/
	* module.cc (depset::hash::find_dependencies): No need to add
	specialization keys here.
	(module_state::erite_cluster): Or sort mergeables here.
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_b.C: Adjust scans.
	* g++.dg/modules/inst-[23]_a.C: Likewise.
	* g++.dg/modules/late-ret-[23_a.H: Likewise.
	* g++.dg/modules/tpl-friend-1_a.C: Likewise.

From-SVN: r277429
2019-10-24 23:16:49 +00:00
Nathan Sidwell
19a4d5d48c Types always keyed by TYPE_NAME. Use TYPE_NAME not TYPE_STUB_DECL.
gcc/cp/
	* module.cc (enum merge_kind): Drop MK_linkage.
	(trees_out::core_vals): Fix DECL_TEMPLATE_PARM_P thinko.
	TYPE_DECLS for linkage are not regular typedefs.
	(trees_{in,out}::add_indirects): Always add a TYPE_DECL's type.
	(trees_{in,out}::decl_value): Write the stub_decl if it's
	different.
	(trees_out::{type,decl}_node): Cleanup some type_decl handling.
	(trees_out::get_merge_kind): Drop MK_linkage.
	(trees_{in,out}::key_mergeable): Likewise.
	(trees_out::{has,write,mark}_definition): Adjust.
	(trees_in::read_definition): Likewise.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust scans.
	* g++.dg/modules/tdef-6_b..C: Adjust scans.

From-SVN: r277428
2019-10-24 23:10:23 +00:00
Nathan Sidwell
fa0ef83417 module.cc (trees_{in,out}::tpl_parm_value): No need to stream bound ttp's TI here.
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parm_value): No need to stream
	bound ttp's TI here.
	(trees_out::get_merge_kind): Refactor anon type determination.

From-SVN: r277423
2019-10-24 20:12:38 +00:00
Nathan Sidwell
3bcf4c0d06 Merge trunk r277416.
From-SVN: r277418
2019-10-24 17:20:12 +00:00
Nathan Sidwell
79d79839f5 module.cc (enum ct_decl_flags): Add cdf_is_defn.
gcc/cp/
	* module.cc (enum ct_decl_flags): Add cdf_is_defn.
	(module_state::{read,write}_cluster): Don't stream definitions
	separately.

From-SVN: r277357
2019-10-23 23:06:43 +00:00
Nathan Sidwell
9c3b02b7b5 module.cc (get_clone_target): Assert more.
gcc/cp/
	* module.cc (get_clone_target): Assert more.
	(trees_in::back_ref): Check the tree's not insane.
	(trees_in::tree_node): Check the clone target is ok.
	(module_state::lazy_load): Inhibit GC.

From-SVN: r277356
2019-10-23 22:56:28 +00:00
Nathan Sidwell
6e64034884 dumpfile.c (dump_begin): Move decls for RAII.
gcc/
	* dumpfile.c (dump_begin): Move decls for RAII.

From-SVN: r277355
2019-10-23 22:16:48 +00:00
Nathan Sidwell
a59bd8ad23 module.cc (trees_{in,out}::tpl_parm_value): Don't stream tpi here.
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parm_value): Don't stream tpi
	here.
	(trees_{in,out}::tree_value): Strip now-unreachable code.

From-SVN: r277350
2019-10-23 20:31:04 +00:00
Nathan Sidwell
0d7974add8 module.cc (enum tree_tag): Add tt_tpl_parm.
gcc/cp/
	* module.cc (enum tree_tag): Add tt_tpl_parm.
	(trees_{in,out}::tpl_parm_value): New.
	(trees_out::add_indirect_tpl_parms): Simpilfy.
	(trees_out::tree_value): No template parms here.
	(trees_{in,out}::tree_node): Deal with call tpl_parm_value.

From-SVN: r277334
2019-10-23 16:03:19 +00:00
Nathan Sidwell
9f93a298de pt.c (reduce_template_parm_level): Attach TPI to the type or decl.
gcc/cp/
	* pt.c (reduce_template_parm_level): Attach TPI to the type or
	decl.
	(convert_generic_types_to_packs): Pass new type to
	reduce_template_parm_level.

From-SVN: r277332
2019-10-23 14:37:25 +00:00
Nathan Sidwell
58b85e2635 module.cc (trees_{in,out}::tpl_parms{,_fini}): Drop outer parms, add tpl_levels.
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms{,_fini}): Drop outer parms,
	add tpl_levels.
	(trees_{in,out}::tpl_header): Likewise.
	(trees_{in,out}::add_indirect_tpl_parms): New.
	(trees_{in,out}::add_indirects): Call them.
	(trees_{in,out}:decl_value): Adjust tpl_header streaming.
	(trees_{in,out}:tree_value): Adjust tpl_header streaming.
	(depset::hadh::find_dependencies): Likewise.
	(module_name): Don't look for current TU's parent.

From-SVN: r277272
2019-10-21 23:03:47 +00:00
Nathan Sidwell
1f48f66ae7 module.cc (trees_in::back_ref): New, broken out of ...
gcc/cp/
	* module.cc (trees_in::back_ref): New, broken out of ...
	(trees_in::tree_node): ... here.  Call it multiple times.

From-SVN: r277269
2019-10-21 19:48:53 +00:00
Nathan Sidwell
10349ff9c5 module.cc (trees_{in,out}::add_indirects): New, broken out of ...
gcc/cp/
	* module.cc (trees_{in,out}::add_indirects): New, broken out of ...
	(trees_out::decl_node, trees_in::tree_node): ... here.  Call them.
	(module_state::{read,write}_cluster): Call them instead of
	duplicate code.
	gcc/testsuite/
	* g++.dg/modules/by-name-1.C: Adjust scans.
	* g++.dg/modules/class-3_[bd].C: Likewise.
	* g++.dg/modules/vmort-2_c.C: Likewise.

From-SVN: r277265
2019-10-21 18:37:50 +00:00
Nathan Sidwell
1fff3965bf module.cc (trees_{in,out}::key_mergeable): Do not stream tpl header of fn parms here.
gcc/cp/
	* module.cc (trees_{in,out}::key_mergeable): Do not stream tpl
	header of fn parms here.
	(tree_{in,out}::decl_value): Stream them here ...
	(depset:hash::find_dependencies): ... and here.

From-SVN: r277263
2019-10-21 17:32:41 +00:00
Nathan Sidwell
f70dedf201 Merge trunk r277167.
From-SVN: r277195
2019-10-18 22:54:09 +00:00
Nathan Sidwell
57a2657977 module.cc (trees_out::decl_value): Excise template_parm handling.
gcc/cp/
	* module.cc (trees_out::decl_value): Excise template_parm
	handling.
	(trees_{in,out}::tree_value): Excise non-template-parm
	tmpl/type/fn/var handling here.

From-SVN: r277163
2019-10-18 18:58:31 +00:00
Nathan Sidwell
b106a456b5 module.cc (dumper::impl::nested_name): Check template_parm_p directly.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Check template_parm_p
	directly.
	(trees_out::core_vals): Check DECL_TEMPLATE_PARM_P.
	(trees_out::decl_value): Never get a DECL_TEMPLATE_PARM_P.
	(trees_in::decl_value): Likewise.
	(trees_out::decl_node): Send DECL_TEMPLATE_PARM_P to tree_value.
	(trees_out::type_node): Simplify name detection.
	(trees_out::tree_value): Allow DECL_TEMPLATE_PARM_P, but no other
	tmpls/type/var/fns.
	* tree.c (bind_template_template_parm): Set DECL_TEMPLATE_PARM_P.

From-SVN: r277162
2019-10-18 18:28:57 +00:00
Nathan Sidwell
2e3baac43a module.cc (dumper::impl::nested_name): Detect template parms.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Detect template parms.
	(trees_{in,out}::core_vals): Don't write context of template
	parms.  Don't clobber template's type.

From-SVN: r277159
2019-10-18 17:50:48 +00:00
Nathan Sidwell
4a8bb127b1 module.cc (trees_{in,out}::start): Stream code if permitted.
gcc/cp/
	* module.cc (trees_{in,out}::start): Stream code if permitted.
	Adjust callers.

From-SVN: r277152
2019-10-18 11:52:44 +00:00
Nathan Sidwell
ea031678c8 module.cc (trees_out::tpl_parms): Assert a lot.
gcc/cp/
	* module.cc (trees_out::tpl_parms): Assert a lot.
	(depset::hash::find_dependencies, module_state::write_cluster):
	Mark mergeable sort-specific points.

From-SVN: r277127
2019-10-17 17:44:13 +00:00
Nathan Sidwell
df2384f4e3 module.cc (trees_out::decl_value): Stream thunks too.
gcc/cp/
	* module.cc (trees_out::decl_value): Stream thunks too.
	(trees_out::decl_node): Forward all potentially mergeable decls to
	decl_value.
	(trees_out::tree_value): Make sure we don't get any potentially
	mergeable decls.
	(trees_{in,out}::tree_value): Stream template parms
	via tpl_parms.
	(trees_{in,out}::tpl_parms): The vector can be 0 length.
	(trees_out::mark_declaration): Don't mark the template parms.

From-SVN: r277116
2019-10-17 15:18:15 +00:00
Nathan Sidwell
0f10a98c56 module.cc (trees_{in,out}::tpl_parms): Cope with non-shared parms.
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms): Cope with non-shared
	parms.
	(trees_{in,out}::tpl_parms_fini): Likewise, stream vec type.

From-SVN: r277109
2019-10-17 12:45:32 +00:00
Nathan Sidwell
d4a3870c8e cp-objcp-common.c (cp_pushdecl): Set DECL_CONTEXT.
gcc/cp/
	* cp-objcp-common.c (cp_pushdecl): Set DECL_CONTEXT.
	gcc/testsuite/
	* g++.dg/modules/builtin-3_[ab].C: New.

From-SVN: r277106
2019-10-17 12:38:33 +00:00
Nathan Sidwell
badc690dab module.cc (trees_{in,out}::decl_value): Refactor some ifs.
gcc/cp/
	* module.cc (trees_{in,out}::decl_value): Refactor some ifs.

From-SVN: r277104
2019-10-17 12:10:55 +00:00
Nathan Sidwell
5db4ba4a1f decl.c (cp_make_fname_decl): Set context to global namespace, outside functions.
gcc/cp/
	* decl.c (cp_make_fname_decl): Set context to global namespace,
	outside functions.
	(builtin_function_1): Merge into ...
	(cxx_builtin_function): ... here.  Nadger the decl before maybe
	copying it.  Set the context.
	(cxx_builtin_function_ext_scope): Push to top level, then call
	cxx_builtin_function.

From-SVN: r277081
2019-10-16 20:54:02 +00:00
Nathan Sidwell
5f44c9577d rtti.c (get_tinfo_desc): Set DECL_CONTEXT.
gcc/cp/
	* rtti.c (get_tinfo_desc): Set DECL_CONTEXT.
	gcc/testsuite/
	* g++.dg/modules/tinfo-1.C: New.

From-SVN: r277074
2019-10-16 16:58:42 +00:00
Nathan Sidwell
fab636d209 module.cc (enum tree_tag): Add tt_parm.
gcc/cp/
	* module.cc (enum tree_tag): Add tt_parm.
	(trees_out::decl_node): Emit tt_parm for parms.
	(trees_in::tree_node): Add tt_parm.
	(trees_out::write_function_def): Simply tag constexpr parms &
	result.
	(trees_in::read_function_def): Clone the originating fn's parms &
	result.
	(module_state::read): Add GC points, when lazy.

From-SVN: r277069
2019-10-16 14:34:17 +00:00
Nathan Sidwell
ce0bab834c module.cc (trees_out::core_vals): Don't assert template arguments visited.
gcc/cp/
	* module.cc (trees_out::core_vals): Don't assert template
	arguments visited.
	(trees_{in,out}::tpl_parms): Stream TMPL_DEPTH.
	(trees_{in,out}::tpl_parms_fini): New.
	(trees_{in,out}::decl_value): Don't stream template parms, use
	tpl_parms_fini.

From-SVN: r277006
2019-10-15 18:33:01 +00:00
Nathan Sidwell
d3d2f001d5 module.cc (trees_out::get_container): New, broken out of ...
gcc/cp/
	* module.cc (trees_out::get_container): New, broken out of ...
	(trees_out::key_mergeable): ... here.  Add container parm.
	(trees_in::key_mergeable): Container is already set.
	(trees_{in,out}::decl_value): Stream container here.
	(dpset::hash::find_dependencies): Adjust mergeable walk.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_a.C: Adjust scan.

From-SVN: r277004
2019-10-15 17:07:00 +00:00
Nathan Sidwell
45916f8c3d Merge trunk r277002.
From-SVN: r277003
2019-10-15 15:22:25 +00:00
Nathan Sidwell
5a9248dc06 Revert TYPE_LAMBDA_P, it's unnecessary churn.
gcc/cp/
	* cp-tree.h (LAMBDA_TYPE_P): Subsume TYPE_LAMBDA_P.
	(TYPE_LAMBDA_P): Delete.  Update all uses.

From-SVN: r277002
2019-10-15 14:57:08 +00:00
Nathan Sidwell
ef5c7fa2b1 module.cc (merge_kind): Add MK_local_friend.
gcc/cp/
	* module.cc (merge_kind): Add MK_local_friend.
	(trees_{in,out}::tpl_parms): New.
	(trees_{in,out}::tpl_header): Adjust parm streaming
	(trees_{in,out}::key_mergeable): Find containing template.

From-SVN: r277001
2019-10-15 14:33:14 +00:00
Nathan Sidwell
43e296f851 Merge trunk r276888.
Pull in c++20 concepts.

From-SVN: r276893
2019-10-11 16:08:42 +00:00
Nathan Sidwell
2b0ffa5977 module.cc (trees_{in,out}::core_vals): Don't stream function parms here.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Don't stream function
	parms here.
	(trees_out::decl_value): Stream has_defn.
	(trees_in::decl_value): Stream has_defn, adjust fn_parms_fini.
	(trees_in::tree_value): Likewise.
	(trees_{in,out}::fn_parms_init): Stream entire parms.
	(trees::fn_parms_fini): Do nothing.
	(trees_in::fn_parms_fini): Add has_defn, adjust.

From-SVN: r276884
2019-10-11 13:39:44 +00:00
Nathan Sidwell
583a504bda module.cc (enum walk_kind): Remove WK_merge.
gcc/cp/
	* module.cc (enum walk_kind): Remove WK_merge.
	(enum trees_out::tags): Remove tag_merging.
	(trees_out::mark_merged): Delete.
	(trees_out::{insert,ref_node}): Adjust.
	(trees_out::decl_value): Insert by value immediately.

From-SVN: r276883
2019-10-11 13:31:12 +00:00
Nathan Sidwell
e19d9e72d5 optimize.c (maybe_clone_body): Allow aliasing with modules.
gcc/cp/
	* optimize.c (maybe_clone_body): Allow aliasing with modules.

From-SVN: r276881
2019-10-11 12:58:12 +00:00
Nathan Sidwell
a514ff7dcf module.cc (enum depset::entity_kind): Remove EK_CLONE.
gcc/cp/
	* module.cc (enum depset::entity_kind): Remove EK_CLONE.
	(depset::add_clone): Delete.
	(enum merge_kind): Remove MK_clone.
	(depset::entity_kind_name): Adjust.
	(trees_in::decl_value): No merging for clones.
	(trees_out::decl_node): Remove clone dependency.
	(trees_out::get_merge_kind): No clone merging.
	(trees_{in,out}::key_mergeable): Likewise.
	(module_state::write_cluster): Never see a clone.

From-SVN: r276880
2019-10-11 12:51:22 +00:00
Nathan Sidwell
86839701cb Reconstruct clones on stream in
Reconstruct clones on stream in
	gcc/cp/
	* module.cc (trees_out::{decl,tree}_value): Write clone info.
	(trees_in::{decl,tree}_value): Reconstruct clone.
	(trees_out::decl_node): Do not depend on clones.
	(module_state::read_cluster): Clone bodies.

From-SVN: r276879
2019-10-11 12:43:11 +00:00
Nathan Sidwell
f8e1cbb894 cp-tree.h (DECL_NEEDS_VTT_PARM_P): Delete.
gcc/cp/
	* cp-tree.h (DECL_NEEDS_VTT_PARM_P): Delete.
	(build_clones): Declare.
	(ctor_omit_inherited_parms): Add exact_name default parm.
	* class.c (build_clone): Add need_vtt & omit_inherited parms, do
	not calculate here.
	(build_clones): New function.  Add need_vtt &
	omit_inherited_parms.  Broken out of ...
	(clone_function_decl): Call build_clones.  Add to method vec here.
	* method.c (ctor_omit_inherited_parms): Add exact_name parm.
	Detect any ctor or specific base ctor as specified.

From-SVN: r276852
2019-10-10 20:38:32 +00:00
Nathan Sidwell
3c68293dda class.c (maybe_add_class_template_decl_list): Don't check template-id-expr friends.
gcc/cp/
	* class.c (maybe_add_class_template_decl_list): Don't check
	template-id-expr friends.
	* module.cc (friend_from_decl_list): Don't stray into primary
	templates.
	(trees_out::{write,mark}_class_def): Adjust local friend
	detection.
	(trees_in::read_class_def): Likewise.

From-SVN: r276775
2019-10-09 21:46:21 +00:00
Nathan Sidwell
0344a960c5 cp-tree.h (DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P): New.
gcc/cp/
	* cp-tree.h (DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P): New.
	* module.cc (trees_{in,out}::core_vals): Stream local template
	friend's DECL_CHAIN.
	(trees_out::decl_node): Use DECL_UNINSTANITATED_TEMPLATE_FRIEND_P.
	(trees_out::{read,write,mark}_class_def): Adjust local template
	friend streaming.
	* pt.c (push_template_decl_real): Set
	DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P.
	(tsubst_friend_function): Clear D_U_T_F_P.

From-SVN: r276769
2019-10-09 19:25:17 +00:00
Nathan Sidwell
36f99a3dba pt.c (push_template_decl_real): Always set DECL_CHAIN for non-pushed friends.
gcc/cp/
	* pt.c (push_template_decl_real): Always set DECL_CHAIN for
	non-pushed friends.

From-SVN: r276761
2019-10-09 15:03:04 +00:00
Nathan Sidwell
18eec4a374 module.cc (trees_out::decl_value): Check streaming before dump.
gcc/cp/
	* module.cc (trees_out::decl_value): Check streaming before dump.
	(module_name): Protect from not modules.

From-SVN: r276710
2019-10-08 19:36:18 +00:00
Nathan Sidwell
4366ec4e28 module.cc (enum merge_kind): Rename non->unique.
gcc/cp/
	* module.cc (enum merge_kind): Rename non->unique.
	(trees_out::key_mergeable): Add decl parm.  Return MK_unique for
	non-dep decls.
	(trees_{out,out}::decl_value): Adjust.

From-SVN: r276704
2019-10-08 15:43:40 +00:00
Nathan Sidwell
46ce8ce6a7 module.cc (struct nodel_decl_hash): New.
gcc/cp/
	* module.cc (struct nodel_decl_hash): New.
	(duplicate_hash_map): New.
	(trees_in::duplicates): New.
	(trees_in::mergeables): Delete.
	(trees_in::{,~}trees_in): Adjust.
	(trees_in::{find,register,unmatched}_duplicate): New.
	(trees_in::{reserve,register,unmcted}_mergeable): Delete.
	(enum trees_in::dupness): Delete DUP_unique.
	(trees_in::decl_value): Adjust duplicate registration.
	(trees_in::get_dupness): Adjust.
	(module_state::{read,write}_cluster): Don't stream mergeable count.

From-SVN: r276701
2019-10-08 14:01:00 +00:00
Nathan Sidwell
0dc19040b2 module.cc (enum walk_kind): Rename body->value, mergeable->merge.
gcc/cp/
	* module.cc (enum walk_kind): Rename body->value,
	mergeable->merge.  Delete clone, merging.
	(trees_in::decl_value): Drop walk_kind parm, read merge kind
	early.
	(trees_in::key_mergeable): Add merge_kind parm, return bool.
	(trees_out::mark_node): Rename to ...
	(trees_out::mark_by_value): ... here.
	(trees_out::get_merge_kind): New, broken out of ...
	(trees_out::key_mergeable): ... here.  Add merge_kind parm.
	(trees_out::decl_value): Replace walk_kind parm with depset.
	Adjust.
	gcc/testsuite/
	* g++.dg/modules/scc-1.C: Adjust scan.
	* g++.dg/modules/builtin-1_a.C: Adjust scan.

From-SVN: r276697
2019-10-08 12:10:23 +00:00
Nathan Sidwell
b9db16d83a module.cc (enum trees_out::tags): Delete tag_mergeable, tag_cloned.
gcc/cp/
	* module.cc (enum trees_out::tags): Delete tag_mergeable,
	tag_cloned.
	(trees_out::mark_mergeable): Delete.
	(trees_out::{insert,ref_node}): Adjust.
	(trees_out::decl_node): Look at depset to determine mergeability.
	(trees_out::key_mergeable): Adjust.
	(trees_in::register_mergeable): Always reserve space.
	(module_state::write_cluster): Don't mark mergeable here.

From-SVN: r276677
2019-10-07 20:32:37 +00:00
Nathan Sidwell
a73cf07789 module.cc (trees_in::get_odrness): Check if overrun.
gcc/cp/
	* module.cc (trees_in::get_odrness): Check if overrun.
	(trees_in::read_class_def): Add overrun protection.
	* name-lookup.c (name_search::search_adl): Tweak.

From-SVN: r276676
2019-10-07 20:29:25 +00:00
Nathan Sidwell
2c6e1dc2f4 module.cc (trees_{in,out}::core_vals): Stream decl_non_common.result for using decls.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream
	decl_non_common.result for using decls.
	(trees_out::decl_node): USING_DECLS are done by value.
	* name-lookup.c (finish_nonmember_using_decl): Set DECL_CONTEXT.
	gcc/testsuite/
	* g++.dg/modules/using-6_[ab].C: New.

From-SVN: r276666
2019-10-07 16:46:17 +00:00
Nathan Sidwell
eb9ca9da08 module.cc (enum tree_tag): Add tt_decl.
gcc/cp/
	* module.cc (enum tree_tag): Add tt_decl.
	(trees_{in,out}::decl_value): Broken out of ...
	(trees_{in,out}::tree_value): ... here.  Deal with non mergeble
	cases only.
	(trees_in::tree_node): Add tt_decl.
	(trees_out::decl_node): Call decl_value.

From-SVN: r276662
2019-10-07 15:39:08 +00:00
Nathan Sidwell
6341b0dee7 module.cc (trees_out::decl_node): Refactor some instantiation discovery.
gcc/cp/
	* module.cc (trees_out::decl_node): Refactor some instantiation
	discovery.

From-SVN: r276656
2019-10-07 14:03:26 +00:00
Nathan Sidwell
2d2d01f0a3 Merge trunk r276597.
From-SVN: r276598
2019-10-04 19:42:21 +00:00
Nathan Sidwell
c67eeaf6a9 module.c (trees_out:decl_node): More switchification and code movement.
gcc/cp/
	* module.c (trees_out:decl_node): More switchification and code
	movement.

From-SVN: r276586
2019-10-04 15:14:06 +00:00
Nathan Sidwell
939f96284d module.c (trees_out:decl_node): Switchify, and move some checks before template detection.
gcc/cp/
	* module.c (trees_out:decl_node): Switchify, and move some checks
	before template detection.

From-SVN: r276583
2019-10-04 14:57:00 +00:00
Nathan Sidwell
e7deb02d93 module.cc (trees_in::tree_value): Rework merge_kind switching.
gcc/cp/
	* module.cc (trees_in::tree_value): Rework merge_kind switching.
	(trees_{in,out}::key_mergeable): Likewise.

From-SVN: r276578
2019-10-04 13:48:44 +00:00
Nathan Sidwell
c50b814d3c module.cc (enum merge_kind): Reorder.
gcc/cp/
	* module.cc (enum merge_kind): Reorder.

From-SVN: r276573
2019-10-04 12:10:09 +00:00
Nathan Sidwell
823e32ee93 module.cc (trees_out::decl_node): Merge and reorder tinfo streaming.
gcc/cp/
	* module.cc (trees_out::decl_node): Merge and reorder tinfo
	streaming.
	(trees_in::tree_node): Merge tinfo streaming.

From-SVN: r276526
2019-10-03 19:39:07 +00:00
Nathan Sidwell
ba8625fcae module.cc (depset::hash::add_dependency): Separate EK_REDIRECT handling from EK_MAYBE_SPEC.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Separate EK_REDIRECT
	handling from EK_MAYBE_SPEC.
	(get_instantiating_module_decl): Reorder checks, remove fixme.

From-SVN: r276521
2019-10-03 18:49:05 +00:00
Nathan Sidwell
64ef524f15 Add module-cmi
From-SVN: r276520
2019-10-03 18:02:52 +00:00
Nathan Sidwell
f87cba67f6 module.cc (trees_out::decl_node): Check DECL_LANG_SPECIFIC.
gcc/cp/
	* module.cc (trees_out::decl_node): Check DECL_LANG_SPECIFIC.
	(depset::hash::add_dependency): Likewise.
	(get_originating_module_decl): Return global_namespace for null.
	(get_originating_module): Correctly handle lack of
	DECL_LANG_SPECIFIC.
	(set_instantiating_module): Lazily allocate lang specific.
	(set_originating_module): Call set_instantiating_module.
	* pt.c (build_template_decl, tsubst_template_decl): Check
	DECL_LANG_SPECIFIC.
	* rtti.c (tinfo_base_init): Likewise.

From-SVN: r276517
2019-10-03 15:59:30 +00:00
Nathan Sidwell
3ce26bd9fc module.cc (elf_in::{defrost,begin}): Advise random seeking.
gcc/cp/
	* module.cc (elf_in::{defrost,begin}): Advise random seeking.

From-SVN: r276514
2019-10-03 14:17:58 +00:00
Nathan Sidwell
6bf2331123 module.cc (depset::hash::add_dependency): Drop is_import arg, update callers.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Drop is_import arg,
	update callers.  Calculate it here.

From-SVN: r276513
2019-10-03 14:07:35 +00:00
Nathan Sidwell
ae01adcd0c cp-tree.h (MODULE_SLOT_*): Move to ...
gcc/cp/
	* cp-tree.h (MODULE_SLOT_*): Move to ...
	* name-lookup.c (MODULE_SLOT_*): ... here.
	* module.cc (depset::hash::add_dependency): More asserts.
	* pt.c (build_template_decl, tsubst_template_decl): Always
	propagate from result.

From-SVN: r276509
2019-10-03 13:19:06 +00:00
Nathan Sidwell
1b28e44fd3 module.cc (trees_out::tree_ctx): Delete, forward all callers to tree_node.
gcc/cp/
	* module.cc (trees_out::tree_ctx): Delete, forward all callers to
	tree_node.
	(trees_out::tree_namespace): Delete, move into tree_decl.
	(trees_out::tree_decl): Rename to ...
	(trees_out::decl_node): ... this.  Update caller.

From-SVN: r276485
2019-10-02 19:48:19 +00:00
Nathan Sidwell
93fa40b795 module.cc (trees_out::tree_type): Rename to ...
gcc/cp/
	* module.cc (trees_out::tree_type): Rename to ...
	(trees_out::type_node): Drop walk_kind arg, return void.  Update
	callers.

From-SVN: r276483
2019-10-02 19:23:56 +00:00
Nathan Sidwell
a10daf43d5 module.cc (trees_out::tree_ctx): Drop need_contents parm.
gcc/cp/
	* module.cc (trees_out::tree_ctx): Drop need_contents parm.
	Update callers.
	(trees_out::tree_{type,decl}: Likewise.

From-SVN: r276478
2019-10-02 18:41:58 +00:00
Nathan Sidwell
8322a462ef module.cc (trees_out::tree_ctx): Drop inner_decl parm.
gcc/cp/
	* module.cc (trees_out::tree_ctx): Drop inner_decl parm.  Update
	callers.
	(trees_out::tree_namespace): Likewise.

From-SVN: r276477
2019-10-02 18:27:37 +00:00
Nathan Sidwell
d1f9e86750 cp-tree.h (MK_*): Document better.
gcc/cp/
	* cp-tree.h (MK_*): Document better.

From-SVN: r276476
2019-10-02 17:48:30 +00:00
Nathan Sidwell
bf32d83a4b cp-tree.h (MODULE_CURRENT, [...]): Delete.
gcc/cp/
	* cp-tree.h (MODULE_CURRENT, MODULE_IMPORT_BASE): Delete.
	* module.cc: Replace with zero/one
	* name-lookup.c: Likewise.
	* decl2.c (no_linkage_error): Likewise.
	* ptree.c (cxx_print_decl): Likewise.

From-SVN: r276475
2019-10-02 17:36:38 +00:00
Nathan Sidwell
fdda1214b5 Don't equivocate GMF with module
Don't equivocate GMF with module
	gcc/cp/
	* cp-tree.h (MODULE_NONE, MODULE_PURVIEW): Delete.
	(MODULE_CURRENT): New.
	(MODULE_IMPORT_BASE): Reduce.
	(DECL_MODULE_OWNER): Rename to ...
	(DECL_MODULE_ORIGIN): ... this.
	(DECL_MODULE_PURVIEW_P): New.
	(MODULE_BITS): Reduce.
	(lang_decl_base::module_purview_p): New bit.
	(module_may_redeclare): Take decl.
	* module.cc (MODULE_UNKNOWN_PARTITION): New.
	(MODULE_LIMIT): Adjust.
	(slurping::remap_module): Return int.
	(trees_in::assert_definition): Adjust.
	(dumper::impl::nested_name): Adjust.
	(trees_{in,out}::lang_decl_bits): Stream module_purview_p.
	(trees_out::tree_{namespace,decl,value}): Adjust.
	(trees_in::tree_node): Adjust.
	(depset::hash::add_{dependency,binding,specializations}): Adjust.
	(module_state::check_not_purview): Adjust.
	(module_state::read_{imports,partitions}): Adjust.
	(module_state::write_{cluster,namespaces,unnamed}): Adjust.
	(module_state::read_unnamed): Adjust.
	(module_state::{write,read}): Adjust.
	(module_visible_instantiation_path): Adjust.
	(get_originating_module): Return int.
	(get_instantiating_module): Adjust.
	(module_may_redeclare): Reimplement.
	(set_{instantating,originating}_module): Adjust.
	(module_state::{do,direct}_import): Adjust.
	(declare_module, module_preprocess, process_deferred_imports): Adjust.
	({init,finish}_module_processing): Adjust.
	* name-lookup.c (get_fixed_binding_slot): Adjust.
	(name_lookup::{search_namespace_only,adl_namespace_fns,search_adl):
	Adjust.
	(check_module_override, extract_module_binding): Adjust.
	(note_pending_specializations): Adjust.
	(get_imported_namespaxe, finish_nonmember_using_decl)
	(lookup_type_scope_1): Adjust.
	(add_imported_namespace): Take int.
	* name-lookup.h ({add,get}_imported_namespace): Module is int.
	* class.c (build_self_ref): Set instantiating module.
	* decl.c (duplicate_decls): Adjust.
	* decl2.c (no_linkage_error): Adjust.
	* mangle.c (maybe_write_module): Adjust.
	* pt.c (build_template_decl): Propagate purview flag.
	(tsubst_template_decl): Likewise.
	(tsubst_decl): Set instantiating_module as necessary.
	* ptree.c (cxx_print_decl): Adjust, print purview flag.
	* rtti.c (tinfo_base_init): Clear purview flag.
	gcc/testsuite/
	* g++.dg/modules/*: Update lang dump scans.

From-SVN: r276460
2019-10-02 13:50:10 +00:00
Nathan Sidwell
475d276318 cp-tree.h (set_originating_module): Add friend_p.
gcc/cp/
	* cp-tree.h (set_originating_module): Add friend_p.
	* decl.c (grokdeclarator): Set it.
	* module.cc (get_originating_module): Always look through template
	info.
	(set_originating_module): Add friend_p.  Assert.
	(set_instantiating_module): Assert.

From-SVN: r276400
2019-10-01 11:01:48 +00:00
Nathan Sidwell
2c7192ea60 cp-tree.h (set_module_owner): Delete.
gcc/cp/
	* cp-tree.h (set_module_owner): Delete.
	* decl.c (duplicate_decls): Propagate module owner.  Set module
	export for builtins, no need to set owner.
	* module.cc (set_module_owner): Delete.
	gcc/testsuite/
	* g++.dg/modules/isalnum.H: New.

From-SVN: r276342
2019-09-30 16:49:01 +00:00
Nathan Sidwell
3c978b7d31 Merge trunk r276201.
From-SVN: r276208
2019-09-27 20:11:10 +00:00
Nathan Sidwell
972da9df5d decl.c (fixup_anonymous_aggr): Partially revert recent change.
gcc/cp/
	* decl.c (fixup_anonymous_aggr): Partially revert recent change.
	(grokfndecl): Call set_originating_module before determining
	specialization.
	(grokdeclarator): Likewise.

From-SVN: r276201
2019-09-27 19:35:02 +00:00
Nathan Sidwell
b095634d58 cp-tree.h (set_{originating,instantiating}_module): Declare.
gcc/cp/
	* cp-tree.h (set_{originating,instantiating}_module): Declare.
	* class.c (layout_class_type): Use set_instantiating_module.
	* pt.c (lookup_template_class_1): Likewise.
	(tsubst_function_decl, instantiate_template_1): Likewise.
	(tsubst_friend): Not here.
	* decl.c (grokfndecl): Use set_originating_module.
	(grokvardecl,grokdeclarator): Likewise.
	* name-lookup.c (do_pushtag): Likewise.
	* friend.c (do_friend): Not here.
	* module.cc (set_implicit_module_origin): Rename to ...
	(set_instantiating_module): ... here.
	(set_originating_module): New.
	gcc/testsuite/
	* g++.dg/modules/friend-3.C: New.
	* g++.dg/modules/friend-4_[ab].C: New.

From-SVN: r276194
2019-09-27 18:33:59 +00:00
Nathan Sidwell
dd09a5c4da cp-tree.h (get_module_owner): Delete.
gcc/cp/
	* cp-tree.h (get_module_owner): Delete.
	(get_instantiating_module_decl, get_instantiating_module): Declare.
	* module.cc (get_instantiating_module_decl)
	(get_instantiating_module): New.
	(dumper::impl::nested_name, trees_out::tree_node)
	(trees_out::tree_decl, depset::hash::add_specializations)
	(set_module_owner): Use them.
	(get_module_owner): Delete.

From-SVN: r276182
2019-09-27 14:54:08 +00:00
Nathan Sidwell
3d48ab1aa4 cp-tree.h (get_declared_module_origin): Delete.
gcc/cp/
	* cp-tree.h (get_declared_module_origin): Delete.
	(get_originating_module, get_originating_module_decl): Declare.
	* module.cc (get_originating_module_decl): New.
	(get_originating_module): New.
	(module_state::write_cluster, module_visible_instantiation_path): Use
	get_originating_module.
	* module.cc (module_state::write_unnamed)
	(lazy_load_specializations): Use get_originating_module_decl.
	* error.c (dump_module_suffix): Use get_originating_module.
	* mangle.c (maybe_write_module): Likewise.
	* name-lookup.c (init_global_partition): Use
	get_originating_module.
	(name_lookup::search_adl): Use get_originating_module_decl.
	* pt.c (lookup_template_class_1): Propagate DECL_MODULE_EXPORT_P.

From-SVN: r276181
2019-09-27 13:28:57 +00:00
Nathan Sidwell
354f7e3bc3 cp-tree.h (DECL_MODULE_OWNER): Restrict to var/fn/type/template/namespace.
gcc/cp/
	* cp-tree.h (DECL_MODULE_OWNER): Restrict to
	var/fn/type/template/namespace.
	(MAYBE_DECL_MODULE_EXPORT_P): Delete.
	({set,get}_{declared,implicit}_module_origin): Declare.
	(module_name): Delete and adjust.
	* modules.cc: Adjust throughout for loss of
	MAYBE_DECL_MODULE_EXPORT_P.  Use get_module_owner more.
	(fixup_unscoped_enum_owner): Delete.
	* class.c (layout_class_type): Use set_implicit_module_origin.
	* decl.c (duplicate_decls): Use get_module_owner.
	(finish_enum_value_list): Set DECL_MODULE_EXPORT_P directly.
	* decl2.c (no_linkage_error): Use DECL_MODULE_OWNER.
	* error.c (dump_module_suffix): Reimplement.
	* mangle.c (maybe_write_module): Adjust.
	* name-lookup.c (init_global_partition): Adjust.
	(name_lookup::search_adl): Owner always has module.
	(do_pushdecl): Adjust namespace exporting.
	(do_nonmember_using_decl): Adjust exporting check.
	* pt.c (build_template_decl): Only propagate module info when
	needed.
	(lookup_template_class_1): Use set_implicit_module_origin.
	(tsubst_friend_function): Propagate to outer template.
	(tsubst_function_decl): Use set_implicit_module_origin.
	(tsubst_template_decl): Simplify tsubst if cascade.  Propagate
	inner module info.
	(instantiate_template_1): Use set_module_owner.
	* ptree.c (cxx_print_decl): Protect module info display.
	gcc/testsuite/
	* g++.dg/modules/friend-1_a.C: Adjust scans.
	* g++.dg/modules/indirect-[13]_[bc].C: Likewise.
	* g++.dg/modules/indirect-4_b.C: Likewise.
	* g++.dg/modules/late-ret-3_a.H: Likewise.
	* g++.dg/modules/scc-1.C: Likewise.
	* g++.dg/modules/vmort-2_[abc].C: Likewise.

From-SVN: r276160
2019-09-26 19:03:49 +00:00
Nathan Sidwell
2d168eaba0 modules.cc (enum merge_kind): Rearrange.
gcc/cp/
	* modules.cc (enum merge_kind): Rearrange.
	(merge_kind_name): Adjust.
	gcc/testsuite/
	* g++.dg/modules/inst_-[234]-[ab].C: Adjust scans.
	* g++.dg/modules/indirect-[234]_b.C: Likewise.

From-SVN: r276124
2019-09-25 13:39:04 +00:00
Nathan Sidwell
1a04d34b11 modules.cc (trees_out::tree_decl): RESULT and LABEL decls written by value.
gcc/cp/
	* modules.cc (trees_out::tree_decl): RESULT and LABEL decls
	written by value.  Assert only expected things remain by name.

From-SVN: r276104
2019-09-24 14:51:18 +00:00
Nathan Sidwell
84e064b5fc modules.cc (enum tree_tag): Add tt_data_member.
gcc/cp/
	* modules.cc (enum tree_tag): Add tt_data_member.
	(trees_out::tree_decl): Use it for consts and fields.
	(trees_in::tree_node): Read it.
	(set_implicit_module_owner): Delete.
	* name-lookup.c (get_field_ident, lookup_field_ident): New.
	* name-lookup.h (get_field_ident, lookup_field_ident): Declare.
	* cp-tree.h (set_implicit_module_owner): Delete.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust scans.
	* g++.dg/modules/indirect-1_c.C: Likewise.

From-SVN: r276101
2019-09-24 14:35:30 +00:00
Nathan Sidwell
5272490981 module.cc (depset): Add DB_BOTH_SPEC_BIT.
gcc/cp/
	* module.cc (depset): Add DB_BOTH_SPEC_BIT.
	(specialization_add): Accept template aliases for !decl_p.
	(depset::hash::add_specializations): Notice duplicate
	specialization paths.

From-SVN: r276066
2019-09-23 20:26:23 +00:00
Nathan Sidwell
9b0d788a82 decl.c (fixup_anonymous_aggr): Clear LAZY flags, no need to strip out fns.
gcc/cp/
	* decl.c (fixup_anonymous_aggr): Clear LAZY flags, no need to
	strip out fns.
	* module.cc (module_state::lazy_load): Distinguish out of order
	from failure to set slot.
	* name-lookup.c (get_binding_or_decl): Fixme :(
	gcc/testsuite/
	* g++.dg/modules/anon-2{,_[ab]}.[hHC]: New.

From-SVN: r276005
2019-09-20 20:14:44 +00:00
Nathan Sidwell
f03556d810 module.cc (enum merge_kind): Add MK_{decl,type}_tmpl_spec, MK_type_partual_spec.
gcc/cp/
	* module.cc (enum merge_kind): Add MK_{decl,type}_tmpl_spec,
	MK_type_partual_spec.
	(tree_in::tree_value): Process them.
	(trees_{in,out}::key_mergeable): Stream them.
	* pt.c (match_mergeable_specialization): Only store if spec !=
	NULL.
	gcc/testsuite/
	* g++.dg/modules/tpl-tpl-merge-[12]{,_[ab].[hHC]: New.

From-SVN: r275988
2019-09-20 02:27:00 +00:00
Nathan Sidwell
404a7ac2e8 module.cc (slurping::slurping): Init current to mostpos - 1.
gcc/cp/
	* module.cc (slurping::slurping): Init current to mostpos - 1.
	(module_state::read): Increment slurp->current when done.

From-SVN: r275987
2019-09-20 00:33:42 +00:00
Nathan Sidwell
471a100c56 module.cc (trees_in::tree_node): Check overrun more.
gcc/cp/
	* module.cc (trees_in::tree_node): Check overrun more.

From-SVN: r275980
2019-09-19 19:58:14 +00:00
Nathan Sidwell
d05c62c7f3 module.cc (trees_in::is_matching_decl): Copy DECL_TEMPLATE_INSTANTIATED.
gcc/cp/
	* module.cc (trees_in::is_matching_decl): Copy
	DECL_TEMPLATE_INSTANTIATED.
	gcc/testsuite/
	* g++.dg/modules/inst-5_[ab].[CH]: New.

From-SVN: r275927
2019-09-19 02:47:12 +00:00
Nathan Sidwell
b0595774eb module.cc (trees_in::mergeables): Vec of intptr_t.
gcc/cp/
	* module.cc (trees_in::mergeables): Vec of intptr_t.
	(trees_in::register_mergeable): Return index.
	(trees_in::unmatched_mergeable): New.
	(trees_in::get_dupness): Drop last parm.  Return DUP_bad as
	necessary.  Adjust callers.
	(trees_in::tree_value): Call unmatched_mergeable as necessary.

From-SVN: r275920
2019-09-19 00:12:40 +00:00
Nathan Sidwell
f5d6fbfc11 module.cc (trees_in): Delete skip_defns & handling.
gcc/cp/
	* module.cc (trees_in): Delete skip_defns & handling.  Add
	any_deduping field.
	(trees_in::register_mergeable): Outline.
	(trees_in::{enum dupness,get_dupness}): New.
	(trees_in::{enum odrness,get_odrness}): New.
	(trees_in::lookup_mergeable): Delete.
	(trees_in::is_existing_mergeable): Delete, use get_dupness.
	(trees_in::is_skippable_defn): Delete, ise get_odrness.
	(trees_in::assert_definition): Adjust.
	(trees_in::read_{function,class,var,enum}_def): Adjust.
	(topmost_decl): Delete.
	gcc/testsuite/
	* g++.dg/modules/part-3_c.C: Adjust scans.
	* g++.dg/modules/tdef-6_b.C: Adjust scans.

From-SVN: r275918
2019-09-18 23:14:43 +00:00
Nathan Sidwell
fda92b0cda module.cc (trees_in::is_skippable_defns): Defns always complete incomplete.
gcc/cp/
	* module.cc (trees_in::is_skippable_defns): Defns always complete
	incomplete.
	gcc/testsuite/
	* g++.dg/modules/merge-3_[ab].[CH]: New.

From-SVN: r275835
2019-09-18 04:02:27 +00:00
Nathan Sidwell
24fe0c0d38 module.cc (depset::DB_TYPE_SPEC_BIT): New.
gcc/cp/
	* module.cc (depset::DB_TYPE_SPEC_BIT): New.
	(depset::is_type_spec): New.
	(enum merge_kind): Replace MK_spec with MK_decl_spec, MK_type_spec.
	(merge_kind_name): Update.
	(trees_in::tree_value): Partition MK_spec handling.
	(trees_{in,out}::key_mergeable): Likewise.
	(depset::hash::add_specialization): Set DB_TYPE_SPEC_BIT.
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_b.C: Update lang dump scans.
	* g++.dg/modules/inst-[234]_[ab].C: Update lang dump scans.

From-SVN: r275767
2019-09-17 03:05:37 +00:00
Nathan Sidwell
ae7be7a931 module.cc (spec_tuple): Delete type.
gcc/cp/
	* module.cc (spec_tuple): Delete type.
	(specialization_add): Adjust data type.
	(depset::hash::add_specializations): Drop PARTITIONS parm. Adjust.
	(module_state::write): Adjust.

From-SVN: r275766
2019-09-17 02:37:46 +00:00
Nathan Sidwell
fabcfee5cd cp-tree.h (check_mergeable_specialization): Declare.
gcc/cp/
	* cp-tree.h (check_mergeable_specialization): Declare.
	(match_mergeable_specialization): Add DECL_P parm, drop INSERT_P parm.
	* module.cc (trees_in::tree_value): Adjust
	match_mergeable_spcialization calls.
	(specialization_add): Use check_mergeable_specializatio.
	* pt.c (check_mergeable_specialization): New.
	(match_mergeable_specialization): Always insert, reorder parms.

From-SVN: r275765
2019-09-17 02:32:07 +00:00
Nathan Sidwell
79ec1864a9 module.cc (enum merge_kind): Add MK_linkage.
gcc/cp/
	* module.cc (enum merge_kind): Add MK_linkage.
	(merge_kind_name): ... and here.
	(trees_in::tree_value): Add it.
	(trees_{in,out}::key_mergeable): Use it.
	* name-lookup.c (match_mergeable_decl): Don't add anon-enum.

From-SVN: r275764
2019-09-17 02:00:51 +00:00
Nathan Sidwell
59c0ac5b08 module.cc (enum merge_kind): Add MK_linkage.
gcc/cp/
	* module.cc (enum merge_kind): Add MK_linkage.
	(merge_kind_name): ... and here.
	(trees_in::tree_value): Add it.
	(trees_{in,out}::key_mergeable): Use it.
	* name-lookup.c (match_mergeable_decl): Don't add anon-enum.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_a.C: Adjust scan.
	* g++.dg/modules/indirect-[234]_b.C: Likewise.
	* g++.dg/modules/inst-[23]_a.C: Likewise.
	* g++.dg/modules/tdef-6_[ab].[HC]: New.

From-SVN: r275756
2019-09-16 18:45:57 +00:00
Nathan Sidwell
d0e0ce4b53 module.cc (trees_in::chained_decls): No need to deal with clones here.
gcc/cp/
	* module.cc (trees_in::chained_decls): No need to deal with clones here.
	(trees_{in::read,out::write}_class_def): Don't chain
	fields until we know we're the definition.

From-SVN: r275732
2019-09-15 19:30:22 +00:00
Nathan Sidwell
a2114feb25 Merge trunk r275727.
From-SVN: r275728
2019-09-15 13:26:21 +00:00
Nathan Sidwell
a159438d1c name-lookup.c (get_namespace_binding): Fish out global binding, if it's a vector.
gcc/cp/
	* name-lookup.c (get_namespace_binding): Fish out global binding,
	if it's a vector.
	gcc/testsuite/
	* g++.dg/modules/binding-2.H: New.

From-SVN: r275711
2019-09-14 01:09:00 +00:00
Nathan Sidwell
32f2cf50b0 cp-tree.h (MODULE_VECTOR_LAZY_SPEC_P): Use TREE_THIS_VOLATILE.
gcc/cp/
	* cp-tree.h (MODULE_VECTOR_LAZY_SPEC_P): Use TREE_THIS_VOLATILE.
	gcc/testsuite/
	* g++.dg/modules/binding-1_[abc].[HC]: New.

From-SVN: r275710
2019-09-14 00:31:02 +00:00
Nathan Sidwell
c60bb6dace cp-tree.def (UNBOUND_CLASS_TEMPLATE): Correct docs.
gcc/cp/
	* cp-tree.def (UNBOUND_CLASS_TEMPLATE): Correct docs.
	* cp-tree.h (make_unbound_class_template_raw): Declare.
	* decl.c (make_unbound_class_template_raw): New, break out of ...
	(make_unbound_class_template): ... this, call it.
	* module.cc (trees_out::tree_type): Handle UNBOUND_CLASS_TEMPLATE.
	(trees_in::tree_node): Likewise.
	gcc/testsuite/
	* g++.dg/modules/tpl-tpl-parm-1_[ab].[HC]: New.

From-SVN: r275688
2019-09-12 18:49:52 +00:00
Nathan Sidwell
e33095fafb module.cc (trees_out::core_vals): Never write template_decl's type ...
gcc/cp/
	* module.cc (trees_out::core_vals): Never write template_decl's
	type ...
	(trees_in::tree_value): .. resurrect it here instead.

From-SVN: r275687
2019-09-12 18:37:06 +00:00
Nathan Sidwell
622baed8ae module.cc: Sort many switch stmts.
gcc/cp/
	* module.cc: Sort many switch stmts.

From-SVN: r275686
2019-09-12 15:34:13 +00:00
Nathan Sidwell
66d30b1a8e Merge trunk r275641.
From-SVN: r275658
2019-09-11 18:57:57 +00:00
Nathan Sidwell
af8dff0709 typos
From-SVN: r275596
2019-09-10 18:22:37 +00:00
Nathan Sidwell
02cd0c0e6f Merge trunk r275518
From-SVN: r275538
2019-09-09 18:39:05 +00:00
Nathan Sidwell
ab38275e2f module.cc (enum depset::disc_bits): Delete DB_REACHED_ONCE_BIT.
gcc/cp/
	* module.cc (enum depset::disc_bits): Delete DB_REACHED_ONCE_BIT.
	(depset::is_reached_once, depset::clear_mergeable): Delete
	(trees_in::tree_value): Set template typedef type.
	(depset::hash::add_dependency): No reached once stuff.
	(sort_mergeables): Just live with tight clusters.
	gcc/testsuite/
	* g++.dg/modules/late-ret-2_a.H: Adjust scans.
	* g++.dg/modules/late-ret-3_[abc].[CH]: New.

From-SVN: r275520
2019-09-09 16:15:36 +00:00
Nathan Sidwell
b2f5eb4815 module.cc (enum depset::disc_bits): Add DB_REACHED_ONCE_BIT.
gcc/cp/
	* module.cc (enum depset::disc_bits): Add DB_REACHED_ONCE_BIT.
	(depset::is_reached_once, depset::clear_mergeable): New.
	(depset::hash::add_dependency): Set and clear DB_REACHED_ONCE_BIT.
	(sort_mergeables): Deal with internal entities.
	(module_state::read_cluster): A voldemort might have been merged.
	gcc/testsuite/
	* g++.dg/modules/late-ret-2_[abc].[HC]: New.

From-SVN: r275474
2019-09-06 19:25:19 +00:00
Nathan Sidwell
5c6dbac60a Merge trunk r275458.
From-SVN: r275459
2019-09-06 13:23:09 +00:00
Nathan Sidwell
d3f8b04777 concept-2_[ab].C: New.
gcc/testsuite/
	* g++.dg/modules/concept-2_[ab].C: New.

From-SVN: r275443
2019-09-05 20:18:34 +00:00
Nathan Sidwell
781a778345 module.cc (trees_{in,out}::core_vals): Stream constraint_info.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream constraint_info.
	(trees_{in,out}::tree_value): Stream constrain node.
	{trees_{in,out}::tpl_header): Stream parm(s) constraints.
	* pt.c (set_constraints): Don't do spurious lookup.
	gcc/testsuite/
	* g++.dg/modules/concept-1_[ab].C: New.

From-SVN: r275441
2019-09-05 20:05:48 +00:00
Nathan Sidwell
cf7bb223a2 module.cc (module_state::write_location): Check streaming here.
gcc/cp/
	* module.cc (module_state::write_location): Check streaming here.
	Adjust many callers.

From-SVN: r275425
2019-09-05 17:19:45 +00:00
Nathan Sidwell
fc7fd59b07 module.cc (trees_{in,out}::core_vals): Move some node handling into the new switch.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Move some node handling
	into the new switch.

From-SVN: r275424
2019-09-05 16:51:55 +00:00
Nathan Sidwell
2494c1dc72 module.cc (trees_{in,out}::core_vals): Reorder part 7.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 7.
	* decl.c (cp_tree_node_structure): Alphabetize.
	gcc/
	* tree.c (tree_node_structure_for_code): Likewise.

From-SVN: r275423
2019-09-05 16:34:31 +00:00
Nathan Sidwell
e7a02b9bbf module.cc (trees_{in,out}::core_vals): Reorder part 6.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 6.

From-SVN: r275420
2019-09-05 15:18:19 +00:00
Nathan Sidwell
3fc6adf03f module.cc (trees_{in,out}::core_vals): Reorder part 5.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 5.

From-SVN: r275419
2019-09-05 15:13:07 +00:00
Nathan Sidwell
61a9ce640d module.cc (trees_{in,out}::core_vals): Reorder part 4.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 4.

From-SVN: r275418
2019-09-05 15:01:56 +00:00
Nathan Sidwell
f2cf6b97d0 module.cc (trees_{in,out}::core_vals): Reorder part 3.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 3.

From-SVN: r275417
2019-09-05 14:51:02 +00:00
Nathan Sidwell
089e5d47a6 module.cc (trees_{in,out}::core_vals): Reorder part 2.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 2.

From-SVN: r275416
2019-09-05 14:39:52 +00:00
Nathan Sidwell
0e3a7bb34c module.cc (trees_{in,out}::core_vals): Reorder part 1.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Reorder part 1.

From-SVN: r275415
2019-09-05 14:26:41 +00:00
Nathan Sidwell
16e6fbbeb4 module.cc (trees_out::tree_type): There are no indescribable types.
gcc/cp/
	* module.cc (trees_out::tree_type): There are no indescribable types.

From-SVN: r275413
2019-09-05 14:04:05 +00:00
Nathan Sidwell
8c1e90cd89 module.cc (trees_{in,out}::core_vals): Redo enum underlying type streaming.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Redo enum underlying type
	streaming.

From-SVN: r275412
2019-09-05 13:58:49 +00:00
Nathan Sidwell
26373cf317 Merge trunk r275404.
From-SVN: r275407
2019-09-05 13:27:34 +00:00
Nathan Sidwell
19caba300d module.cc (trees_out::tree_type): Stream ptrmemfuncs at the appropriate point.
gcc/cp/
	* module.cc (trees_out::tree_type): Stream ptrmemfuncs at the
	appropriate point.

From-SVN: r275226
2019-08-30 20:24:30 +00:00
Nathan Sidwell
b2a492d230 module.cc (trees_in::finish{,_type}): Delete.
gcc/cp/
	* module.cc (trees_in::finish{,_type}): Delete. Move into
	trees_in::tree_value, removing type remapping etc,
	(trees_out::start): Check not streaming an unexpected type.
	(trees_{in,out}::core_vals): Pointers are not streamed.
	(trees_in::tree_value): Move remnants of finish{,_type} here &
	simplify handling.

From-SVN: r275225
2019-08-30 20:08:22 +00:00
Nathan Sidwell
eac2d8ff16 module.cc (trees_out::tree_type): Write non-standard integer types here.
gcc/cp/
	* module.cc (trees_out::tree_type): Write non-standard integer
	types here.
	(trees_in::tree_node): Read them here.
	(trees_out::tree_value): We never see a naked type.
	gcc/testsuite/
	* g++.dg/modules/bfield-2_[ab].C: New.

From-SVN: r275212
2019-08-30 18:00:29 +00:00
Nathan Sidwell
f468a3e002 module.cc (trees_{in,out}::start): Refactor switch.
gcc/cp/
	* module.cc (trees_{in,out}::start): Refactor switch.
	(trees_{in,out}::core_vals): Remove first switch.

From-SVN: r275209
2019-08-30 17:15:45 +00:00
Nathan Sidwell
220a0eb8e4 module.cc (enum streamed_extensions): New.
gcc/cp/
	* module.cc (enum streamed_extensions): New.
	(module_state::extensions): New.
	(module_state::write_readme): Adjust.
	(trees_{in,out}::start): Note or check openmp extension.
	(module_state::{read,write}_config): Adjust.
	gcc/testsuite/
	* g++.dg/modules/omp-1_c.C: New.
	* g++.dg/modules/omp-2_[ab].C: New.

From-SVN: r275203
2019-08-30 16:24:51 +00:00
Nathan Sidwell
cb481848a4 module.cc (trees_{in,out}::start): Deal with OMP_CLAUSE.
gcc/cp/
	* module.cc (trees_{in,out}::start): Deal with OMP_CLAUSE.
	(trees_{in,out}::core_vals): Likewise.
	gcc/testsuite/
	* g++.dg/modules/omp-1_[ab].C: New.

From-SVN: r275194
2019-08-30 15:08:59 +00:00
Nathan Sidwell
71ced5cec1 module.cc (friend_from_decl_list): Reimplement.
gcc/cp/
	* module.cc (friend_from_decl_list): Reimplement.
	(trees_out::tree_decl): When streaming a local template friend
	reference, make sure we find one.

From-SVN: r275179
2019-08-30 14:11:38 +00:00
Nathan Sidwell
5c5bc07d61 module.cc (enum tree_tag): Drop tt_mergeable, tt_clone.
gcc/cp/
	* module.cc (enum tree_tag): Drop tt_mergeable, tt_clone.
	(trees_out::tree_value): Emit tt_node & kind separately.
	(trees_in::tree_node): Read tt_node kind explicitly.

From-SVN: r275169
2019-08-30 13:47:53 +00:00
Nathan Sidwell
06389666f2 module.cc (trees_out::tree_decl): VTTs are just vtables.
gcc/cp/
	* module.cc (trees_out::tree_decl): VTTs are just vtables.
	gcc/testsuite/
	* g++.dg/modules/vtt-1_[abc].C: New.

From-SVN: r275051
2019-08-29 18:52:10 +00:00
Nathan Sidwell
becc5e8e55 module.cc (trees_{in,out}::core_vals): We never see TS_CP_ARGUMENT_PACK_SELECT nodes.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): We never see
	TS_CP_ARGUMENT_PACK_SELECT nodes.

From-SVN: r275048
2019-08-29 17:27:23 +00:00
Nathan Sidwell
69d91d1a29 Merge trunk r275034.
From-SVN: r275047
2019-08-29 15:14:45 +00:00
Nathan Sidwell
39d7025faa module.cc (struct location_map_info): New.
gcc/cp/
	* module.cc (struct location_map_info): New.
	(module_state::prepare_locations): Rename to ...
	(module_state::prepare_maps): ... here.  Return a
	location_map_info.
	(module_state::{read,write}_locations): Split to ...
	(module_state::{read,write}_{ordinary,macro}_maps): ... here. Adjust.
	(module_state::{read,write}): Split location map streaming.
	gcc/testsuite/
	* g++.dg/modules/macro-7_[abc].C: New.

From-SVN: r275006
2019-08-28 20:16:09 +00:00
Nathan Sidwell
0c22b1b8d9 Merge trunk r274992.
From-SVN: r274995
2019-08-28 15:59:20 +00:00
Nathan Sidwell
7c60df6a19 module.cc (note_includes): Renamed from inform_includes.
gcc/cp/
	* module.cc (note_includes): Renamed from inform_includes.
	(module_translate_include): Emit note, not warning.
	(init_module_processing, handle_module_option): Adjust.
	gcc/c-family
	* c.opt (finclude-translate): Renamed from -Winclude-translate.
	gcc/
	* doc/invoke.texi (finclude-translate): Document.

From-SVN: r274948
2019-08-27 11:03:01 +00:00
Nathan Sidwell
82e98476fa module.cc (note_includes): Renamed from inform_includes.
gcc/cp/
	* module.cc (note_includes): Renamed from inform_includes.
	(module_translate_include): Emit note, not warning.
	(init_module_processing, handle_module_option): Adjust.
	gcc/c-family
	* c.opt (finclude-translate): Renamed from -Winclude-translate.
	gcc/
	* doc/invoke.texi (finclude-translate): Document.

From-SVN: r274936
2019-08-26 20:04:20 +00:00
Nathan Sidwell
43ef2376a9 module.cc (trees_in::finish): Don't clear PENDING_TEMPLATE here.
gcc/cp/
	* module.cc (trees_in::finish): Don't clear PENDING_TEMPLATE here.
	Set IDENTIFIER_VIRTUAL_P if t is a vfunc.
	(trees_out::core_bools): Write PENDING_TEMPLATE as false.
	gcc/testsuite/
	* g++.dg/modules/virt-1_[ab].C: New.

From-SVN: r274909
2019-08-25 15:28:46 +00:00
Nathan Sidwell
c3ce5a5dc1 module.cc (trees_out::tree_decl): Vtables are distinguished by DECL_VIRTUAL_P.
gcc/cp/
	* module.cc (trees_out::tree_decl): Vtables are distinguished by
	DECL_VIRTUAL_P.

From-SVN: r274908
2019-08-25 15:10:22 +00:00
Nathan Sidwell
aa04791a0c Merge trunk r274867.
From-SVN: r274873
2019-08-23 20:11:04 +00:00
Nathan Sidwell
9b773ac6ff module.cc (trees_out::core_bools): Don't propagate asm_written for types.
gcc/cp/
	* module.cc (trees_out::core_bools): Don't propagate asm_written
	for types.
	(trees_{in,out}::lang_type_bools): Don't stream debug_requested.
	(trees_in::read_{enum,class}_def): Register for debug.
	(finish_module_processing): Don't write module when syntax only.
	gcc/testsuite/
	* g++.dg/modules/debug-1_[ab].C: New.

From-SVN: r274855
2019-08-23 12:41:14 +00:00
Nathan Sidwell
bd3b1bba8f module.cc (depset::hash::add_dependency): We should never find a redirect.
gcc/cp/
	* module.cc (depset::hash::add_dependency): We should never find a
	redirect.
	(depset::hash::add_redirect): Rename to ...
	(depset::hash::add_partial_redirect): ... here. Mark the redirect
	as unreachable.

From-SVN: r274832
2019-08-22 18:49:22 +00:00
Nathan Sidwell
0fa429d0a8 module.cc (MOD_SNAME_PFX): Resurrect initial dot.
gcc/cp/
	* module.cc (MOD_SNAME_PFX): Resurrect initial dot.
	(elf_out::strtab_write): Elide global namespace.

From-SVN: r274821
2019-08-22 14:36:37 +00:00
Nathan Sidwell
b933d2b895 module.cc (trees_in::assert_definition): Relax already-present assert.
gcc/cp/
	* module.cc (trees_in::assert_definition): Relax already-present
	assert.

From-SVN: r274811
2019-08-21 20:42:46 +00:00
Nathan Sidwell
c96fcf576a module.cc (finish_module_processing): Protect against null filename.
gcc/cp/
	* module.cc (finish_module_processing): Protect against null
	filename.

From-SVN: r274802
2019-08-21 16:39:39 +00:00
Nathan Sidwell
f17b47937b module.cc (elf_in::release): Reset size too.
gcc/cp/
	* module.cc (elf_in::release): Reset size too.
	(enum ct_bind_flags): Correct cbf_wrapped value.
	(module_state::read_cluster): Usings may be unwrapped.

From-SVN: r274801
2019-08-21 16:26:17 +00:00
Nathan Sidwell
4f16704dc7 c.opt (Winclude-translate*): New family of options.
gcc/c-family/
	* c.opt (Winclude-translate*): New family of options.
	gcc/cp/
	* module.cc (inform_includes): New var.
	(module_translate_include): Inform of translations.
	(init_module_processing): Canonicalize inform list.
	(handle_module_option): Process inform options.

From-SVN: r274797
2019-08-21 13:29:29 +00:00
Nathan Sidwell
3039793b79 module.cc (set_cmi_repo): NULL means default init.
gcc/cp/
	* module.cc (set_cmi_repo): NULL means default init.
	(module_mapper::module_mapper): Default init repo.
	(module_mapper::translate_include): Add LEN parm, create STRING.
	(canonicalize_header_name): Correctly prepend './'.
	gcc/testsuite/
	* g++.dg/modules/ben-1.map: Add $root.
	* g++.dg/modules/gc-2.map: Add $root.
	* g++.dg/modules/map-1.map: Add $root.
	* g++.dg/modules/map-1_b.map: Add $root.

From-SVN: r274795
2019-08-21 11:27:41 +00:00
Nathan Sidwell
e4f8c1383f module.cc (module_state::module_state): Header must be .-relative if not absolute.
gcc/cp/
	* module.cc (module_state::module_state): Header must be
	.-relative if not absolute.
	(get_module): Validate module name more.
	gcc/testsuite/
	* g++.dg/modules/map-2.{C,map}: New.

From-SVN: r274752
2019-08-20 18:03:00 +00:00
Nathan Sidwell
41e138cfb0 Merge trunk r274747.
From-SVN: r274750
2019-08-20 14:26:02 +00:00
Nathan Sidwell
f27682ad5a Merge trunk r273943 (Jason's TEMPLATE_INFO changes).
From-SVN: r274747
2019-08-20 12:40:44 +00:00
Nathan Sidwell
a43273e38a Merge trunk r273906 (Martin's function_decl.decl_type changes).
From-SVN: r274745
2019-08-20 11:49:54 +00:00
Nathan Sidwell
bdd8603c1c Merge trunk r273771.
From-SVN: r274679
2019-08-19 19:22:51 +00:00
Nathan Sidwell
29d9d42f90 name-lookup.c (get_cxx_dialect_name): Make extern.
gcc/cp/
	* name-lookup.c (get_cxx_dialect_name): Make extern.
	* name-lookup.h (get_cxx_dialect_name): Declare.
	* module.cc (module_state_config::get_opts): Just determine C++
	dialect.
	gcc/testsuite/
	* g++.dg/modules/flag-1_[ab].C: Adjust.

From-SVN: r274055
2019-08-04 08:55:11 +00:00
Nathan Sidwell
fcc851e556 module.cc (module_state::deferred_macro): Emit warning if at end of TU.
gcc/cp/
	* module.cc (module_state::deferred_macro): Emit warning if at end
	of TU.
	(finish_module_processing): Adjust.
	gcc/
	* doc/invoke.texi (fforce-module-macros): Replace documentation
	with ...
	(Winvalid-imported-macros): ... this.
	gcc/c-family/
	* c.opt (fforce-module-macros): Replace with ...
	(Winvalid-imported-macros): ... this.
	gcc/testsuite/
	* g++.dg/modules/macro-4_[abcdeg].C: Update.
	* g++.dg/modules/macro-5_c.C: Update.

From-SVN: r273970
2019-08-01 10:30:39 +00:00
Nathan Sidwell
f5d248fe3d module.cc (node_template_info): Enums may be function-local.
gcc/cp/
	* module.cc (node_template_info): Enums may be function-local.
	gcc/testsuite/
	* g++.dg/modules/enum-7.C: New.

From-SVN: r273846
2019-07-27 23:35:56 +00:00
Nathan Sidwell
78dd9bcb3a invoke.texi (C++ Modules): Update.
gcc/
	* doc/invoke.texi (C++ Modules): Update.

From-SVN: r273845
2019-07-27 22:33:40 +00:00
Nathan Sidwell
b500dbeede Default to gcm.cache directory.
gcc/cp/
	* cxx-mapper.c (flag_root): Change default.
	(module2bmi): Headers have same suffix.
	(client::action): Prefix root dir to look for bmi.
	gcc/
	* doc/invoke.texi (C++ Module Mapper): Update docs.
	gcc/testsuite/
	* g++.dg/modules/dep-1_[ab].C: Update scans.
	* g++.dg/modules/dep-2.C: Update scans.
	* g++.dg/modules/modules.exp (DEFAULT_REPO): New.
	(dg-module-cmi): Adjust.

From-SVN: r273785
2019-07-25 02:26:09 +00:00
Nathan Sidwell
5f9e9678c0 Drop import alias detection, via controlling macros.
gcc/cp/
	* module.cc (bytes_in::no_more): Delete.
	(module_state::{read,write}_config): Drop controlling macro.
	(module_state::write_readme): Likewise.
	(module_state::read): Drop alias return.
	(module_state::slurp): Delete.  Replace all uses with field
	access.
	(module_state::resolve_alias): Delete.
	(module_state::is_alias): Delete.
	(module_state::read_imports): Drop alias detection.
	gcc/testsuite/
	* g++.dg/modules/alias-[12]_b.C: Drop controlling macro scans.
	* g++.dg/modules/macro-2_c.H: Likewise.
	* g++.dg/modules/macro-3_[abc].[CH]: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.
	* g++.dg/modules/alias-3_*: Delete.
	* g++.dg/modules/sys/alias-3_a.H: Delete.

From-SVN: r273784
2019-07-25 02:15:37 +00:00
Nathan Sidwell
28068e1ed2 Merge trunk r273764.
From-SVN: r273765
2019-07-24 17:01:08 +00:00
Nathan Sidwell
9c4b070dc4 alias-2_a.H: Add dg-module-header.
gcc/testsuite/
	* g++.dg/modules/alias-2_a.H: Add dg-module-header.
	* g++.dg/modules/alias-3_a.H: Likewise.
	* g++.dg/modules/mod-decl-0-2a.C: std=c++2a.
	* g++.dg/modules/mod-decl-0.C: std=c++17.
	* g++.dg/modules/modules.exp: Add dg-module-header, iterate over
	different c++ stds.

From-SVN: r273764
2019-07-24 15:55:57 +00:00
Nathan Sidwell
b6c4971027 module.cc (trees_out::tree_decl): Cope with using decls in the binding list.
gcc/cp/
	* module.cc (trees_out::tree_decl): Cope with using decls in the
	binding list.
	gcc/testsuite/
	* g++.dg/modules/enum-6_[ab].[HC]: New.

From-SVN: r273762
2019-07-24 12:26:06 +00:00
Nathan Sidwell
6295b8d4ae module.cc (enum merge_kind): Add MK_enum.
gcc/cp/
	* module.cc (enum merge_kind): Add MK_enum.
	(trees_out::tree_decl): Deal with anon enums.
	(trees_in::tree_value): Adjust for MK_enum.
	(trees_{in,out}::tree_node): Adjust tt_enum_int streaming.
	(trees_{in,out}::key_mergeable): Add MK_enum key.
	(depset::hash::add_dependency): Enum values are like using decls.
	(depset::hash::add_binding): Likewise.
	(depset_cmp): Reorder for new requirements.
	(enum ct_bind_flags): Add cbf_wrapped.
	(sort_mergeables): Presume sorted by depset_cmp.
	(module_state::{read,write}_cluster): Adjust.
	* name-lookup.c (check_mergeable_decl): Deal with anon-enum
	proxies.
	gcc/testsuite/
	* g++.dg/modules/enum-1_a.C: Adjust scan.

From-SVN: r273760
2019-07-24 11:46:43 +00:00
Nathan Sidwell
c93d61bfb8 module.cc (depset): Rename MARKED to SPECIAL, update all users.
gcc/cp/
	* module.cc (depset): Rename MARKED to SPECIAL, update all users.

From-SVN: r273739
2019-07-23 15:16:08 +00:00
Nathan Sidwell
173b94f0bd Add quoting from Boris Kolpackov
From-SVN: r273735
2019-07-23 11:21:43 +00:00
Nathan Sidwell
c83c9a079f parser.c (cp_parser_class_specifier_1): Fixup a template's type with a late exception specifier.
gcc/cp/
	* parser.c (cp_parser_class_specifier_1): Fixup a template's type
	with a late exception specifier.
	gcc/testsuite/
	* g++.dg/modules/except-1.C: New.

From-SVN: r273701
2019-07-22 15:49:57 +00:00
Boris Kolpackov
aa573b96db Make-lang.in (MODULE_REVISION): Add git rev, if it's git.
gcc/cp/
	* Make-lang.in (MODULE_REVISION): Add git rev, if it's git.

From-SVN: r273699
2019-07-22 15:21:43 +00:00
Nathan Sidwell
994368ba58 detect git clone (from boris kolpackov)
From-SVN: r273565
2019-07-18 06:29:12 +00:00
Nathan Sidwell
a0b8a5f704 Fix additional options
From-SVN: r273532
2019-07-16 15:06:56 +00:00
Nathan Sidwell
91cfd8ec22 module.cc (module_state::read_{bindings,namespaces}): Use plain vec
gcc/cp/
	* module.cc (module_state::read_{bindings,namespaces}): Use plain
	vec
	(module_state::read): Adjust.
	(module_state::write_macros): Use plain vec.
	(module_state::deferred_macro): Use plain vec.

From-SVN: r273530
2019-07-16 14:47:12 +00:00
Nathan Sidwell
5774210561 module.cc (depset::hash::add_writables): Use plain vec.
gcc/cp/
	module.cc (depset::hash::add_writables): Use plain vec.
	(typedef spec_tuple): Use plain vec.
	(depset::hash::add_speciailizations): Correctly init vec.
	(module_state::{read,write}_namespaces): Use plain vec.
	(module_state::{read,write}): Adjust.

From-SVN: r273528
2019-07-16 14:04:34 +00:00
Nathan Sidwell
9fbcbb023f Fix it better.
gcc/cp/
	* mangle.c (mangle_module_substitution): Offset overflow.
	gcc/testsuite/
	* g++.dg/modules/sym-subst-3_[ab].C: Fix
	* g++.dg/modules/sym-subst-[456].C: New.

From-SVN: r273517
2019-07-16 09:00:15 +00:00
Nathan Sidwell
ff216dad57 Fix module backref subst.
gcc/cp/
	* cp-tree.h (mangle_substitution): Rename to ...
	(mangle_module_substitution): ... here.  Drop genecity.
	* mangle.c: Likewise.  Fix mangling.
	* module.cc (module_state::mangle): Adjust.
	gcc/testsuite/
	* g++.dg/modules/sym-subst-1.C: Adjust scan.
	* g++.dg/modules/sym-subst-2_[ab].C: Adjust scan.
	* g++.dg/modules/sym-subst-3_[ab].C: New.

From-SVN: r273512
2019-07-16 08:43:03 +00:00
Nathan Sidwell
7fc0f84d30 c-opts.c (c_common_handle_option): Remove {user,system}_search.
gcc/c-family/
	* c-opts.c (c_common_handle_option): Remove {user,system}_search.
	* c.opt ({user,system}-search): Delete.
	(fmodule-header): Undeprecate.
	gcc/cp/
	* module.cc (module_state_config::get_opts): Drop
	OPT_fmodule_header_.
	(handle_module_option): Handle fmodule-header=.
	gcc/
	* gcc.c (cpp_unique_options): Drop {user,system}-search.

From-SVN: r273307
2019-07-09 14:36:39 +00:00
Nathan Sidwell
ea401bcb1b c-common.c (try_to_locate_new_include): Use strcmp and ignore zero-line maps.
gcc/c-family/
	* c-common.c (try_to_locate_new_include): Use strcmp and ignore
	zero-line maps.
	gcc/cp/
	* module.cc (finish_module_processing): Inhibit module stats if
	not moduling.

From-SVN: r273239
2019-07-08 17:18:25 +00:00
Nathan Sidwell
10a2b8be17 syncing version
From-SVN: r273234
2019-07-08 12:17:11 +00:00
Nathan Sidwell
d848ae7786 Merge trunk r273185.
From-SVN: r273186
2019-07-08 00:14:24 +00:00
Nathan Sidwell
bc1696a438 files.c (cpp_find_failed): Replace with ...
libcpp/
	* files.c (cpp_find_failed): Replace with ...
	(cpp_found_name): ... this.
	(_cpp_stack_file): Check main_search option.
	* include/cpplib.h (cpp_options): Add main_search.
	* internal.h (cpp_find_failed): Replace with ...
	(cpp_found_name): ... this.
	* init.c (cpp_read_main_file): Examine main_search option.
	gcc/c-family/
	* c-opts.c (c_common_handle_options): Add OPT_{user,system}_search.
	* c.opt (user-search, system-search): New.
	gcc/
	* gcc.c (cpp_unique_options): Add {user,system}-search.

From-SVN: r273185
2019-07-07 23:43:59 +00:00
Nathan Sidwell
f4f9311cbc module.cc (module_state::write_cluster): Return cluster size.
gcc/
	* module.cc (module_state::write_cluster): Return cluster size.
	(avalable_clusters, loaded_clusters): New static vars.
	(module_state::{read,write}): Adjust.
	(finish_module_processing): Dump more stats.
	gcc/testsuite/
	* g++.dg/module/part-3_c.C: Adjust scan.

From-SVN: r273183
2019-07-07 16:49:40 +00:00
Nathan Sidwell
91530d70f9 timevar.def (TV_MODULE_{IMPORT,EXPORT,MAPPER}): Define.
gcc/
	* timevar.def (TV_MODULE_{IMPORT,EXPORT,MAPPER}): Define.
	gcc/cp/
	* module.cc: Include timvar.h.  Sprinkle timevar accounting throughout.

From-SVN: r273179
2019-07-07 15:51:12 +00:00
Nathan Sidwell
44981b7596 Merge trunk r273146.
From-SVN: r273150
2019-07-06 00:04:07 +00:00
Nathan Sidwell
fc2657e9dd decl2.c (c_parse_final_cleanups): Don't do static init things for a header module.
Victory!
	gcc/cp/
	* decl2.c (c_parse_final_cleanups): Don't do static init things
	for a header module.
	* module.cc (trees_in::start): Drop unused second parm.
	(module_state::{read,write}_inits): New.
	(trees_out::core_bools): Restrict static->extern hack.
	(module_state::{read,write}_config): Note inits.
	(module_state::{read,write}): Stream inits.
	gcc/testsuite/
	* g++.dg/modules/iostream-1_b.C: Remove ioinit workaround.

From-SVN: r273146
2019-07-05 17:43:53 +00:00
Nathan Sidwell
ac18b2fa17 iostream-1_[ab].[HC]: New.
gcc/testsuite/
	* g++.dg/modules/iostream-1_[ab].[HC]: New.

From-SVN: r273142
2019-07-05 15:44:29 +00:00
Nathan Sidwell
c6ee590834 module.cc (module_state_config::get_opts): Drop -g* switches.
gcc/cp/
	* module.cc (module_state_config::get_opts): Drop -g* switches.

From-SVN: r273141
2019-07-05 15:40:37 +00:00
Nathan Sidwell
309d354cdf cp-tree.h (get_tinfo_decl_direct): Declare.
gcc/cp/
	* cp-tree.h (get_tinfo_decl_direct): Declare.
	* module.cc (trees_out::tree_decl): Stream more tinfo_var info.
	(trees_in::tree_value): Use get_tinfo_decl_direct for tinfo vars.
	* rtti.c (get_tinfo_decl_direct): Break out of ...
	(get_tinfo_decl): ... here.  Call it.

From-SVN: r273137
2019-07-05 13:02:30 +00:00
Nathan Sidwell
6f2a78e717 module.cc (module_state::read_cluster): finalize_function may not GC.
gcc/cp/
	* module.cc (module_state::read_cluster): finalize_function may
	not GC.

From-SVN: r273094
2019-07-04 20:37:37 +00:00
Nathan Sidwell
8fbb349b19 module.cc (enum cluster_tag): Add ct_defn.
gcc/cp/
	* module.cc (enum cluster_tag): Add ct_defn.
	(enum ct_decl_flags): Rmove cdf_has_definition.
	(module_state::{read,write}_cluster): Stream definitions after
	declarations..

From-SVN: r273093
2019-07-04 20:08:41 +00:00
Nathan Sidwell
0848fdc820 module.cc (trees_{in,out}::key_mergeable): Always stream context.
gcc/cp/
	* module.cc (trees_{in,out}::key_mergeable): Always stream context.
	gcc/testsuite/
	* g++.dg/modules/merge-1_[ab].[HC]: New.

From-SVN: r273092
2019-07-04 19:18:53 +00:00
Nathan Sidwell
488c4ecb8d module.cc (trees_out::key_mergeable): Return merge kind.
gcc/cp/
	* module.cc (trees_out::key_mergeable): Return merge kind.
	(trees_out::tree_value): Note key writing.
	(trees_in::tree_value): Adjust key dump.
	gcc/testsuite/
`	* g++.dg/modules/builtin-1_b.C: Adjust scans.
	* g++.dg/modules/inst-[1234]_b.C: Likewise.
	* g++.dg/modules/part-3_[cd].C: Likewise.

From-SVN: r273085
2019-07-04 15:26:38 +00:00
Nathan Sidwell
ce3738a284 module.cc (trees_out::tree_type): Add TYPEOF_TYPE, UNDERLYING_TYPE.
gcc/cp/
	* module.cc (trees_out::tree_type): Add TYPEOF_TYPE, UNDERLYING_TYPE.
	(trees_in::tree_node): Likewise.

From-SVN: r273015
2019-07-03 17:54:35 +00:00
Nathan Sidwell
106fe4aaa3 module.cc (struct unnamed_entity): GTY it.
gcc/cp/
	* module.cc (struct unnamed_entity): GTY it.
	(unnamed_map): Not a GTY object.

From-SVN: r273014
2019-07-03 17:42:53 +00:00
Nathan Sidwell
4cddaa61d0 module.cc (trees_{in,out}::fn_parms): Rename to ...
gcc/cp/
	* module.cc (trees_{in,out}::fn_parms): Rename to ...
	(trees_{in,out}::fn_arg_types): ... this.
	(trees_{in,out}::fn_parms_{init,fini}): New.
	(trees_{in,out}::tree_value): Call fn_parms_fini.
	(trees_{in,out}::key_mergeable): Call fn_parms_init.
	gcc/testsuite/
	* g++.dg/modules/late-ret-1.H: New.
	* g++.dg/modules/scc-1.C: Adjust scan.

From-SVN: r273012
2019-07-03 16:44:07 +00:00
Nathan Sidwell
667dc8ff0e module.cc (trees_out::tree_type): Add DECLTYPE_TYPE.
gcc/cp/
	* module.cc (trees_out::tree_type): Add DECLTYPE_TYPE.
	(trees_in::tree_node): Likewise.

From-SVN: r273010
2019-07-03 13:35:29 +00:00
Nathan Sidwell
27471cebcf module.cc (trees_in::core_vals): Protect binfo base reading.
gcc/cp/
	* module.cc (trees_in::core_vals): Protect binfo base reading.
	(module_state::{read,write}_cluster): Insert types for horcrucifexes.
	gcc/testsuite/
	* g++.dg/modules/horcrux-1_[ab].C: New.

From-SVN: r272945
2019-07-02 17:28:04 +00:00
Nathan Sidwell
7ef5accd5e Rename bmi->cmi everywhere.
gcc/testsuite/
	Rename bmi->cmi everywhere.

From-SVN: r272942
2019-07-02 15:30:28 +00:00
Nathan Sidwell
199d5b5dac cp-tree.h (module_has_cmi_p): Renamed.
gcc/cp/
	* cp-tree.h (module_has_cmi_p): Renamed.
	* name-lookup.c (do_nonmember_using_decl): Adjust.
	* module.cc (cmi_*): Renamed.  Adjust all users.

From-SVN: r272941
2019-07-02 15:27:22 +00:00
Nathan Sidwell
347e6ebdf3 module.cc (trees_out::fn_parms): Don't use canonical type any more.
gcc/cp/
	* module.cc (trees_out::fn_parms): Don't use canonical type any
	more.
	gcc/testsuite/
	* g++.dg/modules/merge-1_[ab].C: New.

From-SVN: r272940
2019-07-02 15:24:35 +00:00
Nathan Sidwell
aa377911c1 module.cc (trees_out::tree_decl): Write types for typedefs.
gcc/cp/
	* module.cc (trees_out::tree_decl): Write types for typedefs.
	(trees_in::tree_node): Adjust.
	gcc/testsuite/
	* g++.dg/modules/tdef-5_[ab].C: New.

From-SVN: r272939
2019-07-02 14:17:06 +00:00
Nathan Sidwell
0edc639154 module.cc (trees_out::tree_type): Add pack types.
gcc/cp/
	* module.cc (trees_out::tree_type): Add pack types.
	(trees_{in,out}::tree_value): Tweak type streaming flags
	(trees_in::tree_node): Add pack types.

From-SVN: r272937
2019-07-02 13:30:36 +00:00
Nathan Sidwell
41c1e24961 module.cc (trees_out::tree_type): Detect bound template template parm.
gcc/cp/
	* module.cc (trees_out::tree_type): Detect bound template template
	parm.
	(trees_{in,out}::tree_value): Stream type on any TYPE_DECL that
	its TYPE_STUB_DECL.

From-SVN: r272936
2019-07-02 12:59:36 +00:00
Nathan Sidwell
633f627ef3 module.cc (trees_out::tree_type): Add COMPLEX and VECTOR types.
gcc/cp/
	* module.cc (trees_out::tree_type): Add COMPLEX and VECTOR types.
	(trees_in::tree_node): ... and here.

From-SVN: r272935
2019-07-02 12:24:49 +00:00
Nathan Sidwell
17848a6f05 module.cc (trees_out::tree_decl): Deal with tinfo vars and vtables here ...
gcc/cp/
	* module.cc (trees_out::tree_decl): Deal with tinfo vars and
	vtables here ...
	(trees_out::tree_node): ... not here.

From-SVN: r272934
2019-07-02 12:02:45 +00:00
Nathan Sidwell
a9d580c881 module.cc (trees_out::tree_decl): Deal with tinfo type_decls here.
gcc/cp/
	* module.cc (trees_out::tree_decl): Deal with tinfo type_decls
	here.
	(trees_out::tree_type): Dectect tinfo types here ...
	(trees_out::tree_node): ... not here.
	(trees_in::tree_node): Add tinfo type too.

From-SVN: r272933
2019-07-02 11:59:10 +00:00
Nathan Sidwell
e76c83f702 module.cc (trees_out::tree_decl): Fix dump typo.
gcc/cp/
	* module.cc (trees_out::tree_decl): Fix dump typo.
	(trees_in::tree_value): Likewise.
	(module_state::read_cluster): Show end.

From-SVN: r272910
2019-07-01 21:44:55 +00:00
Nathan Sidwell
ae69777a4c module.cc (module_state::write): Don't stream env.
gcc/cp/
	* module.cc (module_state::write): Don't stream env.

From-SVN: r272909
2019-07-01 21:31:03 +00:00
Nathan Sidwell
e97ba75490 module.cc (trees_in:::read_function_def): Push the template for post processing.
gcc/cp/
	* module.cc (trees_in:::read_function_def): Push the template for
	post processing.
	(module_state::read_cluster): Deal with abstract post processing.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-7_[ab].C: New.

From-SVN: r272895
2019-07-01 18:35:24 +00:00
Nathan Sidwell
01262014fb module.cc (depset::hash::add_binding): Return added flag.
gcc/cp/
	* module.cc (depset::hash::add_binding): Return added flag.  Deal
	with orphaned using decls.
	(depset::hash::add_writables): Return added flag.
	gcc/testsuite/
	* g++.dg/modules/using-5_[ab].C: New.

From-SVN: r272892
2019-07-01 18:04:35 +00:00
Nathan Sidwell
9302b97ef6 module.cc (enum tree_tag): Add tt_clone_ref.
Clones
	gcc/cp/
	* module.cc (enum tree_tag): Add tt_clone_ref.
	(get_clone_target): Replace get_clone_orig.
	(FOR_EVERY_CLONE): New.
	(trees_out::mark_mergeable): Add tag parm.  Adjust.
	(trees_in::chained_decls): Cope with already-linked clones.
	(trees_out::tree_decl): Support clone walking.
	(trees_{in,out}::tree_value): Likewise.
	(trees_in::tree_node): Support tt_clone_ref.
	(trees_{in,out}::key_mergeable): Key clones.
	(trees_out::{mark,write}_definition): No clones here.
	(trees_in::read_definition): Likewise.
	(depset::hash::add_clone): Reimplement.
	(module_state::write_cluster): Deal with clones.
	gcc/testsuite/
	* g++.dg/modules/clone-1_[ab].C: New.
	* g++.dg/modules/friend-1_a.C: Adjust scan.
	* g++.dg/modules/indirect-[1234]_[bc].C: Likewise.
	* g++.dg/modules/inst-3_a.C: Likewise.

From-SVN: r272888
2019-07-01 16:25:33 +00:00
Nathan Sidwell
179a13f2ef module.cc (depset::entity_kind): Add EK_CLONE.
gcc/cp/
	* module.cc (depset::entity_kind): Add EK_CLONE.
	(depset::hash::add_clone): New.
	(enum walk_kind): Move to global scope.
	(enum merge_kind): New.
	(trees_{in,out}::tree_value): Use new enums.
	(trees_{in,out}::tree_mergeable): Likewise.
	(get_clone): New.
	(member_owned_by_class): Clones are never owned.
	(trees_out::mark_declaration): Walk clones.
	(trees_in::read_definition): Likewise.
	(trees_out::write_definition): Likewise.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_b.C: Adjust dump scans.
	* g++.dg/modules/inst-1_b.C: Adjust dump scans.
	* g++.dg/modules/part-3_[cd].C: Adjust dump scans.

From-SVN: r272775
2019-06-28 00:19:40 +00:00
Nathan Sidwell
f4a515b031 module.cc (trees_{in,out}::core_vals): Stream abstract_origin.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream abstract_origin.

From-SVN: r272762
2019-06-27 19:16:33 +00:00
Nathan Sidwell
636410a5a1 class.c (build_clone): Neaten and assert.
gcc/cp/
	* class.c (build_clone): Neaten and assert.
	* cp-tree.h (lang_decl_u5.cloned_function): Fix comment.
	* name-lookup.c (get_lookup_ident): Don't fall off end of overload.

From-SVN: r272761
2019-06-27 19:12:28 +00:00
Nathan Sidwell
0933d36ef4 Add -Mno-modules.
gcc/c-family/
	* c-opts.c (c_common_init_options): Default module deps on.
	(c_common_handle_option): Handle M{no-}modules.
	* c.opt (Mmodules, Mno-modules): New options.
	gcc/
	* doc/cppopts.texi (Mno-modules): Document it.
	* doc/invoke.texi: Likewise.
	* gcc.c (cpp_unique_options): Add it.
	gcc/testsuite/
	* g++.dg/modules/dep-3.C: New.
	libcpp/
	* include/cpplib.h (struct cpp_options): Add dep.modules.
	* include/mkdeps.h: Include cpplib.h
	(deps_write): Take a cpp_reader.
	* init.c (cpp_finish): Adjust deps_write call.
	* mkdeps.c: Include internal.h
	(make_write): Adjust.  Conditionally inhibit module output.
	(deps_write): Adjust.

From-SVN: r272752
2019-06-27 13:05:53 +00:00
Nathan Sidwell
b397dfaa11 Don't elide primary from partition names.
gcc/cp/
	* cp-tree.h (module_name): Drop maybe_primary parm.
	* modules (module_state::get_flatname): Just get the flatname.
	(get_primary): New.
	(get_module): Expect fully qualified name.  Drop parent arg.
	Adjust callers.
	(module_stae:set_flatname): Create fully qualified name.
	(module_state::read_{imports,partitions}): Check partitions have
	expected primary.
	(module_state::{read,write}_config): Adjust.
	(module_state::do_import, module_preprocess)
	(finish_module_procesing): Adjust deps_add_module calls.
	* name-lookup.c (make_namespace): Adjust anon namespace name
	creation.
	* ptree.c (cxx_print_decl): Adjust module_name call.
	gcc/testsuite/
	* g++.dg/modules/part-2_d.c: Adjust regexp.
	* g++.dg/modules/part-3_c.c: Adjust scans.
	libcpp/
	* include/mkdeps.h (deps_add_module): Drop primary arg.
	* mkdeps.c (deps_add_module): Drop primary arg.

From-SVN: r272724
2019-06-27 00:18:34 +00:00
Nathan Sidwell
8c57d25cd5 Merge trunk r272714.
From-SVN: r272716
2019-06-26 21:12:13 +00:00
Nathan Sidwell
6571868d7f decl.c (duplicate_decls): Non-modules are ok for builtins.
gcc/cp/
	* decl.c (duplicate_decls): Non-modules are ok for builtins.
	gcc/testsuite/
	* g++.dg/modules/builtin-2.C: New.

From-SVN: r272714
2019-06-26 20:43:31 +00:00
Nathan Sidwell
14a2096679 module.cc (depset::hash::add_mergeable_horcrux): Add redirect as necessary.
gcc/cp/
	* module.cc (depset::hash::add_mergeable_horcrux): Add redirect as
	necessary.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-7.C: New.

From-SVN: r272709
2019-06-26 19:00:39 +00:00
Nathan Sidwell
bb885bd186 module.cc (depset::hash::add_redirect): New.
gcc/cp/
	* module.cc (depset::hash::add_redirect): New.
	(depset::hash::add_specialization): Use it.
	(depset::hash::add_mergeable): Use it.
	(depset::hash::add_dependency): Never add a redirect here.

From-SVN: r272707
2019-06-26 18:50:09 +00:00
Nathan Sidwell
ad7d7da738 module.cc (finish_module_processing): Adjust failed to write error.
gcc/cp/
	* module.cc (finish_module_processing): Adjust failed to write error.
	gcc/testsuite/
	* g++.dg/modules/internal-1.C: Adjust.

From-SVN: r272706
2019-06-26 18:24:47 +00:00
Nathan Sidwell
4298af52cf module.cc (depset::entity_kind): Add EK_REDIRECT.
gcc/cp/
	* module.cc (depset::entity_kind): Add EK_REDIRECT.
	(tree_out::tree_decl): Cope with redirects.
	(depset::hash::add_dependency): Likewise.
	(depset::hash::add_specialization): Add redirect for partials.
	(depset::hash::add_mergeable): Likewise.
	(module_state::write_cluster): Assert no redirects here.
	(module_state::write): Check redirects here.
	gcc/testsuite/
	* g++.dg/modules/global-3_a.C: Disable.
	* g++.dg/modules/tpl-spec-6_[ab].C: New.

From-SVN: r272705
2019-06-26 18:14:37 +00:00
Nathan Sidwell
626883fa68 module.cc (trees_{in,out}::note_definition): Rename to ...
gcc/cp/
	* module.cc (trees_{in,out}::note_definition): Rename to ...
	 (trees_{in,out}::assert_definition): ... here.  Update callers.

From-SVN: r272698
2019-06-26 15:56:34 +00:00
Nathan Sidwell
0a234cae43 cp-tree.h (match_mergeable_specialization): Add insert parm.
gcc/cp/
	* cp-tree.h (match_mergeable_specialization): Add insert parm.
	* pt.c (match_mergeable_specialization): Add insert parm.
	* module.cc (depset::entity_kind): Add EK_MAYBE_SPEC.
	(depset::disc_bits): Delete DB_FRIEND_BIT, ADD DB_PSEUDO_SPEC_BIT.
	(depset::is_friend): Delete.
	(depset::is_pseudo_spec): Add.
	(trees_out::tree_decl): Some specializations are findable by name.
	(trees_in::tree_value): Mergeables have an explicit kind.
	(trees_in::tree_node): Protect more.
	(trees_{in,out{::key_mergeable): Explicitly encode key kind.
	(depset::hash::add_dependency): Support EK_MAYBE_SPEC.
	(specialization_add): Add some consistency checking.
	(depset::hash::add_specialization): Specialization might be an
	import.
	(depset::hash::add_mergeable_horcrux): New.
	(sort_mergeables): Add horcrux deps.
	(module_state::write_cluster): Don't mark cdf_is_friend.
	gcc/testsuite/
	* g++.dg/modules/indirect-3_[ab].C: Reenable. Adjust scans.

From-SVN: r272696
2019-06-26 14:46:58 +00:00
Nathan Sidwell
f114147110 module.cc (module_state:note_cmi_name): New.
gcc/cp/
	* module.cc (module_state:note_cmi_name): New.
	(module_state::read_config): Use it.
	(module_state::check_read): Likewise.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-3.C: Adjust diags.
	* g++.dg/modules/atom-preamble-3.C: Likewise.
	* g++.dg/modules/bad-mapper-1.C: Likewise.
	* g++.dg/modules/bad-mapper-3.C: Likewise.
	* g++.dg/modules/circ-1_c.C: Likewise.
	* g++.dg/modules/flag-1_b.C: Likewise.
	* g++.dg/modules/import-2.C: Likewise.
	* g++.dg/modules/mod-stamp-1_d.C: Likewise.
	* g++.dg/modules/p0713-3.C: Likewise.

From-SVN: r272657
2019-06-25 18:47:13 +00:00
Nathan Sidwell
63d76ba153 Revert late specialization insertion.
gcc/cp
	* module.cc (depset): Delete DB_OOT_SPEC_BIT.
	(depset::~depset): Remove deletion.
	(trees_out::key_mergeable): Assert specialization is marked.
	(depset::hash::add_dependency): Assert no late specializations.
	gcc/testsuite
	* g++.dg/modules/modules.exp: Expand dg-module-do capabilities.
	* g++.dg/modules/indirect-3_a.C: Disable.

From-SVN: r272617
2019-06-24 13:30:50 +00:00
Nathan Sidwell
0cce6e60c6 Merge trunk r272583.
From-SVN: r272609
2019-06-23 22:52:08 +00:00
Nathan Sidwell
41debb0329 modules.cc (depset): Add DB_OOT_SPEC_BIT.
gcc/cp/
	* modules.cc (depset): Add DB_OOT_SPEC_BIT.
	(depset::~depset): Free the spec entry if we own it.
	(trees_{in,out}::note_definition): Check template result isn't
	there.
	(depset::hash::add_dependency): Correctly insert discovered
	non-member template instantiations.

From-SVN: r272562
2019-06-21 19:13:13 +00:00
Nathan Sidwell
1a60f0650e modules.cc (note_defs): New checking hash table.
gcc/cp/
	* modules.cc (note_defs): New checking hash table.
	(trees_{in,out}::note_definition): New checkers
	(trees_in::read_{function,class,var,enum}_def): Add maybe_template
	arg, use it.  Note definitions.
	(member_owned_by_class): New, extracted from ...
	(trees_out::mark_class_member): ... here.  Call it.
	(trees_out::write_class_def): Only write the owned definitions.
	(trees_out::write_definition): Note definition.
	(trees_in::read_definition): Pass maybe_template to readers.
	(module_state::write): Reset note_defs hash.
	(init_module_processing): Init it.
	(finish_module_processing): Delete it.

From-SVN: r272557
2019-06-21 17:37:01 +00:00
Nathan Sidwell
5a41b8d65f modules.cc (dumper::operator ()): Print indentation level.
gcc/cp/
	* modules.cc (dumper::operator ()): Print indentation level.
	gcc/testsuite/
	* g++.dg/modules/scc-1.C: Adjust dump scan.

From-SVN: r272548
2019-06-21 14:12:20 +00:00
Nathan Sidwell
7ee18e5293 modules.cc (node_template_info): Enums are awkwarder.
gcc/cp/
	* modules.cc (node_template_info): Enums are awkwarder.
	gcc/testsuite/
	* g++.dg/modules/enum-4_[ab].C: New.

From-SVN: r272546
2019-06-21 13:35:38 +00:00
Nathan Sidwell
839e6349c0 module.cc (tree_out::mark_class_def): Mark bitfield's representative field.
Bitfields.
	gcc/cp/
	* module.cc (tree_out::mark_class_def): Mark bitfield's
	representative field.
	gcc/testsuite/
	* g++.dg/modules/bfield-1_[ab].C: New.

From-SVN: r272522
2019-06-20 20:58:09 +00:00
Nathan Sidwell
a487221d9c module.cc (enum tree_tag): Add tt_thunk.
Thunks.
	gcc/cp/
	* module.cc (enum tree_tag): Add tt_thunk.
	(trees_out::tree_decl): Emit it.
	(trees_out::tree_value): Assert we don't accidentally meet a
	thunk.
	(trees_in::tree_node): Read it.
	(trees_out::{mark,write}_class_def): Emit thunks by value.
	(trees_in::read_class_def): Install thunks.
	gcc/testsuite/
	* g++.dg/modules/thunk-1_[ab].C: New.

From-SVN: r272521
2019-06-20 20:29:51 +00:00
Nathan Sidwell
ff6d81e3e8 parser.c (cp_lexer_tokenize): Skip pragmas.
gcc/cp/
	* parser.c (cp_lexer_tokenize): Skip pragmas.
	* lex.c (module_preprocess_token): Likewise.
	gcc/testsuite/
	* g++.dg/modules/pragma-1_[ab].[HC]: New.
	* g++.dg/modules/tname-spec-1_b.C: Move include earlier.

From-SVN: r272519
2019-06-20 19:38:34 +00:00
Nathan Sidwell
d663910d7c Deconstruct types.
gcc/cp/
	* module.cc (enum tree_tag): Add tt_typename_decl,
	tt_derived_type, tt_variant_type.
	(trees_out::tree_decl): Stream typename types.
	(trees_out::tree_type): Emit tt_{derived,variant}_type records.
	(trees_in::tree_node): Add tt_typename_decl, tt_derived_type,
	tt_variant_type handling.
	gcc/testsuite/
	* g++.dg/modules/class-3_b.C: Adjust dump scan.
	* g++.dg/modules/tname-spec-1_[ab].[HC]: New.
	* g++.dg/modules/typename-1_[ab].C: New.

From-SVN: r272517
2019-06-20 18:11:41 +00:00
Nathan Sidwell
412a45a062 Stream mergeables inline.
gcc/cp/
	* module.cc (depset): Add DB_MERGEABLE_BIT.
	(depset::is_mergeable): New.
	(depset::hash::set_for_mergeable): Delete.
	(trees_{in,out}::tree_mergeable): Delete.
	(tress_{in,out}::key_mergeable): New.
	(trees_out::tags): New enum.
	(trees_out::mark_{mergeable,merged}): New.
	(trees_out::reserve_mergeable,unset_for_mergeable): Delete.
	(trees_out::{insert,ref_node}): Adjust.
	(trees_out::core_vals): Don't stream tpl-tpl-parm contexts.
	(trees_out::tree_decl): tpl-tpl-parms not found by name.
	(trees_{in,out}::tree_value): Stream merging info inline.
	(trees_{in,out}::tpl_header): Take template, not parms.
	(trees_out::mark_declaration): Mark the template parms.
	(depset::hash::find_dependencies): Adjust mergeable walk.
	(depset::hash::add_mergeable): Adjust.
	(module_state::sort_mergeables): Replace with ...
	(sort_mergeables): ... this.
	(enum cluster_tag): Delete ct_mergeable.
	(module_state::write_cluster): Determine mergable ordering
	earlier.  Don't write a mergeable table.
	(module_state::read_cluster): No mergeables to deal with here.
	(module_state::write): Move cluster member dumping to write_cluster.
	* name-lookup.h (match_mergeable_decl): Drop tpl_args parm.
	* name-lookup.c (check_mergeable_decl): Likewise.  Update callers.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_a.C: Adjust dump scans.
	* g++.dg/modules/friend-1_a.C: Likewise.
	* g++.dg/modules/indirect-[234]_[bc].C: Likewise.
	* g++.dg/modules/inst-[23]_[ab].C: Likewise.
	* g++.dg/modules/part-3_[cd].C: Likewise.
	* g++.dg/modules/scc-1.C: Likewise.
	* g++.dg/modules/tpl-friend-[12]_a.C: Likewise.
	* g++.dg/modules/tpl-spec-[12345]_[ab].C: Likewise.
	* g++.dg/modules/vmort-2_b.C: Likewise.

From-SVN: r272488
2019-06-19 22:15:26 +00:00
Nathan Sidwell
d10eccc41c Merge trunk r272419.
From-SVN: r272420
2019-06-18 13:40:53 +00:00
Nathan Sidwell
5a56197b26 module.cc (specialization_cmp): Deal with more equivalencies.
gcc/cp/
	* module.cc (specialization_cmp): Deal with more equivalencies.
	(depset_cmp): New, cloned and adjusted from cluster_cmp.
	(depset::hash::connect): Use it.

From-SVN: r272419
2019-06-18 13:15:23 +00:00
Nathan Sidwell
5757e0421a module.cc (trees_out::fn_parms): Stream canonical type.
gcc/cp/
	* module.cc (trees_out::fn_parms): Stream canonical type.
	(depset::hash::add_dependency): Adjust static inline check.
	gcc/testsuite/
	* g++.dg/modules/mutual-friend.ii: New.

From-SVN: r272398
2019-06-17 18:59:01 +00:00
Nathan Sidwell
ce58251f90 module.cc (depset::hash::add_dependency): Don't register internal entities when in a header module.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Don't register
	internal entities when in a header module.
	(depset::hash::add_binding): Add internal entities in header modules.
	gcc/testsuite/
	* g++.dg/modules/stat-tpl-1_a.H: New.

From-SVN: r272314
2019-06-14 21:19:40 +00:00
Nathan Sidwell
04c45fd07e module.cc (depset::hash::add_dependency): Inhibit internal linkage setting on functions.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Inhibit internal
	linkage setting on functions.
	(cluster_cmp): We can meet matching using decls.

From-SVN: r272313
2019-06-14 20:45:56 +00:00
Nathan Sidwell
993696ab05 module.cc (depset::hash::add_dependency): Unnamed elaborated types have no linkage.
gcc/cp/
	* module.cc (depset::hash::add_dependency): Unnamed elaborated
	types have no linkage.
	gcc/testsuite/
	* g++.dg/modules/enum-5_[ab].[HC]: New.

From-SVN: r272312
2019-06-14 19:33:47 +00:00
Nathan Sidwell
303b4abb58 module.cc (module_state::{read,write}_cluster): Check stat hack is for implicit typedefs.
gcc/cp/
	* module.cc (module_state::{read,write}_cluster): Check stat hack
	is for implicit typedefs.

From-SVN: r272311
2019-06-14 18:57:55 +00:00
Nathan Sidwell
20f1424c05 module.cc (trees_out::tree_type): Simplify if-tree.
gcc/cp/
	* module.cc (trees_out::tree_type): Simplify if-tree.

From-SVN: r272310
2019-06-14 18:41:43 +00:00
Nathan Sidwell
690d2eadc0 module.cc (trees_{in,out}::core_vals): Stream original_type of type of typedefs, not their type.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream original_type of type of
	typedefs, not their type.
	(trees_out::tree_type): Stream type_name of typedefs.
	(trees_out::tree_value): Insert the type of a typedef.
	(trees_in::tree_value): Reconstruct the type of a typedef.
	gcc/testsuite/
	* g++.dg/modules/tdef-4_[abc].C: New.
	* g++.dg/modules/class-3_b.C: Adjust scan.

From-SVN: r272297
2019-06-14 18:04:34 +00:00
Nathan Sidwell
d7f4c4389e module.cc (binding_cmp): There can be an implicit and non-implicit type_decl.
gcc/cp/
	* module.cc (binding_cmp): There can be an implicit and
	non-implicit type_decl.
	* name-lookup.c (check_mergeable_decl): Check implicitness of
	type_decl.

From-SVN: r272286
2019-06-14 12:35:25 +00:00
Nathan Sidwell
6bcf78c2a3 module.cc (depset::hash::add_specializations): Partial instantiations need their template.
gcc/cp/
	* module.cc (depset::hash::add_specializations): Partial
	instantiations need their template.
	gcc/testsuite/
	* g++.dg/modules/tpl-tpl-mem-1_[ab].C: New.

From-SVN: r272246
2019-06-13 14:28:31 +00:00
Nathan Sidwell
cbc8f25dfd syncing version
From-SVN: r272172
2019-06-11 20:42:03 +00:00
Nathan Sidwell
446396ffea fix typo
From-SVN: r272171
2019-06-11 20:41:44 +00:00
Nathan Sidwell
784c087a43 Merge trunk r272149.
From-SVN: r272153
2019-06-11 13:07:17 +00:00
Nathan Sidwell
bb0b8f3c3b missed changelog
From-SVN: r272149
2019-06-11 12:32:12 +00:00
Nathan Sidwell
e96463943e module.cc (module_state::read_location): Don't map UNKNOWN_LOCATION to loc.
gcc/cp/
	* module.cc (module_state::read_location): Don't map
	UNKNOWN_LOCATION to loc.
	(module_state::read_locations): Don't rely on that.
	gcc/testsuite/
	* g++.dg/modules/predef-2{.h,_[ab].C}: New.

From-SVN: r272128
2019-06-10 20:03:21 +00:00
Nathan Sidwell
6172dc2a5f module.cc (loc_spans::init): Correct macro range ordering.
gcc/cp/
	* module.cc (loc_spans::init): Correct macro range ordering.
	(module_state::write_locations): Fix more off-by-ones.
	gcc/testsuite/
	* g++.dg/modules/predef-1.[hC]: New.

From-SVN: r272118
2019-06-10 13:23:13 +00:00
Nathan Sidwell
6f57f5d72b missed changelog
From-SVN: r272052
2019-06-07 20:36:24 +00:00
Nathan Sidwell
fb988b5b3b module.cc (module_state::write_env): New.
gcc/cp/
	* module.cc (module_state::write_env): New.
	(module_state::write): Call it.

From-SVN: r272049
2019-06-07 19:13:43 +00:00
Nathan Sidwell
75d2a29d53 Make-lang.in (REVISION_c): Don't test it.
gcc/cp/
	* Make-lang.in (REVISION_c): Don't test it.
	* module.cc (module_state::write_locations): Fix off-by-one thinko.

From-SVN: r272048
2019-06-07 18:35:20 +00:00
Nathan Sidwell
ffcd1dcb5b module.cc (loc_spans::init): Add lmaps parm, separate main from forced header locs.
gcc/cp/
	* module.cc (loc_spans::init): Add lmaps parm, separate main from
	forced header locs.
	(loc_spans::SPAN_FIRST): New, use it for first span.
	(loc_spans::SPAN_MAIN): Just after the first span.
	gcc/testsuite/
	* g++.dg/modules/macro-5_[abc].[CH]: Adjust.

From-SVN: r272042
2019-06-07 13:14:16 +00:00
Nathan Sidwell
fa038ee5eb module.cc (dumper::MACRO): New flag.
gcc/cp/
	* module.cc (dumper::MACRO): New flag.
	(module_state::{write,install}_macros): Use it.
	(module_state::{undef,deferred}_macro): Likewise.
	gcc/
	* doc.invoke (-fdump-lang): Document.
	gcc/testsuite/
	* g++.dg/modules/macro-[35]_[abc].[CH]: Update.

From-SVN: r272041
2019-06-07 12:24:26 +00:00
Nathan Sidwell
c3907a8619 module.cc (bytes_out::print_time): New.
gcc/cp/
	* module.cc (bytes_out::print_time): New.
	(module_state::write_readme): Dump some environmental data.

From-SVN: r272039
2019-06-07 12:13:38 +00:00
Nathan Sidwell
7a1a5f3c44 syncing version
From-SVN: r272015
2019-06-06 18:02:35 +00:00
Nathan Sidwell
ea30e72655 Tweak svnversion
From-SVN: r272014
2019-06-06 17:06:51 +00:00
Nathan Sidwell
78270d26a6 Fixup revision setting
From-SVN: r272008
2019-06-06 15:14:25 +00:00
Nathan Sidwell
0f7acae37e Make-lang.in (MODULE_REVISION): Read from Changelog.modules.
gcc/cp/
	* Make-lang.in (MODULE_REVISION): Read from Changelog.modules.

From-SVN: r272004
2019-06-06 14:52:57 +00:00
Nathan Sidwell
dd5992f3c5 module.cc (dumper::MAPPER): New flag.
gcc/cp/
	* module.cc (dumper::MAPPER): New flag. Use it on mapper things.
	(dumper::push): Only do blank line when starting a new module
	nest.

From-SVN: r271973
2019-06-05 18:59:27 +00:00
Nathan Sidwell
ac4c63f30f module.cc (trees_out::tree_type): We can meet ttps here.
gcc/cp/
	* module.cc (trees_out::tree_type): We can meet ttps here.
	(trees_{in,out}::tree_mergeable): Stream skeleton before locating info.
	gcc/testsuite/
	* g++.dg/modules/ttp-3_[ab].C: New.
	* g++.dg/modules/builtin-1_[ab].C: Adjust module scan.
	* g++.dg/modules/indirect-[234]_b.C: Likewise.
	* g++.dg/modules/inst-[1234]_[ab].C: Likewise.

From-SVN: r271972
2019-06-05 18:40:51 +00:00
Nathan Sidwell
9408c11acd module.cc (trees_out::core_vals): Template type parms are their own canonical.
gcc/cp/
	* module.cc (trees_out::core_vals): Template type parms are their
	own canonical.
	(trees_in::finish_type): Never subst a canonical type parm for the type.
	gcc/testsuite/
	* g++.dg/modules/ttp-2_[ab].C: New.

From-SVN: r271962
2019-06-05 13:38:27 +00:00
Nathan Sidwell
c4815c2e20 module.cc (global_tree_arys): Add c_global_trees.
gcc/cp/
	* module.cc (global_tree_arys): Add c_global_trees.
	gcc/c-family/
	* c-common.h (enum c_tree_index): Add CTI_MODULE_HWM, move voltale
	entries below it.

From-SVN: r271956
2019-06-05 12:05:41 +00:00
Nathan Sidwell
92314963e5 Merge trunk r271953.
From-SVN: r271955
2019-06-05 11:50:04 +00:00
Nathan Sidwell
e68775bfa3 tree-core.h (enum tree_index): Add TI_MODULE_HWM.
gcc/
	* tree-core.h (enum tree_index): Add TI_MODULE_HWM.
	gcc/cp/
	* cp-tree.h (enum cp_tree_index): Add CPTI_MODULE_HWM  Move
	volatile CPTI's below it.
	(CPTI_STD_IDENTIFIER, std_identifier): Delete.
	(DECL_NAMESPACE_STD): Simplify.
	* decl.c (initialize_predefined_identifiers): Drop std_identifier.
	(cxx_init_decl_processing): Adjust std_node creation. Use push/pop
	nested namespace for std.
	(cxx_builtin_function, cxx_builtin_function_ext_scope): Use
	push/pop nested namespace for std.
	* except.c (init_exception_processing): Likewise.
	* rtti (init_rtti_processing): Likewise.
	* module.cc (global_tree_arys): Restrict C & C++ trees.
	* name-lookup.c (push_namespace): Set location if it was a
	builtin.
	gcc/testsuite/
	* g++.dg/modules/std-1_[ab].C: New.

From-SVN: r271953
2019-06-05 10:39:28 +00:00
Nathan Sidwell
5e722ecf5c class.c (maybe_add_class_template_decl): Mark (some) local templates.
gcc/cp/
	* class.c (maybe_add_class_template_decl): Mark (some) local
	templates.
	* module.cc (friend_from_decl_list): Some friends are overloads.
	(trees_{in,out}::core_vals): Stream TREE_VEC CHAIN.
	(trees_out::mark_class_def): Directly mark friend decls.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-6_[ab].C: New.

From-SVN: r271924
2019-06-04 18:47:16 +00:00
Nathan Sidwell
de7fd0b983 tpl-friend-5_[ab].C: New.
gcc/testsuite/
	* g++.dg/modules/tpl-friend-5_[ab].C: New.

From-SVN: r271923
2019-06-04 17:23:19 +00:00
Nathan Sidwell
3541a28521 name-lookup.c (lookup_type_scope_1): Look in imported slots too.
gcc/cp/
	* name-lookup.c (lookup_type_scope_1): Look in imported slots too.
	gcc/testsuite/
	* g++.dg/modules/class-8_[ab].C: New.

From-SVN: r271922
2019-06-04 17:01:28 +00:00
Nathan Sidwell
7e87e9f49e name-lookup.c (lookup_type_scope_1): Reimplement, handle local and namespace scopes separately.
gcc/cp/
	* name-lookup.c (lookup_type_scope_1): Reimplement, handle local
	and namespace scopes separately.

From-SVN: r271911
2019-06-04 15:16:54 +00:00
Nathan Sidwell
0cf0ada9f9 module.cc (friend_from_decl_list): New.
gcc/cp/
	* module.cc (friend_from_decl_list): New.
	(trees_out::{tree_decl,{write,mark}_class_def}): Use it.
	(trees_in::{tree_node,read_class_def}): Likewise.

From-SVN: r271882
2019-06-03 19:29:36 +00:00
Nathan Sidwell
bf24ad34b5 Template friends of templates.
gcc/testsuite/
	* g++.dg/modules/tpl-tpl-friend-1_[ab].C: New.

From-SVN: r271880
2019-06-03 18:41:06 +00:00
Nathan Sidwell
ed6c098d21 Non-template friends of templates.
gcc/testsuite/
	* g++.dg/modules/tpl-friend-4_[ab].C: New.

From-SVN: r271879
2019-06-03 18:36:27 +00:00
Nathan Sidwell
0704afc24b Non-template friends of templates.
gcc/cp/
	* module.cc (has_definition): Use DECL_SAVED_TREE.
	(trees_{in,out}::{read,write}_class_def): Stream definitions of
	local friends.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-3_[ab].C: New.

From-SVN: r271878
2019-06-03 18:29:16 +00:00
Nathan Sidwell
1692b6f689 Merge trunk r271874.
From-SVN: r271875
2019-06-03 17:08:03 +00:00
Nathan Sidwell
9d1f0afc4d Non-template friends of templates.
gcc/cp/
	* module.cc (depset::disc_bits): Add DB_FRIEND.
	(depset::is_friend): New.
	(enum tree_tag): Add tt_friend_template.
	(trees_out): Add section field, init it.
	(trees_out::tree_decl): Deal with template friends.  Assert lazy
	ordering.
	(trees_in::tree_node): Add tt_friend_template support.
	(trees_{in,out}::{read,write,mark}_class_def):  Deal with friend
	templates.
	(depset::hash::add_dependency): Notice friend templates.
	(depset::hash::add_specializations): Add non-specializations.
	(depset::hash::find_dependencies): Specializations depend on their
	template & args.
	(enum ct_decl_flags): Add cdf_is_friend.
	(module_state::write_cluster): Set it.
	(module_state::write): Add specializations before bindings.
	Expand cluster dump.
	* pt.c (push_template_decl_real): Friend template's DECL_CHAIN
	points at the befriending class.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-2_[ab].C: New.
	* g++.dg/modules/tpl-friend-1_a.C: Adjust scans.

From-SVN: r271874
2019-06-03 15:36:51 +00:00
Nathan Sidwell
7a8dc3649b Non-template friends of templates.
gcc/cp/
	* module.cc (trees_{in,out}::{read,write}_class_def): Stream
	friend lists and decl lists specially.
	(trees_out::mark_class_def): Mark local friend decls.
	(depset::hash::add_specializations): Don't add non-specializations
	that are in the table.
	* pt.c (push_template_decl_real): Mark non-pushed friend templates.
	gcc/testsuite/
	* g++.dg/modules/tpl-friend-1_[ab].C: New.

From-SVN: r271809
2019-05-31 11:00:59 +00:00
Nathan Sidwell
85476fad7e decl.c (duplicate_decls): Remove duplicate assert.
gcc/cp/
	* decl.c (duplicate_decls): Remove duplicate assert.
	* pt.c (build_template_decl): Set RESULT & TYPE of the template
	here ...
	(process_partial_specialization): ... not here ...
	(add_inherited_template_parms): ... nor here ...
	(push_template_decl_Real): ... nor here.  Refactor.
	gcc/
	* doc/invoke.texi (C++ Modules): Document atomicity.
	gcc/fortran/
	* cpp.c (gfc_cpp_add_dep, gfc_cpp_add_target, gfc_cpp_init):
	Rename mrules to mkdeps.

From-SVN: r271745
2019-05-29 16:27:33 +00:00
Nathan Sidwell
7e9e2b43f5 module.cc (maybe_add_bmi_prefix): Replace FORCE with LEN_P.
gcc/cp/
	* module.cc (maybe_add_bmi_prefix): Replace FORCE with LEN_P.
	Set it.
	(create_dirs): Input is guarantueed unique.
	(module_state::check_read): Show full BMI filename in errors.
	(finish_module_processing): Likewise. Rename output atomically.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-3.C: Adjust diagnostics.
	* g++.dg/modules/atom-preamble-3.C: Likewise.
	* g++.dg/modules/bad-mapper-[13].C: Likewise.
	* g++.dg/modules/circ-1_c.C: Likewise.
	* g++.dg/modules/flag-1_b.C: Likewise.
	* g++.dg/modules/import-2.C: Likewise.
	* g++.dg/modules/internal-1.C: Likewise.
	* g++.dg/modules/mod-stamp-1_d.C: Likewise.
	* g++.dg/modules/p0713-3.C: Likewise.

From-SVN: r271742
2019-05-29 14:55:34 +00:00
Nathan Sidwell
6d6f1822d1 decl.c (duplicate_decls): Assert a template newdecl has no specializations.
* decl.c (duplicate_decls): Assert a template newdecl has no
	specializations.

From-SVN: r271714
2019-05-28 17:05:22 +00:00
Nathan Sidwell
2164265365 Revert inadvertent commits.
gcc/cp/
	* pt.c (push_template_decl_real): Here.
	* decl.c (duplicate_decls): Here.

From-SVN: r271711
2019-05-28 15:06:49 +00:00
Nathan Sidwell
4684777be2 Merge trunk r271702.
From-SVN: r271709
2019-05-28 14:19:17 +00:00
Nathan Sidwell
762c582bea module.cc (loc_spans): Make spans a vec.
gcc/cp/
	* module.cc (loc_spans): Make spans a vec.
	(module_state::{read,write}_locations): Use vec.

From-SVN: r271581
2019-05-23 20:51:38 +00:00
Nathan Sidwell
7258717682 module.cc (trees_in): Replace auto_vec with vec.
gcc/cp/
	* module.cc (trees_in): Replace auto_vec with vec.

From-SVN: r271579
2019-05-23 20:43:28 +00:00
Nathan Sidwell
0fac6831b9 Template template parms, and a bunch of other stuff
Template template parms, and a bunch of other stuff
	gcc/cp/
	* cp-tree.h (DECL_TEMPLATE_INFO): Augment docs.
	* module.cc (depset::clear_flag_bit): New.
	(depset::is_unreached): Replace is_implicit_specialization.
	(depset::is_marked): Replace is_first_dep_repurposed.
	(dumper::impl::nested_name): Template args may be NULL.
	(trees_{in,out}::core_vals): Template decl result & args streamed
	with decl.
	(trees_out::tree_decl): TTPs by value.
	(trees_{in,out}::tree_value): Reorder body streaming, stream more
	template bits.
	(trees_out::tree_mergeable): Redo specialization tagging.
	(trees_out::mark_class_def): Only mark decls on decl list.
	(trees_out::mark_declaration): Simplify.
	(depset::hash::add_dependency): Deal with reaching unreached.
	(specialization_add): Grab all instantiations from this TU.
	(depset::hash::add_specialiazations): Determing is_unreached.
	(depset::hash::find_dependencies): Iterate until no more unreached
	reached.
	(module_state::write_unnamed): Adjust.
	* pt.c (tsubst_function_decl): Set DECL_MODULE_OWNER.
	gcc/testsuite/
	* g++.dg/modules/ttp-1_[ab].C: New.
	* g++.dg/modules/indirect-[234]_[bc].C: Adjust scans.
	* g++.dg/modules/inst-[24]_ab.C: Likewise.

From-SVN: r271578
2019-05-23 20:37:41 +00:00
Nathan Sidwell
045fa6bebe module.cc (dumper::impl::nested_name): Cope with TTPs.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Cope with TTPs.
	(depset:hash::connect): Return the vec.
	(depset::tarjan): Create and return the vec.
	(module_state::write_{bindings,unnamed}): SCCS are in a vec.
	(module_state::write): Likewise.

From-SVN: r271551
2019-05-23 11:16:16 +00:00
Nathan Sidwell
aa6ee0cd0f module.cc (depset::hash::hash): Create worklist.
gcc/cp/
	* module.cc (depset::hash::hash): Create worklist.
	(depset::tarjan::tarjan): Create stack.
	(depset::depset): Create deps.

From-SVN: r271519
2019-05-22 19:03:44 +00:00
Nathan Sidwell
e7ddc4f7d8 Stream binfos properly (again).
gcc/cp/
	* module.cc (trees_out::mark_node): Binfos may be marked.
	(trees_{in,out}::start): Binfos may be streamed.
	(trees_{in,out}::core_vals): Likewise.
	(trees_{in,out}::tree_node): Reachable binfos may always be
	inserted.
	(trees_{in,out}::{read,write}_binfos): Delete.
	(trees_out::mark_class_def): Mark the binfo heirarchy.
	(trees_{in,out}::{read,write}_class_def): Stream binfos here.

From-SVN: r271518
2019-05-22 18:58:17 +00:00
Nathan Sidwell
3a42b90dcc module.cc (trees_out::mark_declaration): Add do_defn parm, mark definition if set.
gcc/cp/
	* module.cc (trees_out::mark_declaration): Add do_defn parm, mark
	definition if set.  Adjust callers.
	(trees_out::mark_definition): Merge into mark_declaration.

From-SVN: r271481
2019-05-21 18:56:49 +00:00
Nathan Sidwell
176bc67c7a Merge trunk r271478.
From-SVN: r271480
2019-05-21 18:31:03 +00:00
Nathan Sidwell
ee60276eab Merge trunk r271467.
From-SVN: r271478
2019-05-21 17:37:03 +00:00
Nathan Sidwell
e8cd1617dd Merge trunk r271420.
From-SVN: r271426
2019-05-20 16:44:51 +00:00
Nathan Sidwell
b92822cfc9 Merge trunk r271338.
From-SVN: r271347
2019-05-17 19:29:40 +00:00
Nathan Sidwell
f0f1d00906 module.cc (trees_out::mark_class_member): Add do_defn parm.
gcc/cp/
	* module.cc (trees_out::mark_class_member): Add do_defn parm.
	Mark the definition.
	(trees_out::mark_class_def): Adjust.
	(depset::hash::find_dependencies, module_state::write_cluster):
	Use mark_declaration.

From-SVN: r271337
2019-05-17 17:55:39 +00:00
Nathan Sidwell
d53b438cf1 module.cc (trees_out::mark_node): Drop OUTERMOST parm.
gcc/cp/
	* module.cc (trees_out::mark_node): Drop OUTERMOST parm.  Don't
	consider templateness.
	(trees_out::mark_declaration): New.
	(trees_out::mark_class_member): New.
	(trees_out::mark_class_def): Use mark_class_member.
	(depset::hash::find_dependencies): Adjust.
	(module_state::write_cluster): Likewise.

From-SVN: r271333
2019-05-17 17:16:27 +00:00
Nathan Sidwell
8235c316a9 module.cc (trees_{in,out}::tpl_parms): Rename to ...
gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms): Rename to ...
	(trees_{in,out}::tpl_headr): ... here.  Stream the whole parms.
	(trees_out::tree_type): Assert no surprising
	TEMPLATE_TEMPLATE_PARM.
	(trees_{in,out}::tree_value): Stream template template parms.

From-SVN: r271332
2019-05-17 16:56:29 +00:00
Nathan Sidwell
24abd06faa module.cc (dumper::operator ()): Add null check.
gcc/cp/
	* module.cc (dumper::operator ()): Add null check.
	(trees_out::mark_node): Permit fixed nodes.
	(trees_out::tree_decl, trees_in::tree_node): More anon.
	* name-lookup.c (mark_pending_on_decl): Fix field marking thinko.
	(lookup_by_ident): Lookup anon.
	(get_lookup_ident): Likewise.
	gcc/testsuite/
	* g++.dg/modules/anon-1_[abc].C: New.

From-SVN: r271288
2019-05-16 13:08:07 +00:00
Nathan Sidwell
87947cc4f8 module.cc (depset::DB_HIDDEN_BIT): New, add accessors.
gcc/cp/
	* module.cc (depset::DB_HIDDEN_BIT): New, add accessors.
	(depset::hash::add_binding): Set hidden binding bit.
	(binding_cmp): Adjust hidden.
	(enum ct_bind_flags): New.
	(module_state::{read,write}_cluster): Reimplement binding flag
	streaming.
	* name-lookup.c (name_lookup::adl_namespace_fns): Skip hidden.
	gcc/testsuite/
	* g++.dg/modules/friend-2_[ab].C: New.

From-SVN: r271214
2019-05-15 15:03:06 +00:00
Nathan Sidwell
3c595fb47d module.cc (trees_in::tree_value): New, broken out of ...
gcc/cp/
	* module.cc (trees_in::tree_value): New, broken out of ...
	(trees_in::tree_node): ... here.  Call it.
	(trees_{in,out}::lang_type_vals): Don't stream befriending classes.
	gcc/testsuite/
	* g++.dg/modules/friend-1_[abc].C: New.

From-SVN: r271188
2019-05-14 19:27:22 +00:00
Nathan Sidwell
68528ea4b3 Cleanup merging, friend streaming.
gcc/cp/
	* module.cc (trees_{in,out}::tree_mergeable): Reimplement.
	(trees_out::tree_value): Significant adjustment.
	(trees_in::tree_node): Likewise.
	(trees_{in,out}::tree_node_specific): Move into ...
	(trees_{in,out}::tree_node_bools): ... here.
	(trees_out::mark_mergeable): Delete.
	(trees_{in,out}::insert): Adjust.
	(trees_{in,out}::lang_vals): New, broken out of ...
	(trees_node_vals): ... here.  Call them.
	(trees_out::ref_node): Process mergeable cases.
	(trees_{in,out}::tpl_parms): Adjust.
	(trees_{in,out}::{read,write}_class_def): Stream and connect
	friend lists.
	(binding_cmp): Order hidden decls.
	(module_state::write_cluster): Adjust mergeable streaming.
	(module_State::read_cluster): Hide hidden overloads.
	* name-lookup.c (extract_module_binding): Don't skip hidden.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_a.C: Adjust scans.
	* g++.dg/modules/class-3_b.C: Likewise.
	* g++.dg/modules/indirect-[24]_[bc].C: Likewise.
	* g++.dg/modules/inst-[123]_[bcd].C: Likewise.

From-SVN: r271187
2019-05-14 18:53:22 +00:00
Nathan Sidwell
77f9e67e98 decl.c (duplicate_decls): Don't check moduleness on friend decl.
gcc/cp/
	* decl.c (duplicate_decls): Don't check moduleness on friend decl.
	* pt.c (tsubst_friend_function): Set module ownership.

From-SVN: r271072
2019-05-10 18:56:39 +00:00
Nathan Sidwell
28c2c14231 module.cc (trees_{in,out}::{read,write}_function_def): Serialize FRIEND_CONTEXT.
gcc/cp/
	* module.cc (trees_{in,out}::{read,write}_function_def): Serialize
	FRIEND_CONTEXT.
	(trees_{in,out}::{read,write}_class_def): Reattach befriending classes.

From-SVN: r271071
2019-05-10 18:35:38 +00:00
Nathan Sidwell
a33b0b13dd decl.c (duplicate_decls): Check and adjust anticipated builtin decls.
gcc/cp/
	* decl.c (duplicate_decls): Check and adjust anticipated builtin
	decls.
	* friend.c (do_friend): Set module ownership.
	* module.cc (tree_{in,out}::lang_decl_vals): Conditionally stream
	context and befriending classes.
	* name-lookup.c (init_global_partition): Header unit uses global
	slot.
	* parser.c (cp_parser_template_declaration): Conditionalize export
	warning.

From-SVN: r271068
2019-05-10 17:53:14 +00:00
Nathan Sidwell
932bd31ce9 Partial specializations!
gcc/cp/
	* module.cc (trees_out::tree_mergeable): Correct finding of
	general template.
	(trees_in::tree_mergeable): Recover a merged partial
	specialization.
	(depset::hash::add_specializations): Deal with partial
	specializations.
	(enum ct_decl_flags): New.
	(module_state::write_cluster): Set specialization flags.
	(module_state::read_cluster): Install specializations.
	(install_specialization): New.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-5_[ab].C: New.

From-SVN: r271067
2019-05-10 15:14:00 +00:00
Nathan Sidwell
c0440f6bd3 gcc/cp/
* module.cc
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_[bc].C: Adjust module dump scans.
	* g++.dg/modules/inst-[1234]_[ab].C: Likewise.
	* g++.dg/modules/vmort-2_c.C: Likewise.

From-SVN: r271041
2019-05-09 19:41:38 +00:00
Nathan Sidwell
4dc260a470 Atomically mark template's DECL_TEMPLATE_RESULT, IMPLICIT_TYPEDEF's type
Atomically mark template's DECL_TEMPLATE_RESULT, IMPLICIT_TYPEDEF's type
	gcc/cp/
	* module.cc (enum tree_tag): Replace
	tt_{primary,secondary}_type with tt_typedef.
	(trees_out::mark_node): Mark the template_decl.
	(trees_out::maybe_insert_typeof): Delete.
	(trees_out::tree_decl): Stream the template_decl, name implicit
	templates. Always mark result & type.
	(trees_out::tree_type): Simplify implicit_typedef streaming.
	(trees_out::tree_value): Assert correct ordering.
	(trees_in::tree_node): Adjust tt switch.  Insert result & type.
	(module_state::{read,write}_cluster): Always add voldemort's type.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust module dump scans.
	* g++.dg/modules/indirect-[234]_[bc].C: Likewise.
	* g++.dg/modules/inst-[234]_[ab].C: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.
	* g++.dg/modules/using-4_a.C: Likewise.

From-SVN: r271040
2019-05-09 18:28:47 +00:00
Nathan Sidwell
e7166810f7 pr39425.C: Adjust errors.
gcc/testsuite/
	* g++.dg/template/pr39425.C: Adjust errors.
	* g++.old-deja/g++.pt/spec20.C: Adjust errors.

From-SVN: r270980
2019-05-07 19:46:02 +00:00
Nathan Sidwell
9388a87902 Merge trunk r270943.
From-SVN: r270979
2019-05-07 18:57:23 +00:00
Nathan Sidwell
207936eba2 mkdeps.h: Rename struct mrules to struct mkdeps.
libcpp/
	* include/mkdeps.h: Rename struct mrules to struct mkdeps.
	* mkdeps.c: Likewise.
	* include/cpplib.h (cpp_get_deps): Rename return type..
	* directives.c (cpp_get_deps): Likewise.
	* internal.h (struct cpp_reader): Rename deps field type.
	gcc/cp/
	* cp-tree.h (module_preprocess): Adjust first arg type.
	* module.cc: Rename mrules to mkdeps.
	* lex.c (module_preprocess_token): Rename mrules->mkdeps.
	gcc/c-family/
	* c-opts.c (handle_defered_opts): Rename struct deps to struc mkdeps.

From-SVN: r270923
2019-05-06 21:14:34 +00:00
Nathan Sidwell
88ed7e7d78 module.cc (enum tree_tag): Delete tt_builtin.
gcc/cp/
	* module.cc (enum tree_tag): Delete tt_builtin.
	(trees_out::tree_decl): Builtins are merely GMF entities.
	(tree_in::tree_node): Delete tt_builtin handling.
	* name-lookup.c (init_global_partition): New.
	(get_fixed_binding_slot): Populate global & partition slots.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_[ab].C: Adjust scans.
	* g++.dg/modules/by-name-1.C: Likewise.

From-SVN: r270922
2019-05-06 19:53:45 +00:00
Nathan Sidwell
33ececd4be cp-tree.h (global_purview_p): New.
gcc/cp/
	* cp-tree.h (global_purview_p): New.
	(module_header_p): Rename to ...
	(header_module_p): ... this.
	(named_module_p): New.  Replace ...
	(module_not_header_p): ... this.
	(module_global_p): ... delete.
	* module.cc (trees_out::tree_mergeable, module_state::write)
	(module_cpp_undef, finish_module_processing): Adjust.
	* name-lookup.c (get_fixed_binding_slot, record_mergeable_decl)
	(check_module_override, make_namespace): Adjust.
	* parser.c (cp_parser_translation_unit, cp_parser_module_name): Adjust.

From-SVN: r270920
2019-05-06 17:30:27 +00:00
Nathan Sidwell
6c95795c31 cp-tree.h (spec_entry): Moved from pt.c.
gcc/cp/
	* cp-tree.h (spec_entry): Moved from pt.c.
	(walk_specializations): Declare.
	(get_specializations_for_module): Delete.
	* module.cc (depset):  Add DB_FIRST_BIT.
	(depset::{is,set}_first_dep_repurposed): New.
	(depset::{,tarjan::}connect): Drop for_mergeable parm, use
	is_first_dep_repurposed instead.
	(spec_tuple): New.
	(specialization_add): New.
	(specialization_cmp): Adjust.
	(depset::hash::add_specializations): Reimplement.
	(depset::hash::add_mergable): Set set_first_dep_repurposed.
	(module_state::sort_mergeables): Adjust.
	(module_state::write): Likewise.
	* pt.c (spec_entry): Move to cp-tree.h
	(get_specializations, get_specializations_for_module): Replace
	with ...
	(walk_specializations): ... this.
	gcc/testsuite/
	* g++.dg/modules/inst-1_b.C: Adjust scans.

From-SVN: r270821
2019-05-02 19:26:41 +00:00
Nathan Sidwell
5bf72297fd module.cc (depset): Add DB_PARTIAL_BIT, is_partial_specialization, set_implicit_specialization.
gcc/cp/
	* module.cc (depset): Add DB_PARTIAL_BIT,
	is_partial_specialization, set_implicit_specialization.
	(depset::hash::add_dependency): Drop is_implicit parm.  Return the
	depset.
	(trees_out::tree_decl): Set the implicit bit myself.
	(depset::hash::add_specializations): Preliminary tweak.

From-SVN: r270782
2019-05-01 23:18:06 +00:00
Nathan Sidwell
4aeef1729c pt.c (get_specializations): Adjust type template checking.
gcc/cp/
	* pt.c (get_specializations): Adjust type template checking.
	(get_specializations_for_module): Get the type specializations
	too.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-4_[ab].C: New.

From-SVN: r270781
2019-05-01 21:49:25 +00:00
Nathan Sidwell
a231906c89 module.cc (set_module_owner): Deal with specializations.
gcc/cp/
	* module.cc (set_module_owner): Deal with specializations.
	* name-lookup.c (mark_pending_on_decl): Walk class members.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-3_[ab].C: New.

From-SVN: r270772
2019-05-01 15:48:41 +00:00
Nathan Sidwell
57abf5c7c1 parser.c (cp_parser_explicit_instantiation): Correctl unwind state.
gcc/cp/
	* parser.c (cp_parser_explicit_instantiation): Correctl unwind state.
	* decl.c (grokfndecl): Set module ownership after specializationness
	is known.

From-SVN: r270771
2019-05-01 15:30:39 +00:00
Nathan Sidwell
0bfa294358 macro.c (_cpp_new_macro): memset before initing.
libcpp/
	* macro.c (_cpp_new_macro): memset before initing.

From-SVN: r270769
2019-05-01 14:28:26 +00:00
Nathan Sidwell
9a1b29d399 module.cc (module_state:write_bindings): Iterate over sccs array, not hash table.
gcc/cp/
	* module.cc (module_state:write_bindings): Iterate over sccs
	array, not hash table.
	(module_state::write): Adjust.

From-SVN: r270768
2019-05-01 14:21:38 +00:00
Nathan Sidwell
eb8ee5ceb9 macro.c (_cpp_new_macro): Initialize imported field.
libcpp/
	* macro.c (_cpp_new_macro): Initialize imported field.

From-SVN: r270767
2019-05-01 14:12:06 +00:00
Nathan Sidwell
a730352e3b Merge trunk r270765.
From-SVN: r270766
2019-05-01 13:51:24 +00:00
Nathan Sidwell
a47a770f80 cp-tree.h (module_normal_import_p): Declare.
gcc/cp/
	* cp-tree.h (module_normal_import_p): Declare.
	* module.cc (module_normal_import_p): New.
	* name-lookup.c (note_pending_specializations): Note already
	loaded normal imports.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-2_d.C: New

From-SVN: r270708
2019-04-30 17:50:41 +00:00
Nathan Sidwell
32283aa5fe tpl-spec-2_[abc].C: New.
gcc/testsuite/
	* tpl-spec-2_[abc].C: New.

From-SVN: r270707
2019-04-30 17:32:48 +00:00
Nathan Sidwell
38a941c78f Namespace-scope function specializations.
gcc/cp/
	* cp-tree.h (MODULE_VECTOR_LAZY_{PARTITION,GLOBAL}_SPEC_P):
	Delete.
	* module.cc (struct specset): New.
	(module_for_unnamed): New.
	(lazy_load_specializations): New.
	(module_state::{read,write}_unnamed): Register the
	specializations.
	({init,finish}_module_processing): Adjust.
	* name-lookup.c (mark_pending_on_decl, mark_pending_on_binding):
	New.
	(set_module_binding): If pending, mark the new decls.
	(note_pending_specializations, note_loaded_specializations): New
	* name-lookup.h (note_pending_specializations)
	(note_loaded_specializations): Declare.
	gcc/testsuite/
	* g++.dg/modules/tpl-spec-1_[ab].C: New.

From-SVN: r270706
2019-04-30 16:55:36 +00:00
Nathan Sidwell
0e1957bb53 gcc/cp/
* cp-tree.h (MODULE_VECTOR_LAZY_SPEC_P)
	(MODULE_VECTOR_LAZY_GLOBAL_SPEC_P)
	(MODULE_VECTOR_LAZY_PARTITION_SPEC_P): New.
	* module.cc (struct unnamed_entity): New.
	(unnamed_ary): Array of unnamed_entity.
	(module_state::write_cluster): Return void.
	(module_state::{read,write}_unnamed): Deal with specializations.
	(module_State::{read,write}_specializations): Delete.
	(module_state::read_cluster): Adjust.
	(module_state_config): Drop specialization count.
	(module_state::{read,write}_config): Adjust.
	(module_state::{read,write}): Drop specialization streaming.

From-SVN: r270663
2019-04-29 21:34:45 +00:00
Nathan Sidwell
1ce0952a84 Merge trunk r270644. (GCC 10)
From-SVN: r270645
2019-04-29 11:22:46 +00:00
Nathan Sidwell
9af40c5e05 modules.cc (depset::hash::add_depednency): More STRIP_TEMPLATE.
gcc/cp/
	* modules.cc (depset::hash::add_depednency): More STRIP_TEMPLATE.

From-SVN: r270644
2019-04-29 10:54:25 +00:00
Nathan Sidwell
aec57f39de cp-tree.h (get_specializations_for_module): Declare.
gcc/cp/
	* cp-tree.h (get_specializations_for_module): Declare.
	* module.cc (depset): Add DB_IMPLICIT_BIT,
	is_implicit_specialization.
	(depset::hash::add_dependency): Add is_implicit arg.  Allow NULL
	current.  Set is_imolicit_specialization.
	(module_state::write_specializations): Implement.
	(trees_out::tree_decl): Stream specializations.
	(specialization_cmp): New.
	(depset::hash::add_specializations): New.
	(module_state::write_cluster): Count specializations.
	(module_state::write): Add and stream specializations.
	* pt.c (spec_hash_table): New typedef.  Use it.
	(get_specializations): New.
	(get_specializations_for_module): New.

From-SVN: r270584
2019-04-25 18:49:48 +00:00
Nathan Sidwell
a78d967de4 cp-tree.h (DECL_TEMPLATE_LAZY_SPECIALIZATIONS_P): New.
gcc/cp/
	* cp-tree.h (DECL_TEMPLATE_LAZY_SPECIALIZATIONS_P): New.
	(lazy_load_specializations): Declare.
	* module.cc (module_state::{read,write}_specializations): New.
	(module_state::write_cluster) Return template count.
	(module_state_config): Add num_specializations.
	(module_state::{read,write}_config): Stream it.
	(module_state::{read,write}): Stream spcializizations.
	(lazy_load_specializations): New.
	* pt.c (lookup_template_class_1, instantiate_template_1): Lazy
	load specializations.

From-SVN: r270555
2019-04-24 20:19:59 +00:00
Nathan Sidwell
be11483861 Merge trunk r270543.
From-SVN: r270546
2019-04-24 14:21:18 +00:00
Nathan Sidwell
e88b0e49e0 Instantiations now streamed.
gcc/cp/
	* module.cc (tree_tag): Delete tt_inst.
	(trees_out::tree_decl): All instantiations are depended.  Never
	tt_inst.
	(trees_in::tree_node): Delete tt_inst handling.
	(trees_in::tree_mergeable): Deal with type specializations.
	* pt.c (lookup_template_class_1): Set instatiation owner to
	current TU.
	(match_mergable): Accept type.
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_[bc].C: Adjust scans.
	* g++.dg/modules/inst-[34]_[bc].C: New.

From-SVN: r270543
2019-04-24 13:01:39 +00:00
Nathan Sidwell
a11a2ae3b6 cp-tree.h (module_name): New overload.
gcc/cp/
	* cp-tree.h (module_name): New overload.
	* module.cc (dumper::impl::nested_name): Adjust module dump.
	(module_name): New.
	* error.c (dump_module_suffix): Dump for namespace-scope decl.
	(dump_aggr_type): Dump module suffix.
	gcc/testsuite/
	* g++.dg/modules/adhoc-1_b.C: Adjust regexps.
	* g++.dg/modules/err-1_[cd].C: Likewise.
	* g++.dg/modules/macloc-1_[cd].C: Likewise
	* g++.dg/modules/by-name-1.C: Adjust scans.
	* g++.dg/modules/class-3_[bd].C: Likewise.
	* g++.dg/modules/enum-1_a.C: Likewise.
	* g++.dg/modules/global-[23]_a.C: Likewise.
	* g++.dg/modules/indirect-[1234]_[bc].C: Likewise.
	* g++.dg/modules/inst-[12]_[ab].C: Likewise.
	* g++.dg/modules/part-3_c.C: Likewise.
	* g++.dg/modules/scc-1.C: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.
	* g++.dg/modules/using-4_a.C: Likewise.
	* g++.dg/modules/vmort-2_[abc].C: Likewise.

From-SVN: r270519
2019-04-23 20:47:19 +00:00
Nathan Sidwell
427b477a37 module.cc (trees_{in,out}::tree_mergeable): Stream more for specializations.
gcc/cp/
	* module.cc (trees_{in,out}::tree_mergeable): Stream more for
	specializations.

From-SVN: r270517
2019-04-23 18:52:58 +00:00
Nathan Sidwell
e6468b82d7 module.cc (trees_{in,out}::core_vals): Don't stream template instantiations.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Don't stream template
	instantiations.
	(trees_{in,out}::tree_mergeable): Refactor.
	(module_state::prepare_locations): Fix dumper.

From-SVN: r270516
2019-04-23 18:38:24 +00:00
Nathan Sidwell
994b4e1e31 Make-lang.in: Wedge revision number into REVISISON_s.
gcc/cp/
	* Make-lang.in: Wedge revision number into REVISISON_s.

From-SVN: r270508
2019-04-23 12:47:14 +00:00
Nathan Sidwell
58c90f922f Function instantiation merging
Function instantiation merging
	gcc/cp/
	* cp-tree.h (get_module_owner): Add tpl_owner parm.
	(match_mergeable_specialization): New.
	* mangle.c (maybe_write_module): Look through template
	instantiations.
	* method.c (implicitly_declare_fn): Do not set owner here.
	* module.cc (trees_out::tree_decl): Namespace-scope function
	instantiations are merged.
	(trees_in::tree_node): Likewise.
	(trees_{in,out}::tree_mergeable): Allow instantiation merging.
	(depset::hash::add_dependency): Specializations are unnameable.
	(module_state::write_cluster): Seed specializations too.
	(module_state::read_define): Fix size_t/unsigned mismatch.
	(module_visible_instantiation_path): Use TYPE_STUB_DECL.
	(get_module_owner): Add inst_owner_p arg.  Look through
	instantiation, or don't.
	* pt.c (instantiate_template_1): Set module owner here.
	(instantiate_decl): ... not here.
	(match_mergeable_decl): New.
	gcc/testsuite/
	* lib/scanlang.exp (scan-lang-dump-times): New. Cut-paste fu!
	* g++.dg/modules/inst-[12]_[ab].C: New.
	* g++.dg/modules/adl-1_c.C: Comment.
	* g++.dg/modules/indirect[234]_[bc].C: Adjust.

From-SVN: r270507
2019-04-23 12:46:32 +00:00
Nathan Sidwell
dad12fbb88 Make-lang.in (MODULE_REVISION): New.
gcc/cp/
	* Make-lang.in (MODULE_REVISION): New.
	* module.cc (dumper::impl::nested_name): Print module number.
	(module_state::write_readme): Write revision.
	gcc/testsuite/
	* g++.dg/modules/by-name-1.C: Adjust scans.
	* g++.dg/modules/class-3_[bd].C: Likewise.
	* g++.dg/modules/enum-1_a.C: Likewise.
	* g++.dg/modules/global-[23]_a.C: Likewise.
	* g++.dg/modules/indirect-[1234]_[bc].C: Likewise.
	* g++.dg/modules/part-3_c.C: Likewise.
	* g++.dg/modules/scc-1.C: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.
	* g++.dg/modules/using-4_a.C: Likewise.
	* g++.dg/modules/vmort-2_[abc].C: Likewise.

From-SVN: r270325
2019-04-12 18:03:15 +00:00
Nathan Sidwell
00c28486ba module.cc (dumper::impl::nested_name): Remove namespace owner fiddling.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Remove namespace owner
	fiddling.
	* name-lookup.c (make_namespace): Don't set owner.  Adjust callers.

From-SVN: r270312
2019-04-12 11:51:21 +00:00
Nathan Sidwell
4edbc4c435 Ownership only on namespace-scope.
gcc/cp/
	* module.cc (dumper::impl::nested_name): Show decl's ownership.
	(trees_out::tree_decl): Remove unnecessary unnameable code.
	(depset::hash::add_dependency): Add is_import parm.
	(module_state::write_clister): Get owner decl of unnamed.
	(get_module_owner): Always look at the namespace-scope entity.
	(set_module_owner): Only set namespace-scope entity.
	(set_implicit_module_owner): Likewise.
	gcc/testsuite/
	* g++.dg/modules/by-name-1.C: Adjust scans.
	* g++.dg/modules/class-3_[bd].C: Likewise.
	* g++.dg/modules/enum-1_a.C: Likewise.
	* g++.dg/modules/global-[23]_a.C: Likewise.
	* g++.dg/modules/indirect-[1234]_[bc].C: Likewise.
	* g++.dg/modules/part-3_c.C: Likewise.
	* g++.dg/modules/scc-1.C: Likewise.
	* g++.dg/modules/stdio-1_a.H: Likewise.
	* g++.dg/modules/using-4_a.C: Likewise.
	* g++.dg/modules/vmort-2_[abc].C: Likewise.

From-SVN: r270311
2019-04-12 11:41:44 +00:00
Nathan Sidwell
b02ca4a23e mangle.c (decl_is_template_id): Rename to ...
gcc/cp/
	* mangle.c (decl_is_template_id): Rename to ...
	(maybe_template_info): ... here.  Simplify API.
	(mangle_return_type, write_encoding, write_name)
	(write_nested_name, write_prefix, write_template_prefix)
	(write_unqualified_name): Update all callers.

From-SVN: r270290
2019-04-11 18:57:23 +00:00
Nathan Sidwell
66036b6f7f module.cc (module_for_{ordinary,macro}_loc): New.
gcc/cp/
	* module.cc (module_for_{ordinary,macro}_loc): New.
	(module_state::{read,write}_location): Deal with imported locations.

From-SVN: r270285
2019-04-11 14:30:04 +00:00
Nathan Sidwell
ea6d7d26ff module.cc (depset::entity_kind_name): Tweak.
gcc/cp/
	* module.cc (depset::entity_kind_name): Tweak.
	(trees_{in,out}::tree_mergeable): Frob context.
	* name-lookup.h (match_mergeable_decl): Pass context explicitly.
	* name-lookup.c (match_mergeable_decl): Pass context explicitly.
	gcc/testsuite/
	* g++.dg/modules/global-[23]_a.C: Adjust scans.
	* g++.dg/modules/stdio-1_a.H: Likewise.

From-SVN: r270283
2019-04-11 14:01:35 +00:00
Nathan Sidwell
f0e3f45c31 module.cc (loc_kind): New.
gcc/cp/
	* module.cc (loc_kind): New.
	(module_state::{read,write}_location): Use tagging, compress macro
	& adhoc better.

From-SVN: r270282
2019-04-11 13:58:55 +00:00
Nathan Sidwell
88730fedea module.cc (loc_spans): Main span is all but reserved.
gcc/cp/
	* module.cc (loc_spans): Main span is all but reserved.
	(slurping): Drop pre_early_ok.
	(loc_spans::init): Don't push command line and forced header
	spans.
	(loc_spans::macro): Fix comparison thinko.
	(module_state::read_location): No such thing as early.
	(module_state::prepare_locations): Drop command line and forced
	header handling.
	(maybe_add_macro): Ignore lazy macros.
	(canonicalize_header_name): Return the buffer.
	gcc/testsuite/
	* g++.dg/modules/macro-5_c.C: Adjust regexp.

From-SVN: r270281
2019-04-11 13:40:35 +00:00
Nathan Sidwell
f12d92379c module.cc (module_preprocess): Module partitions always produce a BMI.
gcc/cp/
	* module.cc (module_preprocess): Module partitions always produce
	a BMI.
	gcc/testsuite/
	* g++.dg/modules/dep-2.C: New.

From-SVN: r270261
2019-04-10 15:36:08 +00:00
Nathan Sidwell
63428ba45d module.cc (module_state::write_cluster): Remove unnecessary check & FIXME.
gcc/cp/
	* module.cc (module_state::write_cluster): Remove unnecessary
	check & FIXME.

From-SVN: r270256
2019-04-10 14:37:30 +00:00
Nathan Sidwell
3d5e4fc8bb module.cc (trees_out::depending_p): Delete.
gcc/cp/
	* module.cc (trees_out::depending_p): Delete.
	(trees_out::tree_decl): Refactor asserts.
	(module_state::write_cluster): Refactor initial scan.

From-SVN: r270255
2019-04-10 14:28:33 +00:00
Nathan Sidwell
d4ae24566c mkdeps.c (deps_add_module): Swap primary & module args.
libcpp/
	* mkdeps.c (deps_add_module): Swap primary & module args.  Too
	confusing.
	gcc/cp/
	* module.cc (module_state::do_import, module_preprocess)
	(finish_module_processing): Adjust.

From-SVN: r270252
2019-04-10 12:26:27 +00:00
Nathan Sidwell
0afed47af4 module.cc (slurping): Move {ordinary,macro}_locs to ..
gcc/cp/
	* module.cc (slurping): Move {ordinary,macro}_locs to ..
	(module_state): ... here.
	(module_state::read_location): Adjust.
	(module_state::read_locations): Adjust, recorded locations are for
	current TU.

From-SVN: r270242
2019-04-09 20:21:31 +00:00
Nathan Sidwell
d4b26417f0 module.cc (get_module): Add parent option, use it.
gcc/cp/
	* module.cc (get_module): Add parent option, use it.
	(module_state::read_{imports,partitions}): Adjust.
	(finish_module_processing): Show full module name on error.
	gcc/testsuite/
	* g++.dg/modules/ben-1{_[ab].C,.map}: New.
	* g++.dg/modules/alias-1_f.C: Use [srcdir].
	* g++.dg/modules/gc-2_a.C: Likewise.
	* g++.dg/modules/inc-xlate-1_d.C: Likewise.
	* g++.dg/modules/legacy-6_[cdef].C: Likewise.
	* g++.dg/modules/map-1_[ab].C: Likewise.

From-SVN: r270235
2019-04-09 18:41:48 +00:00
Nathan Sidwell
6b4d396c13 module.cc (depset::is_imported_entity): New.
gcc/cp/
	* module.cc (depset::is_imported_entity): New.
	(module_for_unnamed): Delete.
	(depset::hash::add_dependency): Note imported dependencies.
	(module_state::{read,write}_cluster): Deal with imported unnamed.
	(module_state::write): Skip imported dependencies.
	gcc/testsuite/
	* g++.dg/modules/vmort-2_[abc].C: New.

From-SVN: r270232
2019-04-09 16:01:44 +00:00
Nathan Sidwell
9e12215923 mkdeps (munge): Quote ':'.
libcpp/
	* mkdeps (munge): Quote ':'.
	(deps_add_module): Correct partion/module order.
	(make_write): Add .c++m suffix to module name.
	gcc/testsuite/
	* g++.dg/modules/dep-1_[ab].C: New.

From-SVN: r270230
2019-04-09 13:39:03 +00:00
Nathan Sidwell
3c5ef6cce2 mkdeps (mkrules::~mkrules): Use free appropriately.
libcpp/
	* mkdeps (mkrules::~mkrules): Use free appropriately.

	gcc/
	* doc/invoke.texi (C++ Module Mapper): Fix markup.

From-SVN: r270228
2019-04-09 12:46:17 +00:00
Nathan Sidwell
8822a1013c cp-tree.h (language_function): Remove x_auto_return_pattern.
gcc/cp/
	* cp-tree.h (language_function): Remove x_auto_return_pattern.
	(current_function_auto_return_pattern): Delete.
	(FNDECL_USED_AUTO): Correct documentation.
	* decl.c (save_function_data): Delete.
	(fndecl_declared_return_type): Don't look at language_function.
	(start_preparsed_function): Replace
	current_function_auto_return_pattern with
	DECL_SAVED_AUTO_RETURN_TYPE.
	(finish_function): Likewise.
	* mangle.c (write_unqualified_name): Likewise.
	* parser.c (cp_parser_jump_statement): Likewise.
	* typeck.c (check_return_expr): Likewise.

From-SVN: r270227
2019-04-09 12:39:26 +00:00
Nathan Sidwell
da2a1ce97f module.cc (unnamed_ary, [...]): New.
gcc/cp/
	* module.cc (unnamed_ary, unnamed_map_t, unnamed_map): New.
	(struct slurping): Delete unnamed, alloc_unnamed, & deletion of
	same.
	(struct moduls_state): Add unnamed_lwm, unnamed_num.
	(module_for_unnamed): New.
	(dumper::impl::nested_name): More informative unnamedness.
	(module_state::read_cluster): Use the unnamed_ary.
	(module_state::read_unnamed): Populate unnamed_ary.
	({init,finish}_module_processing): Adjust.
	gcc/testsuite/
	* g++.dg/modules/indirect-4_[bc].C: Adjust scans.

From-SVN: r270213
2019-04-08 17:56:40 +00:00
Nathan Sidwell
71218c59dc cp-tree.h (struc mc_slot): Move to ...
gcc/cp
	* cp-tree.h (struc mc_slot): Move to ...
	* name-lookup.h: ... here.
	* module.c (depset::hash::{add_mergeable,connect}): Use depsets
	not decls.
	(depset::tarjan::connect): Add for_mergeables parm.
	(tree_node::{mark,tree}_mergeable): Likewise.
	(module_state::sort_mergeables): Likewise,
	(module_state::{read,write}_bindings): Return/expect number of
	bindings.
	(module_state::write_macros): Return number of macros.
	(module_state::write_cluster): Adjust.
	(module_state::{read,write}_config): Adjust.
	(module_state::{read,write}): Adjust.

From-SVN: r270211
2019-04-08 14:58:50 +00:00
Nathan Sidwell
b6e2fa23ce module.cc (dumper): Add CLUSTER.
gcc/cp/
	* module.cc (dumper): Add CLUSTER.
	(module_state::write): Dump cluster information.

From-SVN: r270130
2019-04-03 16:07:44 +00:00
Nathan Sidwell
72c633d8c6 module.cc (node_template_info): Move earlier, protect from partial read in.
gcc/cp/
	* module.cc (node_template_info): Move earlier, protect from
	partial read in.
	(dumper::impl::nested_name): Dump template args.
	gcc/testsuite/
	* g++.dg/modules/indirect-[234]_[abc].C: Adjust scans.

From-SVN: r270128
2019-04-03 15:36:58 +00:00
Nathan Sidwell
f7c4c77ba3 module.cc (module_state::write_cluster): Refactor.
gcc/cp/
	* module.cc (module_state::write_cluster): Refactor.

From-SVN: r270127
2019-04-03 13:18:15 +00:00
Nathan Sidwell
138f3409bc module.cc (cluster_tag): Remove ct_defn.
gcc/cp/
	* module.cc (cluster_tag): Remove ct_defn.
	(module_state::{read,write}_cluster): Definitions marked via flag.

From-SVN: r270125
2019-04-03 13:05:12 +00:00
Nathan Sidwell
8628504b5e module.cc (depset::hash): Rename mergeables flag to mergeable_dep.
gcc/cp/
	* module.cc (depset::hash): Rename mergeables flag to mergeable_dep.

From-SVN: r270124
2019-04-03 12:53:50 +00:00
Nathan Sidwell
dc15f2553b Allow mapper protocol of file descriptors.
gcc/
	* doc/invoke.texi (C++ Module Mapper): Document <> form.
	gcc/cp/
	* module.cc (module_mapper::module_mapper): Parse <> option.

From-SVN: r270107
2019-04-02 20:09:57 +00:00
Nathan Sidwell
90feea63ef Write bmi /after/ deferred instantiations.
gcc/cp/
	* cp-tree.h (finish_module_processing): Add cpp arg.
	(finish_module_parse): Delete.
	* name-lookup.h (lookup_by_type): Declare.
	* decl2.c (c_parse_final_cleanups): Adjust.
	* module.c (tree_tag): Add tt_builtin.
	(trees_out::tree_decl): Use tt_builtin for builtins.
	(trees_in::tree_node): Likewise.
	(finish_module_parse): Move processing into ...
	(finish_module_processing): ... here.
	* name-lookup.c (lookup_by_type): New.
	gcc/testsuite/
	* g++.dg/modules/builtin-1_[ab].C: New.

From-SVN: r270106
2019-04-02 19:48:41 +00:00
Nathan Sidwell
166185fcdd module.cc (depset): Add EK_UNNAMED.
gcc/cp/
	* module.cc (depset): Add EK_UNNAMED. Delete DB_IS_UNNAMED_BIT,
	is_unnamed accessor.
	(depset::hash::add_dependency): Add entity_kind arg, simplify
	logic.  Update callers.
	gcc/testsuite/
	* g++.dg/modules/using-4_a.C: Adjust scan.

From-SVN: r270103
2019-04-02 17:25:46 +00:00
Ben Boeckel
9abdb7a846 mkdeps.c (mrules): Rename is_legacy to is_header_init, adjust uses.
libcpp/
	* mkdeps.c (mrules): Rename is_legacy to is_header_init, adjust uses.
	(deps_add_module): Correctly duplicate and use strings.

Co-Authored-By: Nathan Sidwell <nathan@acm.org>

From-SVN: r270094
2019-04-02 15:38:14 +00:00
Nathan Sidwell
edc4dc7b3f module.cc (depset::add_dependency): Drop maybe_using arg.
gcc/cp/
	* module.cc (depset::add_dependency): Drop maybe_using arg.
	Adjust callers.
	(dumper::operator()): Overloads have a name.
	(has_definition): Adjust.

From-SVN: r270093
2019-04-02 15:24:49 +00:00
Nathan Sidwell
20886e31e6 module.cc (depset): Move flags into discriminator field.
gcc/cp/
	* module.cc (depset): Move flags into discriminator field.  Adjust uses.

From-SVN: r270067
2019-04-01 20:04:45 +00:00
Nathan Sidwell
f18eb8e774 module.cc (depset): Replace key wih entity/discriminator tuple.
gcc/cp/
	* module.cc (depset): Replace key wih entity/discriminator tuple.
	Add entity_kind and disc_bits enums.  Adjust hashing &
	construction routines.

From-SVN: r270063
2019-04-01 17:07:15 +00:00
Nathan Sidwell
02d8687e67 module.cc (depset): Entity keying uses unique entity.
gcc/cp/
	* module.cc (depset): Entity keying uses unique entity.  Set
	entity kind later.
	(depset::hash): Adjust hashing.
	(depset::hash::add_dependency): Set kind after insertion.
	(depset::hash::add_mergeable): Adjust.
	gcc/
	* doc/invoke.texi: Fix module mapper thinko.

From-SVN: r270058
2019-04-01 14:58:53 +00:00
Nathan Sidwell
e3e00e67c6 cp-tree.h (saved_scope): Remove this_module field.
gcc/cp/
	* cp-tree.h (saved_scope): Remove this_module field.
	(current_module): Delete.
	(module_import_bitmap): Rename to ...
	(get_import_bitmap): ... here.  Lose arg.
	* module.cc (module_import_bitmap): Rename to ...
	(get_import_bitmap): ... here.  Lose arg.
	* name-lookup.c (name_lookup::search_namespace_only): Adjust.
	(check_module_override, finish_nonmember_using_decl): Likewise.
	(do_push_to_top_level): Drop this_module field init.

From-SVN: r270018
2019-03-29 14:54:34 +00:00
Nathan Sidwell
9ff2773a29 pt.c: Comment some structures.
gcc/cp/
	* pt.c: Comment some structures.

From-SVN: r269993
2019-03-28 14:25:25 +00:00
Nathan Sidwell
ed2d6b09d7 invoke.texi (C++ Modules): Update.
gcc/
	* doc/invoke.texi (C++ Modules): Update.

From-SVN: r269989
2019-03-28 13:35:49 +00:00
Nathan Sidwell
5c3ed9d552 Merge trunk r269975.
From-SVN: r269988
2019-03-28 11:55:29 +00:00
Nathan Sidwell
4ae801b63e invoke.texi (C++ Modules): Update.
gcc/
	* doc/invoke.texi (C++ Modules): Update.

From-SVN: r269974
2019-03-27 19:13:18 +00:00
Nathan Sidwell
e206a204a8 Header unit compilations retrofit includeness.
gcc/cp/
	* cxx-mapper.c (module2bmi): Don't use PCH suffix.
	* module.cc (module_header_macro, controlling_node): Delete.
	(module_state::write_macros): Rely on cpp to determine controlling
	macro.
	(module_state::{write,read}): Likewise.
	(module_begin_main_file): Retrofit as a header.
	(finish_module_parse): Delete header_macro stuff.
	libcpp/
	* files.c (_cpp_stack_file): Set main_file.
	(_cpp_find_header_unit): Close the file.
	(cpp_retrofit_as_include): New.
	(cpp_main_controlling_macro): New.
	* include/cpplib.h (cpp_retrofit_as_include): Declare.
	(cpp_main_controlling_macro): Declare.
	* internal.h (struct cpp_buffer): Add main_file flag.
	(cpp_in_primary_file): Use it.
	gcc/testsuite/
	* g++.dg/modules/{,sys/}inext-1.H: New.
	* g++.dg/modules/macro-[23]_[abc].[CH]: Adjust.
	* g++.dg/modules/modules.exp (dg-module-bmi): Adjust.
	* g++.dg/modules/stdio-1_a.H: Asjust.

From-SVN: r269973
2019-03-27 18:53:10 +00:00
Nathan Sidwell
6681bbff73 Expunge header name quoting in mapper
Expunge header name quoting in mapper
	gcc/cp/
	* cxx-mapper.cc (IS_HEADER_NAME): New.
	(module2bmi): Adjust.
	* module.cc (module_mapper::imex_query): Drop quotes.
	(module_mapper::translate_include): Likewise.
	gcc/testsuite/
	* g++.dg/modules/modules.exp (dg-module-bmi): Adjust mapping.

From-SVN: r269968
2019-03-27 16:49:16 +00:00
Nathan Sidwell
efd079f064 Header unit names lack quotes
Header unit names lack quotes
	gcc/c-family/
	* c.opt (fmodule-header): Set a var.
	* cp-tree.h (module_map_header): Pass string as ptr/len tuple.
	* lex.c (module_map_header): Move to module.cc.
	(module_process_token): Remove gratuitous representation frobbing.
	* module.cc (module_state::module_state): Assert no quotes.
	(module_header_name): Delete.
	(get_module): Detect header via pathism.
	(module_mapper::imex_query): Add quotes.
	(module_mapper::translate_include): Drop reader parms, don't push
	buffer here.
	(canonicalize_header_name): New, from lex.c.
	(module_map_header): Wrapper for canonicalize_header_name.
	(module_translate_include): Do buffer pushing here.  Canonicalize
	name.
	(set_module_header_name): Delete.
	(module_begin_main_file): Simplify header name setting.
	(handle_module_option): Adjust header name flag setting.
	* parser.c (cp_lexer_tokenize): Adjust header name mapping.
	libcpp/
	* lex.c (cpp_output_token): Add quotes back onto CPP_HEADER_NAME.
	gcc/testsuite/
	* g++.dg/modules/alias-3_[bc].C: Adjust.
	* g++.dg/modules/leg-merge-4_c.C: Adjust.
	* g++.dg/modules/macro-[2456]_[bcde].C: Adjust.
	* g++.dg/modules/stdio-1_b.C: : Adjust.
	* g++.dg/modules/sys: Add.

From-SVN: r269966
2019-03-27 16:13:49 +00:00
Nathan Sidwell
fa7e225f49 Header unit names are strings
Header unit names are strings
	gcc/cp/
	* lex.c (module_map_header): Build string_cst.
	(module_preprocess_token): Adjust.
	* module.cc (module_state::module_state): Header names are
	strings.
	(module_name_hash): New.
	(module_state_hash::{hash,equal}): Adjust.
	(dumper::impl::nested_name): Fix string_cst.
	(get_module): Tweak.
	(module_state::set_flatname): Tweak.
	(module_begin_main_file): Build string.

From-SVN: r269963
2019-03-27 13:13:28 +00:00
Nathan Sidwell
7ad3e652a2 c-opts.c (c_common_post_options): Invert sense of cpp_read_main_file arg.
gcc/c-family/
	* c-opts.c (c_common_post_options): Invert sense of
	cpp_read_main_file arg.
	* parser.c (cp_parser_translation_unit): Reject include
	translation in module purview.
	libcpp/
	* files.c (_cpp_stack_file): Take include type parm.  Drop line
	parm. Do line-table adjusting here ...
	(_cpp_stack_include): ... not here.
	* include/cpplib.h (cpp_read_main_file): Invert final parm.
	* init.c (cpp_read_main_file): Adjust.
	* internal.h (include_type): Add more enumerations, and document.
	(_cpp_stack_file): Adjust prototype.
	gcc/testsuite/
	* g++.dg/modules/alias-2_[ab].[CH]: New.
	* g++.dg/modules/exp-xlate-1_[ab].[CH]: New.
	* g++.dg/modules/legacy-3_c.H: Robustify testing.

From-SVN: r269955
2019-03-26 20:17:19 +00:00
Nathan Sidwell
39a54be1fb Header units disambiguated by originating header path
Header units disambiguated by originating header path
	libcpp/
	gcc/
	* doc/invoke.texi (-fmodule-header): Adjust.
	* langhooks.h (struct lang_hooks): Adjust preprocess hook.
	gcc/cp/
	* cp-tree.h (module_preprocess_token): Adjust.
	(module_map_header): Declare.
	(module_translate_include): Adjust.
	* cxx-mapper.cc (module2bmi): Header units map to relative path.
	(client::action): Look for header bmi.
	* lex.c (module_map_header): New.
	(module_preprocess_token): Remap header unit names.
	* module.cc (create_dirs): Fix.
	(module_mapper::translate_include): Adjust.
	(module_translate_include): Likewise.
	(finish_module_parse): Fix directory creation.
	(handle_module_option): Remove fmodule-header=FOO handling.
	* parser.c (cp_lexer_tokenize): Remap header unit names.
	gcc/c-family/
	* c-lex.c (c_lex_with_flags): Build a string for header names.
	* c-ppoutput.c (scan_translation_unit): Allow preprocess hook to
	nadger token.
	* c.opt (fmodule-header=): Deprecate.
	libcpp/
	* directives.c (do_include_common): Move include translation to ...
	* files.c (_cpp_file): Add header_unit field.
	(should_stack_file): Break into ...
	(is_known_idempotent_file): ... this, and ...
	(has_unique_contents): ... this.
	(_cpp_stack_file): ... do include translation.
	(cpp_find_header_unit): New.
	* include/cpplib.h (cpp_callbacks): Adjust translate_include hook.
	(cpp_find_header_unit): Declare.
	gcc/testsuite/
	* g++.dg/modules/: Many changes.

From-SVN: r269950
2019-03-26 15:47:19 +00:00
Nathan Sidwell
85d18f6c28 files.c (struct _cpp_file): Make bools bitfields, add header_unit flag.
libcpp/
	* files.c (struct _cpp_file): Make bools bitfields, add
	header_unit flag.
	(_cpp_find_file): Don't write for (; !fake;) to mean if (!fake)
	for (;;).
	(_cpp_stack_file): Refactor.

From-SVN: r269844
2019-03-21 18:29:26 +00:00
Nathan Sidwell
8b85ef4aa1 Merge trunk r269839.
From-SVN: r269840
2019-03-21 15:31:58 +00:00
Nathan Sidwell
98c80272f9 gcc.c (execute): Frob argv[0] to show spawning from driver.
gcc/
	* gcc.c (execute): Frob argv[0] to show spawning from driver.
	(process_command): Don't check input file exists here.

From-SVN: r269839
2019-03-21 15:01:41 +00:00
Nathan Sidwell
dbc1a921e5 gcc.c (execute): Frob argv[0] to show spawning from driver.
gcc/
	* gcc.c (execute): Frob argv[0] to show spawning from driver.
	(process_command): Don't check input file exists here.

From-SVN: r269833
2019-03-21 11:45:27 +00:00
Nathan Sidwell
bc43c9c9e3 module.cc (trees_out::mark_class_def): Skip friends in decl_list.
gcc/cp/
	* module.cc (trees_out::mark_class_def): Skip friends in decl_list.

From-SVN: r269825
2019-03-20 16:02:04 +00:00
Nathan Sidwell
772de12369 module.cc (module_state::read_namespaces): Module-linkage namespaces are visible in the module itself.
gcc/cp/
	* module.cc (module_state::read_namespaces): Module-linkage
	namespaces are visible in the module itself.
	* name-lookup.h (add_imported_namespace): Rename parm.
	* name-lookup.c (add_imported_namespace): Export_p becomes visible_p.
	gcc/testsuite/
	* g++.dg/modules/enum-3_[ab].C: New.

From-SVN: r269824
2019-03-20 15:46:44 +00:00
Nathan Sidwell
edfbd9ff45 Enum members of templates part 2.
gcc/cp/
	* module.cc (trees_out::tree_node): Any enum can be tt_enum_int.
	(trees_out::mark_enum_def): Only mark integer_cst inits.
	gcc/testsuite/
	* g++.dg/modues/enum-2_[ab].C: Add.

From-SVN: r269822
2019-03-20 15:04:35 +00:00
Nathan Sidwell
609acdc0d7 Enum members of templates.
gcc/cp/
	* class.c (maybe_add_class_template_decl): No need to add
	CONST_DECLs.
	* pt.c (instantiate_class_template_1): CONST_DECLs are not on the
	template decl list no more.
	* module.cc (node_template_info): Cope with enum members of
	templates.
	(trees_in::insert): Allow null when failing.
	(trees_{in,out}::core_vals): Uninstantiated enums have no
	underlying type.
	(trees_out::tree_decl): Enums can be members too.
	(trees_out::write_class_def): Only announce when streaming.
	(trees_out::mark_class_def): Don't mark const_decl fields.
	(trees_out::mark_enum_def): Always mark the enum here.
	gcc/testsuite.
	* g++.dg/modules/enum-2_[ab].C: New.

From-SVN: r269821
2019-03-20 14:00:35 +00:00
Nathan Sidwell
1f07d4ec78 module.cc (depset::hash::find_dependencies): It might be a fixed tree.
gcc/cp/
	* module.cc (depset::hash::find_dependencies): It might be a fixed
	tree.
	gcc/testsuite/
	* g++.dg/modules/stdns_[ab].C: New.

From-SVN: r269810
2019-03-19 18:42:30 +00:00
Nathan Sidwell
e9a6dab33f Using decls part 3.
gcc/cp/
	* cp-tree.h (ovl_iterator::exporting_p): Simplify.
	* name-lookup.c (do_nonmember_using_decl): Upgrade export in place.
	gcc/testsuite/
	* g++.dg/modules/using-4_[ab].C: New.

From-SVN: r269806
2019-03-19 17:33:14 +00:00
Nathan Sidwell
df0f4e522b using-3.C: New.
gcc/testsuite/
	* g++.dg/modules/using-3.C: New.

From-SVN: r269805
2019-03-19 17:10:13 +00:00
Nathan Sidwell
30b9e7ddab Using decls part 2.
gcc/cp/
	* cp-tree.h (OVL_EXPORT_P): New.
	(ovl_iterator::exporting_p): New.
	(ovl_insert): Change using_p arg type.
	* tree.c (ovl_insert): USINGNESS parm conveys exporting too.
	* name-lookup.c (do_nonmember_using_decl): Deal with exports.
	* module.cc (binding_cmp): Sort usings too.
	(module_state::{read,write}_cluster): Using decls too.
	gcc/testsuite/
	* g++.dg/modules/using-2_[abc].C: New.

From-SVN: r269803
2019-03-19 17:02:04 +00:00
Nathan Sidwell
96df6ff310 name-lookup.c (do_nonmember_using_decl): Cleanups.
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Cleanups.
	(finish_nonmember_using_decl): Likewise.

From-SVN: r269798
2019-03-19 14:27:36 +00:00
Nathan Sidwell
9b842b4490 Using decls part 1.
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Unnest if.
	(finish_nonmember_using_decl): Deal with module vector.
	gcc/testsuite/
	* g++.dg/modules/global-3_[ab].C: New.

From-SVN: r269774
2019-03-18 18:25:55 +00:00
Nathan Sidwell
2c59f7dc96 module.cc (module_state::{read,write}_locations): Cope with trailing empty expansions.
gcc/cp/
	* module.cc (module_state::{read,write}_locations): Cope with
	trailing empty expansions.

From-SVN: r269773
2019-03-18 18:23:13 +00:00
Nathan Sidwell
6fbf6d226a module.cc (module_state::{read,write}_locations): Macro maps can have embedded zeroes.
gcc/cp/
	* module.cc (module_state::{read,write}_locations): Macro maps can
	have embedded zeroes.

From-SVN: r269768
2019-03-18 17:01:21 +00:00
Nathan Sidwell
7ec6aa514c name-lookup.c (do_nonmember_using_decl): Add install & fn_scope args.
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Add install & fn_scope
	args.
	(finish_nonmember_using_decl): Adjust, prep for modules.
	gcc/testsuite/
	* g++.dg/lookup/using53.C: Restore & extend DR36 errors.

From-SVN: r269767
2019-03-18 16:21:16 +00:00
Nathan Sidwell
d07b25ea84 name-lookup.c (do_nonmember_using_decl): Have lookup passed in.
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Have lookup passed in.
	(validate_nonmember_using_decl): Delete.  Absorb
	into ...
	(finish_nonmember_using_decl): ... here.  Do lookup once.
	lookup_enum_member): New.  Broken out of ...
	(get_binding_or_decl): ... here.  Call it.
	(finish_nonmember_using_decl): Drop LOOKUP parm. Do lookup here.
	gcc/testsuite/
	* g++.dg/cpp0x/using-enum-2.C: Adjust diagnostics.
	* g++.dg/cpp0x/using-enum-3.C: Likewise.
	* g++.dg/lookup/hidden-class9.C: Likewise.
	* g++.dg/lookup/hidden-temp-class11.C: Likewise.
	libstdc++-v3/
	* testsuite/18_support/byte/global_neg.cc: Adjust diagnostics.
	* testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc: Likewise.
	* testsuite/27_io/headers/cstdio/functions_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc: Likewise.

From-SVN: r269714
2019-03-15 18:52:47 +00:00
Nathan Sidwell
596478979d name-lookup.h (finish_nonmember_using_decl): Drop LOOKUP parm.
gcc/cp/
	* name-lookup.h	(finish_nonmember_using_decl): Drop LOOKUP parm.
	* name-lookup.c (lookup_enum_member): New.  Broken out of ...
	(get_binding_or_decl): ... here.  Call it.
	(finish_nonmember_using_decl): Drop LOOKUP parm. Do lookup here.
	* parser.c (cp_parser_using_declaration): Adjust.
	* pt.c (tsubst_expr): Likewise.
	gcc/testsuite/
	* g++.dg/lookup/hidden-class9.C: Adjust diagnostics.
	* g++.dg/lookup/hidden-temp-class11.C: Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_add_using_decl): Adjust
	finish_nonmember_using_decl call.
	libstdc++-v3/
	* testsuite/18_support/byte/global_neg.cc: Adjust diagnostics.
	* testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/types_std_c++0x_neg.cc: Likewise.
	* testsuite/27_io/headers/cstdio/functions_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++0x_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc: Likewise.

From-SVN: r269711
2019-03-15 16:44:47 +00:00
Nathan Sidwell
8df20b9d9a Merge using directive fields & fns.
gcc/cp/
	* cp-tree.h (lang_decl_ns): Drop usings field.
	(DECL_NAMESPACE_USING): Delete.
	* name-lookup.h (finish_using_directive): Declare.
	(finish_namespace_using_directive)
	(finish_local_using_directive): Delete.
	* name-lookup.c (name_lookup::search_usings)
	(name_lookup::queue_namespace): Adjust.
	(has_using_namespace_std_directive_p): No need to search
	namespaces separately.
	(finish_using_directive): New.  Merged from ...
	(finish_namespace_using_directive, finish_local_using_directive): ...
	here.  Delete.
	(push_namespace): Adjust.
	* parser.c (cp_parser_using_directive): Call finish_using_directive.
	* pt.c (tsubst_expr): Likewise,
	libcc1/
	* libcp1plugin.cc (plugin_add_using_namespace): Call
	finish_using_directive.

From-SVN: r269705
2019-03-15 12:55:17 +00:00
Nathan Sidwell
4c4d38c246 backport: name-lookup.c (finish_nonmember_using_decl): New, merged from ...
Merge finish using decl fns
	gcc/cp/
	* name-lookup.c (finish_nonmember_using_decl): New, merged from ...
	(finish_namespace_using_decl, finish_local_using_decl): ... here.
	Delete.
	* name-lookup.h (finish_nonmember_using_decl): Declare
	(finish_namespace_using_decl, finish_local_using_decl): Delete.
	* parser.c (cp_parser_using_declaration): Adjust.
	* pt.c (tsubst_expr): Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_add_using_decl): Likewise.

From-SVN: r269693
2019-03-14 20:14:58 +00:00
Nathan Sidwell
14ee6cf798 Drop cp_binding_level::usings
Drop cp_binding_level::usings
	gcc/cp/
	* name-lookup.h (cp_binding_level): Remove usings field.
	* name-lookup.c (push_using_decl, push_using_decl_1): Delete.
	(validate_nonmember_using_decl): Make using decl here.

From-SVN: r269689
2019-03-14 17:25:02 +00:00
Nathan Sidwell
185689391c name-lookup.c (validate_nonmember_using_decl): Drop DR 36 case.
gcc/cp/
	* name-lookup.c (validate_nonmember_using_decl): Drop DR 36 case.
	gcc/testsuite/
	* g++.dg/lookup/using53.C: Permit DR 36 case.

From-SVN: r269686
2019-03-14 16:03:04 +00:00
Nathan Sidwell
52f258b8e7 Merge trunk r269682.
From-SVN: r269685
2019-03-14 14:33:46 +00:00
Nathan Sidwell
7665fe6f9f Start doing something with using decls
Start doing something with using decls
	gcc/cp/
	* cp-tree.h (ovl_iterator): Add get_using accessor.
	* module.cc (depset::is_using): New.
	(depset::hash::add_dependency): Add maybe_using parm.  Use it.
	(depset::hash::add_binding): Deal with using decls.
	(depset::hash::find_dependencies): Likewise.
	(cluster_cmp): Likewise.
	(module_state::{read,write}_cluster): Likewise.
	gcc/testsuite/
	* g++.dg/modules/using-1_[abc].C: New.

From-SVN: r269657
2019-03-13 19:14:31 +00:00
Nathan Sidwell
2b95910389 stdio.h can be a legacy unit!
gcc/testsuite/
	* g++.dg/modules/stdio-1_[ab].[CH]: New.
	* g++.dg/modules/global-2_[ab].C: New.

From-SVN: r269654
2019-03-13 17:19:28 +00:00
Nathan Sidwell
878edb8187 typedef struct {} foo; part 2
typedef struct {} foo; part 2
	gcc/cp/
	* module.cc (tt_anon_decl): New.
	(trees_out::tree_decl): Deal with anonymous decls.
	(trees_out::tree_type): Use TYPE_STUB_DECL.
	(trees_in::tree_node): Deal with tt_anon_decl.
	* name-lookup.c (get_lookup_ident): Assert not anonymous.
	gcc/testsuite/
	* g++.dg/modules/tdef-3_[ab].C: Extend.
	* g++.dg/modules/tdef-3_c.C: New.

From-SVN: r269653
2019-03-13 16:54:17 +00:00
Nathan Sidwell
410e860f50 module.cc (trees_out::tree_decl): Refactor named decl streaming.
gcc/cp/
	* module.cc (trees_out::tree_decl): Refactor named decl streaming.
	(trees_in::tree_node): Remove as_base special casing.
	* name-lookup.c (lookup_by_ident, get_lookup_ident): Handle
	as_base here.

From-SVN: r269649
2019-03-13 13:52:29 +00:00
Nathan Sidwell
25146f8bcc module.cc (trees_out::tree_node): Refactor.
gcc/cp/
	* module.cc (trees_out::tree_node): Refactor.
	(module_state::write_cluster): Prefer non-anonymous name.

From-SVN: r269626
2019-03-12 18:56:30 +00:00
Nathan Sidwell
b8e6e1a709 typedef struct {} foo;
gcc/cp/
	* module.cc (trees_out::tree_value): Cope with name-for-linkage.
	(trees_out::write_class_def): Likewise.
	(depset::hash::add_dependency): Likewise.
	gcc/testsuite/
	* g++.dg/modules/tdef-3_[ab].C: New.

From-SVN: r269621
2019-03-12 17:06:12 +00:00
Nathan Sidwell
b7d3611843 decl.c (fndecl_declared_return_type): Remove BMI FIXME.
gcc/cp/
	* decl.c (fndecl_declared_return_type): Remove BMI FIXME.
	* module.cc (trees_{in,out}::lang_decl_vals): Stream
	saved_auto_return_type.

From-SVN: r269617
2019-03-12 15:30:31 +00:00
Nathan Sidwell
cf446185f3 tree.c (ovl_splice): Delete.
gcc/cp/
	* tree.c (ovl_splice): Delete.

From-SVN: r269615
2019-03-12 15:09:49 +00:00
Nathan Sidwell
4e6a491d2d Kill DECL_SAVED_FUNCTION_DATA part 1
Kill DECL_SAVED_FUNCTION_DATA part 1
	gcc/cp/
	* cp-tree.h (lang_decl_fn): Replace saved_language_function with
	saved_auto_return type.
	(DECL_SAVED_FUNCTION_DATA): Delete.
	(DECL_SAVED_AUTO_RETURN_TYPE): New.
	* decl.c (duplicate_decls, start_preparsed_function): Adjust.
	(save_function_data): Only save auto return type.
	(finish_function): Drop DECL_SAVED_FUNCTION_DATA member zapping.
	(fndecl_declared_return_type): Adjust.
	* method.c (make_thunk, make_alias_for): Adjust.

From-SVN: r269614
2019-03-12 15:09:15 +00:00
Nathan Sidwell
39dbb42cd5 module.cc (writable_cmp): New.
gcc/cp/
	* module.cc (writable_cmp): New.
	(depset::hash::add_writables): Sort the hash before inserting.

From-SVN: r269610
2019-03-12 12:59:07 +00:00
Nathan Sidwell
959c6fba9e decl.c (fndecl_declared_return_type): Extend BMI hack.
gcc/cp/
	* decl.c (fndecl_declared_return_type): Extend BMI hack.
	* module.cc (tt_anon_id, tt_lambda_id): New.
	(trees_{in,out}::tree_node): Stream them.
	gcc/
	* tree.c (make_anon_name): Drop format #.

From-SVN: r269609
2019-03-12 12:41:36 +00:00
Nathan Sidwell
161c01072e avoid spurious error
From-SVN: r269593
2019-03-11 17:55:32 +00:00
Nathan Sidwell
f8ca116fbe Anon entities never placed in symbol tables.
gcc/cp/
	* module.cc (depset::hash::add_binding): Assert not anonymous.
	* name-lookup.c (pop_local_binding): Popping anonymous is a NOP.
	(do_pushdecl): Pushing anonymous doesn't push to symbol table.
	gcc/testsuite/
	* g++.dg/other/pr28114.C: Adjust errors.

From-SVN: r269590
2019-03-11 17:16:00 +00:00
Nathan Sidwell
5b6706bd46 tree.h (make_anon_name): Drop optional parm.
gcc/
	* tree.h (make_anon_name): Drop optional parm.
	* tree.c (make_anon_name): Drop 'extra' parm.
	gcc/cp/
	* cp-tree.h (TYPE_LAMBDA_P): New, require a type.
	(LAMBDA_TYPE_P): Refactor.
	(TYPE_ANON_P): New.
	(TYPE_UNNAMED_P): Use it, reject lambdas.
	* class.c (add_implicitly_declared_members): Replace LAMDBA_TYPE_P
	with TYPE_LAMBDA_P.
	(finalize_literal_type_property, explain_non_literal_class)
	(check_bases_and_members, finish_struct)
	(current_nonlambda_class_type, maybe_note_name_used_in_class): Likewise.
	* constexpr.c (check_constexpr_bind_expr_vars): Likewise.
	* decl.c (cp_finith_decomp, grokdeclarator): Likewise.
	* lambda.c (begin_lambda_type): Don't clear IDENTIFIER_ANON_P.
	(lambda_function): Replace LAMBDA_TYPE_P with TYPE_LAMBDA_P.
	(current_lambda_expr, resolvable_dummy_lambda)
	(nonlambda_method_basetype): Likewise.
	* mangle.c (decl_mandling_context, write_unqualified_name): Likewise.
	(write_local_name): Simplify anon check.
	* method.c (synthesized_method_walk): Replace LAMBDA_TYPE_P with
	TYPE_LAMBDA_P.
	(maybe_explain_explicit_delete): Likewise.
	* parser.c (cp_parser_simple_type_specifier)
	(cp_parser_parameter_declaration_clause)
	(cp_parser_parameter_declaration)
	(synthesize_immplicit_template_parm): Likewise.
	* pt.c (template_class_depth, check_for_bare_parameter_packes)
	(push_templated_decl_real, lookup_template_class_1)
	(instantiate_class_template_1, tsubst_expr)
	(tsubst_copy_and_build): Likewise.
	* semantics.c (finish_this_expr, finish_member_declaration): Likewise.
	* error.c (dump_aggr_type): Check for lambda before anonymous.
	* cp-lang.c (cxx_dwarf_name): Treat all anonymous names anonymously.

From-SVN: r269589
2019-03-11 16:45:39 +00:00
Nathan Sidwell
b9078b1565 name-lookup.h (extract_module_binding): Return binding, not name.
gcc/cp/
	* name-lookup.h (extract_module_binding): Return binding, not name.
	* name-lookup.c (extract_module_binding): Return binding, not name.
	* module.cc (depset::set_binding_name): New.
	(depset::hash::add_binding): Drop name parm, check anon names
	here.
	(depset::hash::add_writables): Adjust extract_module_binding use.

From-SVN: r269498
2019-03-08 15:55:50 +00:00
Nathan Sidwell
27020aa92c cp-tree.h (ovl_sort): Delete.
gcc/cp/
	* cp-tree.h (ovl_sort): Delete.
	* name-lookup.h (extract_module_binding): Drop type_r parm.
	* module.cc (depset::hash::add_binding): Drop type parm.
	(depset::hash::add_writables): Adjust extract_module_binding API.
	* name-lookup.c (extract_module_binding): Return name, valye by
	reference.  Don't sort.
	* tree.c (ovl_sort): Delete.

From-SVN: r269496
2019-03-08 15:21:19 +00:00
Nathan Sidwell
736df565ab Base lambda names off anonymous names.
gcc/cp/
	* cp-tree.h (IDENTIFIER_LAMBDA_P): New.
	(LAMBDA_TyPE_P): Key off name.
	(TYPE_UNNAMED_P): Simplify.
	(LAMBDANAME_PREFIX, LAMBDANAME_FORMAT): Delete.
	(make_lambda_name): Delete.
	* lambda.c (begin_lambda_type): Use make_anon_name.
	* name-lookup.c (lambda_cnt, make_lambda_name): Delete.

From-SVN: r269490
2019-03-08 12:32:27 +00:00
Nathan Sidwell
9e3484d867 Commonize anonymous name generation.
gcc/
	* tree.h (IDENTIFIER_ANON_P): New.
	(anon_aggrname_p, anon_aggrname_format): Delete.
	(make_anon_name): Declare.
	* tree.c (anon_aggrname_p, anon_aggrname_format): Delete.
	(make_anon_name): New.
	* lto-streamer-out.c (DFS::DFS_write_tree_body): Use IDENTIFIER_ANON_P.
	(hash_tree): Likewise.
	* tree-streamer-out.c (write_ts_decl_minimal_tree_pointers): Likewise.
	gcc/cp/
	* cp-tree.h (TYPE_UNNAMED_P): Use IDENTIFIER_ANON_P.
	(make_anon_name): Delete.
	* class.c (find_flexarrays): Use IDENTIFIER_ANON_P.
	* cp-lang.c (cxx_dwarf_name): Likewise.
	* decl.c (name_unnamed_type, xref_tag_1): Likewise.
	* error.c (dump_aggr_type): Likewise.
	* name-lookup.c (anon_cnt, make_anon_name): Delete.
	(consider_binding_level): Use IDENTIFIER_ANON_P.
	* pt.c (push_template_decl_real): Likewise.
	gcc/d/
	* types.cc (fixup_anonymous_offset): Use IDENTIFIER_ANON_P.
	(layout_aggregate_members): Use make_anon_name.

From-SVN: r269466
2019-03-07 18:15:30 +00:00
Nathan Sidwell
eeef66eefd Refactor all the things!
gcc/cp/
	* module.cc: Tighten up access.

From-SVN: r269439
2019-03-06 19:43:57 +00:00
Nathan Sidwell
226bf5f2ed module.cc (module_state): Reorder member fn definitions.
Refactor.
	gcc/cp/
	* module.cc (module_state): Reorder member fn definitions.

From-SVN: r269438
2019-03-06 19:35:33 +00:00
Nathan Sidwell
ded9e97b0d module.cc (module_state::is_matching_decl): Moved to ...
Refactor.
	gcc/cp/
	* module.cc (module_state::is_matching_decl): Moved to ...
	(trees_in::is_matching_decl): ... here.
	(trees_{in,out}::{mark,write,read}_*): Move earlier.

From-SVN: r269437
2019-03-06 19:29:07 +00:00
Nathan Sidwell
3c25ac9d61 module.cc (module_state::read_definition): Moved to ...
Refactor.
	gcc/cp/
	* module.cc (module_state::read_definition): Moved to ...
	(trees_in::read_definition): ... here.
	(module_state::is_skippable_defn): Move to ...
	(trees_in::is_skippable_defn): ... here.
	(module_state::read_{function,var,class,enum}_def): Move to ...
	(trees_in::read_{function,var,class,enum}_def): ... here.
	(module_state::read_binfos): Move to ...
	(trees_in::read_binfos): ... here.

From-SVN: r269436
2019-03-06 19:11:47 +00:00
Nathan Sidwell
cedae516af module.cc (module_state::{write,mark}_definition): Move to ...
Refactor.
	gcc/cp/
	* module.cc (module_state::{write,mark}_definition): Move to ...
	(trees_out::{write,mark}_definition): ... here.
	(module_state::{write,mark}_{function,var,class,enum}_def): Move to ...
	(trees_out::{write,mark}_{function,var,class,enum}_def): ... here.
	(module_state::write_binfos): Move to ...
	(trees_out::write_binfos): ... here.
	(depset::hash::find_dependencies): Drop module_state parm.

From-SVN: r269435
2019-03-06 18:51:33 +00:00
Nathan Sidwell
30e6874ffc module.cc (module_state::{add_writables,find_dependencies}): Move to ...
Refactor.
	gcc/cp/
	* module.cc (module_state::{add_writables,find_dependencies}): Move
	to ...
	(depset::hash::{add_writables,find_dependencies}): ... here.
	(depset::hash::get_work): Delete.

From-SVN: r269432
2019-03-06 18:22:27 +00:00
Nathan Sidwell
b732f7efd0 GMF pruning, Part 2
GMF pruning, Part 2
	gcc/cp/
	* module.cc (depset::hash): Rename flags fields.
	(trees_out::tree_decl): Self references by dependency binding.
	(depset::hash::add_dependency): Fix thinko.
	(binding_cmp): New.
	(depset::hash::finalize_dependencies): New.
	(module_state::write): Adjust.
	* name-lookup.c (extract_module_binding): The FIXMEs have become
	irrelevant.
	(get_binding_or_decl): Only imports for namespaces.
	gcc/testsuite/
	* g++.dg/modules/internal-1.C: Prune output.
	* g++.dg/modules/mod-sym-2.C: Check GMF not discarded.

From-SVN: r269431
2019-03-06 18:01:24 +00:00
Nathan Sidwell
093af63697 module.cc (trees_out::trees_out): Add depset::hash parm.
gcc/cp/
	* module.cc (trees_out::trees_out): Add depset::hash parm.
	(trees_out::depending_p): Invert streaming_p.
	(module_state::write_cluster): Add depset::hash parm, adjust.
	(trees_out::begin): Single ctor for both uses.
	(trees_out::end): Don't clear dep_hash.
	(module_state::find_dependencies): Adjust.
	(module_state::write): Adjust.

From-SVN: r269430
2019-03-06 17:07:05 +00:00
Nathan Sidwell
d34d579b9d Linkage promotion ban GMF pruning, Part 1
Linkage promotion ban
	GMF pruning, Part 1
	gcc/cp/
	* module.cc (depset::is_internal): New field.
	(depset::hash): Add gmfs, & internals fields.
	(depset::hash::add_dependency): Deal with gmf & internal.
	(depset::hash::add_binding): Ignore GMF & internals here.
	(module_state::write): Errors for referenced internals.
	* name-lookup.c (get_binding_or_decl): Get globals.
	gcc/testsuite/
	* g++.dg/modules/internal-1.C: New.
	* g++.dg/modules/namespace-[34]_[abc].C: Adjust.

From-SVN: r269425
2019-03-06 14:35:13 +00:00
Nathan Sidwell
712c899f52 module.cc (depset::hash::add_binding): Ignore internal-linkage entities.
gcc/cp/
	* module.cc (depset::hash::add_binding): Ignore internal-linkage
	entities.
	(module_state::add_writables): Don't walk anonymous namespaces.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_a.C: Adjust scan.
	* g++.dg/modules/unnamed-2.C: Adjust scan.

From-SVN: r269400
2019-03-05 19:48:47 +00:00
Nathan Sidwell
32596325f8 module.cc (depset::add_dependency): Drop kind arg, return void.
gcc/cp/
	* module.cc (depset::add_dependency): Drop kind arg, return void.
	(depset::hash::add_binding): Set current during addition.
	(module_state::add_writables): Tweak.

From-SVN: r269397
2019-03-05 17:48:00 +00:00
Nathan Sidwell
c6b84af365 module.cc (depset): Add refs_internal field.
gcc/cp/
	* module.cc (depset): Add refs_internal field.  Replace decl_key
	and defn_key with entity_key. Remove is_decl, add is_namespace.
	Replace get_decl with get_entity.

From-SVN: r269395
2019-03-05 16:44:10 +00:00
Nathan Sidwell
1574453f6a Merge trunk r269375.
From-SVN: r269377
2019-03-04 22:59:11 +00:00
Nathan Sidwell
e17a95cad8 Merge trunk r269375.
From-SVN: r269376
2019-03-04 22:58:49 +00:00
Nathan Sidwell
7e89ef6593 GMF content locations
GMF content locations
	gcc/cp/
	* parser.h (cp_token): Remove C compatibility macros. Add
	main_source_p field.
	* parser.c (cp_lexer_get_preprocessor_token): Set main_source_p
	field.
	(cp_lexer_before_phase_4): Rename to ...
	(cp_lexer_not_macro): ... here.  Drop main-file check.
	(cp_parser_translation_unit): Emit main-file errors.
	(cp_parser_{module,import}_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/global-1_a.C: Adjust.
	* g++.dg/modules/mod-decl-3.C: Adjust.
	* g++.dg/modules/mod-decl-5_b.C: Adjust.
	* g++.dg/modules/mod-exp-1_b.C: Adjust.
	* g++.dg/modules/mod-sym-2.C: Adjust.
	* g++.dg/modules/namespace-2_a.C: Adjust.
	* g++.dg/modules/static-1_a.C: Adjust.
	* g++.dg/modules/token-1.C: Adjust.
	* g++.dg/modules/token-2_b.C: Adjust.
	* g++.dg/modules/token-3.C: Adjust.
	* g++.dg/modules/token-4.C: Adjust.
	* g++.dg/modules/token-5.C: New.

From-SVN: r269375
2019-03-04 20:53:15 +00:00
Nathan Sidwell
58df4b11dd New # semantics for popping to "" name.
libcpp/
	* directives.c (do_linemarker): Popping to "" name means fill in
	the name.
	gcc/testsuite/
	* c-c++-common/cpp/line-1.c: New.

From-SVN: r269373
2019-03-04 20:18:21 +00:00
Nathan Sidwell
d0495cc99f cpplib.h (struct cpp_hashnode): Drop C compatibility macros.
Cleanups.
	libcpp/
	* include/cpplib.h (struct cpp_hashnode): Drop C compatibility
	macros.  Correct bit calculation.
	* include/line-map.h: Formatting.
	* line-map.c (get_pure_location): Formatting.

From-SVN: r269370
2019-03-04 17:42:40 +00:00
Nathan Sidwell
20869ca8a1 module.cc (declare_module): Deal with de-GMFing here, get name of implicit header module.
gcc/cp/
	* module.cc (declare_module): Deal with de-GMFing here, get name
	of implicit header module.
	* parser.c (enum module_preamble): New enum.
	(cp_parser_translation_unit):  Use it.
	(cp_parser_{module,import}_declaration): Use it.
	gcc/testsuite/
	* g++.dg/modules/p0713-3.C: Adjust diags.

From-SVN: r269369
2019-03-04 17:39:20 +00:00
Nathan Sidwell
a39a7395c1 Merge trunk r269321.
From-SVN: r269323
2019-03-01 17:55:50 +00:00
Nathan Sidwell
49837c4a7d Merge trunk r269078 (metadata update).
From-SVN: r269321
2019-03-01 16:39:06 +00:00
Nathan Sidwell
69dd4456b3 Apply trunk r269078.
gcc/cp/
	* module.cc (module_state::{read,write}_function_def): Adjust.

From-SVN: r269320
2019-03-01 16:34:49 +00:00
Nathan Sidwell
bcaf28b18d cp-tree.h (struct constexpr_fundef): Moved from constexpr.c.
gcc/cp/
	* cp-tree.h (struct constexpr_fundef): Moved from constexpr.c.
	(register_constexpr_fundef): Adjust.
	(find_constexpr_fundef): Replace with ...
	(retrieve_constexpr_fundef): ... this.
	* constexpr.c (struct constexpr_fundef): Moved to cp-tree.h
	(constexpr_fundef_hasher): Constify.
	(retrieve_constexpr_fundef): Make extern.
	(find_constexpr_fundef): Delete.
	(check_constexpr_fundef): Adjust.
	(register_constexpr_fundef): Adjust API.
	* module.cc (module_state::{read,write}_function_def): Adjust.

From-SVN: r269316
2019-03-01 14:22:02 +00:00
Nathan Sidwell
ec8bd3709c Merge trunk r269077.
From-SVN: r269310
2019-03-01 13:46:08 +00:00
Nathan Sidwell
fd7f592ed4 parser.c (cp_lexer_set_source_position_from_token): Revert.
gcc/cp/
	* parser.c (cp_lexer_set_source_position_from_token): Revert.

From-SVN: r269306
2019-03-01 12:51:04 +00:00
Nathan Sidwell
4ebef46785 module & import-semi lexing rules
module & import-semi lexing rules
	gcc/cp/
	* parser.c (cp_lexer_tokenize): Fix EOF push.
	(cp_lexer_before_phase_4): New.
	(cp_lexer_set_source_position_from_token): Simplify.
	(cp_parser_{module,import}_declaration): Check phase-4 requirements.
	gcc/testsuite/
	* g++.dg/modules/class-2_a.C: Do not #include
	* g++.dg/modules/token-[123]*.C: New.

From-SVN: r269284
2019-02-28 19:31:23 +00:00
Nathan Sidwell
348c719f8e Remove eof_token
Remove eof_token
	gcc/cp/
	* parser.h (cp_token): Add tree_check_p, adjust GTY tagging.
	(cp_lexer): Add saved_type, saved_keyword fields.
	* parser.c (eof_token): Delete.
	(cp_lexer_new_from_tokens): Overwrite EOF here.
	(cp_lexer_destroy): Restore overwritten token here.
	(cp_lexer_token_position, cp_lexer_previous_token_position): Simplify.
	(cp_lexer_tokenize): Likewise.
	(cp_lexer_peek_nth_token, cp_lexer_consume_token): Likewise.
	(cp_lexer_purge_token, cp_lexer_purge_tokens_after): Likewise.
	(cp_parser_nested_name_specifier, cp_parser_decltype)
	(cp_parser_template_id): Set tree_check_p.

From-SVN: r269279
2019-02-28 13:33:34 +00:00
Nathan Sidwell
314f0f37eb __import in extern "C"
__import in extern "C"
	gcc/cp/
	* parser.c (cp_lexer_tokenize): Add extern_c_depth arg, tokenize
	through extern "C".
	(cp_parser_translation_unit): Handle top-level extern "C".
	(cp_parser_module_name): Force header unit.
	(cp_parser_{module,import}_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/inc-xlate-1_[cd].C: New.

From-SVN: r269261
2019-02-27 18:26:43 +00:00
Nathan Sidwell
a966ed3bf4 cp-tree.h (import_module): Return bool.
gcc/cp/
	* cp-tree.h (import_module): Return bool.
	* module.cc (import_module): Return is_header flag.
	* parser.c (cp_parser_tokenize): Rename to ...
	(cp_lexer_tokenize): ... this.  Reimplement.
	(cp_parser_import_declaration): Return is_header flag.
	(cp_parser_translation_unit): Adjust lexer tokenization interaction.

From-SVN: r269257
2019-02-27 15:29:33 +00:00
Nathan Sidwell
dd2acf6a68 Flag_modules is strictly boolean.
gcc/c-family/
	* c.opt (fmodules-ts): Allow negation.
	gcc/cp/
	* decl.c (duplicate_decls): Use modules_p.
	* lex.c (module_preprocess_token): Use modules_p.
	* parser.c (cp_parser_diagnose_invalid_type)
	(cp_parser_translation_unit, cp_parser_tokenize): Likewise.
	* module.cc (module_begin_main_file): Likewise.
	(handle_module_option): Adjust.
	gcc/
	* doc/invoke.texi (fmodules-ts): Adjust.

From-SVN: r269231
2019-02-26 21:02:08 +00:00
Nathan Sidwell
80b046381a Preprocess __import.
gcc/cp/
	* cp-tree.h (import_module): Add extern C flag.
	* lex.c (module_preprocess_token): Allow __import in extern-c
	* module.c (import_module): Add extern C flag.
	* parser.c (cp_parser_import_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/inc-xlate-1{.map,_[ab].H}: New.

From-SVN: r269228
2019-02-26 20:03:43 +00:00
Nathan Sidwell
a2e74eee5a Distinguished __import spelling.
gcc/c-family/
	* c-common.c (c_common_reswords): Add __import spelling.
	gcc/cp/
	* module.cc (module_mapper::translate_include): Use __import.
	gcc/testsuite/
	* g++.dg/modules/legacy-[3456]*: Adjust.
	* g++.dg/modules/map-2.C: Likewise.

From-SVN: r269225
2019-02-26 18:49:34 +00:00
Nathan Sidwell
921577aedf Fix preprocessor tokenizing rules.
gcc/cp/
	* lex.c (module_preprocess_token): Detect extern "C" {, tokenize
	trailing attributes before importing header unit.
	gcc/testsuite/
	* g++.dg/modules/cpp-2_[abc].[CH]: Extend testing.

From-SVN: r269223
2019-02-26 18:08:34 +00:00
Nathan Sidwell
680f8b6f1b Fix interface partition export rules.
gcc/cp/
	* module.cc (module_state::read_imports): Don't check partition
	import/export here ...
	(module_state::direct_import): ... or here ...
	(module_state::write): ... but do it here.
	gcc/testsuite/
	* g++.dg/modules/part-2_[cd].C: Adjust.
	* g++.dg/modules/part-2_e.C: New.

From-SVN: r269215
2019-02-26 15:30:38 +00:00
Nathan Sidwell
6dcef32638 invoke.texi: Update modules documentation.
gcc/
	* doc/invoke.texi: Update modules documentation.

From-SVN: r269147
2019-02-23 02:35:12 +00:00
Nathan Sidwell
99679bed65 mkdeps.h (deps_write): Add phony arg.
libcpp/
	* mkdeps.h (deps_write): Add phony arg.
	(deps_phony_targets): Delete.
	* init.c (cpp_finish): Adjust deps_write call.
	* mkdeps.c (mrules): Add quote_lwm member.
	(munge): Just return static buffer.
	(deps_add_target, deps_add_dep, deps_add_module): Store unmunged.
	(write_name): Rename ...
	(make_write_name): ... here.  Maybe munge here.
	(write_vec, deps_write): Rename to ...
	(make_write_vec, make_write): ... here.  Adjust.
	(deps_write): New wrapper.

From-SVN: r269146
2019-02-23 02:04:15 +00:00
Nathan Sidwell
ef2904ca0c cp-tree.h (init_module_processing): Add arg.
gcc/cp/
	* cp-tree.h (init_module_processing): Add arg.
	* decl.c (cxx_init_decl_processing): Adjust.
	* module.cc (init_module_processing): Check preprocess sanity.

From-SVN: r269128
2019-02-22 18:29:12 +00:00
Nathan Sidwell
4dcc1c0fae mkdeps.c (deps_add_module): Allow empty bmi name.
libcpp/
	* mkdeps.c (deps_add_module): Allow empty bmi name.
	(deps_write): Refactor. Add PHONY.
	gcc/cp/
	* cp-tree.h (module_preprocess): Declare.
	* lex.c (module_preprocess_token): Have a proper state object,
	register imports with dependency machinery.
	* module.cc (module_preprocess_token): New.
	(module_begin_main_file): Cope with just preprocessing.

From-SVN: r269126
2019-02-22 17:54:10 +00:00
Nathan Sidwell
6b2ca38c1b c.opt: Rename fmodule-legacy to fmodule-header
gcc/c-family/
	* c.opt: Rename fmodule-legacy to fmodule-header
	gcc/
	* doc/invoke.texi: Update.
	gcc/cp/
	* cp-tree.h, module.cc, lang-specs.h, name-lookup.c, parser.c:
	Rename.
	gcc/testsuite/
	* g++.dg/modules/: Likewise.

From-SVN: r269092
2019-02-22 01:24:43 +00:00
Nathan Sidwell
fedfa06cb8 langhooks.h (struct lang_hooks): Adjust preprocess_token API.
gcc/
	* langhooks.h (struct lang_hooks): Adjust preprocess_token API.
	gcc/cp/
	* lex.c (module_preprocess_token): Adjust API.
	* cp-tree.h (module_preprocess_token): Adjust API.
	* module.cc (module_state::direct_import): Not fatal if preprocessing.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Adjust preprocess_token
	hook API.

From-SVN: r269076
2019-02-21 20:53:53 +00:00
Nathan Sidwell
46d51789a5 REVISION: Add [].
gcc/
	* REVISION: Add [].
	gcc/cp/
	* Make-lang.in (MODULE_VERSION): Replace ...
	(MODULE_STAMP): ... this.  Adjust
	* cxx-mapper.cc: Update.
	* module.cc: Update version behaviour.
	(module_state::do_import): Add dependency.
	libcpp/
	* mkdeps.c (mrules): Add dtor properly.   Add modules.
	(deps_write): Spew module deps.

From-SVN: r269051
2019-02-20 20:21:25 +00:00
Nathan Sidwell
92577f23eb Merge trunk r268782.
From-SVN: r268794
2019-02-12 13:46:25 +00:00
Nathan Sidwell
2a6bf78629 Make dependencies
Make dependencies
	libcpp/
	* include/cpplib.h (cpp_get_deps): Change type.
	* include/mkdeps.h (struct deps): Rename to ...
	(struct mrules): ... this.  Adjust accessors.
	(deps_add_module): Declare.
	* internal.h (sttuct cpp_reader): Likewise.
	* mkdeps.c (struct mrules): Rename from deps.  Add module fields.
	(munge): Allow concatenation.
	(deps_add_module): New.
	(write_name, write_vec): New, broken out of ...
	(deps_write): ... this.  Add module pieces.
	gcc/
	* module.cc: #include mkdeps.h.
	(module_state::direct_import): Add module to dependencies.
	(finish_module_parse): Set target dependency info.
	gcc/c-family/
	* c-opts.c (handle_deferred_opts): Adjust dep accessors.
	gcc/fortran/
	* cpp.c (gfc_cpp_add_dep, gfc_cpp_add_target, gfc_cpp_init): Adjust
	dep accessors.

From-SVN: r268782
2019-02-11 20:38:49 +00:00
Nathan Sidwell
f95467a7ec mkdeps.c (struct deps): Make more C++y.
libcpp/
	* mkdeps.c (struct deps): Make more C++y.  Update all uses.

From-SVN: r268703
2019-02-08 15:40:42 +00:00
Nathan Sidwell
350b3f1aea module.cc (module_mapper::module_mapper): Fix local socket creation.
gcc/cp/
	* module.cc (module_mapper::module_mapper): Fix local socket creation.

From-SVN: r268641
2019-02-07 14:52:32 +00:00
Nathan Sidwell
0c8ec7dd9d c++-mapper.cc (module2bmi): Do not map dir separators.
gcc/cp/
	* c++-mapper.cc (module2bmi): Do not map dir separators.
	gcc/testsuite/
	* g+.dg/modules/modules.exp (decode_mod_spec): Likewise.

From-SVN: r268616
2019-02-07 13:24:38 +00:00
Nathan Sidwell
ac3f39bbcc module.cc (create_dirs): New.
gcc/cp/
	* module.cc (create_dirs): New.
	(maybe_add_bmi_prefix): Add FORCE parm, adjust.
	(finish_module_parse): Try and create intermediate dirs.

From-SVN: r268615
2019-02-07 13:03:11 +00:00
Nathan Sidwell
70cd6925c0 prefix mismatch to dump file
From-SVN: r268577
2019-02-06 12:46:19 +00:00
Nathan Sidwell
e7642770e3 name-lookup.c (finish_namespace_using_decl): Add assert + FIXME.
gcc/cp/
	* name-lookup.c (finish_namespace_using_decl): Add assert + FIXME.

From-SVN: r268549
2019-02-05 17:10:52 +00:00
Nathan Sidwell
dde51bb05f cxx-mapper.cc (client::action): Add mapper agent.
gcc/cp/
	* cxx-mapper.cc (client::action): Add mapper agent.
	* module.cc (module_mapper::handshake): Add mapper agent slot.
	gcc/
	* doc/invoke.texi (C++ Module Mapper): Update handshake.

	gcc/cp/
	* module.cc (module_state::read_locations): Make warning
	development-only.

From-SVN: r268548
2019-02-05 16:59:53 +00:00
Nathan Sidwell
b0bb86d3bf module.cc (module_state::read_locations): Make wanring development-only.
gcc/cp/
	* module.cc (module_state::read_locations): Make wanring
	development-only.

From-SVN: r268538
2019-02-05 14:48:25 +00:00
Nathan Sidwell
3663899cf1 module.cc (get_module_slot): New broken out of ...
gcc/cp/
	* module.cc (get_module_slot): New broken out of ...
	(get_module): ... here.  Call it.
	(module_mapper::translate_include): Cope with file mapper.
	gcc/testsuite/
	* g++.dg/modules/map-2.{C,map}: New.	gcc/cp/
	* module.cc (get_module_slot): New broken out of ...
	(get_module): ... here.  Call it.
	(module_mapper::translate_include): Cope with file mapper.
	gcc/testsuite/
	* g++.dg/modules/map-2.{C,map}: New.

From-SVN: r268535
2019-02-05 14:29:43 +00:00
Nathan Sidwell
83d7176282 Merge trunk r268456.
From-SVN: r268457
2019-02-01 21:01:45 +00:00
Nathan Sidwell
5eb5a3f722 indent
From-SVN: r268456
2019-02-01 20:58:03 +00:00
Nathan Sidwell
ee75767dbc decl.c (duplicate_decls): Accomodate anticipated fns.
gcc/cp/
	* decl.c (duplicate_decls): Accomodate anticipated fns.
	* module.cc (set_module_owner): Adjust.
	gcc/testsuite/
	* g++.dg/modules/printf-1_[ab].[HC]: New.

From-SVN: r268454
2019-02-01 17:59:28 +00:00
Nathan Sidwell
4cc495496b module.cc (try_increase_lazy): Fix setrlimit call.
gcc/cp/
	* module.cc (try_increase_lazy): Fix setrlimit call.
	(init_module_processing): Fix getrlimit call.

From-SVN: r268423
2019-01-31 14:43:42 +00:00
Nathan Sidwell
48df08ee81 module.cc (init_module_processing): Dump even more config.
gcc/cp/
	* module.cc (init_module_processing): Dump even more config.
	Tweak lazy limit.

From-SVN: r268421
2019-01-31 13:42:39 +00:00
Nathan Sidwell
b201fbc904 Rework lazy limit handling.
gcc/cp/
	* module.cc (lazy_limit, lazy_hard_limit, LAZY_HEADROOM): New.
	(lazy_open): Invert sense, make unsigned.  Adjust all uses.
	(try_increase_lazy): New.
	(module_state::freeze_an_elf): Call it first.
	(init_module_processing): Adjust lazy_limit setting.

From-SVN: r268420
2019-01-31 12:57:47 +00:00
Nathan Sidwell
10323633c0 ADL part 2
ADL part 2
	gcc/cp/
	* cp-tree.h (LOOKUP_FOUND_P): Allow enumeral type.
	* module.cc (module_visible_instantiation_path): Protect against
	not modules.
	* name-lookup.c (name_lookup::adl_enum): New.
	(name_lookup::adl_type): Use it.
	(name_lookup::adl_namespace): INST_PATH may be null.
	(name_lookup::search_adl): Add partitions of types.
	gcc/testsuite/
	* g++.dg/modules/adl-[23]_[abc].C: New.

From-SVN: r268401
2019-01-30 20:38:28 +00:00
Nathan Sidwell
7b3dfc8207 ADL part 1
ADL part 1
	gcc/cp/
	* cp-tree.h (module_visible_instantiation_path): Declare.
	* module.cc (module_visible_instantiation_path): Implement.
	* name-lookup.c (name_lookup::add_module_fns): Delete.
	(name_lookup::add_namespace_fns): Add visible bitmaps,
	reimplement.
	(name_lookup::search_adl): Get path of instantiation.
	gcc/testsuite/
	* g++.dg/modules/adl-1_[abc].C: New.

From-SVN: r268399
2019-01-30 17:42:03 +00:00
Nathan Sidwell
40bcebefe7 name-lookup.c (name_lookup::adl_namespace_only): Delete.
gcc/cp/
	* name-lookup.c (name_lookup::adl_namespace_only): Delete.
	(name_lookip::adl_{namespace,class}_fns): New.
	(name_lookup::adl_{namespace,class}): Adjust.
	(name_lookup::search_adl): Refactor.

From-SVN: r268395
2019-01-30 15:29:54 +00:00
Iain Sandoe
3ccfaa402e module.cc: Reorder includes.
gcc/cp/
	* module.cc: Reorder includes.
	* cxx-mapper.cc: Likewise.

From-SVN: r268387
2019-01-30 12:25:22 +00:00
Iain Sandoe
b02aa56a34 fn-inline-1_{bc}.C: Adjust weak scan.
gcc/testsuite/
	* g++.dg/modules/fn-inline-1_{bc}.C: Adjust weak scan.

From-SVN: r268386
2019-01-30 12:03:32 +00:00
Nathan Sidwell
fe7848b86c invoke.texi (C++ Modules): Add submenu.
gcc/
	* doc/invoke.texi (C++ Modules): Add submenu.

From-SVN: r268385
2019-01-30 12:00:41 +00:00
Nathan Sidwell
41dfd13ea0 module.cc (init_module_processing): Dump more config.
gcc/cp/
	* module.cc (init_module_processing): Dump more config.

From-SVN: r268364
2019-01-29 13:32:11 +00:00
Nathan Sidwell
e7b08c11b9 module.cc (MAPPED_READING, [...]): 0 or 1
gcc/cp/
	* module.cc (MAPPED_READING, MAPPED_WRITING): 0 or 1
	(init_module_processing): Dump mapping behaviour.

From-SVN: r268363
2019-01-29 12:59:03 +00:00
Nathan Sidwell
ad4d4f6512 module.cc (module_mapper::make): Drop options arg, look at CXX_MODULE_MAPPER.
gcc/cp/
	* module.cc (module_mapper::make): Drop options arg, look at
	CXX_MODULE_MAPPER.
	gcc/
	* doc/invoke.texi (fmodule-mapper): Document env var.
	(C++ Module Mapper): Likewise.

From-SVN: r268340
2019-01-28 18:47:37 +00:00
Nathan Sidwell
cad26d5035 module.cc (trees_{in,out}::core_vals): Lambda location.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Lambda location.
	* cp-objcp-common.c (cp_common_init_ts): Fix LAMBDA_EXPR marking.
	* cp-tree.h (tree_lambda_expr): Save 8 bytes.

From-SVN: r268339
2019-01-28 18:12:27 +00:00
Nathan Sidwell
23fd81f8f2 Merge trunk r268337.
From-SVN: r268338
2019-01-28 16:50:45 +00:00
Nathan Sidwell
639a13481e More fixme reformatting
From-SVN: r268227
2019-01-24 00:30:43 +00:00
Nathan Sidwell
303f8733c1 Reformat FIXMEs
From-SVN: r268226
2019-01-24 00:17:02 +00:00
Nathan Sidwell
cc8c93090b module.cc (trees_{in,out}::core_vals): Stream expression locii.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream expression locii.

From-SVN: r268222
2019-01-23 23:17:45 +00:00
Nathan Sidwell
c5c761a75d cp-objcp-common.c (cp_common_init_ts): MARK_TS_EXP for tcc_statement.
gcc/cp/
	* cp-objcp-common.c (cp_common_init_ts): MARK_TS_EXP for tcc_statement.

From-SVN: r268221
2019-01-23 23:05:31 +00:00
Nathan Sidwell
cf0b8150a7 cp-objcp-common.c (cp_common_init_ts): MARK_TS_EXP for scope_ref & noexcept_expr.
gcc/cp/
	* cp-objcp-common.c (cp_common_init_ts): MARK_TS_EXP for scope_ref
	& noexcept_expr.
	* module.cc (trees_{in,out}::core_vals): Rely on TS_EXP.

From-SVN: r268220
2019-01-23 22:54:43 +00:00
Nathan Sidwell
19549423da module.cc (trees_{in,out}::core_vals): Adjust expression streaming.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Adjust expression streaming.

From-SVN: r268218
2019-01-23 22:42:22 +00:00
Nathan Sidwell
a71b42a283 Fix TS_CONTAINS_STRUCT for tcc_expression.
gcc/
	(MARK_TS_EXP): New.
	gcc/c-family/
	* c-common.c (c_common_init_ts): Use MARK_TS_EXP. Mark
	SIZEOF_EXPR.
	gcc/cp/
	* cp-objcp-common.c (cp_common_init_ts): MARK_TS_EXP for
	tcc_expression nodes.  Call c_common_init_ts.

From-SVN: r268217
2019-01-23 22:19:32 +00:00
Nathan Sidwell
4385532f1f module.cc (trees_{in,out}::core_vals): Clean up enumeral type handling.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Clean up enumeral type
	handling.
	(trees_out:tree_node, module_state::mark_enum_def): Use
	SCOPED_ENUM_P.

From-SVN: r268206
2019-01-23 20:53:13 +00:00
Nathan Sidwell
019fec68e1 module.cc (tree_tag): Add tt_enum_int.
gcc/cp/
	* module.cc (tree_tag): Add tt_enum_int.
	(trees_out::mark_node): Allow marking non-decls.
	(trees_{in,out}::tree_node): Serialize enum values.
	(module_state::mark_enum_def): Mark enum int_csts.
	gcc/testsuite/
	* g++.dg/modules/enum_1_[ab].C: Test serialization.

From-SVN: r268196
2019-01-23 19:40:33 +00:00
Nathan Sidwell
f63dc19d3f module.cc (trees_in::finish_type): Don't speciual case TYPE_PACKs.
gcc/cp/
	* module.cc (trees_in::finish_type): Don't speciual case
	TYPE_PACKs.
	* pt.c (template_parm_to_arg, coerce_template_parameter_pack)
	(make_argument_pack, tsubst_template_args, tsubst)
	(type_unification_real, unify_pack_expansion): Set
	TYPE_STRUCTURAL_EQUALITY for type packs.

From-SVN: r268194
2019-01-23 18:59:19 +00:00
Nathan Sidwell
e6b2e9ff5f cp-objcp-common.c (cp_common_init_ts): Set TYPE_PACK_EXPANSION and TYPE_ARGUMENT_PACK correctly.
gcc/cp/
	* cp-objcp-common.c (cp_common_init_ts): Set TYPE_PACK_EXPANSION
	and TYPE_ARGUMENT_PACK correctly.
	* module.c (trees_in::finish_type): Special case pack types and
	bound parms.
	gcc/testsuite/
	* g++.dg/modules/var-tpl-1_[ab].C: New.

From-SVN: r268171
2019-01-22 23:58:11 +00:00
Nathan Sidwell
a0f65afcfa module.cc (tree_tag): Add tt_ptrmem_type.
gcc/cp/
	* module.cc (tree_tag): Add tt_ptrmem_type.
	(trees_{in,out}::core_vals): Don't scrog pointer's ptrmem cache.
	(trees_out::tree_type): Stream pointers to member functions.
	(trees_in::tree_node): Likewise.
	gcc/testsuite/
	* g++.dg/modules/nodes-1_[ab].C: More.

From-SVN: r268169
2019-01-22 22:42:42 +00:00
Nathan Sidwell
a19f26e866 module.cc (trees_{in,out}::core_vals): Stream tcc_reference, baselink, static_assert, trait_expr.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream tcc_reference,
	baselink, static_assert, trait_expr.
	gcc/testsuite/
	* g++.dg/modules/nodes-1_[ab].C: New.

From-SVN: r268078
2019-01-18 14:23:44 +00:00
Nathan Sidwell
284bf9e027 module.cc (trees_{in,out}::core_vals): Stream tcc_reference, baselink, static_assert, trait_expr.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): Stream tcc_reference,
	baselink, static_assert, trait_expr.
	gcc/testsuite/
	* g++.dg/modules/nodes-1_[ab].C: New.

From-SVN: r268074
2019-01-18 12:39:20 +00:00
Nathan Sidwell
3da1800b6e module.cc (module_state::{read,write}_locations): Fix macro expansion compression.
gcc/cp/
	* module.cc (module_state::{read,write}_locations): Fix macro
	expansion compression.

From-SVN: r268073
2019-01-18 12:37:19 +00:00
Nathan Sidwell
abd3e0919e Enable partition entity merging.
gcc/cp/
	* module.cc (depset::hash): Add mergeable flag.
	(trees_out::{tpl_parms,tree_mergeable}): Protect from not
	streaming.
	(depset::hash::add_dependency): Deal with mergeablility.
	(depset::hash::add_mergeable): New.
	(depset::hash::connect): Adjust dump.
	(module_state::write_cluster): Sort mergeables.
	(module_state::find_dependencies): Deal with mergeability.
	(module_state::sort_mergeables): New.
	gcc/testsuite/
	* g++.dg/modules/scc-1.C: Adjust scans.
	* g++.dg/modules/part-3_[cd].C: Remove xfails.

From-SVN: r268040
2019-01-17 16:58:47 +00:00
Nathan Sidwell
f0f13f827c module.cc (trees_{in,out}::fn_parms): New.
gcc/cp/
	* module.cc (trees_{in,out}::fn_parms): New.
	(trees_{in,out}::tree_mergeable): Call them.
	(cluster_cmp): Move earlier.
	(depset::hash::connect): New, broken out of ...
	(module_state::write): ... here.  Call it.

From-SVN: r268039
2019-01-17 16:49:09 +00:00
Nathan Sidwell
7bbc69c239 module.cc (trees_{in,out}::tree_mergeable): Allow non-implicit typedefs.
gcc/cp/
	* module.cc (trees_{in,out}::tree_mergeable): Allow non-implicit
	typedefs.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-9_[abc].[HC]: New.

From-SVN: r267990
2019-01-16 22:56:04 +00:00
Nathan Sidwell
d035d32af8 Merge partition entities (disabled).
gcc/cp/
	* module.cc (trees_{in,out}::tree_mergeable): Fold partitions.
	(module_state::{read,write}_cluster): Register module entities.
	gcc/testsuite/
	* g++.dg/modules/part-3_[abcd].C: New.

From-SVN: r267988
2019-01-16 22:35:30 +00:00
Nathan Sidwell
d1ee5e53da module.cc (dumper::GM): Rename to MERGE.
gcc/cp/
	* module.cc (dumper::GM): Rename to MERGE.  Update uses.

From-SVN: r267982
2019-01-16 18:16:48 +00:00
Nathan Sidwell
fb95135d25 cp-tree.h (module_name): Replace FULL parm with primary pointer.
gcc/cp/
	* cp-tree.h (module_name): Replace FULL parm with primary pointer.
	* error.c (dump_module_suffix): Adjust.
	* module.cc (module_state::fullname): Rename to flatname.
	(module_state::{get,set}_flatname): New.  Use get_flatname.
	(module_state::attach): Conditionally call set_flatname.
	(get_module): Likewise.
	(module_mapper::imex_query): Adjust.
	(module_mapper::bmi_response): Likewise.
	(module_state::write_readme): Adjust.
	(module_state::{read,write}_config): Adjust name checking.
	* name-lookup.c (make_namespace): Adjust anonymous name creation.
	* ptree.c (cxx_print_decl): Adjust.
	gcc/testsuite/
	* g++.dg/modules/part-2_[cd].C: Adjust regex.

From-SVN: r267981
2019-01-16 18:14:26 +00:00
Nathan Sidwell
eacd1d2c32 cp-tree.h (module_name): Add FULL parm.
gcc/cp/
	* cp-tree.h (module_name): Add FULL parm.
	* module.cc (module_name): Check it and strip partitions if not.
	* error.c (dump_module_suffix): Don't want full name.

From-SVN: r267977
2019-01-16 15:58:35 +00:00
Nathan Sidwell
82cdbd898a Merge trunk r267946.
From-SVN: r267947
2019-01-15 20:17:22 +00:00
Nathan Sidwell
59877906f3 Partition BMI folding, but not entity merging.
gcc/cp/
	* cp-tree.h (get_module_owner): Mark PURE.
	* module.cc (loc_spans::open): Add location parm.
	(trees_out::{lang_decl_bools,tree_node_specific,tree_decl}): Account
	for remapping.
	(depset::hash::add_binding): Account for partitions.
	(module_state::write_locations): Account for partitions.
	(module_state::read_locations): Add partition spans to primary
	interface.
	(module_state::add_writables): Add partition bitmap arg.  Adjust
	extraction.
	(module_state::write): Generate partition bitmap.
	(module_state::read): Only read partitions on primary.
	* name-lookup.h (extract_module_binding): Adjust parms.
	* name-lookup.c (add_mergeable_decl): Break out from ...
	(record_mergeable_decl): ... here.  Call it.
	(match_mergeable_decl): Likewise.
	(check_mergeable_decl): Tweak.
	(extract_module_binding): Examine partitions and merge.
	* tree.c (ovl_sort): Simplify. 
	gcc/testsuite/
	* g++.dg/modules/part-1_a.C: Adjust.
	* g++.dg/modules/part-1_c.C: New.

From-SVN: r267945
2019-01-15 18:58:21 +00:00
Nathan Sidwell
9cfc4be642 tree.h (cache_integer_cst): Add defaulted small parm.
gcc/
	* tree.h (cache_integer_cst): Add defaulted small parm.
	* tree.c (cache_integer_cst): Add small parm, adjust.
	gcc/cp/
	* module.cc (trees_out::start): FIXED_CST are C only.
	(trees_in::finish): Merge small INTEGER_CSTs.
	(trees_{in,out}::core_bools): Don't write base.public_flag of types.

From-SVN: r267919
2019-01-14 15:03:33 +00:00
Nathan Sidwell
9ab9abbc96 module.cc (trees_out::start): Catch POLY_INT_CST, adjust VECTOR_CST.
gcc/cp/
	* module.cc (trees_out::start): Catch POLY_INT_CST, adjust
	VECTOR_CST.
	(trees_{in,out}::core_vals): Do TS_VECTOR.
	* g++.dg/modules/literals-1_[ab].C: Add vector cst.

From-SVN: r267918
2019-01-14 13:37:39 +00:00
Nathan Sidwell
aed4f51ab8 String literals.
gcc/cp/
	* module.cc (trees_{in,out}::core_vals): String literals (a NOP).
	gcc/testsuite/
	* g++.dg/modules/literals-1_[ab].C: Add string lit.

From-SVN: r267857
2019-01-11 20:36:21 +00:00
Nathan Sidwell
7e39994e30 Reals & Complex
Reals & Complex
	gcc/cp/
	* module.cc (bytes_{in,out}::buf): Void pointer
	(trees_{in,out}::core_vals): Stream REAL_CST & COMPLEX.
	gcc/testsuite/
	* g++.dg/modules/literals-1_[ab].C: New.

From-SVN: r267856
2019-01-11 20:21:37 +00:00
Nathan Sidwell
5283d2b1f1 module.cc (get_module): Fix partition parsing.
gcc/cp/
	* module.cc (get_module): Fix partition parsing.
	(module_state::read_imports): Check interface import requirements.
	(module_state::{read,write}_partitions): No need for exported.
	(module_state::write_config): Write is_interface.
	(module_state::direct_import): Check interface import
	requirements.
	(declare_module): Set interface_p, not exported_p.
	* parser.c (cp_parser_module_name): Partitions only in non-legacy
	module purview.
	gcc/testsuite/
	* g++.dg/modules/part-2_[abcd].C: New.

From-SVN: r267853
2019-01-11 19:16:01 +00:00
Nathan Sidwell
c6b110ddac cp-tree.h (module_not_legacy_p): New.
gcc/cp/
	* cp-tree.h (module_not_legacy_p): New.
	* module.cc (trees_out::tree_namespace): Rema namespace owner.
	(tree_in::tree_node): Protect bogus tt_namespace.
	* name-lookup.c (record_mergeable_decl): New.
	(check_mergeable_decl): Namespaces are never overloaded.
	(check_module_override): Add to mergeable list.
	(do_pushdecl): Record mergeable.
	(make_namespace_finish): Use check_mergeable_decl.  Never add to level
	(push_namespace): Add to level here.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_b.C: Adjust dump scan.

From-SVN: r267813
2019-01-10 15:48:47 +00:00
Nathan Sidwell
d38cefbdd5 module.cc (finish_module_parse): Better location info on errors.
gcc/cp/
	* module.cc (finish_module_parse): Better location info on errors.
	* name-lookup.c (name_lookup::search_namespace_only): Skip
	partition slot too.
	(check_module_override): Likewise.
	(check_mergeable_decl): New broken out of ...
	(match_mergeable_decl): ... here.  Call it.
	(reuse_namespace): Iterate over global slot.
	* ptree.c (cxx_print_xnode): More cluster info.

From-SVN: r267807
2019-01-10 12:35:36 +00:00
Nathan Sidwell
9bd3deff8b module.cc (module_state::read_partitions): New.
gcc/cp/
	* module.cc (module_state::read_partitions): New.
	(module_state::read_imports): Deal with elided partitions.
	(module_state::write_partitions): Write more.
	(module_state::read): Read partitions.
	(module_state::direct_import): Deal with elided partitions.
	(process_deferred_imports): Don't request known filenames.  Avoid
	double request.
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-2_d.C: Check no duplicate.
	gcc/
	* doc/invoke.texi (C++ Modules): Update.

From-SVN: r267782
2019-01-09 20:38:06 +00:00
Nathan Sidwell
8dec5c04fa module.cc (module_state::read_partitions): New.
gcc/cp/
	* module.cc (module_state::read_partitions): New.
	(module_state::read_imports): Deal with elided partitions.
	(module_state::write_partitions): Write more.
	(module_state::read): Read partitions.
	(module_state::direct_import): Deal with elided partitions.
	(process_deferred_imports): Don't request known filenames.  Avoid
	double request.
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-2_d.C: Check no duplicate.
	gcc/
	* doc/invoke.texi (C++ Modules): Update.

From-SVN: r267780
2019-01-09 19:56:45 +00:00
Nathan Sidwell
e64aacbe18 module.cc (module_state::from_partition_p): New field.
gcc/cp/
	* module.cc (module_state::from_partition_p): New field.
	(module_state::maybe_partition_name): New.
	(module_state::{read,write}_imports): Adjust.
	(module_state::write_partitions): New.
	(module_state::remap_partitions): Delete.
	(trees_out::tree_decl): Remap owner.
	(module_state::write_readme): Adjust.
	(module_state_config): Add imports and partitions fields.
	(module_state::{read,write}_config): Adjust.
	(module_state::write): Separate out hidden partitions.  Adjust
	import & partition writing.
	(module_state::read): Adjust import reading.
	gcc/testsuite/
	* g++.dg/modules/import-1_c.C: Adjust scan.
	* g++.dg/modules/mod-imp-1_c.C: Likewise.

From-SVN: r267777
2019-01-09 17:37:14 +00:00
Nathan Sidwell
baab95c119 missed checkin
From-SVN: r267737
2019-01-08 20:28:08 +00:00
Nathan Sidwell
0f0ebbad70 cxx-mapper.cc (module2bmi): Update mapping
gcc/cp/
	* cxx-mapper.cc (module2bmi): Update mapping
	* module.cc (module_state::{maybe_defrost,freeze_an_elf}): Quote
	filename..
	gcc/testsuite/
	* g++.dg/modules/modules.exp (decode_mod_spec): Update mapping.
	* g++.dg/modules/freeze-1_d.C: Adjust scan-final.
	* g++.dg/modules/import-2.C: Likewise.
	* g++.dg/modules/mod-stamp-1_d.C: Likewise.

From-SVN: r267736
2019-01-08 20:16:30 +00:00
Nathan Sidwell
52ce475262 module.cc (module_state::{interface_p,is_interface}): New.
gcc/cp/
	* module.cc (module_state::{interface_p,is_interface}): New.
	(module_state::resolve_alias): Don't propagate exported_p here.
	(module_state::write_readme): Show exportedness of imports.
	(module_state::read_imports): Use resolve_alias.
	(module_state::read_config): Set interface_p.
	(module_state::read): Reformat.
	(module_state::set_import): Correctly set imports.
	(module_state::direct_import): Not here.
	(declare_module): Set interface_p.
	gcc/testsuite/
	* g++.dg/modules/import-1_e.C: Adjust scan.

From-SVN: r267733
2019-01-08 18:55:41 +00:00
Nathan Sidwell
2686e405b2 module.cc (bytes_out::set_crc): Only set if crc_ptr != 0.
gcc/cp/
	* module.cc (bytes_out::set_crc): Only set if crc_ptr != 0.
	(module_state::write_readme): Update for partitions.
	(module_state::{read,write}_config): Write exported_p for
	partitions.
	(finish_module_parse): Write partitions.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-2.C: Adjust.
	* g++.dg/modules/atom-pragma-3.C: Adjust.
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-decl-3.C: Adjust.

From-SVN: r267730
2019-01-08 15:42:25 +00:00
Nathan Sidwell
e29a29fdbb module.cc (module_state::direct_import): Add LAZY parm, use it rather than legacy_p.
gcc/cp/
	* module.cc (module_state::direct_import): Add LAZY parm, use it
	rather than legacy_p.  Never expect a has_bmi file.
	(declare_module): Always add to pending imports.
	* parser.c (cp_parser_translation_unit): Expect a deferred import
	for a legacy module.

From-SVN: r267729
2019-01-08 14:55:04 +00:00
Nathan Sidwell
e5d618176e cp-tree.h (module_has_bmi_p): New.
gcc/cp/
	* cp-tree.h (module_has_bmi_p): New.
	* module.cc (module_state::{is_interface,interface_p}): Rename to ...
	(module_state::{is_primary,primary_p}): ... here.  Adjust users.
	(module_state::read_cluster): Partitions need deduping too.
	(declare_module): Set primary_p, partition_p.
	(process_pending_imports): Adjust.

From-SVN: r267727
2019-01-08 14:27:32 +00:00
Nathan Sidwell
daa60bdd32 cp-tree.h (module_export_depth, [...]): Replace with ...
gcc/cp
	* cp-tree.h (module_export_depth, module_purview): Replace with ...
	(module_kind): ... this.
	(MK_MODULE, MK_GLOBAL, MK_INTERFACE, MK_PARTITION, MK_EXPORTING): New.
	(module_purview_p, not_module_p, module_legacy_p)
	(module_interface_p, module_partition_p, module_global_p)
	(module_exporting_p): Adjust.
	(declare_module): Return bool.
	* module.cc (module_export_depth, module_purview): Replace with ...
	(module_kind): ... this.
	(module_maybe_interface_p): Delete.
	(module_state::direct_import, declare_module)
	(module_begin_main_file, process_deferred_imports)
	(finish_module_parse): Adjust.
	* name-lookup.c (make_namespae): Use module_global_p.
	* parser.c (cp_parser_module_declaration): Return bool.  Deal with
	GMF introducer.
	(cp_parser_translation_unit, cp_parser_module_export): Adjust.
	gcc/testsuite/
	* g++.dg/modules/circ-1_d.C: Adjust.
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-decl-5_b.C: Adjust.
	* g++.dg/modules/p0713-3.C: Adjust.

From-SVN: r267724
2019-01-08 12:52:00 +00:00
Nathan Sidwell
e649824165 cxx-mapper.cc (module2bmi): Don't map ':'.
gcc/cp/
	* cxx-mapper.cc (module2bmi): Don't map ':'.
	* module.cc: Update design description.
	gcc/testsuite/
	* g++.dg/modules/modules.exp (decode_mod_spec): Don't map ':'

From-SVN: r267659
2019-01-07 20:22:30 +00:00
Nathan Sidwell
1500f4c1e6 name-lookup.h (match_global_decl): Rename to ...
gcc/cp/
	* name-lookup.h (match_global_decl): Rename to ...
	(match_mergeable_decl): ... this.  Add global/partition flag.
	* name-lookup.c (match_global_decl): Rename to ...
	(match_mergeable_decl): ... this.  Adjust.
	* module.cc: Rename mme to mergeable.
	(trees_{in,out}::tree_mergeable): Stream global/partition
	indicator. Call match_mergeable_decl.

From-SVN: r267561
2019-01-03 18:21:44 +00:00
Nathan Sidwell
2b57d22567 name-lookup.c (module_binding_slot): Break apart to ...
gcc/cp/
	* name-lookup.c (module_binding_slot): Break apart to ...
	(search_imported_binding_slot, get_fixed_binding_slot)
	(append_imported_binding_slot): ... these.
	(fixed_module_binding_slot): Delete.
	(do_pushdecl, match_global_decl, import_module_binding)
	(set_module_binding, get_binding_or_decl, get_imported_namespace)
	(reuse_namespace, make_namespace_finish)
	(add_imported_namespace): Update for new API.

From-SVN: r267554
2019-01-03 15:03:03 +00:00
Nathan Sidwell
4e0fcebd25 name-lookup.c (module_binding_slot): Use FIXED parm.
gcc/cp/
	* name-lookup.c (module_binding_slot): Use FIXED parm.

From-SVN: r267530
2019-01-02 20:36:14 +00:00
Nathan Sidwell
9347e70a4e more sensible parm ordering
From-SVN: r267529
2019-01-02 20:27:45 +00:00
Nathan Sidwell
dc5338d75a name-lookup.c (module_binding_slot): Add FIXED parm, adjust all callers.
gcc/cp/
	* name-lookup.c (module_binding_slot): Add FIXED parm, adjust all
	callers.

From-SVN: r267527
2019-01-02 19:49:48 +00:00
Nathan Sidwell
80486f45a7 module.cc: Rename gme -> mme, because partitions.
gcc/cp/
	* module.cc: Rename gme -> mme, because partitions.

From-SVN: r267525
2019-01-02 19:10:15 +00:00
Nathan Sidwell
5d89f69864 cp-tree.h (DECL_MODULE_PURVIEW_P): Delete.
gcc/cp/
	* cp-tree.h (DECL_MODULE_PURVIEW_P): Delete.
	(MAYBE_DECL_MODULE_PURVIEW_P): Delete.
	* mangle.c (maybe_write_module): Adjust.

From-SVN: r267524
2019-01-02 18:53:29 +00:00
Nathan Sidwell
fecf9a164c legacy-8_[abcde].[CH]: New.
gcc/testsuite/
	* g++.dg/modules/legacy-8_[abcde].[CH]: New.

From-SVN: r267523
2019-01-02 18:45:57 +00:00
Nathan Sidwell
943e880d1b re PR c++/88664 (False positive -Waddress-of-packed-member)
gcc/cp/
	* cxx-mapper.cc (server): Workaround PR c++/88664.

From-SVN: r267516
2019-01-02 15:23:56 +00:00
Nathan Sidwell
e7acf9612a Merge trunk r267509.
* module.cc, cxx-mapper.cc: Update copyright years.

From-SVN: r267514
2019-01-02 14:59:37 +00:00
Nathan Sidwell
f58c351b4e MODULE_VEC has alloc field too.
gcc/cp/
	* cp-tree.h (MODULE_VECTOR_ALLOC_CLUSTERS): New.
	(MODULE_VECTOR_NUM_CLUSTERS): Adjust.
	(struct tree_module_vec): Adjust.
	* tree.c (make_module_vec): Adjust.
	* name-lookup.c (module_binding_slot): Extend vector if it fits.
	* ptree.c (cxx_print_xnode): Cope with lazy module-vector slots.

From-SVN: r267311
2018-12-20 19:14:37 +00:00
Nathan Sidwell
3bd761bef1 module.cc (module_state::check_read): Fix bogus note.
gcc/cp/
	* module.cc (module_state::check_read): Fix bogus note.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_c.C: Add bogus note test.

From-SVN: r267310
2018-12-20 19:11:02 +00:00
Nathan Sidwell
03e91ef2d8 module.cc (module_state::remap): New member var.
gcc/cp/
	* module.cc (module_state::remap): New member var.
	(module_state::remap_partitions): New.
	(module_state::write_imports): Skip partitions.
	(module_state::write): Remap partitions.

From-SVN: r267300
2018-12-20 14:47:38 +00:00
Nathan Sidwell
2f1ac0bb75 Partition parsing. Don't get excited!
gcc/cp/
	* module.cc (get_module): Attach current module for null
	partition.
	* parser.c (cp_parser_module_name): Parse partitions
	gcc/testsuite/
	* g++.dg/modules/part-1_[ab].C: New.

From-SVN: r267269
2018-12-19 14:44:15 +00:00
Nathan Sidwell
84df79b99a cp-tree.h (get_module): Add partition arg.
gcc/cp/
	* cp-tree.h (get_module): Add partition arg.
	* module.cc (module_state): Add partition flag.
	(module_state_hash): Hash & compare partition flag.
	(module_state::mangle, get_module, attach): Add partition awareness.

From-SVN: r267243
2018-12-18 20:44:04 +00:00
Nathan Sidwell
d641a8cccc cp-tree.h (get_module): Default NULL parent.
gcc/cp/
	* cp-tree.h (get_module): Default NULL parent.
	* lex.c (module_preprocess_token): Adjust get_module call.
	* module.cc (get_module, module_begin_main_file): Likewise.
	* parser.c (cp_parser_module_name): Likewise.

From-SVN: r267242
2018-12-18 19:53:50 +00:00
Nathan Sidwell
b7194ae846 module.cc (trees_out::tree_decl): Remove some remaining non-atomic template hacks.
gcc/cp/
	* module.cc (trees_out::tree_decl): Remove some remaining
	non-atomic template hacks.

From-SVN: r267241
2018-12-18 18:53:33 +00:00
Nathan Sidwell
53a49b6a17 module.cc (module_state::write): Sort dependency table.
gcc/cp/
	* module.cc (module_state::write): Sort dependency table.

From-SVN: r267240
2018-12-18 18:47:20 +00:00
Nathan Sidwell
00c04f31d8 module.cc (module_cpp_undef): Don't zap undef hook if we don't own it.
gcc/cp
	* module.cc (module_cpp_undef): Don't zap undef hook if we don't
	own it.
	gcc/c-family/
	* c-opts.c (c_common_init): Don't unilaterally clobber undef
	callback.
	* c-ppoutput.c (cb_undef): Call lang_hook if non-null.
	gcc/testsuite/
	* g++.dg/modules/dir-only-1.C: New.

From-SVN: r267233
2018-12-18 13:57:03 +00:00
Nathan Sidwell
fbb306e144 Merge trunk r267229.
From-SVN: r267231
2018-12-18 13:32:58 +00:00
Nathan Sidwell
60e871169d module.cc (trees_out::{write,mark}_template_def): Delete.
gcc/cp/
	* module.cc (trees_out::{write,mark}_template_def): Delete.
	(trees_out::{write,mark}_definition): Adjust.
	(trees_in::read_template_def): Delete.
	(trees_in::read_definition): Adjust.

From-SVN: r267218
2018-12-17 21:36:27 +00:00
Nathan Sidwell
de8fb4cf1b Kill old broken global module merge code.
gcc/cp/
	* module.cc (trees_in::finish): Remove DECL merging.
	* name-lookup.c (merge_global_decl): Delete.
	* name-lookup.h (merge_global_decl): Delete decl.

From-SVN: r267217
2018-12-17 21:32:02 +00:00
Nathan Sidwell
6f890569fa Atomic TEMPLATE_DECL + DECL_TEMPLATE_RESULT.
gcc/cp/
	* module.cc (trees_out::mark_node): Remove temp tpl hack.
	(trees_out::tree_decl): Remove tt_template remarking.
	(trees_out::tree_value): Atomic TEMPLATE_DECL.
	(trees_in::tree_node): Likewise.
	(trees_out::{mark,read,write}_template_def): Move DECL_LIST to ...
	(trees_out::{mark,read,write}_class_def): ... here.
	(trees_{in,out}::tree_gme): Don't mark inner decl.
	gcc/testsuite/
	* leg-merge-8_[abc].[CH]: New.

From-SVN: r267211
2018-12-17 21:24:47 +00:00
Nathan Sidwell
21f892e82f Intermediate step to atomic TEMPLATE_DECL + DECL_TEMPLATE_RESULT.
Breaks leg-merge-7_c.C,
	gcc/cp/
	* module.c (tree_tag): Add tt_template, tt_implicit_template.
	(node_template_info): Not a member fn.
	(trees_out::{mark_node,mark_gme}): Mark the template.
	(trees_{in,out}::tree_decl): Do implicit_template.

From-SVN: r267205
2018-12-17 16:55:00 +00:00
Nathan Sidwell
7aab222631 module.cc (trees_out::node_template_info): New, broken out of ...
gcc/cp/
	* module.cc (trees_out::node_template_info): New, broken out of
	...
	(trees_out::tree_decl): ... here.  Use it.

From-SVN: r267140
2018-12-14 19:18:58 +00:00
Nathan Sidwell
82faacf1c7 module.cc (trees_out::tree_decl): Adjust TEMPLATE_INFO access.
gcc/cp/
	* module.cc (trees_out::tree_decl): Adjust TEMPLATE_INFO access.

From-SVN: r267139
2018-12-14 18:46:13 +00:00
Nathan Sidwell
6b4442fd28 Function template deduping
Function template deduping
	gcc/cp/
	* module.cc (trees_{in,out}::tpl_parms): New.
	(trees_out::mark_gme): Mark template result too.
	(trees_{in,out}::tree_gme): Do templates.
	(module_state::write_cluster): Any decl can be a GME.
	* name-lookup.c (match_global_decl): Do template matching.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-7_[abc].[HC]: New.

From-SVN: r267110
2018-12-13 20:55:24 +00:00
Nathan Sidwell
0a873b629b module.cc (slurping::remap): Heap allocate.
gcc/cp/
	* module.cc (slurping::remap): Heap allocate.
	(gt_pch_nx): Delete hacks.

From-SVN: r266814
2018-12-05 02:23:35 +00:00
Nathan Sidwell
2a812ddd13 module.cc (tree_tag): Replace tt_named_type with tt_{primary,secondary}_type.
gcc/cp/
	* module.cc (tree_tag): Replace tt_named_type with
	tt_{primary,secondary}_type.
	(trees_out::tree_type): Not recursive.
	(trees_in::tree_node): Adjust tt_named_type case.

From-SVN: r266802
2018-12-04 22:38:19 +00:00
Nathan Sidwell
2bd52d9f6c Class deduping
Class deduping
	gcc/cp/
	* module.cc (trees_in::tree_node): Record defn to skip.
	(trees_in::is_skip{,pable}_defn): Fix int/long ptr const.
	(module_state::read_{function,var,class}_def): Add skip checking.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-6_[abc].[HC]: New.

From-SVN: r266800
2018-12-04 22:12:46 +00:00
Nathan Sidwell
ba05fa80f5 TYPE streamed with its implicit typedef.
gcc/cp/
	* module.cc (trees_in::reserve_gmes): Only 2 per.
	(trees_in::{set,get}_backref_gme): Delete.
	(trees_in::existing_gme): Rename to ...
	(trees_in::is_existing_gme): ... this.  Return bool.
	(trees_out::mark_gme): Adjust assert.
	(trees_in::insert): Add assert.
	(trees_out::tree_type): Always look at typedef.
	(trees_out::tree_value): Stream type with its decl.
	(trees_in::tree_node): Likewise.
	(trees_{in,out}::tree_gme): Adjust.

From-SVN: r266797
2018-12-04 20:54:35 +00:00
Nathan Sidwell
f46b60b2f4 module.c (module_state::{read,write,mark}_enum): Take DECL.
gcc/cp/
	* module.c (module_state::{read,write,mark}_enum): Take DECL.
	(module_state::{read,write,mark}_definition): Adjust.

From-SVN: r266791
2018-12-04 18:04:56 +00:00
Nathan Sidwell
8db16f3cd3 class.c (layout_class_type): Base type has same module as owner.
gcc/cp/
	* class.c (layout_class_type): Base type has same module as owner.
	* module.c (module_state::{read,write,mark}_class): Take DECL.
	(module_state::{read,write,mark}_definition): Adjust.
	(topmost_decl, get_module_owner): Don't look at TYPE_CONTEXT.

From-SVN: r266790
2018-12-04 18:00:42 +00:00
Nathan Sidwell
62fb31f235 class.c (build_base_field_1): Refactor.
gcc/cp/
	* class.c (build_base_field_1): Refactor.
	(layout_class_type): Give as_base type a name.
	* decl.c (initialize_predefined_identifiers): Make as_base name
	unpronouncable.
	* module.cc (tree_tag): Delete tt_as_base.
	(trees_out::mark_node): Don't expect fake base here.
	(trees_out::tree_decl): Write fake base as pseudo-named.
	(trees_out::tree_type): Don't handle fake base specially here.
	(trees_in::tree_node): Read fake base as pseudo-named.  Delete
	tt_as_base handling.
	(module_State::mark_class_def): Adjust.

From-SVN: r266789
2018-12-04 17:39:16 +00:00
Nathan Sidwell
4c65fd4b39 module.cc (trees_in): Rename bad_decls to skip_defns.
gcc/cp/
	* module.cc (trees_in): Rename bad_decls to skip_defns.
	(trees_in::{record,is}_bad_decl): Delete.
	(trees_in::{record,is,any}_skip_defn): New.
	(module_state::is_ignorable_defn): Rename to ...
	(module_state::is_skippable_defn): Key off namespace-scope decl.
	(topmost_decl): New.
	(module_state::read_function_def): Adjust.

From-SVN: r266778
2018-12-04 13:23:25 +00:00
Nathan Sidwell
7b01562cbb Merge trunk r266680.
From-SVN: r266681
2018-11-30 20:02:13 +00:00
Nathan Sidwell
49034139b0 module.cc: Fix enums with trailing commas.
gcc/cp/
	* module.cc: Fix enums with trailing commas.
	* name-lookup.c (match_global_decl): Avoid unused arg warning.

From-SVN: r266679
2018-11-30 18:50:23 +00:00
Nathan Sidwell
05a3404e10 module.cc (module_state::write_binfos): Binfo was not visited.
gcc/cp/
	* module.cc (module_state::write_binfos): Binfo was not visited.

From-SVN: r266676
2018-11-30 16:41:53 +00:00
Nathan Sidwell
734f6391ec module.cc (module_state::write_binfos): Always write number of vbases.
gcc/cp/
	* module.cc (module_state::write_binfos): Always write number of
	vbases.
	(module_state::read_binfos): Don't smash the type here.
	(module_state:{read,write}_class_def): Adjust binfo serializing.

From-SVN: r266675
2018-11-30 16:34:14 +00:00
Nathan Sidwell
8ba50616ca class.c (fixup_type_variants): Copy TYPE_SIZE & TYPE_SIZE_UNIT.
gcc/cp/
	* class.c (fixup_type_variants): Copy TYPE_SIZE & TYPE_SIZE_UNIT.
	(finish_struct): Use fixup_type_variants for template.
	* module.cc (trees_{in.out}::core_vals): Don't serialize TYPE_SIZE
	and TYPE_SIZE_UNIT for classes.
	(trees_in::finish_type): Don't layout clesses here.
	(module_state::{read,write}_class_def): Do it here.

From-SVN: r266670
2018-11-30 15:48:46 +00:00
Nathan Sidwell
120a966312 module.cc (trees_in): Add bad_decls and post_decls.
gcc/cp/
	* module.cc (trees_in): Add bad_decls and post_decls.
	(trees_in::{record,is}_bad_decl): New.
	(trees_in::post_process): New.
	(module_state::is_{matching_decl,ignorable_defn}): New.
	(trees_in::tree_node): Use former.
	(module_state::read_function_def): Use latter. Register for
	post-processig.
	(module_state::read_cluster): Post process.

From-SVN: r266669
2018-11-30 15:43:11 +00:00
Nathan Sidwell
d148c88a0c Merge global module function definitions.
gcc/cp/
	* modules.cc (module_state::write_function_def ): Don't rely on
	decl's form.
	(module_state::read_function_def): Allow multiple decls.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-5_[abc].[CH]: New.

From-SVN: r266643
2018-11-29 21:20:09 +00:00
Nathan Sidwell
3718e2186e modules.cc (module_state::check_read): Adjust, print inform of outer location.
gcc/cp/
	* modules.cc (module_state::check_read): Adjust, print inform of
	outer location.
	(module_state::write_cluster): defns are decls too.
	(lazy_load_binding): Don't inform here.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-4_c.C: Adjust regexps.

From-SVN: r266642
2018-11-29 21:03:21 +00:00
Nathan Sidwell
f1c25f2869 Fixing GME classes
Fixing GME classes
	gcc/cp
	* module.cc (trees_in::tree_node_vals): Add specific bool arg,
	adjust.
	(trees_in::existing_gme): Return cookie.
	(trees_in::{get,set}_backref_gme): New.
	(trees_out::mark_gme): Mark typedef target.
	(trees_out::tree_type): Don't be fooled by GME TYPE_NAME.
	(trees_out::tree_value): Write GME type code.
	(trees_in::tree_node): Use backref channel for typedefs.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-4_c.C: Adjust.

From-SVN: r266639
2018-11-29 20:14:43 +00:00
Nathan Sidwell
33b8e3aff6 Some ODR checking of GMEs
Some ODR checking of GMEs
	gcc/cp/
	* module.cc (trees_in::tree_node): Check type of matched GME.
	(lazy_load_binding): Add note if diagnostics emitted.
	* name-lookup.c (name_lookup::search_namespace_only): Forward
	iterate over slots.
	(match_global_decl): Return close matches.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-4_[abc].[CH]: New.

From-SVN: r266629
2018-11-29 17:03:34 +00:00
Nathan Sidwell
d2f39fedb2 Global module var declaration merging.
gcc/cp/
	* module.cc (trees_in::reserve_gmes): Add headroom.
	(trees_{in,out}::tree_gme): Deal with VAR_DECLs.
	(module_state::write_cluster): Likewise.
	* name-lookup.c (match_global_decl): Likewise.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-3_[abcd].[CH]: New.

From-SVN: r266626
2018-11-29 15:34:26 +00:00
Nathan Sidwell
ca9a8bb144 Global module class declaration merging.
gcc/cp/
	* module.cc (trees_in::start): Check code & category.
	(trees_in::tree_node): Allow gme types.  Refactor gme/node
	reading.
	(trees_{in,out}::tree_gme): Allow implicit typedefs.
	(module_state::write_cluster): GME Implicit typedefs too.
	* name-lookup.c (match_global_decl): Match TYPE_DECLs too.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-2_[abc].[CH]: New.

From-SVN: r266623
2018-11-29 15:10:47 +00:00
Nathan Sidwell
f190073977 Global module function declaration merging.
gcc/cp
	* module.cc (tree_tag): Add tt_gme.
	(trees_in::gmes): New data member.
	(trees_in::tree_node_specific): Add no-alloc flag.
	(trees_in::{tree_gme,reserve_gmes,existing_gme}): New.
	(trees_out::walk_kind): Add WK_gme.
	(trees_out::{mark,tree}_gme): New.
	(trees_out::{ref_node,insert}): Deal with WK_gme walk.
	(trees_out::tree_{decl,value}): Likewise.
	(trees_in::tree_node): Add tt_gme support.
	(cluster_tag): Add ct_gme.
	(module_state::{read,write}_cluster): Add gme support.
	* name-lookup.h (match_global_decl): Declare.
	(add_module_decl): Declare.
	* name-lookup.c (match_global_decl): New.
	(set_module_binding): Don't dedup here.
	(add_module_decl): New.
	gcc/testsuite/
	* g++.dg/modules/leg-merge-1_[abcd].[CH]: New.

From-SVN: r266589
2018-11-28 21:20:30 +00:00
Nathan Sidwell
6b36d7be1e modules.cc (trees_{in,out}::tree_node_bools): Break out tree_node_specific.
gcc/cp/
	* modules.cc (trees_{in,out}::tree_node_bools): Break out
	tree_node_specific.
	(trees_out::ref_force_{lwm.hwm}): Delete.
	(trees_out::gme_lwm): New.
	(trees_out::insert): Change force to walk_kind.
	(trees_out::mark_node): Drop walk_kind arg.
	(trees_out::{,un}mark_trees): Adjust.
	(trees_out::{mark_node,insert}): Adjust.
	(trees_out::start): Drop CODE parm.
	(trees_out::{ref_node,tree_ctx}): Adjust.
	(trees_out::tree_value): Adjust.
	(trees_{in,out}::tree_node): Likewise.
	(module_state::write_binfos): Likewise.
	(module_state::mark_{class,enum}_def): Adjust.
	(module_state::{read,write}_cluster): Adjust.
	(module_state::find_dependencies): Adjust.

From-SVN: r266580
2018-11-28 20:02:59 +00:00
Nathan Sidwell
8f87c1ad93 modules.cc (trees_{in,out}::tree_node_raw): Bifurcate to ...
gcc/cp/
	* modules.cc (trees_{in,out}::tree_node_raw): Bifurcate to ...
	(trees_{in,out}::tree_node_{bools,vals}): ... these.
	(trees_out::tree_value): Adjust.
	(trees_in::tree_node): Likewise.

From-SVN: r266479
2018-11-26 20:29:32 +00:00
Nathan Sidwell
9f45de6c9f modules.cc (trees_out::tree_ref): Rename to ...
gcc/cp/
	* modules.cc (trees_out::tree_ref): Rename to ...
	(trees_out::ref_node): ... this.
	(trees_out::tree{value,decl,type,namespace}): Replace FORCE
	paramenter with walk_kind.
	(trees_out::tree_node): Adjust.
	(module_state::mark_{class,enum,template}_def): Adjust.
	(module_state::write_cluster): Adjust.
	(module_state::find_dependencies): Adjust.

From-SVN: r266476
2018-11-26 19:30:00 +00:00
Nathan Sidwell
f04c95414a modules.cc (trees_out::walk_kind): New enum.
gcc/cp/
	* modules.cc (trees_out::walk_kind): New enum.
	(trees_out::tree_ref): Return it.
	(trees_out::tree_{ctx,decl,node}): Use it.

From-SVN: r266475
2018-11-26 18:33:35 +00:00
Nathan Sidwell
1fe194e0a3 modules.cc (trees_out::ref_force_{lwm.hwm}): New ref values.
gcc/cp/
	* modules.cc (trees_out::ref_force_{lwm.hwm}): New ref values.
	(trees_out::{,un}mark_trees): Use them.
	(trees_out::{mark_node,tree_ref}): Likewise.

From-SVN: r266474
2018-11-26 18:24:48 +00:00
Nathan Sidwell
c66affd04e modules.cc (dumper): Rename dump flags.
gcc/cp/
	* modules.cc (dumper): Rename dump flags.  Adjust throughout.

From-SVN: r266324
2018-11-20 17:26:58 +00:00
Nathan Sidwell
07e801d065 module.cc (handle_module_option): Handle OPT_fmodule_legacy.
gcc/cp/
	* module.cc (handle_module_option): Handle OPT_fmodule_legacy.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Insert /./ in legacy names.
	* g++.dg/modules/*.H: Adjust as necessary.

From-SVN: r266283
2018-11-19 20:22:46 +00:00
Nathan Sidwell
854342c3c4 Merge trunk r266271.
From-SVN: r266273
2018-11-19 13:56:35 +00:00
Nathan Sidwell
83c7b55fbf Merge trunk r266161.
From-SVN: r266191
2018-11-15 17:25:22 +00:00
Nathan Sidwell
3b595d9a8e invoke.texi: Rename cookie->ident, people read too much into 'cookie'.
gcc/
	* doc/invoke.texi: Rename cookie->ident, people read too much into
	'cookie'.

From-SVN: r266189
2018-11-15 16:04:38 +00:00
Nathan Sidwell
b0d59a42dd parser.c (cp_parser_translation_unit): Refactor.
gcc/cp/
	* parser.c (cp_parser_translation_unit): Refactor.

From-SVN: r265907
2018-11-08 03:41:47 +00:00
Nathan Sidwell
4c645696da Implement d0924r1 (to be written).
gcc/cp/
	* lex.c (init_reswords): Set D_CXX_MODULES mask.
	* module.cc (declare_module): Check purview state.
	* parser.c (cp_parser_translation_unit): Module and import are
	always conditional.
	(cp_parser_tokenize): Likewise.
	gcc/
	* doc/invoke.texi (fno-module-keywords): Delete.
	gcc/c-family/
	* c-common.c (c_common_reswords): Don't mark import, module for CXXWARN.
	* c.opt (fmodule-keywords): Delete.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-1.C: Delete.
	* g++.dg/modules/keyword-1_[ab].C: Adjust.
	g++.dg/modules/mod-decl-[13].C: Adjust.
	g++.dg/modules/p0713-3.C: Adjust.

From-SVN: r265905
2018-11-08 03:25:47 +00:00
Nathan Sidwell
9d94d3fa2e cp-tree.h (module_gmf_p): Adjust.
gcc/cp/
	* cp-tree.h (module_gmf_p): Adjust.
	(not_module_p): New.
	* module.cc (declare_module): Don't deal with starting GMF.
	* parser.c (cp_parser_translation_unit): Adjust module_purview
	values.

From-SVN: r265883
2018-11-07 18:38:03 +00:00
Nathan Sidwell
1680f7c06d Implement Bjarne's suggested solution.
gcc/cp/
	* parser.cc (cp_parser_translation_unit): No tentative parsing.
	Look for following ::.
	(cp_parser_module_{name,declaration,import}): Adjust.
	(cp_parser_tokenize): Adjust, tokenize more.
	gcc/
	* doc/invoke.texi (C++ Modules): Update.
	gcc/testsuite/
	* g++.dg/modules/cpp-5_b.C: Update.
	* g++.dg/modules/keyword-1_[ab].C: Likewise.

From-SVN: r265779
2018-11-04 21:14:23 +00:00
Nathan Sidwell
11e6f415b0 modules.c (module_state::read): Interface can be lazy too.
gcc/cp/
	* modules.c (module_state::read): Interface can be lazy too.

From-SVN: r265754
2018-11-02 17:49:06 +00:00
Nathan Sidwell
4abd8c3652 name-lookup.c (STAT_EXPORTS): Rename to ...
gcc/cp/
	* name-lookup.c (STAT_EXPORTS): Rename to ...
	(STAT_VISIBLE): ... this.
	(name_lookup::search_namespace_only, name_lookup::add_module_fns)
	(check_module_override, set_module_binding): Adjust.
	* module.cc (module_state::read_cluster): Likewise.

From-SVN: r265753
2018-11-02 17:47:14 +00:00
Nathan Sidwell
90b6ad4130 cp-tree.h (module_may_redeclare): Declare.
gcc/cp/
	* cp-tree.h (module_may_redeclare): Declare.
	* decl.c (duplicate_decls): Check moduleness.
	* module.cc (module_state::read_cluster): Adjust export tail.
	(module_may_redeclare): New.
	* name-lookup.c (name_lookup::search_namespace_only): Check
	STAT_TYPE_VISIBLE_P.
	(update_binding): Allow NULL LEVEL.
	(check_module_override): New.
	(do_pushdecl): Deal with module overrides.
	(set_module_binding): Adjust.  Don't push interface bindings.
	gcc/testsuite/
	* g++.dg/modules/ambig-1_[ab].C: New.
	* g++.dg/modules/macro-4_e.C: Avoid error.
	* g++.dg/modules/namespace-2_b.C: Remove xfail.

From-SVN: r265752
2018-11-02 17:43:11 +00:00
Nathan Sidwell
2bbc1ae543 module.cc (module_state::read_cluster): Preserve export_tail.
gcc/cp/
	* module.cc (module_state::read_cluster): Preserve export_tail.
	* name-lookup.c (STAT_HACK_TYPE_VISIBILE_P): New.
	(name_lookup::process_module_binding): Reimplement.
	(name_lookp::search_namespace_only): Likewise.
	(set_module_binding): Adjust when STAT_HACK_EXPORTS is set.

From-SVN: r265750
2018-11-02 15:40:31 +00:00
Nathan Sidwell
f229dde02a decl.c (duplicate_decls): Refactor export check.
gcc/cp/
	* decl.c (duplicate_decls): Refactor export check.
	gcc/testsuite/
	* g++.dg/modules/export-1.C: New.

From-SVN: r265746
2018-11-02 13:35:27 +00:00
Nathan Sidwell
c02dc66f04 decl.c (duplicate_decls): Refactor checks.
gcc/cp/
	* decl.c (duplicate_decls): Refactor checks.
	* name-lookup.c (name_lookup::process_module_binding): Only pubic
	namespaces are shared.
	gcc/testsuite/
	* g++.dg/lookup/crash6.C: Adjust error
	* g++.dg/parse/crash38.C: Likewise.

From-SVN: r265731
2018-11-01 20:10:24 +00:00
Nathan Sidwell
8c22ebb3ad Merge trunk r265714.
Move to autoconf 2.69.

From-SVN: r265718
2018-11-01 11:58:49 +00:00
Nathan Sidwell
af3ec4196f module.cc (module_state::read): Don't read macros for preprocessed innput.
gcc/cp/
	* module.cc (module_state::read): Don't read macros for
	preprocessed innput.
	(module_state::set_import): Adjust legacy test.

From-SVN: r265712
2018-11-01 11:09:23 +00:00
Nathan Sidwell
d07061a786 module.cc (module_state::check_not_purview): Check name.
gcc/cp/
	* module.cc (module_state::check_not_purview): Check name.
	(mangle_mondule, module_name): Likewise.
	(declare_module): Set parent, not alias.

From-SVN: r265699
2018-10-31 19:48:35 +00:00
Nathan Sidwell
422b84c0a2 Merge trunk r265692.
From-SVN: r265694
2018-10-31 15:33:14 +00:00
Nathan Sidwell
b00a830393 Merge trunk r265679.
From-SVN: r265682
2018-10-31 13:11:56 +00:00
Nathan Sidwell
b75e475c45 cp-tree.h (OVL_EXPORT_P): Delete.
gcc/cp/
	* cp-tree.h (OVL_EXPORT_P): Delete.
	(OVL_DEDUP_P): Move to lang flag 0.
	* module.cc (module_state::read_cluster): Don't set OVL_EXPORT_P.
	* tree.c (ovl_copy): Don't copy OVL_EXPORT_P.

From-SVN: r265671
2018-10-31 11:25:37 +00:00
Nathan Sidwell
08e39eb508 Module interface gets own mod number
Module interface gets own mod number
	gcc/cp/
	* cp-tree.g (ovl_iterator::set_dedup): New.
	* module.cc (module_state::{interface_p,is_interface}): New.
	(module_state::check_not_purview): Adjust.
	(mangle_module, module_name): Likewise.
	(module_state::read_cluster): Adjust.
	(module_state::read): Adjust.
	(module_state::{set_import,direct_import}): Adjust import setting.
	(declare_module): Module interface gets number.
	* name-lookup.h (set_module_binding): Add iface parameter.
	* name-lookup.c (name_lookup::search_namespace): Fix indexing.
	(set_module_binding): Insert interface decls.
	gcc/testsuite/
	* g++.dg/modules/namespace-4_b.C: Remove xfails.
	* g++.dg/modules/static-1_b.C: Remove xfails.

From-SVN: r265643
2018-10-30 20:13:18 +00:00
Nathan Sidwell
e205126cdb cp-tree.h (OVL_HAS_USING_P): Rename to ...
gcc/cp/
	* cp-tree.h (OVL_HAS_USING_P): Rename to ...
	(OVL_DEDUP_P): ... here.
	* name-lookup.c (name_lookup::add_overload)
	(get_class_binding_direct): Adjust.
	* tree.c (ovl_make, ovl_copy, ovl_insert, lookup_maybe_add): Adjust.

From-SVN: r265642
2018-10-30 20:07:05 +00:00
Nathan Sidwell
567d0d4ff7 Less ordered overloads
Less ordered overloads
	gcc/cp/
	* cp-tree.h (ovl_sort): Declare.
	* name-lookup.h (extract_module_binding): Binding is reference.
	* tree.c (ovl_insert): Don't sort non-hidden members.
	(ovl_splice, ovl_sort): New.
	* name-lookup.c (extract_module_binding): Binding is reference.
	Sort the binding.
	* ptree.c (cxx_print_xnode): Print MODULE_VEC name.
	* module.cc (module_state::add_writables): Binding is reference.
	gcc/testsuite/
	* g++.dg/lookup/friend21.C: New.

From-SVN: r265630
2018-10-30 15:31:19 +00:00
Nathan Sidwell
8933fb8cb1 cp-tree.h (ovl_insert): Drop export_tail parm.
gcc/cp/
	* cp-tree.h (ovl_insert): Drop export_tail parm.
	* name-lookup.c (update_binding): No need to track export_tail.
	* tree.c (ovl_insert): Drop export_tail parm.
	* ptree.c (cxx_print_xnode): Output formatting.

From-SVN: r265597
2018-10-29 17:42:12 +00:00
Nathan Sidwell
b460c8b6fd module.cc (module_state::read_imports): Do in one pass.
gcc/cp/
	* module.cc (module_state::read_imports): Do in one pass.

From-SVN: r265592
2018-10-29 14:32:37 +00:00
Nathan Sidwell
2537f5fb21 module.cc (module_state::direct_import): Drop DEFERRABLE arg.
gcc/cp/
	* module.cc (module_state::direct_import): Drop DEFERRABLE arg.
	({import,declare}_module): Deal with deferring here.
	(process_deferred_imports): Adjust direct_import call.

From-SVN: r265589
2018-10-29 14:11:44 +00:00
Nathan Sidwell
06f6e8f887 Merge trunk r265554.
From-SVN: r265560
2018-10-27 20:57:40 +00:00
Nathan Sidwell
02fb5f5a85 Anon namespaces
Anon namespaces
	gcc/cp/
	* module.cc (elf_out::strtab_write): Fallback to assembler name.
	(elf_out::name): Allow 0 name.
	(dumper::impl::nested_name): Fallback to assembler name.
	(module_state::{read,write}_namespaces): Write assembler name for
	anons.
	* name-lookup.h (add_imported_namespace): add anon-name arg.
	* name-lookup.c (get_imported_namespace): Look in current slot
	too.
	(make_namespace): Add anon-name arg, calculate as necessary.
	(add_imported_namespace): add anon-name arg.
	gcc/testsuite/
	* gcc/testsuite/g++.dg/modules/namespace-4_[abc].C: New.

From-SVN: r265540
2018-10-26 18:30:33 +00:00
Nathan Sidwell
1dc5389ef2 Statics on bindings
Statics on bindings
	gcc/cp/
	* module.cc (depset::hash::add_binding): Take overload and type
	values, do pruning here.
	(module_state::write_cluster): Reorder binding emission.
	(module_state::read_cluster): Determine export_tail here.
	(module_state::add_writables): Adjust.
	* cp-tree.h (ovl_iterator::export_tail): Delete.
	* name-lookup.h (extract_module_decls): Rename to ...
	(extract_module_binding): ... here.  Return overload set.
	* name-lookup.c ( (extract_module_decls): Rename to ...
	(extract_module_binding): ... here.  Don't prune here.
	(set_module_binding): Simplify.
	(lookup_by_ident, get_lookup_ident): Simplify.
	gcc/testsuite/
	* g++.dg/modules/static-1_b.C: XFAIL error
	* gcc/testsuite/g++.dg/modules/unnamed-1_[ab].C: Adjust scans.
	* gcc/testsuite/g++.dg/modules/unnamed-2.C: Likewise.

From-SVN: r265536
2018-10-26 17:31:35 +00:00
Nathan Sidwell
318f05b158 cp-tree.h (module_purview): Declare.
gcc/cp/
	* cp-tree.h (module_purview): Declare.
	(module_purview_p, module_interface_p, module_gmf_p): Inline
	predicates.
	* module.cc (module_purview): Extern.
	(module_purview_p, module_interface_p): Delete.

From-SVN: r265530
2018-10-26 13:39:55 +00:00
Nathan Sidwell
1299d08f39 p1103 no implicit namespace export
p1103 no implicit namespace export
	gcc/cp/
	* module.cc (trees_out::mark_node): Allow namespace marking.
	(trees_out::tree_ctx): Namespaces may be forced.
	(trees_out::tree_namespace): Reimplement.
	(trees_out::tree_{type,decl}): Adjust tree_ctx calls.
	(module_state::write_cluster): Likewise.
	(module_state::{read,write}_namespace): Adjust.
	(module_state::find_dependencies): Also walk namespaces.
	* name-lookup.c (name_lookup::process_binding): Fixup hidden
	namespaces.
	(implicitly_export_namespace): New.
	(do_pushdecl, push_namespace): Call it.
	(add_imported_namespace): Add export_p arg, adjust.
	* name-lookup.h (add_imported_namespace): Add export_p arg.
	* ptree.c (cxx_print_node): Adjust MODULE_VEC printing.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_b.C: Adjust scans.
	* g++.dg/modules/namespace-[23].C: Split to ...
	* g++.dg/modules/namespace-[23]_[ab].C: ... these.

From-SVN: r265529
2018-10-26 13:11:05 +00:00
Nathan Sidwell
2f324aac6f Rationalize bool ok == true
Rationalize bool ok == true
	gcc/cp/
	* module.cc (elf::has_error): Rename to ...
	(elf::get_error): ... this.  Update all callers.
	(elf::end): Return true == ok.  Update (indirect) callers.
	(module_state::check_read): Likewise.  Update callers.
	(module_state::lazy_load): Zap slot on failure.
	* name-lookup.c (get_binding_or_decl): No need to assert here.

From-SVN: r265504
2018-10-25 19:26:13 +00:00
Nathan Sidwell
9a038d3360 module.cc (module_state::write_readme): Tidy.
gcc/cp/
	* module.cc (module_state::write_readme): Tidy.
	(module_state::{add_writables,find_dependencies): Dump
	DEPENDENCIES.
	(module_state::direct_import): Always pop dump.
	* ptree.c (cxx_print_decl): Print DECL_MODULE_EXPORT_P.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Remove unused var.

From-SVN: r265501
2018-10-25 18:18:10 +00:00
Nathan Sidwell
329f657f95 module.cc (enum tree_tag): Add tt_namespace.
gcc/cp/
	* module.cc (enum tree_tag): Add tt_namespace.
	(trees_out::tree_namespace): Use it.
	(trees_in::tree_node): Grok it.
	* name-lookup.h (get_imported_namespace): Declare.
	* name-lookup.c (get_imported_namespace): New.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_c.C: Adjust.

From-SVN: r265468
2018-10-24 18:39:55 +00:00
Nathan Sidwell
7fa0e4d562 module.cc (trees_out::{tree_{decl,type}): Drop owner arg.
gcc/cp/
	* module.cc (trees_out::{tree_{decl,type}): Drop owner arg.
	(trees_out::tree_namespace): New.
	(trees_out::ctx): Take owning-decl arg, use tree_namespace.
	(trees_out::{core_vals,tree_binfo}): Adjust.
	(trees_out::{read,write}_cluster): Adjust.

From-SVN: r265466
2018-10-24 17:47:15 +00:00
Nathan Sidwell
8c0bb64033 module.cc: Add dumper::TREES to tree streamers.
gcc/cp/
	* module.cc: Add dumper::TREES to tree streamers.
	gcc/testsuite/
	* g++.dg/modules/: Add -uid to several lang dumps.

From-SVN: r265435
2018-10-23 18:06:00 +00:00
Nathan Sidwell
3887c46291 module.cc (slurping::remap_module): New.
gcc/cp/
	* module.cc (slurping::remap_module): New.
	(depset::hash::add_binding): Don't deal with namespaces here.
	(module_state::write_namespaces): No longer static.  Write
	locations.
	(module_state::read_namespaces): Read locations.
	(module_state::add_writables): Deal with namespaces here.
	(module_state::find_dependencies): Don't walk namespaces.
	* name-lookup.h (get_lookup_ident, find_by_ident): Reorder args,
	update callers.
	(add_imported_namespace): Add location arg.
	* name-lookup.c (module_binding_slot): Fix initial alloc.
	(extract_module_decls): Return namespace.
	(get_binding_or_decl, lookup_by_ident, get_lookup_ident): Reorder
	args.
	(make_namespace): Add loc & module args.
	(push_namespace): Adjust.
	(add_imported_namespace): Adjust.
	* ptree.c (cxx_print_decl): Avoid final linefeed.
	(cxx_print_xnode): Adjust MODULE_VEC
	gcc/
	* doc/invoke.texi: Document -fdump-lang-module options.
	gcc/testsuite/
	* g++.dg/modules/namespace-2.C: Adjust.

From-SVN: r265434
2018-10-23 17:38:41 +00:00
Nathan Sidwell
c4f79b6c9d cp-tree.h (module_exporting_level): Delete.
gcc/cp/
	* cp-tree.h (module_exporting_level): Delete.
	(module_export_depth): Declare.
	(module_exporting_p): New.
	({push,pop}_module_export): Adjust, make inline.
	* module.cc (export_depth): Replace with ...
	(module_exporting_level): ... this.
	({push,pop}_module_export): Delete.
	(set_module_owner, import_module, module_begin_main_file)
	(finish_module_parse): Adjust.
	* parser.cc (cp_parser_module_export): Adjust.

From-SVN: r265394
2018-10-22 14:47:37 +00:00
Nathan Sidwell
96e69857f3 lex.c (module_preprocess_token): Fix padding/comment states.
gcc/cp/
	* lex.c (module_preprocess_token): Fix padding/comment states.
	* parser.c (cp_parser_tokenize): Reduce is_decl states.

From-SVN: r265384
2018-10-22 11:28:30 +00:00
Nathan Sidwell
d5a15b13d4 Merge trunk r265362.
From-SVN: r265367
2018-10-22 01:29:35 +00:00
Nathan Sidwell
c4b93105ff Add -fno-module-keywords.
gcc/
	* doc/invoke.text (fmodule-keywords): Document.
	gcc/cp/
	* lex.c (init_reswords): Don't add module keywords if
	fno-module-keywords.
	*module_preprocess_token): Adjust.
	* module.cc (module_State_config:get_opts): Drop fmodule-keywords.
	* parser.c (cp_parser_import_declaration): Allow to be tentative.
	(cp_parser_translation_unit): Allow module & import to not be
	keywords. Tentatively parse import declaration.
	(cp_parser_module_keyword): Commit to tentative parse.
	(cp_parser_tokenize): Allow import to not be a keyword.
	gcc/testsuite/
	* g++.dg/modules/keywords-1_[ab].C: New.

From-SVN: r265361
2018-10-21 22:31:41 +00:00
Nathan Sidwell
1e66ee3211 lex.c (module_preprocessing_token): Pay attention to braces.
gcc/cp/
	* lex.c (module_preprocessing_token): Pay attention to braces.
	* parser.c (cp_parser_tokenize): Return ptr to stopping import.
	Pay attention to CPP_HEADER tokenization.
	(cp_parser_translation_unit): Adjust.

From-SVN: r265355
2018-10-21 19:28:53 +00:00
Nathan Sidwell
70b01eb74e parser.c (cp_parser_diagnose_invalid_type_name): Use C_RID_CODE more.
gcc/cp/
	* parser.c (cp_parser_diagnose_invalid_type_name): Use C_RID_CODE more.

From-SVN: r265354
2018-10-21 18:44:09 +00:00
Nathan Sidwell
2ab2a56c2f parser.c (cp_parser_tokenize): Don't stop after nested module/import decl.
gcc/cp/
	* parser.c (cp_parser_tokenize): Don't stop after nested
	module/import decl.

From-SVN: r265328
2018-10-19 21:44:10 +00:00
Nathan Sidwell
c8e29f81fc parser.c (cp_parser_translation_unit): Adjust GMF deferred imports.
gcc/cp/
	* parser.c (cp_parser_translation_unit): Adjust GMF deferred
	imports.
	(cp_parser_tokenize): Only pay attention to module/export at start
	of decl.

From-SVN: r265299
2018-10-18 23:45:49 +00:00
Nathan Sidwell
1bf6d8496b parser.c (cp_parser_translation_unit): Process deferred imports here ...
gcc/cp/
	* parser.c (cp_parser_translation_unit): Process deferred imports
	here ...
	(cp_parser_tokenize): ... not here.
	gcc/testsuite/
	* g++.dg/modules/macloc-1_d.C: Correct regexp.

From-SVN: r265298
2018-10-18 23:31:26 +00:00
Nathan Sidwell
566f8f346e Expunge -fmodules-atom as a thing.
gcc/
	* doc/invoke.texi (fmodules-atom): Delete.
	gcc/cp/
	* cp-tree.h (modules_legacy_p): Adjust.
	* module.cc: Expunge OPT_fmodules-atom.
	gcc/c-family/
	* c.opt (fmodules-ts): Adjust.
	(fmodules-atom): Alias fmodules-ts
	(fmodule-legacy*): Adjust.

From-SVN: r265292
2018-10-18 21:53:27 +00:00
Nathan Sidwell
b51b6105ab modules.exp (mode-list): Delete.
gcc/testuite/
	* g++.dg/modules/modules.exp (mode-list): Delete.
	(main): Don't use mode-list.
	* g++.dg/modules/: Add -fmodules-ts to many tests.

From-SVN: r265289
2018-10-18 20:42:16 +00:00
Nathan Sidwell
b61c4b968b Remove ATOM as a distinction.
gcc/c-family/
	* c-cppbuiltin.c (c_cpp_builtins): Remove __cpp_modules_{atom,ts}.
	* c.opt (fmodules-ts): Adjust.
	gcc/cp/
	* cp-tree.h (modules_atom_p): Delete.
	* module.cc (module_state::write_readme): Drop ATOM distinction.
	(module_state::{read,write}_config): Likewise.
	(init_module_processing): Drop atom distinction.
	(handle_module_option): Adjust.
	gcc/testsuite/
	* g++.dg/modules/: Drop -fmodules-atom from all tests.

From-SVN: r265282
2018-10-18 19:07:52 +00:00
Nathan Sidwell
861f12b441 Simplify translate-include hook.
libcpp/
	include/cpplib.h (cpp_translate_include_t): Delete.
	(struct cpp_calbacks): Adjust translate_include decl.
	gcc/
	* langhooks.h (struct lang_hooks): Adjust preprocess_translate_include.
	gcc/c-family
	* c-opts.c (c_common_post_options): Adjust.
	gcc/cp/
	* cp-tree.h (maybe_import_include): Replace by ...
	(module_translate_include): ... this.
	* cp-lang.c (LANG_HOOKS_PREPROCESS_TRANSLATE_INCLUDE): Adjust.
	* module.c (module_state::do_import): Check read on all top level
	imports.
	(do_translate_include): Rename to ...
	(module_translate_include): ... this.  Explicitly turn off.
	(maybe_import_include): Delete.

From-SVN: r265280
2018-10-18 18:32:18 +00:00
Nathan Sidwell
7f9f78a1af Preamble on module
Preamble on module
	gcc/cp/
	* parser.c (cp_parser_import_declaration): Always check past_preamble.
	gcc/testsuite/
	* g++.dg/modules/atom-norescan-1.C: Delete.
	* g++.dg/modules/atom-pragma-1.C: Not atom-specific.
	* g++.dg/modules/atom-pragma-3.C: Likewise.
	* g++.dg/modules/atom-preamble-1.C: Likewise.
	* g++.dg/modules/atom-preamble-2_a.C: Likewise.
	* g++.dg/modules/atom-preamble-2_b.C: Likewise.
	* g++.dg/modules/atom-preamble-2_c.C: Likewise.
	* g++.dg/modules/atom-preamble-2_d.C: Likewise.
	* g++.dg/modules/atom-preamble-2_e.C: Likewise.
	* g++.dg/modules/atom-preamble-3.C: Likewise.
	* g++.dg/modules/atom-preamble-4.C: Likewise.
	* g++.dg/modules/mod-indirect-1_b.C: Adjust.

From-SVN: r265279
2018-10-18 18:14:07 +00:00
Nathan Sidwell
678cf35731 No export { import x; }
No export { import x; }
	gcc/cp/
	* parser.c (cp_parser_tokenize): Drop nested arg, adjust.
	(cp_parser_translation_unit): Don't deal with outermost export { block.
	gcc/testsuite/
	* g++.dg/modules/err-1_a.C: Adjust.
	* g++.dg/modules/err-1_c.C: Adjust.
	* g++.dg/modules/import-1_c.C: Adjust.
	* g++.dg/modules/mod-decl-1.C: Adjust.

From-SVN: r265278
2018-10-18 18:01:57 +00:00
Nathan Sidwell
e72fdf3200 No atom preamble in non-module
No atom preamble in non-module
	gcc/cp/
	* parser.c (cp_parser_translation_unit): Preamble is tristate.
	(cp_parser_module_name): Add FOR_MODULE arg, issue error.
	(cp_parser_module_declaration): Adjust.
	(cp_parser_import_declaration): Adjust twice.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-[23].C: Adjust.
	* g++.dg/modules/legacy-6_f.C: Remove XFAIL.

From-SVN: r265269
2018-10-18 15:31:16 +00:00
Nathan Sidwell
c14e05ef47 err-2_[ab].*: Move to ...
gcc/testsuite/
	* g++.dg/modules/err-2_[ab].*: Move to ...
	* g++.dg/modules/cpp-5_[ab].*: ... here.
	* g++.dg/modules/cpp5_c.C: New.

From-SVN: r265258
2018-10-18 04:02:39 +00:00
Nathan Sidwell
d695de064d Robustify parse errors on module/import decls.
gcc/cp/
	* parser.c (cp_parser_consume_semicolon_at_end_of_statement):
	Return void.
	(cp_parser_translation_unit): Adjust.
	(cp_parser_{module,import}_declaration): Don't try and resync
	here.
	(cp_parser_tokenize): Deal with unprocessed incoming tokens.
	gcc/testsuite/
	* g++.dg/modules/err-2_[ab].*: New.

From-SVN: r265256
2018-10-18 00:52:35 +00:00
Nathan Sidwell
0cf81d5c41 Remove some atom/ts differences.
gcc/cp/
	* module.cc (declare_module): Copy always.
	* parser.c (cp_parser_translation_unit): Allo GMF under atom.
	(cp_parser_module_name): Allow legacy name under ts
	(cp_parser_initial_pragma): Fix from trunk.
	gcc/testsuite/
	* g++.dg/modules: Many changes.

From-SVN: r265230
2018-10-17 03:38:17 +00:00
Nathan Sidwell
0543a9b26a module.cc (module_purview): New.
gcc/cp/
	* module.cc (module_purview): New.
	(module_purview_p, module_interface_p): Use it.
	(module_maybe_interface_p): New.
	(module_state::direct_import): Use it.
	(process_deferred_imports): Likewise.
	(declare_module): Set it.
	* parser.c (cp_parser_translation_unit): Inform modules of GMF.

From-SVN: r265229
2018-10-17 03:00:53 +00:00
Nathan Sidwell
d11439a99d macloc-1_[abcd].C: No longer atom-specific.
gcc/testsuite/
	* g++.dg/modules/macloc-1_[abcd].C: No longer atom-specific.

From-SVN: r265222
2018-10-17 00:02:33 +00:00
Nathan Sidwell
9cf5bed662 Locations for everyone!
gcc/cp/
	* module.cc (loc_spans::{init,open,close}): Dump info.
	(module_state::{read,write}_location): No longer atom-specific.
	(module_state::{read,write}): Locations for everyone.
	(process_deferred_imports): Open and close spans correctly.
	gcc/testsuite/
	* g++.dg/modules/adhoc-1_[ab].C: No longer atom-specific.
	* g++.dg/modules/loc-1_[abc].C: Likewise.
	* g++.dg/modules/loc-2_[abcdef].C: Likewise.

From-SVN: r265221
2018-10-16 23:58:36 +00:00
Nathan Sidwell
40f1895868 dumpfile.c (dump_switch_p_1): Don't let a '-' filename fool the option machinery.
gcc/
	* dumpfile.c (dump_switch_p_1): Don't let a '-' filename fool the
	option machinery.

From-SVN: r265220
2018-10-16 23:34:52 +00:00
Nathan Sidwell
76ad592023 Legacy importing during -E
Legacy importing during -E
	gcc/c-family/
	* c-lex.c (init_c_lex): Don't use lang_hooks here.
	* c-opts.c (c_common_init): Set them here.
	gcc/cp/
	* lex.c (module_preprocess_token): Enable legacy importing.
	* module.cc (module_state::read): Skip items when preprocessing
	only.
	(module_cpp_undef): Adjust unsetting.
	gcc/testsuite/
	* g++.dg/modules/cpp-2_c.C: Adjust.

From-SVN: r265219
2018-10-16 22:49:17 +00:00
Nathan Sidwell
0ba2999325 Remove token peeking & preamble related infrastructure.
libcpp/
	* include/cpplib.h (cpp_relocate_peeked_tokens): Delete.
	(cpp_peek_token_with_location): Delete.
	(cpp_in_macro_expansion_p): Delete.
	* directives-only.c (_cpp_preprocess_dir_only): Adjust
	_cpp_handle_directive call.
	* directives.c (struct if_stack): Drop hash_loc.
	(PEEK_INVISIBLE): Delete.
	(linemarker_dir): Adjust.
	(_cpp_handle_directive): Drop hash_loc arg.  dont set it.
	(push_conditional): Drop hash_loc.
	* init.c (read_original_filename): Adjust _cpp_handle_directive
	call.
	* internal.h (struct cpp_reader): Delete peeked_directive field.
	(_cpp_handl_directive): Drop hash_loc arg.
	* lex.c (cpp_relocate_peeked_tokens): Delete.
	(cpp_peek_token): Swallow ...
	(cpp_peek_token_with_location): ... this.  Delete.
	(_cpp_lex_token): Adjust _cpp_handle_directive call.
	* macro.c (cpp_in_macro_expansion_p): Rename to ...
	(cpp_in_macro_expansion): ... this.  Make static.
	* traditional.c (_cpp_scan_out_logical_line): Adjust
	_cpp_handle_directive call.

From-SVN: r265217
2018-10-16 21:23:56 +00:00
Nathan Sidwell
1650e24fb5 Uncommitted tests
From-SVN: r265216
2018-10-16 21:16:57 +00:00
Nathan Sidwell
02b0993280 *.H: Drop unnecessary -fmodules-atom option.
gcc/testsuite/
	* g++.dg/modules/*.H: Drop unnecessary -fmodules-atom option.

From-SVN: r265214
2018-10-16 20:57:43 +00:00
Nathan Sidwell
7a5205cf8b Reimplement preamble peeking
Reimplement preamble peeking
	gcc/
	* doc/invoke.texi (fmodule-preamble): Delete.
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_PREAMBLE): Replace with ...
	(LANG_HOOKS_PREPROCESS_TOKEN): ... this.
	* langhooks.h (struct lang_hooks): Replace preprocess_preamble
	with preprocess_token.
	c-family/
	* c-ppoutput.c (scan_translation_unit): Adjust preprocess lang
	hook.
	* c.opt (fmodule-preamble, fmodule-preamble=): Delete.
	gcc/cp/
	* cp-lang.c (module_preamble_fsm): Delete.
	(LANG_HOOKS_PREPROCESS_PREAMBLE): Delete.
	(LANG_HOOKS_PREPROCESS_TOKEN): Override.
	* cp-tree.h (enum module_preamble_state): Delete.
	(module_preamble_prefix_{peek,next}): Delete.
	(module_preprocess_token): Declare.
	* lex.c (module_preamble_prefix_{peek,next}): Delete.
	(module_preprocess_token): New.
	* module.c (init_module_processing, handle_module_option): Drop
	preamble option handling.
	gcc/testsuite/
	* g++.dg/modules/*: Many changes.

From-SVN: r265213
2018-10-16 20:44:26 +00:00
Nathan Sidwell
3bcda11dec Remove preamble repeating.
gcc/cp/
	* cp-tree.h (maybe_repeat_preamble): Delete.
	* module.c (maybe_repeat_preamble): Delete.
	* parser.c (cp_parser_initial_pragma): Revert to trunk.
	* lex.c (modle_preamble_prefix_peek): Don't repeat preamble.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-1.C: Adjust.
	* g++.dg/modules/atom-preamble-1.C: Is now well formed.

From-SVN: r265209
2018-10-16 17:24:53 +00:00
Nathan Sidwell
efc2b73d25 Remove preamble peeking
Remove preamble peeking
	gcc/cp/
	* cp-tree.h ({import,declare}_module): return void.
	(process_deferred_imports): Return void.
	(module_state::direct_import): Return void, deferrable is
	tristate.  Push onto pending_import vector if permitted.
	({import,declare}_module): Don't return adjustment, use
	direct_import always.
	(process_deferred_imports): Don't return adjustment.
	* parser.c (cp_parser_module_declaration): Return void, drop first
	arg.
	(cp_parser_import_declaration): Return void.
	(cp_parser_module_export): Don't deal with module declaration
	here.
	(cp_parser_get_module_preamble_tokens)
	(cp_parser_parse_module_preamble): Delete.
	(cp_parser_tokenize): Delete #ifdef'd adjustment code.
	(c_parse_file): Don't peek preamble.
	libcpp/
	* line-map.c (linemap_module_restore): Don't calculate adjustment.
	* include/line-map.h (linemap_module_restore): Return void.

From-SVN: r265208
2018-10-16 17:11:58 +00:00
Nathan Sidwell
8a7846ccad Common tokenizer for atom & ts
Common tokenizer for atom & ts
	gcc/cp/
	* module.cc ({import,declare}_module): Don't defer legacy modules.
	* parser.c (cp_parser_translation_unit): Deal with atom preamble.
	(cp_parser_module_declaration): No need to check if first.
	(cp_parser_tokenize): Enable filename token as needed.
	(c_parse_file): Disable preamble scan.
	gcc/testsuite/
	* g++.dg/modules/alias-1_b.C: Adjust.
	* g++.dg/modules/atom-pragma-1.C: Adjust
	* g++.dg/modules/atom-pragma-2.C: Delete.
	* g++.dg/modules/atom-preamble-2_e.C: Copy from 2_f.C
	* g++.dg/modules/atom-preamble-2_f.C: Delete.
	* g++.dg/modules/atom-preamble-[34].C: Adjust.
	* g++.dg/modules/atom-rescan-1.C: Delete.
	* g++.dg/modules/ice-1.C: Adjust
	* g++.dg/modules/macro-2_c.H: Adjust
	* g++.dg/modules/macro-3_b.H: Adjust
	* g++.dg/modules/macro-3_c.C: Adjust
	* g++.dg/modules/macro-6_b.C: Adjust

From-SVN: r265207
2018-10-16 17:10:53 +00:00
Nathan Sidwell
fdc0841a38 Common tokenizer for atom & ts
Common tokenizer for atom & ts
	gcc/cp/
	* module.cc ({import,declare}_module): Don't defer legacy modules.
	* parser.c (cp_parser_translation_unit): Deal with atom preamble.
	(cp_parser_module_declaration): No need to check if first.
	(cp_parser_tokenize): Enable filename token as needed.
	(c_parse_file): Disable preamble scan.
	gcc/testsuite/
	* g++.dg/modules/alias-1_b.C: Adjust.
	* g++.dg/modules/atom-pragma-1.C: Adjust
	* g++.dg/modules/atom-pragma-2.C: Delete.
	* g++.dg/modules/atom-preamble-2_e.C: Copy from 2_f.C
	* g++.dg/modules/atom-preamble-2_f.C: Delete.
	* g++.dg/modules/atom-preamble-[34].C: Adjust.
	* g++.dg/modules/atom-rescan-1.C: Delete.
	* g++.dg/modules/ice-1.C: Adjust
	* g++.dg/modules/macro-2_c.H: Adjust
	* g++.dg/modules/macro-3_b.H: Adjust
	* g++.dg/modules/macro-3_c.C: Adjust
	* g++.dg/modules/macro-6_b.C: Adjust

From-SVN: r265206
2018-10-16 16:48:36 +00:00
Nathan Sidwell
8625c76d82 cp-tree.h (process_deferred_imports): Drop location arg.
gcc/cp/
	* cp-tree.h (process_deferred_imports): Drop location arg.
	* modules.cc ({import,declare}_module): Disable eager imports.
	(process_deferred_imports): Drop location arg, take it from the
	deferred imports.
	* parser.c (cp_parser_translation_unit): Process deferred imports.
	(cp_parser_tokenize): Correct close-brace handling.  Process
	deferred imports.
	(c_parse_file): Adjust prcess_deferred_imports call.
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-1.C: More workarounds

From-SVN: r265201
2018-10-16 15:53:31 +00:00
Nathan Sidwell
58fbbb0659 parser.c (cp_parser_translation_unit): Detect GMF here ...
gcc/cp/
	* parser.c (cp_parser_translation_unit): Detect GMF here ...
	(cp_parser_module_declaration): ... not here.

From-SVN: r265196
2018-10-16 14:35:31 +00:00
Nathan Sidwell
11b06e13df cp-tree.h ({import,declare}_module): Return adjustment.
gcc/cp/
	* cp-tree.h ({import,declare}_module): Return adjustment.
	* module.c (module_state::direct_import): Preserve line table,
	return adjustment.
	* parser.c (cp_parser_fill_main): Delete.
	(cp_parser_tokenize): Take cp_token pointer, reorder check & push.
	(cp_parser_translation_unit): Take cp_token pointer, call
	cp_parser_tokenize.
	(c_parse_file): Don't tokenize here.

From-SVN: r265184
2018-10-16 00:32:20 +00:00
Nathan Sidwell
1cce6582a2 lang-specs.h: Fix .s elision with legacy modules.
gcc/cp/
	* lang-specs.h: Fix .s elision with legacy modules.

From-SVN: r265176
2018-10-15 19:37:02 +00:00
Nathan Sidwell
dbdad8e2ea langhooks.h (struct lang_hooks): Adjust preprocess_main_file signature.
gcc/
	* langhooks.h (struct lang_hooks): Adjust preprocess_main_file
	signature.
	gcc/c-family/
	* c-opts.c (push_command_line_include): Adjust
	preprocess_main_file hook call.
	(cb_file_change): Likewise.
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_MAIN_FILE): Adjust.
	* cp-tree.h (module_note_main_file): Rename to ...
	(module_begin_main_file): ... here.
	(maybe_begin_legacy_module): Delete.
	* module.cc (declare_module): Remove legacy handling here.
	(module_note_main_file): Rename to ...
	(module_begin_main_file): ... here.  Swallow ...
	(maybe_begin_legacy_module): ... this.
	(process_deferred_imports): We're already exporting for legacy
	headers.
	* parser.c (c_parse_file): Don't call maybe_begin_legacy_module.

From-SVN: r265174
2018-10-15 17:49:49 +00:00
Nathan Sidwell
fffe126027 cp-tree.h (process_deferred_imports): New.
gcc/cp/
	* cp-tree.h (process_deferred_imports): New.
	(module_preamble_load): Delete.
	* module.cc (module_state::direct_import): Fatal error here.
	(module_state::preamble_load): Delete, move into ...
	(process_deferred_imports): ... here.  Subsume ...
	(module_preamble_load): ... this.
	* parser.c (c_parse_file): Adjust.
	gcc/testsuite/
	* g++.dg/modules/atom-inc-1.C: Delete.
	* g++.dg/modules/atom-inc-1_[abc].*: New.
	* g++.dg/modules/import-2.C: Adjust.

From-SVN: r265173
2018-10-15 17:22:12 +00:00
Nathan Sidwell
9d868e6610 module.cc (module_state::direct_import): New.
gcc/cp/
	* module.cc (module_state::direct_import): New.
	({import,declare}_module): Call it.
	(module_state::preamble_load): Likewise.

From-SVN: r265170
2018-10-15 16:20:31 +00:00
Nathan Sidwell
f5fbc61a5f lex.c (cpp_peek_token_with_location): Fix pragma rewinding.
libcpp/
	* lex.c (cpp_peek_token_with_location): Fix pragma rewinding.
	gcc/cp/
	* parser.c (cp_parser_initial_pragma): Peek at first token.

From-SVN: r265134
2018-10-12 21:18:11 +00:00
Nathan Sidwell
c9ce90a301 Merge trunk r265127.
From-SVN: r265128
2018-10-12 18:51:32 +00:00
Nathan Sidwell
afbedd82db parser.c (cp_parser_{module,import}_declaration): Remove temp hacks.
gcc/cp/
	* parser.c (cp_parser_{module,import}_declaration): Remove temp hacks.
	(cp_parser_translation_unit, cp_parser_parse_module_preamble): Adjust.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-1.C: Adjust errors.
	* g++.dg/modules/atom-preamble-1.C: Likewise. XFAIL.
	* g++.dg/modules/mod-decl-1.C: Likewise,
	* g++.dg/modules/p0713-[23].C: Likewise.

From-SVN: r265124
2018-10-12 18:04:43 +00:00
Nathan Sidwell
601962c1f5 parser.c (cp_parser_translation_unit): Deal with one level of export block here.
gcc/cp/
	* parser.c (cp_parser_translation_unit): Deal with one level of
	export block here.
	(check_module_outermost): Delete.
	(cp_parser_{module,import}_declaration): Don't call it.
	(cp_parser_declaration): Don't deal with module or import decls.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-[13].C: Adjust errors.

From-SVN: r265123
2018-10-12 17:45:49 +00:00
Nathan Sidwell
755e116b27 parser.c (cp_parser_translation_unit): Detect module and import declarations here.
gcc/cp/
	* parser.c (cp_parser_translation_unit): Detect module and import
	declarations here.

From-SVN: r265114
2018-10-12 16:35:02 +00:00
Nathan Sidwell
c63997ab5b Start breaking out toplevel parsing.
gcc/c-family/
	* c.opt (Wlegacy-header): Delete.
	gcc/
	* doc/invoke.texi (Wlegacy-header): Delete.
	gcc/cp/
	* cp-lang.c (module_preamble_fsm): Don't call atom_preamble_end.
	* cp-tree.h (atom_preamble_end): Delete.
	* lex.c (module_preamble_prefix_peek): Drop Wlegacy_header check.
	* module.cc (module_preamble_end_loc): Delete.
	(do_translate_include): Always translate.
	(maybe_import_include): Drop Wlegacy_header check.
	(atom_preamble_end): Delete.
	* parser.h (cp_parser): Drop implicit_extern_c.
	* parser.c (cp_parser_tokenize): New.
	(cp_debug_parser): Drop implicit_extern_c.
	(cp_parser_new): Likewise.
	(cp_parser_translation_unit): Move global module detectin here.
	(module_preamble_end_loc): Delete declaration.
	(in_preamble): Temp hack.
	(cp_parser_{import,module}_declaration): A couple of temp hacks.
	(cp_parser_parse_module_preamble): Manipulate in_preamble.
	(cp_parser_toplevel_declaration): New, broken out of ...
	(cp_parser_declaration_seq_opt): ... here, call it. Drop top_level arg.
	(c_parse_file): Adjust.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-[23].C: Adjust diags.
	* g++.dg/modules/atom-preamble-[13].C: Likewise.
	* g++.dg/modules/legacy-6_[df].C: Likewise.

From-SVN: r265104
2018-10-12 14:45:28 +00:00
Nathan Sidwell
128447fbff Merge trunk r265055.
From-SVN: r265057
2018-10-11 19:04:52 +00:00
Nathan Sidwell
7f81cebb79 Kill proclaiming decls
Kill proclaiming decls
	gcc/cp/
	* cp-tree.h (push_module_export): Drop proclaiming arg.
	* module.c (proclaimer): Delete.
	({push,pop}_module_export): Adjust.
	(maybe_begin_legacy_module, module_preamble_load): Adjust.
	* parser.c (cp_parser_module_export): Adjust error.
	(cp_parser_module_proclamation): Delete.
	(cp_parser_declaration): Don't call it.
	gcc/testsuite/
	* g++.dg/modules/proclaim-1.C: Delete.

From-SVN: r265045
2018-10-11 16:52:52 +00:00
Nathan Sidwell
83d23cb763 Macro locations!
Macro locations! (ATOM only)
	libcpp/
	* internal.h (linemap_enter_macro): Move declaration to ...
	* include/cpplib.h (linemap_enter_macro): ... here.
	(linemap_lookup_macro_index): Declare.
	* line-map.c (linemap_lookup_macro_index): Break out of ...
	(linemap_macro_map_lookup): ... this.  Use it.
	gcc/cp/
	* module.cc (loc_spans): Record macro spans.
	(module_state::write_readme): Record controlling macro.
	(module_state::{read,write}_location{s,}): Stream macro locations.
	(module_state::write_readme): Move later.
	gcc/testsuite/
	* g++.dg/modules/macloc-1_[abcd].C: New.

From-SVN: r265043
2018-10-11 15:35:01 +00:00
Nathan Sidwell
ebc987cf16 Merge trunk r265037.
From-SVN: r265039
2018-10-11 13:14:06 +00:00
Nathan Sidwell
6e67aae285 module.cc (loc_spans::close): Close the current last map.
gcc/cp/
	* module.cc (loc_spans::close): Close the current last map.
	(module_state::prepare_locations): Adjust.
	(module_state::preamble_load): Adjust span closing.
	(finish_module_parse): Likewise.

From-SVN: r265023
2018-10-10 16:44:06 +00:00
Nathan Sidwell
c76ed612b7 module.cc (pending_imports): New.
gcc/
	* module.cc (pending_imports): New.
	({import,declare}_module): Use it.
	(module_from_cmp): Delete.
	(module_state::preamble_load): Use pending_imports array.

From-SVN: r265022
2018-10-10 15:49:57 +00:00
Nathan Sidwell
af9a599036 invoke.texi (fmodule-legacy): Augment syntax.
gcc/
	* doc/invoke.texi (fmodule-legacy): Augment syntax.
	gcc/cp/
	* module.cc (module_controlling_macro): Replace with ...
	(module_legacy_macro): ... this.
	(module_state::{read,write}_config): Controlling macros only for
	legacy mode.
	(set_module_legacy_name): New.
	(maybe_begin_legacy_module, handle_module_option): Use it.
	(init_module_processing, finish_module_parse): Adjust.
	gcc/c-family/
	* c.opt (fmodule-macro): Delete.
	gcc/testsuite/
	* g++.dg/modules/alias-1_a.H: Fix.
	* g++.dg/modules/legacy=0[ab].H: Adjust.
	* g++.dg/modules/alias-2_*: New.

From-SVN: r265018
2018-10-10 14:43:01 +00:00
Nathan Sidwell
6da37d1077 module.cc (module_state::controlling_macro): Delete.
gcc/cp/
	* module.cc (module_state::controlling_macro): Delete.
	(module_state_config): New struct.
	(module_state::{read,write}_config): Wrap args in a struct.
	(get_option_string): Move into module_state_config.
	(module_state::write_macros): Adjust.
	(module_state::{read,write}): Adjust.

From-SVN: r265016
2018-10-10 13:15:58 +00:00
Nathan Sidwell
ebacb5661b module.cc (module_state::{read,write}_defines): Rename to ...
gcc/cp/
	* module.cc (module_state::{read,write}_defines): Rename to ...
	(module_state::{read,write}_macros): ... here.
	(module_state::{read,write}): Cope with legacy aliases.
	(finish_module_parse): Install initialized controlling macro.
	gcc/testsuite/
	* g++.dg/modules/alias-1_[cdef].C: New.

From-SVN: r265015
2018-10-10 12:08:43 +00:00
Nathan Sidwell
e086cf4eb5 Lazy macro table loading
Lazy macro table loading
	gcc/cp/
	* module.cc (struct slurping): Add macro_tbl, rename macros to
	macros_def.
	(slurping::~slurping): Release macro_tbl.
	(module_state::{read,write}_config): Replace macro count with
	boolean.
	(module_state::{import,install}_defines): New.
	(module_state::read_defines): Map in the table, don't read it.
	(module_state::{check_read,freeze_an_elf}): Adjust.
	(import_module, module_state::preamble_load): Use install_defines.
	gcc/testsuite/
	* g++.dg/modules/macro-6_[abc].*: New.

From-SVN: r264998
2018-10-09 23:18:31 +00:00
Nathan Sidwell
0debbe53d0 Controlling macros & alias detection
Controlling macros & alias detection
	gcc/cp/
	* module.cc (cpp_node, identifier): Conversions between
	cpp_hashnode and IDENTIFIER. Use them.
	(data_in::no_more): Seek end.
	(module_state::{resolve,is}_alias): New.
	(module_state::read): Return alias.
	(module_state::read_config): Initialize controlling macro,
	determine alias.
	(module_state::{read,write}_define): Allow unlocated macros.
	(module_controlling_macro): New switch.
	(module_state::{read_imports,do_import}): Deal with aliases.
	(module_state::write_config): Write controlling macro.
	(module_state::write_defines): Deal with controlling macro.
	(module_state::preamble_load): Deal with aliases.
	(finish_module_parse): Process explicit controlling macro.
	gcc/testsuite/
	* g++.dg/modules/alias-1*: New.
	* g++.dg/modules/macro-[234]*: Adjust.
	* g++.dg/modules/only-[23].C: Adjust.
	libcpp/
	* include/cpplib.h (HT_NODE,NODE_LEN,NODE_NAME): Adjust.
	(cpp_set_deferred_macro): Add defaulted forced arg.

From-SVN: r264997
2018-10-09 21:16:39 +00:00
Nathan Sidwell
b4935ffb77 module.cc (module_state::deferred_macro): Print macro definition.
gcc/cp/
	* module.cc (module_state::deferred_macro): Print macro
	definition.
	gcc/testsuite/
	* g++.dg/modules/macro-2_d.C: Adjust regexps.
	* g++.dg/modules/macro-4_[de].C: Likewise.
	* g++.dg/modules/macro-5_c.C: Likewise.
	libcpp/
	* include/cpplib.h (cpp_macro_definition): Add overload.
	(cpp_macro_definition_location): Make inline, adjust.
	* macro.c (get_deferred_or_lazy_macro): New, broken out of ...
	(_cpp_notify_macro_use): ... here.  Call it.
	(warn_of_redefinition): Call it.
	(cpp_macro_definition): Split into two overloads. Deal with
	deferred macros.
	(cpp_macro_definition_location): Delete.

From-SVN: r264885
2018-10-05 18:49:09 +00:00
Nathan Sidwell
b071dd56b0 module.cc (module_state): Add controlling_macro, unionize slurp with alias.
gcc/cp/
	* module.cc (module_state): Add controlling_macro, unionize slurp
	with alias.  Add accessors.  Use them.
	(module_state::{read,do_import,read_config}): Drop check_crc arg.
	(module_state::read_imports): Zap direct_p before importing.

From-SVN: r264878
2018-10-05 16:53:11 +00:00
Nathan Sidwell
ad55fdc542 Use 'include translation' terminology.
gcc/c-family/
	* c-opts.c (c_common_post_options): Adjust.
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_TRANSLATE_INCLUDE): Override.
	* cp-tree.h (maybe_import_include): Adjust return type.
	* module.cc (module_mapper::translate_include): Replace ...
	(module_mapper::divert_include): ... this.
	(do_translate_include): Replace ...
	(do_divert_include): ... this.
	(maybe_import_include, atom_preamble_end): Adjust.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_DIVERT_INCLUDE): Replace
	with ...
	(LANG_HOOKS_PREPROCESS_TRANSLATE_INCLUDE): ... this.
	* langhooks.h (struct lang_hooks): Replace
	preprocess_divert_include with preprocess_translate_include.
	libcpp/
	* directives.c (do_include_common): Adjust.
	* include/cpplib.h (cpp_divert_include_t): Rename to ...
	(cpp_translate_include_t): ... this.
	(struct cpp_callbacks): Replace divert_include with translate_include.

From-SVN: r264873
2018-10-05 15:12:26 +00:00
Nathan Sidwell
5bb46ac836 Mainfile loc has no line number.
libcpp/
	* internal.h (_cpp_stack_file): Add line_one_p arg.
	* files.c (_cpp_stack_file): Likewise.  Use it.
	* include/cpplib.h (cpp_read_main_file): Add line_one_p arg.
	* init.c (cpp_read_main_file): Likewise, use it.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Start main file on line zero.
	(push_command_line_include): Call preprocess_main_file hook here ...
	(cb_file_change): ... except when reading preprocessed source.
	* c.opt: Add full stops.
	gcc/cp/
	* module.cc (module_note_main_file): Remove fixmes fixed yesterday.
	gcc/testsuite/
	* g++.dg/modules/macro-4_[de].C: Adjust regexp.
	* g++.dg/modules/macro-5_c.C: Likewise.
	* lib/options.exp (check_for_options): Fix comment typos.

From-SVN: r264870
2018-10-05 13:58:37 +00:00
Nathan Sidwell
9aae012981 Dump command line macros, better command line locs
Dump command line macros, better command line locs
	libcpp/
	* include/cpplib.h (cpp_force_token_locations): Take location, not
	pointer.
	* internal.h (cpp_reader): Replace forced_token_location_p with
	forced_token_location.
	* init.c (cpp_create_reader): Adjust.
	* lex.c (_cpp_lex_direct, cpp_force_token_locations): Adjust.
	(cpp_stop_forcing_token_locations): Adjust.
	gcc/c-family/
	* c-opts.c (c_finish_options): Force command line locations.
	gcc/cp/
	* module.cc (loc_spans::init): Add fixed and cmd line locs.
	(loc_spans::SPAN_*): New.
	(loc_spans::cmd_line): New.
	(module_state::read_location): Adjust, return module loc for
	UNKNOWN.
	(module_state::{prepare,read,write}_locations): Adjust.
	(maybe_add_macro): Write cmd_line macros.
	(load_macros): Location is main source file.
	gcc/fortran/
	* cpp.c (gfc_cpp_init): Adjust token forcing.
	gcc/testsuite/
	* g++.dg/modules/macro-4_[de].C: Adjust regexp.
	* g++.dg/modules/macro-5_*: New.

From-SVN: r264854
2018-10-04 19:45:50 +00:00
Nathan Sidwell
6959ba5e58 Merge trunk r264769.
Slip in module.c -> module.cc rename

From-SVN: r264770
2018-10-01 19:50:18 +00:00
Nathan Sidwell
9c9e83ee33 Merge trunk r264765.
From-SVN: r264768
2018-10-01 17:16:57 +00:00
Nathan Sidwell
d50914c164 lang-specs.h: Error out on -fcoroutines.
gcc/cp/
	* lang-specs.h: Error out on -fcoroutines.

	From c++-coroutines branch:
	2018-10-01  Iain Sandoe  <iain@sandoe.co.uk>
	gcc/c-family/
	* c-common.h (RID_CO_AWAIT, RID_CO_YIELD, RID_CO_RETURN,
	D_CXX_COROUTINES, D_CXX_COROUTINES_FLAGS): New.
	* c-common.c (c_common_reswords): co_await, co_yield,
	co_return New keywords.
	gcc/cp/
	* lex.c (init_reswords): Handle flag_coroutines.
	gcc/c-family/
	* c.opt (fcoroutines, fcoroutines-ts): New.

From-SVN: r264765
2018-10-01 16:10:52 +00:00
Nathan Sidwell
33c74848f2 Avoid UB type punning union shenanigans
Avoid UB type punning union shenanigans
	gcc/cp/
	* module.c (macro_import::slot): Explicitly code bit
	manipulation.  Update all users.
	gcc/testsuite/
	* g++.dg/modules/adhoc-1_b.C: Adjust regexp for wierd dejagnu/TCL bug.

From-SVN: r264763
2018-10-01 15:46:19 +00:00
Nathan Sidwell
d83f99cbdd AdHoc locations
AdHoc locations
	gcc/cp/
	* modules.c (dumper): Add LOCATIONS, flags.
	(dumper::operator()): Add default arg.
	(dumper::push): Set flags.
	(module_state::{read,write}_location): Serialize adhoc locs.
	(module_state::deferred_macro): Optimize current TU undef case.
	gcc/testsuite/
	* g++.dg/modules/adhoc-1_[ab].C: New.

From-SVN: r264743
2018-10-01 11:25:02 +00:00
Nathan Sidwell
88cf0cde4a module.c (module_state::deferred_macro): Fix undef hiding logic.
gcc/cp/
	* module.c (module_state::deferred_macro): Fix undef hiding logic.
	gcc/testsuite/
	* g++.dg/modules/macro-4*: New.

From-SVN: r264700
2018-09-28 20:51:53 +00:00
Nathan Sidwell
18dc9790ac No speculative undefs.
gcc/cp/
	* module.c (maybe_add_macro): Simplify.
	(module_state::undef_macro): Only add undef for a deferred macro.

From-SVN: r264672
2018-09-27 15:38:50 +00:00
Nathan Sidwell
6286335648 fix typo.
From-SVN: r264671
2018-09-27 14:55:18 +00:00
Nathan Sidwell
df62d620b3 Add -fforce-module-macros
Add -fforce-module-macros
	libcpp/
	* include/cpplib.h (get_deferred_macro): Declare.
	* macro.c (undefer_macro): Rename to ...
	(get_deferred_macro): ... here.  Adjust callers.
	gcc/
	* doc/invoke.texi (fforce-module-macros): Document.
	gcc/c-family/
	* c.opt (fforce-module-macros): New.
	gcc/cp/
	* module.c (get_option_string): Prune more options.
	(load_macros): New.
	(finish_module_parse): Walk identifiers, if forcing macros.

From-SVN: r264670
2018-09-27 14:54:38 +00:00
Nathan Sidwell
a58c76e653 Add deferred cpp_hashnode field.
Add deferred cpp_hashnode field. Replace macro_imports hash table
	with vector and refactor.
	libcpp/
	* include/cpplib.h (NODE_DEFERRED_MACRO): Delete.
	(cpp_hashnode): Reduce flags width.  Add deferred field.
	(cpp_deferred_macro_p): Delete.
	(cpp_set_deferred_macro): Don't set flag.
	* directives.c (do_undef): Adjust deferred check.
	* macro.c (undefer_macro): Adjust.
	gcc/cp/
	* module.c (macro_export): Drop node field.  Add ctor.
	(macro_import): Rename one to struct slot.  Add ctors, type
	erase.  Delete struct traits.
	(macro_imports): Change to vec type.
	(macro_import::{append,exported}): Adjust.
	(get_macro_{imports,exports}): Allocate node deferred index,
	adjust.
	(maybe_add_macro): Add to macros vector, check unexported undefs
	here.
	(macro_loc_cmp): Reimplement.
	(module_state::{read,write}_macros): Adjust.
	(module_state::{undef,deferred}_macro): Likewise.
	(finish_module_parse): Adjust deallocation.

From-SVN: r264662
2018-09-27 04:12:31 +00:00
Nathan Sidwell
b509bc44ae Macro import and export (corrected).
libcpp/
	* include/cpplib.h (cpp_callbacks): Add user_deferred_macro.
	(NODE_DEFERRED_MACRO): New.
	(cpp_hashnode): Increase flags size.
	(cpp_deferred_macro_p, cpp_set_deferred_macro): New.
	(cpp_compare_macros): Take two macros.
	* internal.h (_cpp_notify_macro_use): Take source location, return bool.
	(_cpp_maybe_notify_macro_use): Likewise.
	* directives.c (do_undef): Don't warn about unresolved deferred
	macros.
	(do_ifdef, do_ifndef): Cope with deferred macros evaporating.
	* expr.c (parse_defined): Likewise.
	* macro.c (undefer_macro): New.
	(enter_macro_context): Adjust notify call.
	(cpp_get_token_1): Deal with deferred nodes.
	(warn_of_redefinition):  Node extraction of compare, call ...
	(cpp_compare_macros): ... this to compare two macros.
	(cpp_create_definition): Adjust compare call.
	(_cpp_notify_macro_use): Deal with deferred macros.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_DEFERRED_MACRO): New.
	* langhooks.h (struct langhooks): Add preprocess_deferred_macro.
	gcc/c-family/
	* c-lex.c (init_c_lex): Register deferred_macro hook.
	gcc/cp/
	* cp-tree.h (module_cpp_deferred_macro): Declare.
	* cp-lang.c (LANG_HOOKS_PREPROCESS_DEFERRED_MACRO): Override.
	* module.c (bytes_in::random_access): New.
	(elf_in::{preserve,release}): New.
	(slurping::{legacies,macros}): New fields.
	(slurping::close): New.
	(module_state::legacies): Remove field.
	(module_state::slurper): Delete.
	(module_state::{read,write}_config): Add number of macros.
	(module_state::{read,write}_define{,s}): Reimplement.
	(module_state::{undef,deferred}_macro): New.
	(cpp_undefs): Delete.
	(struct macro_export, struct macro_import): New.
	(get_macro_{export,import}): New.
	(maybe_add_macro,macro_loc_cmp): Adjust.
	(module_state::{read,write}): Adjust.
	(module_state::check_read): Adjust.
	(module_state::set_import): Adjust.
	(module_state::freeze_an_elf): Preserve macros.
	(import_module): Update legacies bitmap.
	(module_cpp_undef): Call module_state::undef_macro.
	(module_cpp_deferred_macro): New.
	(finish_module_parse): Free macro state.
	gcc/testsuite/
	* g++.dg/modules/macro-2_*: Adjust tests.
	* g++.dg/modules/macro-3_*: Likewise.

From-SVN: r264654
2018-09-26 20:57:31 +00:00
Nathan Sidwell
39f5ffe4a0 modules (module_state): Add legacies bitmap.
gcc/cp/
	* modules (module_state): Add legacies bitmap.
	(module_state::write): Write README later.
	(module_state::read): Set legacies bit.
	(module_state::set_import): Update legacies.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_b.C: Update.

From-SVN: r264517
2018-09-23 17:08:47 +00:00
Nathan Sidwell
dc091b0758 invoke.texi (C++ Modules): Update mapper protocol.
gcc/
	* doc/invoke.texi (C++ Modules): Update mapper protocol.
	* cxx-mapper.c (client): Remove bewait, forget members.
	(client::action): Remove BYIMPORT, BEWAIT & RESET.

From-SVN: r264348
2018-09-16 14:09:00 +00:00
Nathan Sidwell
25e5695385 Remove BYIMPORT, BEWAIT.
gcc/cp/
	* module.c (module_mapper::uncork): Send blank command.
	(module_mapper::imex_query): Take exported_p bool.
	(module_mapper::bewait_{cmd,response}): Delete.
	(module_mapper::send_command): Don't shortcut blank format.
	(module_state::preamble_load): Avoid async commands.

From-SVN: r264347
2018-09-16 14:01:37 +00:00
Nathan Sidwell
2faf245da1 langhooks.h (preprocess_main_file): Drop index arg.
gcc/
	* langhooks.h (preprocess_main_file): Drop index arg.
	gcc/c-family/
	* c-opts.c (cb_file_change): Adjust preprocess_main_file hook.
	gcc/cp/
	* cp-tree.h (module_node_main_file): Drop index parm.
	* module.c (loc_spans::init_p, ): New.
	(loc_spans::init_once): Rename to ...
	(loc_spans::init): ... here.
	(loc_spans::main_start): New.
	(prefix_line_maps_hwm, prefix_locations_hwm): Delete.
	(maybe_add_macro, declare_module, do_divert_include)
	(module_note_main_file, maybe_begin_legacy_module): Adjust.

From-SVN: r264321
2018-09-14 15:57:30 +00:00
Nathan Sidwell
11d8450c81 A grand renaming
A grand renaming
	gcc/cp/
	* cp-tree.h (atom_preamble_state, atom_preamble_prefix_peek)
	(atom_preamble_prefix_next): Rename to ...
	(atom_preamble_state, atom_preamble_prefix_peek)
	(atom_preamble_prefix_next): ... here.
	(atom_cpp_undef, atom_module_preamble, atom_main_file)
	(atom_divert_include, maybe_atom_legacy_module): Rename to ...
	(module_cpp_undef, module_preamble_load, module_note_main_file)
	(maybe_import_include, maybe_begin_legacy_module): ... here.
	* cp-lang.c (LANG_HOOKS_PREPROCESS_MAIN_FILE)
	(LANG_HOOKS_PREPROCESS_DIVERT_INCLUDE)
	(LANG_HOOKS_PREPROCESS_UNDEF, LANG_HOOKS_PREPROCESS_PREAMBLE): Adjust.
	(module_preamble_fsm): Adjust.
	* lex.c (atom_preamble_prefix_peek, atom_preamble_prefix_next):
	Rename to ...
	(atom_preamble_prefix_peek, atom_preamble_prefix_next): ... here.
	Adjust.
	* module.c (atom_cpp_undef, atom_module_preamble, atom_main_file)
	(atom_divert_include, maybe_atom_legacy_module): Rename to ...
	(module_cpp_undef, module_preamble_load, module_note_main_file)
	(maybe_import_include, maybe_begin_legacy_module): Here ... Adust.
	* parser.c (cp_parser_get_module_preamble_tokens, c_parse_file):
	Adjust.

From-SVN: r264314
2018-09-14 13:44:41 +00:00
Nathan Sidwell
1103fd4652 Expunge the spewer
Expunge the spewer
	gcc/cp/
	* module.c (struct slurping): No need to tag.
	(struct spewing): Delete.
	(declare_module, module_state::atom_preamble)
	(finish_module_parse): Don't deal with it.

From-SVN: r264311
2018-09-14 12:49:17 +00:00
Nathan Sidwell
ef660b1f8c Expunge old location scheme
Expunge old location scheme
	gcc/cp/
	* module.c (struct slurper): Remove early_locs, late_locs,
	loc_offset, filenames.
	(module_state::{prepare,read,write}_locations): Delete
	(module_state::{read,write}): Adjust.

From-SVN: r264310
2018-09-14 12:31:37 +00:00
Nathan Sidwell
e669b19d44 New locations working
New locations working
	gcc/cp/
	* module.c (module_state::prepare_locations): New, broken out of ...
	(module_state::write_locations): Adjust.
	(module_state::read_locations): Fix.

From-SVN: r264309
2018-09-14 12:22:38 +00:00
Nathan Sidwell
d09c3ceb89 Read & write new locations (buggy, disabled).
gcc/cp/
	* module.c (module_state::{read,write}_location): Add new-loc
	scheme.
	(module_state::{read,write}_locations): Adjust.
	(module_state::read): Select location scheme.
	gcc/testsuite/
	* g++.dg/modules/loc-1_c.C: Use regexp for note loc.

From-SVN: r264289
2018-09-13 20:17:37 +00:00
Nathan Sidwell
6cfa701876 Reading location spans (but not using them).
gcc/cp/
	* module.c (loc_range_t): Global typedef.
	(loc_spans::release): Delete.
	(slurping): Add new range locs.
	(module_state::write_locations): Adjust.
	(module_state::read_locations): New.
	(module_state::read): Call it.

From-SVN: r264284
2018-09-13 18:22:49 +00:00
Nathan Sidwell
712e258ffd Stop passing line_map around. There is only one.
gcc/cp/
	* cp-tree.h (import_module, declare_module, atom_module_preamble)
	(finish_module_parse, maybe_atom_legacy_module): Drop line_map
	arg.
	* decl2.c (c_parse_final_cleanups): Adjust.
	* parser.c (cp_parser_module_declaration)
	(cp_parser_import_declaration, c_parse_file): Adjust.
	* module.c (loc_spans): Drop lmaps member & adjust.
	(module_state): Drop line_maps from some but not all members.

From-SVN: r264272
2018-09-13 13:56:09 +00:00
Nathan Sidwell
41720e0d4a Refactor location spans
Refactor location spans
	gcc/cp/
	* module.c (class loc_spans): New.  Absorb ...
	({open,close,ordinary,macro}_interval): ... these.  Update all uses.

From-SVN: r264269
2018-09-13 12:03:07 +00:00
Nathan Sidwell
c2d95cd0f7 Adding location spans
Adding location spans
	gcc/cp/
	* module.c (loc_range_t): New range.
	(struct lmap_interval): New.
	(lmap_spans): New.
	(open_interval, close_interval, ordinary_interval)
	(macro_interval): New.
	(module_state::write_locations): Write spans.
	(module_state::write): Write spans.
	(module_state::atom_preamble): Update spans.
	(atom_main_file): Initialize spans.
	(finish_module_parse): Close out span.

From-SVN: r264252
2018-09-12 19:25:39 +00:00
Nathan Sidwell
ffc9daa086 parser.c (cp_parser_get_module_preamble_tokens): Don't read past EOF.
gcc/cp/
	* parser.c (cp_parser_get_module_preamble_tokens): Don't read past
	EOF.
	gcc/testsuite/
	* g++.dg/modules/ice-1.C: New.
	* g++.dg/modules/modules.exp: Remove old pruning.

From-SVN: r264242
2018-09-12 14:36:17 +00:00
Nathan Sidwell
9d9de35620 Implement p1103r0 19.3/2 not-a-keyword.
gcc/cp/
	* module (module_state::write_define): Don't export keywords.
	gcc/testsuite/
	* g++.dg/modules/legacy-7_{a.H,b.C}: New.

From-SVN: r264240
2018-09-12 13:54:15 +00:00
Nathan Sidwell
39e61e5dbb diagnostic.c (diagnostic_report_current_module): Do not line break after module name.
gcc/
	* diagnostic.c (diagnostic_report_current_module): Do not line
	break after module name.
	gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Adjust module loc regexp.
	* g++.dg/modules/loc-2_[def].C: Adjust dg-regexp.
	* g++.dg/modules/macro-2_d.C: Likewise.

From-SVN: r264190
2018-09-10 07:20:13 +00:00
Nathan Sidwell
e68c900521 c.opt (fmodule-only): Set flag.
gcc/c-family/
	* c.opt (fmodule-only): Set flag.
	gcc/cp/
	* decl2.c (c_parse_final_cleanups): Always call finish_module_parse.
	* module.c (finish_module_parse): Warn on incorrect -fmodule-only.
	gcc/testsuite/
	* g++.dg/modules/only-[123].C: New.

From-SVN: r264144
2018-09-06 07:41:16 +00:00
Nathan Sidwell
7b5e7691b0 Add -fmodule-only, rename -fmodules-legacy
Add -fmodule-only, rename -fmodules-legacy
	gcc/c-family/
	* c.opt (fmodules-legacy*): Rename to ...
	(fmodule-legacy*): ... here.
	(fmodule-only): New.
	gcc/cp/
	* lang-specs.h: Incorporate -fmodule-only.
	* module.c (get_option_string, handle_module_option): Adjust.
	gcc/
	* doc.invoke.texi: Update module options.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Adjust.
	* g++.dg/modules/*: Adjust options.

From-SVN: r264140
2018-09-06 07:21:02 +00:00
Nathan Sidwell
237c80469f configure.ac (checkfuncs, [...]): Add pipe2.
libiberty/
	* configure.ac (checkfuncs, AC_CHECK_FUNCS): Add pipe2.
	* configure, config.in: Regenerated.
	* pex-unix.c (pex_unix_execute): Use pipe to transfer child failure.

From-SVN: r264018
2018-08-31 14:13:18 +00:00
Nathan Sidwell
8ecf52e2ab AIXify tests fcc/testsuite/
AIXify tests
	fcc/testsuite/
	* fn-inline-1_[abc].C: Adjust regexps.
	* sym-subst-2_a.C: Don't add -fat-lto option, use scan-assembler instead.

From-SVN: r264002
2018-08-30 21:41:58 +00:00
Nathan Sidwell
58bbdfab5b Fix AIX
Fix AIX
	gcc/cp/
	* cxx-mapper.cc (buffer::get_request): Reinit pos.

From-SVN: r263998
2018-08-30 20:36:42 +00:00
Nathan Sidwell
3b33cb575c Fix --enable-checking=release.
gcc/cp/
	* name-lookup.c (set_module_binding): Add static cast.

From-SVN: r263996
2018-08-30 20:05:53 +00:00
Nathan Sidwell
480a532292 Fix more GC
Fix more GC
	gcc/cp/
	* module.c (module_state): Tag for_user.
	(module_state_hash): Defive from ggc_ptr_hash.
	(init_module_processing): GGC alloc hash table.  get mapper when
	not lazy, add ggc_collect.
	(finish_module_parse): Don't zap hash table here ...
	(finish_module_processing): ... do it here instead.
	gcc/testsuite/
	* g++.dg/modules/gc-2_a.C: New.
	* g++.dg/modules/gc-2.map: New.

From-SVN: r263995
2018-08-30 19:47:57 +00:00
Nathan Sidwell
e405162d40 AIX build
AIX build
	gcc/
	* configure.ac: Check sighandler_t, memrchr.
	* config.in, configure: Rebuilt.
	gcc/cp/
	* Make-lang.in (MODULE_STAMP): Protect against non--r capable
	date.
	(cxx-mapper): Add LIBINTL, not LIBBACKTRACE.
	* module.c (memrchr, sighandler_t): Provide fallback.
	* cxx-mapper.cc (memrchr, sighandler_t): Provide fallback.

From-SVN: r263984
2018-08-30 14:58:54 +00:00
Nathan Sidwell
93907de55e * Merge trunk r263974.
From-SVN: r263975
2018-08-30 12:23:46 +00:00
Nathan Sidwell
ff85d84ef1 module.c (atom_cpp_undef): location_t arg is unused.
gcc/cp/
	* module.c (atom_cpp_undef): location_t arg is unused.

From-SVN: r263961
2018-08-29 15:36:07 +00:00
Nathan Sidwell
5a85780040 module.c (module_state::{read,write}_define): Add NUL terminators to CPP_TOKEN_FLD_STR elements.
gcc/cp/
	* module.c (module_state::{read,write}_define): Add NUL
	terminators to CPP_TOKEN_FLD_STR elements.

From-SVN: r263956
2018-08-29 12:39:15 +00:00
Nathan Sidwell
9f049b4e6e lex.c (cpp_alloc_token_string): Don't clobber ending NUL.
libcpp/
	* lex.c (cpp_alloc_token_string): Don't clobber ending NUL.

From-SVN: r263951
2018-08-29 12:03:32 +00:00
Nathan Sidwell
e8aac46da4 cp-lang.c (LANG_HOOKS_PREPROCESS_UNDEF): Override.
Undefs
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_UNDEF): Override.
	* cp-tree.h (atom_cpp_undef): Declare.
	* module.c: Include langhooks.h.
	(cpp_undefs): New global.
	(module_state::{read,write}_defines): Stream undefs.
	(atom_cpp_undef): Define.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_UNDEF): Default.
	(LANG_HOOKS_INITIALIZER): Add it.
	* langhooks.h (struct lang_hooks): Add preprocess_undef hook.
	gcc/c-family/
	* c-lex.c: Include langhooks.h
	(init_c_lex, cb_undef): Look at lang hook.
	gcc/testsuite/
	* g++.dg/modules/macro-3_[ab].H: New.
	* g++.dg/modules/macro-3_c.C: New.

From-SVN: r263932
2018-08-28 20:28:26 +00:00
Nathan Sidwell
2982e99ef9 Sorted macros
Sorted macros
	gcc/cp/
	* module.c (module_state::{read,write}_define): New, single-macro
	streamers.
	(module_state::write_define_cb): Delete.
	(maybe_add_macro, macro_loc_cmp): New.
	(module_state::write_defines): Write in source order.
	(module_state::read_defines): Adjust.

From-SVN: r263929
2018-08-28 19:19:13 +00:00
Nathan Sidwell
2b2dae3856 Macro define locations
Macro define locations
	libcpp/
	* include/cpplib.h (cpp_macro): Add imported field.
	gcc/cp/
	* module.c (module_state::write_define_cb): Ignore imported, write
	location.
	(module_state::read_defines): Read location.
	gcc/testsuite/
	* g++.dg/modules/macro-2_[abc].H: New.
	* g++.dg/modules/macro-2_d.C New.

From-SVN: r263927
2018-08-28 18:33:23 +00:00
Nathan Sidwell
3d3f97f14e Reading macros.
gcc/cp/
	* module.c (bytes_{in,out}::cpp_node): New.
	(bytes_out::buf): New.
	(bytes_{in,out}::str): Treat zero-length strings specially.
	(module_state::write_define_cb): Concatenate strings.
	(module_state::write_defines): Write padding byte.
	(module_state::read_defines): New.
	(module_state::read): Call it.
	libcpp/
	* include/cpplib.h (cpp_alloc_token_string): New.
	(cpp_compare_macros): Declare.
	* lex.c (cpp_alloc_token_string): New, broken out of ...
	(create_literal): ... here.  Call it.
	* macro.c (warn_of_redefinition): Rename to ...
	(cpp_compare_macros): ... this, and make it extern.
	(_cpp_create_definition): Adjust.
	gcc/testsuite/
	* g++.dg/modules/macro-1_a.H: Adjust.
	* g++.dg/modules/macro-1_b.C: New.

From-SVN: r263926
2018-08-28 17:02:44 +00:00
Nathan Sidwell
d8655a0f9d Writing macros.
gcc/cp/
	* cp-tree.h (import_module, declare_module, atom_module_preamble,
	finish_module_parse, maybe_atom_legacy_module): Add cpp_reader
	arg.
	* decl2.c (c_parse_final_cleanups): Adjust finish_module_parse.
	* module.c (bytes_out::str): Overload for cpp_hashnode.
	(module_state::read_imports,write_imports,do_import): Add
	cpp_reader arg.
	(module_state::atom_preamble): Likwise.
	(import_module, declare_module, atom_module_preamble)
	(finish_module_parse, maybe_atom_legacy_module): Likewise.
	(module_state::write_{define_cb,defines}): New.
	(module_state::write): Write defines when in legacy mode.
	* parser.c (cp_parser_module_declaration)
	(cp_parser_import_declaration, c_parse_file): Pass parse_in.
	gcc/testsuite/
	* g++.dg/modules/macro-1_a.H: New.

From-SVN: r263919
2018-08-28 13:37:15 +00:00
Nathan Sidwell
8bcd4fe221 Merge trunk r263897.
From-SVN: r263898
2018-08-27 22:13:02 +00:00
Nathan Sidwell
13ee363fef module.c (module_state): Remove depth.
gcc/cp/
	* module.c (module_state): Remove depth.
	(module_state::maybe_create_loc): Replace ...
	(module_state::set_loc): ... this.
	(module_state::read_imports): Check CRC of indirect imports too.
	(module_state::attach): Simplify logic.
	libcpp/
	* include/linemaph (linemap_module_loc): Drop CURRENT parm.
	* line-map.c (linemap_module_loc): Drop reseating capability.

From-SVN: r263897
2018-08-27 21:17:58 +00:00
Nathan Sidwell
bc41258a85 module.c (module_state::check_not_purview): New.
gcc/cp/
	* module.c (module_state::check_not_purview): New.
	(module_state::read_imports,import_module): Use it.

From-SVN: r263895
2018-08-27 20:06:27 +00:00
Nathan Sidwell
a86bf07345 Remove %M formatter, it is not worth complexity.
gcc/c-family/
	* c-format.c (local_module_ptr_node): Remove
	(gcc_cxxdiag_char_table): Remove 'M'
	(init_dynamic_diag_info): Remove module_state lookup
	* c-format.h (T89_M): Remove
	gcc/cp/
	* cp-tree.h (class module_state): Move to module.c section.
	(pp_module_name): Delete.
	* error.c (cp_printer): Remove %M.
	* module.c: Remove %M error printing.
	(pp_module_name): Delete.
	* ptree.c (cxx_print_decl): Print module number too.

From-SVN: r263893
2018-08-27 19:43:25 +00:00
Nathan Sidwell
846b3cc8e8 Mangling substitutions!
gcc/cp/
	* cp-tree.h (module_vec_name): Delete.
	* mangle.c (mangle_substitution): Fix name typo.
	* module.c (class module_state): Drop vec_name field.  Make mod
	short.  Add subst field.
	(module_state::mangle): New.
	(mangle_module): Deal with substitutions.
	(mangle_module_fini): Undeal with substitutions.
	(module_vec_name): Delete.
	(module_state::attach): Don't set vec_name.
	gcc/testsuite/
	* g++.dg/modules/sym-subst-1.C: New.
	* g++.dg/modules/sym-subst-2_[ab].C: New.

From-SVN: r263892
2018-08-27 19:13:26 +00:00
Nathan Sidwell
4cf98010d2 Fix module-state lifetime issue.
gcc/cp/
	* cp-tree.h (finish_module): Break into ...
	(finish_modle_{parse,procesing}): ... these two.
	* decl2.c (c_parse_final_cleanups): Adjust modules finalization.
	* modules.c (finish_modules): Break into ...
	(finish_module_{parse,procesing}): ... these two.
	(module_state::release): Break out ...
	(module_state::slurped): ... this.
	(module_state::{init,fini}): Fold into callers.

From-SVN: r263889
2018-08-27 16:14:43 +00:00
Nathan Sidwell
668499eda8 Refactor mangling interface.
gcc/cp/
	* cp-tree.h (mangle_module, mangle_module_fini): Declare.
	(mangle_substitution, mangle_identifer): Declare.
	* mangle.c (mangle_substitution, mangle_identifer): Define.
	(struct globals): Add mod field.
	(maybe_write_module): Call mangle_module.
	(finish_mangling_internal): Call mangle_module_fini.
	* module.c (mangle_module, mangle_module_fini): Define.

From-SVN: r263883
2018-08-27 13:45:47 +00:00
Nathan Sidwell
cb89a1901c Module state gains parent.
gcc/cp/
	* cp-tree.h (get_module): Add parent argument.
	(module_name): Return string.
	* error.c (dump_module_suffix): Adjust module_name use.
	* module.c (module_state_hash): Adjust for having a parent.
	(module_state: Add parent & fullname fields.
	(module_state::set_name): Delete.
	(get_module): Add parent.
	(get_module): Split string.
	(module_mapper::{export_done,imex_query}): Adjust module name access.
	(module_state::write_readme): Adjust.
	(module_state::{read,write}_{imports,config}): Adjust.
	(module_state::set_loc): Use fullename.
	(module_state::attach): Create fullname.
	* parser.c (cp_parser_module_name): Generate parental name.
	* ptree.c (cxx_print_decl): Adjust.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-1.C: Adjust diags.

From-SVN: r263823
2018-08-23 23:24:56 +00:00
Nathan Sidwell
116c1274ae Kill N: prefix notation
Kill N: prefix notation
	gcc/cp/
	* module.c (enum module_kind): Delete.
	(module_state): Replace kind with legacy, adjust is_legacy.
	(module_state::set_name): Adjust.
	(module_state_hash): Adjust hasher & comparator.
	(module_legacy_system_p): Delete.
	(make_flat_name): Move into ...
	(get_module): ... here.  Adjust.
	(get_module): Add string variant.
	(module_mapper::module_mapper): Adjust.
	(module_mapper::{module_name_kind,response_name}): Delete.
	(module_mapper::{imex_query,bewait_response,divert_include}): Adjust.
	(module_state::{read_imports,attach}): Adjust.
	(pp_module_name): Adjust.
	(maybe_atom_legacy_module, init_module_processing)
	(handle_module_option): Adjust.
	* cxx-mapper.cc (module2bmi): Remove encoding.
	(encode_module_name): Remove encoding.
	gcc/c-family/
	* c-lex.c (c_lex_with_flags): CPP_HEADER include quoting.
	gcc/
	* doc/invoke.texi (C++ Modules): Adjust protocol doc.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Adjust BMI mapping.
	* g++.dg/modules/legacy-0[ab].H: New.
	* g++.dg/modules/legacy-*: Adjust.

From-SVN: r263812
2018-08-23 13:05:06 +00:00
Nathan Sidwell
590bce27e4 %M formatter
%M formatter
	gcc/c-family/
	* c-format.c (local_module_ptr_node): New.
	(gcc_cxxdiag_char_table): Add 'M'.
	(argument_parser::handle_conversions): Allow wanted type to be
	NULL.
	(init_dynamic_diag_info): Simplify lookup, add module_state.
	* c-format.h (T89_M): New.
	gcc/cp/
	* cp-tree.h (class module_state): Declare before diagnostics.
	* error.c (cp_printer): Add %M.
	* module.c: Use %M error printing.

From-SVN: r263779
2018-08-22 15:58:14 +00:00
Nathan Sidwell
abc6abad07 Use modules as handles themselves.
gcc/cp/
	* cp-tree.h (class module_state): Forward declare.
	(get_module, pp_module_name): Declare.
	(import_module, declare_module, push_module_export): Take
	module_state.
	* module.c (proclaimer): A module.
	(get_module, pp_module_name): Define.
	(push_module_export, import_module, declare_module): Adjust.
	* parser.c (cp_parser_module_name): Return module_state.
	(cp_parser_module_declaration, cp_parser_import_declaration)
	(cp_parser_module_proclamation): Adjust.

From-SVN: r263777
2018-08-22 13:43:05 +00:00
Nathan Sidwell
fbfe859a1d Fix GTY
Fix GTY
	gcc/cp/
	* cp-tree.h (struct mc_index): Don't mark.
	(struct mc_slot): Converted from union.  Adjust.
	(struct module_cluster): Skip mc_index.
	* module.c (struct slurping,spewing): Skip range_t members.
	(class module_state): Remove static data members.
	(global_tree_arys, fixed_trees, global_crc, our_opts, lazy_lru)
	(lazy_open, modules, modules_hash): New static vars.  Adjust uses.
	(finish_module): Add gc point.
	gcc/testsuite/
	* g++.dg/modules/gc-1_[abcd].C: New.

From-SVN: r263775
2018-08-22 13:21:36 +00:00
Nathan Sidwell
db585e2c26 cp-tree.h (declare_module, [...]): Separate name from location.
gcc/cp/
	* cp-tree.h (declare_module, import_module): Separate name from location.
	* module.c (module_state::attach): Drop maybe_vec_name arg.
	(module_state::get_module): Flatten here.
	(declare_module, import_module): Separate name and from loc.
	(maybe_atom_legacy_module): Adjust.
	* parser.c (cp_parser_module_name): Return tree only.
	(cp_parser_module_declaration, cp_parser_import_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/legacy-4.H: Adjust error.

From-SVN: r263748
2018-08-21 18:13:55 +00:00
Nathan Sidwell
4a6628459d module.c (module_mapper::divert_include): Don't append export attrib.
gcc/cp/
	* module.c (module_mapper::divert_include): Don't append export attrib.
	(import_module): Don't scan attribs.
	(maybe_atom_legacy_module): Push exporting.
	gcc/testsuite/
	* g++.dg/modules/legacy-3_[bc].H: Adjust.
	* g++.dg/modules/legacy-5_b.C: Adjust.
	* g++.dg/modules/legacy-6_[cd].C: Adjust.

From-SVN: r263746
2018-08-21 16:54:22 +00:00
Nathan Sidwell
220324eef2 module.c (module_state::get_module): Lose dflt & insert args.
gcc/cp/
	* module.c (module_state::get_module): Lose dflt & insert args.
	(module_state::insert_mapping): Move directly into ...
	(module_mapper::module_mapper): ... here.
	(module_mapper::bewait_response, module_state::read_imports): Adjust.
	(import_module, declare_module): Adjust.

From-SVN: r263740
2018-08-21 15:33:19 +00:00
Nathan Sidwell
630fdc5ccc module.c (module_state::is_mapping): Rename to ...
gcc/cp/
	* module.c (module_state::is_mapping): Rename to ...
	(module_state::is_detached): ... here.  Use from_loc.
	(module_state::attach): New broken out of ...
	(module_state::find_module): ... here.  Delete, fold into ...
	(module_state::read_imports, import_module, declare_module):
	... these callers.
	(module_state::read): Adjust module index setting.

From-SVN: r263705
2018-08-21 14:13:45 +00:00
Nathan Sidwell
e73f417376 pex-unix.c (IS_FAKE_VFORK): Rename to VFORK_IS_FORK.
libiberty/
	* pex-unix.c (IS_FAKE_VFORK): Rename to VFORK_IS_FORK.
	(pex_unix_exec_child): Avoid spuros clobber warning, use stdio
	when forking.

From-SVN: r263704
2018-08-21 14:11:05 +00:00
Nathan Sidwell
b7b25d8e7c Merge trunk r263679.
From-SVN: r263684
2018-08-21 00:26:53 +00:00
Nathan Sidwell
9507acab94 Merge trunk r263673.
From-SVN: r263674
2018-08-20 20:23:03 +00:00
Nathan Sidwell
052da585c1 Revert r263619 2018-08-17 Nathan Sidwell <nathan@acm.org> Revert r263597...
Revert r263619  2018-08-17  Nathan Sidwell  <nathan@acm.org>
	Revert r263597  2018-08-16  Nathan Sidwell  <nathan@acm.org>
	They break GTY strangely.

From-SVN: r263673
2018-08-20 19:49:07 +00:00
Nathan Sidwell
4f9491d50c module.c (module_state::is_detached): New.
gcc/cp/
	* module.c (module_state::is_detached): New.
	(module_state::attach): New, broken out of ...
	(module_state::find_module): ... here.  Call it.
	(declare_modules): Do module-specific attaching here.

From-SVN: r263619
2018-08-17 13:12:23 +00:00
Nathan Sidwell
3eed57f321 modules.exp (dg-module-pre-prune): Delete
gcc/testsuite/
	* g++.dg/modules/modules.exp (dg-module-pre-prune): Delete
	(g++-dg-prune): Don't override.
	* g++.dg/modules/legacy-4.H: Use dg-regexp.
	* g++.dg/modules/loc-2_[def].C: Likewise.

From-SVN: r263599
2018-08-16 19:01:57 +00:00
Nathan Sidwell
a6e2cbe7ad cp-tree.h (class module_state): Forward declare.
gcc/cp/
	* cp-tree.h (class module_state): Forward declare.
	(get_module, pp_module_name): Declare.
	(push_module_export, declare_module, import_module): Take
	module_state.
	* error.c (cp_printer): Accept %M.
	* module.c (module_state::find_module): Take module_state.
	(module_state::get_module): Drop default & insert args.
	(module_state::insert_mapping): Delete.
	(module_mapper::{module_mapper,bewait_response): Adjust.
	(module_mapper::divert_include): Drop indentation.
	(module_state::read_imports): Adjust.
	(proclaimer): Is a module_state pointer.
	(push_module_state, declare_module, import_module): Adjust.
	(pp_module_name): New.
	(get_module): New.
	(maybe_atom_legacy_module): Adjust.
	* parser.c (cp_parser_module_name): Return module_state, adjust.
	(cp_parser_module_declaration, cp_parser_import_declaration):
	Adjust.
	gcc/testsuite/
	* g++.dg/modules/legacy-4.H: Adjust regexp.

From-SVN: r263597
2018-08-16 18:51:36 +00:00
Nathan Sidwell
ac589de58e Merge trunk r263429.
From-SVN: r263431
2018-08-08 19:33:14 +00:00
Nathan Sidwell
dd6ea0f635 Merge trunk r263272.
From-SVN: r263276
2018-08-02 20:25:52 +00:00
Nathan Sidwell
68bf538f62 cpplib.h (cpp_clear_if_stack): Renamed from cpp_pop_directives.
libcpp/
	* include/cpplib.h (cpp_clear_if_stack): Renamed from
	cpp_pop_directives.
	* directives.c (cpp_clear_if_stack): Likewise, drop all arg.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Fixup.

From-SVN: r262594
2018-07-12 14:11:18 +00:00
Nathan Sidwell
aa5b71ef7c c.opt (fmodule-preamble): Alias fmodule-preamble=
gcc/c-family/
	* c.opt (fmodule-preamble): Alias fmodule-preamble=
	(fmodule-preamble): Fix type.
	* module.c: Add i18n markers.
	(init_module_processing): Detect unsupported option combos.
	(handle_module_option): Don't zap explicit modules-ts.
	gcc/
	* diagnostic.c (diagnostic_report_current_module): Add i18n
	markers.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-9.C: New.
	* g++.dg/modules/modules.exp (mode_list): Preamble is atom.
	libcpp/
	* directives.c (cpp_pop_directives): Buffer could be NULL.

From-SVN: r262593
2018-07-12 13:38:20 +00:00
Nathan Sidwell
ae2917b615 Hide NT_MACRO
Hide NT_MACRO
	libcpp/
	* include/cpplib.h (cpp_macro_p): New.
	* macro.c (cpp_fun_like_macro_p): Use it.
	gcc/c-family/
	* c-ada-spec.c (count_ada_macro, store_ada_macro): Use
	cpp_macro_p.
	* c-ppoutput.c (dump_macro): Likewise.
	* c-spellcheck.cc (should_suggest_as_macro_p): Likewise.
	gcc/
	* config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Use cpp_macro_p.
	* config/powerpcspe/powerpcspe-c.c (rs6000_macro_to_expand): Likewise.
	gcc/fortran/
	* cpp.c (dump_macro): Use cpp_macro_p.

From-SVN: r262592
2018-07-12 13:33:48 +00:00
Nathan Sidwell
76b367c3b7 modules.exp: Restore g++-dg-prune after test.
gcc/testsuite/
	* g++.dg/modules/modules.exp: Restore g++-dg-prune after test.
	* g++.dg/modules/legacy-5_c.C: Fix scan-lang-dump.

From-SVN: r262478
2018-07-06 14:43:07 +00:00
Nathan Sidwell
c1f45e4923 No ALIASes for IMPORTS
No ALIASes for IMPORTS
	gcc/cp/
	* cxx-mapper.cc (module2bmi): No aliases here.
	(client::imex_response): Adjust.
	gcc/
	* doc/invoke.texi (C++ Modules): Remove ALIAS from IMPORT response
	set.

From-SVN: r262450
2018-07-05 18:06:47 +00:00
Nathan Sidwell
77317a8b43 Legacy header warning
Legacy header warning
	gcc/
	* invoke.texi (Wlegacy-header): New warning.
	gcc/c-family/
	* c.opt (Wlegacy-header): New.
	gcc/cp/
	* cp-tree.h (atom_preamble_end): Declare.
	* cp-lang.c (atom_preamble_fsm): Use it.
	* lex.c (atom_preamble_prefix_peek): Check OPT_Wlegacy_header.
	* module.c (do_divert_include): Likewise.
	(atom_divert_include): Default -Wlegacy-header.
	(atom_preamble_end): New.
	* parser.c (c_parse_file): Use it.
	gcc/testsuite/
	* g++.dg/modules/legacy-6*: New.

From-SVN: r262449
2018-07-05 17:41:55 +00:00
Nathan Sidwell
51cbdcc2e9 Legacy header aliasing
Legacy header aliasing
	gcc/
	* doc/invoke.texi (C++ Modules): Update protocol docs
	gcc/cp/
	* cxx-module.cc (module2bmi): Deal with aliasing.
	(encode_module_name): New.
	(read_mapping_file): Use it.  Deal with aliasing.
	(client::imex_response): Likewise.
	(client::action): Likewise,
	* module.c (module_mapper::module_name_kind): New.
	(module_mapper::response_name): Use it.
	(module_mapper::divert_include): Allow aliasing.
	gcc/testsuite/
	* g++.dg/modules/legacy-5.*: New.

From-SVN: r262441
2018-07-05 15:09:59 +00:00
Nathan Sidwell
06b6cb5bac backport: invoke.texi (C++ Modules): Adjust.
Merge legacy header options to -fmodules-
	gcc/
	* doc/invoke.texi (C++ Modules): Adjust.
	gcc/c-family/
	c.opt (fmodules_legacy, fmodules_legacy=): New.
	(fmodule-{user,system}-header{,=}): Delete.
	gcc/cp/
	* cp-tree.h (modules_legacy_p): Renamed from modules_header_p.
	* lang-specs.h (@c++-header): Update.
	* lex.c (atom_preamble_prefix_peek): Adjust.
	* module.c (module_legacy_name): Do not force to empty string.
	(module_state::get_option_string): Adjust.
	(declare_module, maybe_atom_legacy_module, init_module_processing)
	(handle_module_option): Likewise.
	gcc/testsuite/
	* g++.dg/modules/legacy-[1234]*: update.
	* g++.dg/modules/atom-inc-1.C: Update.

From-SVN: r262356
2018-07-03 19:13:59 +00:00
Nathan Sidwell
651ccaf2ee Explicit user/system legacy headers
Explicit user/system legacy headers
	gcc/c-family/
	* c-lex.c (c_lex_with_flags): Encode header names in tree lists.
	* c.opt (fmodule-{user,system}-header): New.
	gcc/cp/
	* cxx-mapper.cc (module2bmi): Adjust.
	(read_mapping_file): Encode legacy header names.
	* lang-specs.h (@c++-header): Update.
	* module.c (module_state_hash::hash): Update hashers.
	(enum module_kind): New.
	(module_state::set_name): Adjust.
	(module_state_hash::equal): Adjust.
	(module_header_is_system): New.
	(make_legacy_name): Delete.
	(module_state::get_module): Adjust.
	(module_mapper::response_name): New.
	(module_mapper::imex_query): Adjust.
	(module_mapper::bewait_response): Adjust.
	(module_mapper::divert_include): Adjust.
	(declare_module, maybe_atom_legacy_module): Likewise.
	(handle_module_option): Check new options.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: update BMI encodings.
	* g++.dg/modules/legacy-[1234]*: update.
	* g++.dg/modules/atom-inc-1.C: Update.
	gcc/
	* doc/invoke.texi (C++ Modules): Document new options.

From-SVN: r262355
2018-07-03 18:03:15 +00:00
Nathan Sidwell
13a14c25f6 Diverted header column preservation
Diverted header column preservation
	libcpp/
	* directives.c (do_include_common): Adjust divert callback.
	* include/cpplib.h (cpp_divert_include_t): Likewise.
	gcc/cp/
	* module.c (module_mapper::divert_include): Add line_maps.
	Preserve column number.
	(import_module): Look at attribs.
	(do_divert_include): Adjust.
	* parser.c (cp_parser_module_declaration): Return loc of name.
	(cp_parser_import_declaration): Likewise.
	(cp_parser_parse_module_preamble): Adjust.
	gcc/
	* langhooks.h (lang_hooks): Adjust preprocess_divert_include.
	gcc/testsuite/
	* g++.dg/modules/legacy-3_b.H: Adjust.
	* g++.dg/modules/legacy-3_c.H: Adjust.
	* g++.dg/modules/legacy-4.H: Adjust.

From-SVN: r262259
2018-06-29 20:06:15 +00:00
Nathan Sidwell
41db2dbfef Diverted include line numbering
Diverted include line numbering
	libcpp/
	* directives.c (do_include_common): Fixup diversion line
	numbering.
	(_cpp_pop_buffer): Free to_free even if not a file.
	gcc/c-family/
	* c-ppoutput.c (print_line_1): More C++y.
	gcc/cp/
	* module.c (module_mapper::divert_include): Two \n's.
	gcc/testsuite/
	* g++.dg/modules/legacy-4: New.
	* g++.dg/modules/legacy-3_b.H

From-SVN: r262256
2018-06-29 17:42:19 +00:00
Nathan Sidwell
540eb3a7ec modules.exp (dg-module-pre-prunes): Renamed.
gcc/testsuite/
	* g++.dg/modules/modules.exp (dg-module-pre-prunes): Renamed.

From-SVN: r262253
2018-06-29 14:44:00 +00:00
Nathan Sidwell
f4a86773b9 directives.c (do_include_common): Include diverter will push buffer.
libcpp/
	* directives.c (do_include_common): Include diverter will push
	buffer.
	* include/cpplib.h (cpp_divert_include_t): Adjust signature.
	gcc/
	* langhooks.h (lang_hooks): Adjust preprocess_divert_include
	signature.
	gcc/cp/
	* module.c (module_mapper::divert_include): Push buffer here.
	(do_divert_include): Adjust.

From-SVN: r262252
2018-06-29 14:34:29 +00:00
Nathan Sidwell
39af15a3d3 legacy-3*: New.
gcc/testsuite/
	* g++.dg/modules/legacy-3*: New.

From-SVN: r262235
2018-06-28 21:06:54 +00:00
Nathan Sidwell
f802b4e39e modules.exp: Fix execution tests.
gcc/testsuite/
	* g++.dg/modules/modules.exp: Fix execution tests. Add dg-module-literal
	* g++.dg/modules/legacy-2_d.C: Fix expected line number.
	* g++.dg/modules/loc-2_[def].C: Use dg-module-literal.

From-SVN: r262233
2018-06-28 20:30:51 +00:00
Nathan Sidwell
1f00e190b1 (Beginnings of) Include diversion.
gcc/c-family/
	* c-opts.c (c_common_post_options): Set divert_include hook.
	(cb_file_change): Fixup precedence.
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_PREPROCESS_DIVERT_INCLUDE): Override.
	* cp-tree.h (modules_header_p): New.
	(atom_divert_include): Declare.
	* cxx-mapper.cc (flag_fallback): New flag.
	(module2bmi): Deal with NULL names.
	(buffer::get_request): Fix off-by-one error.
	(read_mapping_file): Can be multiply called.  Target file name can
	be null.
	(client::action): Deal with INCLUDE.
	(main): There can be may files after connection.  Fixup networking
	errors.
	* lex.c (atom_preamble_prefix_peek): Don't rescan legacy header
	module.
	* module.c (module_preamble_end_loc): Declare here.
	(module_mapper::module_mapper): Prepend path for anything looking
	defaulty.
	(module_mapper::divert_include): New.
	(do_divert_include): New.
	(atom_divert_include): New.
	(init_module_processing): Set header mode here.
	* parser.c (module_preamble_end_loc): Extern.
	gcc/
	* doc/invoke.text (C++ Modules): Document -fmodule-header.
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_DIVERT_INCLUDE): Provide
	default.
	* langhooks.h (lang_hooks): Add preprocess_divert_include.
	libcpp/
	* directives.c (do_include_common): Add diversion smarts.
	* include/cpplib.h (cpp_divert_include_t): New.
	(struct cpp_callbacks): Add divert_include.
	* line-map.c (linemap_module_loc): Missed commit.
	gcc/testsuite/
	* g++.dg/modules/legacy-2.*: New.
	* g++.dg/modules/modules.exp: Fixup header compilation.

From-SVN: r262229
2018-06-28 19:07:07 +00:00
Nathan Sidwell
bc33e2e808 (Beginnings of) Legacy importing
(Beginnings of) Legacy importing
	gcc/cp/
	* cxx-mapper.cc (module2bmi): Map legacy header names.
	* module.c (module_state::legacy): New field.
	(module_state::{is_legacy,set_name}): New.
	(make_legacy_name): New.
	(module_state::get_module): Canonicalize legacy name.
	(module_state::get_option_string): Strip -fmodule-header.
	(declare_module): Check correct kind.
	(maybe_atom_legacy_module): Use make_legacy_name.
	* parser.c (cp_parser_module_name): Parse legacy names.
	(cp_parser_import_declaration): Don't special case legacy names
	here.
	gcc/testsuite/
	* g++.dg/modules/atom-inc-1.C: Add expected errors.
	* g++.dg/modules/legacy-1_[abc].[CH]: New.
	* g++.dg/modules/modules.exp: Support legacy header compilation.

From-SVN: r262187
2018-06-27 14:46:32 +00:00
Nathan Sidwell
dbea8969da (Beginnings of) Legacy header modules
(Beginnings of) Legacy header modules
	libcpp/
	* line-map.c (linemap_module_loc): Expect ordinary loc.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_MAIN_FILE): Provide
	default.
	* langhooks.h (lang_hooks): Add preprocess_main_file hook.
	gcc/c-family/
	* c-opts.c (cb_file_change): Call new hook.
	gcc/cp/
	* cp-tree.h (enum atom_preamble_state): Define.
	(atom_preamble_prefix_{peek,next}): Use enum.
	(atom_main_file, maybe_atom_legacy_module): Declare.
	* cxx-mapper.cc (module2bmi): Munge legacy module chars.
	* lang-specs.h (@c++-header): Fix -fmodule-header use.
	* lex.c (atom_preamble_prefix_{peek,next}): Adjust for enum.
	* module.c (prefix_line_maps_hwm, prefix_locations_hwm): New.
	(module_state::{read,write,prepare}_locations): Adjust prefix checking.
	(ordinary_loc_of): New.
	(import_module): Use it.
	(declare_module): Set preamble prefix if needed.
	(atom_main_file, maybe_atom_legacy_module): New.
	(init_module_processing): Don't default module_header_name here.
	(atom_module_preamble, finish_module): Push & pop exporting state in
	legacy mode.
	* parser.c (cp_parser_get_module_preamble_tokens): Adjust for
	preamble state.  Return indicator of preamble contents.
	(c_parse_file): Maybe inject legacy module decl.
	* cp-lang.c (LANG_HOOKS_PREPROCESS_MAIN_FILE): Override hook.
	(atom_preamble_fsm): Adjust for state enum.

From-SVN: r262183
2018-06-27 12:05:47 +00:00
Nathan Sidwell
36b0f6f555 Merge trunk r262148.
From-SVN: r262151
2018-06-26 14:31:59 +00:00
Nathan Sidwell
4489b4ee94 configure.ac: Fix AF_INET6 & accept4 tests.
gcc/
	* configure.ac: Fix AF_INET6 & accept4 tests.
	* configure, config.in: Rebuilt.
	gcc/cp/
	* module.c: Update some comments.
	(module_mapper::module_mapper): Fix up conditional code.
	(module_state::read_imports): Replace local class with std::pair,
	because C++98.
	* cxx-mapper.cc (accept_from): Fixup conditional code.

From-SVN: r262148
2018-06-26 13:34:13 +00:00
Nathan Sidwell
6692af0529 cxx-module.cc (kill_signal): New.
gcc/cp/
	* cxx-module.cc (kill_signal): New.
	(server): Fixup inet_ntop use.

From-SVN: r262019
2018-06-25 14:47:29 +00:00
Nathan Sidwell
1e5bfe6116 configure.ac: Check for inet_ntop.
gcc/
	* configure.ac: Check for inet_ntop.
	* configure, config.in: Rebuilt.
	gcc/cp/
	* cxx-mapper.cc (server): Use inet_ntop when available.a

From-SVN: r262018
2018-06-25 13:13:51 +00:00
Nathan Sidwell
172c473884 cxx-mapper.cc: BMI->GCC
gcc/cp/
	* cxx-mapper.cc: BMI->GCC
	* module.c: Likewise.
	gcc/
	* doc/invoke.texi: Likewise.

From-SVN: r261996
2018-06-24 15:03:56 +00:00
Nathan Sidwell
3572c5ba3f cxx-mapper.cc (struct netmask): New.
gcc/cp/
	* cxx-mapper.cc (struct netmask): New.
	(server): Validate connection addresses.
	(accept_from): New.
	(process_args): Add -a arg.

From-SVN: r261993
2018-06-24 01:12:37 +00:00
Nathan Sidwell
ebae4682fa Simplify protocol.
gcc/cp/
	* cxx-mapper.c (buffer::empty): New.
	(buffer::send_response): Fixup buffer management.
	(client::imex_response): New.
	(client::action): Reimplement.
	* module.c (module_mapper): Update.
	gcc/
	* doc/invoke.texi (C++ Modules): Update protocol.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_c.C: Tweak scan.

From-SVN: r261987
2018-06-23 23:33:46 +00:00
Nathan Sidwell
a0b17abcec A proper server
A proper server
	gcc/cp/
	* cxx-module-mapper.sh: Delete.
	* cxx-mapper.cc: New.
	* Make-lang.in: Adjust.
	* module.c (module_mapper:get_response): Fixup errors.
	(module_mapper::import_query): Drop filename.

From-SVN: r261986
2018-06-23 20:08:27 +00:00
Nathan Sidwell
25f3198d17 module.c (module_mapper::send_command): Fix off-by-one.
gcc/cp/
	* module.c (module_mapper::send_command): Fix off-by-one.
	(module_mapper::get_response): Cleanup batch splitting.
	(module_mapper::handshake): Adjust.
	* cxx-module-mapper.sh (cmd): Adjust HELLO.
	gcc/
	* doc/invoke.texi (C++ Modules): Tweak mapper protocol.

From-SVN: r261889
2018-06-22 13:12:26 +00:00
Nathan Sidwell
747350a736 configure.ac: Check select, accept4.
gcc/
	* configure.ac: Check select, accept4.
	* config.in, configure: Rebuilt.

From-SVN: r261887
2018-06-22 12:32:02 +00:00
Nathan Sidwell
4a2623caab c.opt: Add -fmodule-header.
gcc/c-family/
	* c.opt: Add -fmodule-header.
	gcc/cp/
	* lang-specs.h: Add legacy import options.
	* module.c (module_header_name): New.
	(init_module_processing): Default it.
	(handle_module_option): Set it.

From-SVN: r261862
2018-06-21 20:04:36 +00:00
Nathan Sidwell
a12bfc32cc Use getaddrinfo, not gethostbyname2
Use getaddrinfo, not gethostbyname2
	gcc/
	* configure.ac (HAVE_AF_INET6): Test for getaddrinfo.
	* configure: Rebuilt.
	* doc/invoke.text (C++ Modules): Default is loopback.
	gcc/cp/
	* module.c (module_mapper::module_mapper): Reorganize network startup.
	gcc/testsuite/
	* g++.dg/modules/bad-mapper-[23].C: Adjust diagnostics.

From-SVN: r261852
2018-06-21 16:43:43 +00:00
Nathan Sidwell
79a84edce9 Early & late location maps.
gcc/cp/
	* modules.c (slurping, spewing): Rearrange.
	(module_state::{prepare,read,write}_locations): Reimplement.
	(module_state::{read,write}): Adjust.
	(module_state::atom_preamble): Adjust.

From-SVN: r261747
2018-06-19 15:11:51 +00:00
Nathan Sidwell
412b9ca98e loc-2_[a-f].C: New.
gcc/testsuite/
	* g++.dg/modules/loc-2_[a-f].C: New.

From-SVN: r261701
2018-06-18 14:19:33 +00:00
Nathan Sidwell
693ce46d3f configure.ac: Detect epoll & pselect.
gcc/
	* configure.ac: Detect epoll & pselect.
	* configure, config.in: Rebuilt.

From-SVN: r261691
2018-06-17 20:42:35 +00:00
Nathan Sidwell
e289a38232 module.c (module_mapper::module_mapper): Fixup length errors.
gcc/cp/
	* module.c (module_mapper::module_mapper): Fixup length errors.

From-SVN: r261690
2018-06-17 18:23:06 +00:00
Nathan Sidwell
e4fbddce07 cxx-module-mapper.sh: Remove recompilation capability.
gcc/cp/
	* cxx-module-mapper.sh: Remove recompilation capability.
	gcc/testsuite/
	* g++.dg/modules/import-2.C: Adjust messages.
	* g++.dg/modules/main-aux.cc: Delete.
	* g++.dg/modules/main_1.C: Delete.

From-SVN: r261689
2018-06-17 18:18:01 +00:00
Nathan Sidwell
d7b179ec6b diagnostic.c (diagnostic_report_current_module): Starting location could be a module.
gcc/
	* diagnostic.c (diagnostic_report_current_module): Starting
	location could be a module.
	gcc/cp/
	* module.c (trees_{in,out}::loc): Move to ...
	(module_state::{read,write}_location}): ... here.
	(trees_{in,out}::core_vals): Adjust.
	(module_state::{read,write}_imports): Serialize import location.
	(module_state::set_loc): Add floc parm, adjust.
	gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Adjust regexp.

From-SVN: r261669
2018-06-15 23:14:04 +00:00
Nathan Sidwell
630361e3cf cp-tree.h (make_module_loc): Delete.
gcc/cp/
	* cp-tree.h (make_module_loc): Delete.
	* lex.c (make_module_loc): Delete.
	* module.c (module_state): Add depth field.
	(module_state::set_loc): Deal with reseating.  Add line_maps parm.
	(module_state::read_imports): Do two passes.
	(module_state::write_imports): Write length.
	gcc/testsuite/
	* g++.dg/modules/import-1_e.C Adjust lang dump scan.
	* g++.dg/modules/mod-imp-1_d.C: Likewise.
	libcpp/
	* include/line-map.h (linemap_module_loc): Add incomping loc parm.
	* line-map.c (linemap_module_loc): Do reseating.

From-SVN: r261667
2018-06-15 21:46:51 +00:00
Nathan Sidwell
2c2b15bf34 Location! Location! Location!
gcc/cp/
	* module.c (module_state::slurper): New.
	(trees_{in,out}::loc): Implement.
	(trees_in::core_vals): Set locus.
	(spewing::linemaps): Fixup offset calculation.
	(module_state::read_locations): Set ord_locs.
	gcc/testsuite/
	* g++.dg/module/loc-1_[abc].C: New.

From-SVN: r261652
2018-06-15 19:51:08 +00:00
Nathan Sidwell
a838847239 line-map.h (IS_ORDINARY_LOC, [...]): New.
libcpp/
	* include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New.
	(IS_ADHOC_LOC): Simplify.
	(MAP_ORDINARY_P): Use IS_ORDINARY_LOC.
	* line-map.c (linemap_module_restore): Fixup included_at.

From-SVN: r261651
2018-06-15 19:49:11 +00:00
Nathan Sidwell
47f9ef48d2 diagnostic.c (diagnostic_report_current_module): Fixup include stack messages.
gcc/
	* diagnostic.c (diagnostic_report_current_module): Fixup include
	stack messages.
	gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Adjust include stack regexps.

From-SVN: r261650
2018-06-15 19:46:15 +00:00
Nathan Sidwell
677caa2b9d module.c (spewer::linemaps): Return mask.
gcc/cp/
	* module.c (spewer::linemaps): Return mask.
	(module_state::{find,write}_locations): Use mask.
	(module_state::read_locations): Implement.

From-SVN: r261628
2018-06-15 13:49:06 +00:00
Nathan Sidwell
d2c838639c Line_maps args everywhere!
gcc/cp/
	* cp-tree.h (declare_module, import_module, atom_module_preamble):
	Add line_maps arg.
	* module.c (module_state::{read_imports,do_import}): Add line_maps.
	(module_state::set_loc): New.
	(module_state::atom_preamble): Deal with restoring line_maps.
	(module_state::read): Add line_maps.  Call read_locations.
	* parser.c (cp_parser_module_declaration)
	(cp_parser_import_declaration): Adjust.
	(c_parse_file): Line_maps restoration is moved.
	libcpp/
	* include/line-map.h (linemap_save_pre_module): Delete.
	(linemap_restore_pre_module): Rename to ...
	(linemap_module_restore): ... here.
	* line-map.c (linemap_save_pre_module): Delete.
	(linemap_restore_pre_module): Rename to ...
	(linemap_module_restore): ... here.

From-SVN: r261627
2018-06-15 13:31:18 +00:00
Nathan Sidwell
d6fbd62bef module.c (bytes_{in,out}::align): New.
gcc/cp/
	* module.c (bytes_{in,out}::align): New.
	(bytes_{in,out}::buf): Use it.

From-SVN: r261625
2018-06-15 12:27:40 +00:00
Nathan Sidwell
be1d228db3 line-map.c (linemap_init): Set default allocator here.
libcpp/
	* line-map.c (linemap_init): Set default allocator here.
	(line_map_new_raw): Break out of ...
	(new_linemap): ... here.  Call it.
	* include/line-map.h (line_map_new_raw): Declare

From-SVN: r261624
2018-06-15 12:25:49 +00:00
Nathan Sidwell
e8828e4109 Break out import section.
gcc/cp/
	* module.c (module_state::{read,write}_imports): New.
	(module_state::{read,write}_config): Don't do imports here ...
	(module_state::{read,write}): ... do them here.

From-SVN: r261600
2018-06-14 16:39:35 +00:00
Nathan Sidwell
3a4a4caf81 Fix section alignment.
gcc/cp/
	* module.c (elf_out::grow): Fix padding calc.
	(elf_out::add): Assert aligned.

From-SVN: r261599
2018-06-14 15:39:20 +00:00
Nathan Sidwell
16145d49b4 Write out line maps.
gcc/cp/
	* cp-tree.g (atom_module_preamble, finish_module): Add line_maps.
	* decl2.c (c_parse_final_cleanups): Pass line_table.
	* parser.c (c_parse_file): Adjst.
	* module.c (struct spewing): New.
	(struct slurping): Add GTY tagging.
	(module_state::spewer): New.
	(module_state::{write,atom_preamble}): Add linemaps.
	(module_state::{find,write,read}_locations): New.

From-SVN: r261598
2018-06-14 15:29:58 +00:00
Nathan Sidwell
2afb723635 module.c (struct slurping): New, broken out of ...
gcc/cp/
	* module.c (struct slurping): New, broken out of ...
	(struct module_state): ... here.  Move loading data there and
	adjust all users.

From-SVN: r261590
2018-06-14 11:37:17 +00:00
Nathan Sidwell
c9e6b5c24c Reorg line_map data structures.
libcpp/
	* include/line-map.h (LINE_MAP_MAX_LOCATION): Define here.
	(struct line_map): Move reason field to line_map_ordinary.  Adjust
	GTY tagging.
	(struct line_map_ordinary): Reorder fields for less padding.
	(struct line_map_macro): Likewise.
	(MAP_ORDINARY_P): New.
	(linemap_check_ordinary, linemap_check_macro): Adjust.
	(MAP_MODULE_P): Adjust.
	* line-map.c (LINE_MAP_MAX_SOURCE_LOCATION): Delete.
	(new_linemap): Take start_location, not reason.  Adjust.
	(linemap_add, linemap_enter_macro): Adjust.
	(linemap_line_start): Likewise.
	(linemap_macro_expansion_map_p): Use MAP_ORDINARY_P.
	(linemap_macro_loc_to_spelling_point): Likewise.
	(linemap_macro_loc_to_def_point): Likewise.
	(linemap_dump): Likewise.

From-SVN: r261573
2018-06-13 21:19:00 +00:00
Nathan Sidwell
febab22ba5 Better socket handling.
Better socket handling.  Kill mapping from fd
	gcc/cp/
	* module.c (class module_mapper): Add from & to fds.
	(module_mapper::{module_mapper,kill}): Adjust.
	(module_mapper::{send_command,get_response}): Likewise.
	(module_from_cmp): New.
	(module_state::atom_preamble): Reimplement.
	gcc/
	* doc/invoke.texi (C++ Modules): Remove fd mapper options.
	gcc/testsuite/
	* g++.dg/modules/import-2.C: Adjust messages.
	* g++.dg/modules/flag-1_b.C: Likewise.
	* g++.dg/modules/mod-stamp-1_d.C: Likewise.

From-SVN: r261513
2018-06-12 16:51:12 +00:00
Nathan Sidwell
198c62f0a7 configure.ac: Rename HOST_HAS_AF_$FOO to HAVE_AF_$FOO.
gcc/
	* configure.ac: Rename HOST_HAS_AF_$FOO to HAVE_AF_$FOO.
	* configure, config.in: Rebuilt.
	gcc/cp/
	* module.c: Adjust.

From-SVN: r261492
2018-06-12 11:16:35 +00:00
Nathan Sidwell
2c22aece84 gcc/cp/
* module.c
	(elf_out::grow): Always define, always align.
	(elf_out::write): Streaming buffers must be using our
	allocator.  No need to align here.

From-SVN: r261473
2018-06-12 00:53:34 +00:00
Nathan Sidwell
e13a0f64c3 MMAP writing
MMAP writing
	gcc/
	* configure.ac: Check for posix_fallocate.
	* configure, config.in: Rebuilt.
	gcc/cp/
	* module.c (MAPPED_WRITING): New.
	(data::allocator::{grow,shrink}): New overloads.
	(data::use): Check available.
	(data::allocator::grow): Deal with allocator failure.
	(bytes_in::read): Set overflow on fail.
	(bytes_{in,out}::{u32,c,i,u,wi,buf}): Adjust.
	(bytes_out::printf): Likewise.
	(bytes_out::bytes_out): Allocator is non-optional.
	(elf_out): Derive from data::allocator.
	(elf_out::{grow,shrink}): New overriders.
	(elf_out::elf_out): Find page size.
	(elf_out::{create,remove}_mapping): New.
	(elf_out::write): New overload.
	(elf_out::add): Take bytes_out.  Adjust users.
	(elf_out::{begin,end}): Add mapping support.
	(trees_out::trees_out): Add allocator parm.
	(trees_{in::out}::fixed_refs): Delete, adjust uses.
	(module_state::write_{readme,config,namespaces,bindings}): Adjust.
	(module_state::write_{unnamed,cluster}): Adjust.

From-SVN: r261468
2018-06-11 22:27:57 +00:00
Nathan Sidwell
5995dc71ad Prep for MMAP exporting.
gcc/cp/
	* module.c (MODULE_MMAP_IO): Rename to ...
	(MAPPED_READING): This.
	(data): Add allocator class with default instance.
	(data::{write,printf}): Move to bytes_out.
	(data::read): Move to bytes_in.
	(data::{extend,release}): Delete. Adjust uses.
	(bytes_out): Add allocator pointer, alter ctor.
	(bytes_out::begin): Add need_crc parm.
	(elf::section_vec): Delete.
	(elf): Add sectab, strtab data members.
	(get_num_sections): Delete.
	(elf_{in,out}::strings): Delete here.
	(elf_in::{grow,shrink}): New.
	(elf_in::{get_section{,_limit}): New, adjust uses.
	(elf_in::{keep_sections,forget_section}): Delete.

From-SVN: r261437
2018-06-11 16:35:05 +00:00
Nathan Sidwell
3d7733d3be MMAP importing!
gcc/cp/
	* module.c (MODULE_MMAP_IO): New define.
	(bytes::{begin,end}): Delete.
	(elf_in::{freeze,defrost}): Adjust.
	(elf_in::{begin,end}): Adjust.
	(elf_in::{keep,forget}_section): Adjust.
	(elf_in::read): Adjust.
	(module_state::our_opts): New static member.  Adjust uses.
	gcc/
	* doc/invoke.texi (C++ Modules): Document lazy limit change.

From-SVN: r261358
2018-06-09 06:19:23 +00:00
Nathan Sidwell
3f927e6544 module.c (elf): Replace FILE *stream with int fd.
gcc/cp/
	* module.c (elf): Replace FILE *stream with int fd.  Update uses.

From-SVN: r261345
2018-06-08 19:12:22 +00:00
Nathan Sidwell
895f037429 module.c (bytes::begin): Add CRC parm.
gcc/cp/
	* module.c (bytes::begin): Add CRC parm.
	(elf_in): Read buffers, adjust.

From-SVN: r261342
2018-06-08 18:54:45 +00:00
Nathan Sidwell
3328b019f5 module.c (elf_out): Track file position directly.
gcc/cp/
	* module.c (elf_out): Track file position directly.
	(elf_out::pad): Remove, fold into ...
	(elf_out::write): ... here.  Take a buffer.
	(elf_out::{add,begin,end}): Adjust.

From-SVN: r261341
2018-06-08 17:46:16 +00:00
Nathan Sidwell
594c200a7d module.c (elf): Add hdr member.
gcc/cp/
	* module.c (elf): Add hdr member.
	(elf_in::begin): Adjust.
	(elf_out::{begin,end}): Adjust.

From-SVN: r261334
2018-06-08 15:22:54 +00:00
Nathan Sidwell
8779f0f60c module.c (data::printf): Moved from ...
gcc/cp/
	* module.c (data::printf): Moved from ...
	(bytes_out::printf): ... here.
	(elf): Replace sections pointer with section_vec local class.
	Adjust all uses.
	(elf_out): Remove strtab member class.
	(elf_out::end): Adjust.

From-SVN: r261330
2018-06-08 15:06:37 +00:00
Nathan Sidwell
bc7b42f152 module.c (bytes::calc_crc): Take length parm.
gcc/cp/
	* module.c (bytes::calc_crc): Take length parm.  Adjust callers.
	(elf_out::strtab): Reimplement.
	(elf_out::add): Use buffer pos for length.

From-SVN: r261294
2018-06-07 19:41:03 +00:00
Nathan Sidwell
c5b0ec7959 module.c (struct data): Resurrect.
gcc/cp/
	* module.c (struct data): Resurrect.  Move buffer extension here.
	Update users.
	(class bytes): Derive from data.

From-SVN: r261292
2018-06-07 18:48:46 +00:00
Nathan Sidwell
82ed44e186 module.c (struct data): Delete.
gcc/cp/
	* module.c (struct data): Delete.  Move into ...
	(struct bytes): ... here.  Update uses.

From-SVN: r261279
2018-06-07 14:23:32 +00:00
Nathan Sidwell
925d264aec module.c (struct data): Make buffer a pointer.
gcc/cp/
	* module.c (struct data): Make buffer a pointer.  Redo interface.

From-SVN: r261274
2018-06-07 13:48:51 +00:00
Nathan Sidwell
259bd8e666 Change integer on-disk format.
gcc/cp/
	* module.c (bytes_{in,out}::{i,u,wi}): Reimplement.
	(make_bmi_path): Don't prefix absolute paths.

From-SVN: r261271
2018-06-07 11:36:13 +00:00
Nathan Sidwell
88b039a0f9 BMI repo directory
BMI repo directory
	libiberty/
	* pex-unix.c: Fixup optimization issues.
	gcc/cp/
	* cxx-module-mapper.sh: Add repo to HELLO.
	* module.c (bmi_repo, bmi_repo_length, bmi_path, bmi_path_alloc): New.
	(set_bmi_repo, make_bmi_path, drop_bmi_prefix): New.
	(module_mapper::{handshake,module_mapper}): Repo location from file.
	(relativize_import): Delete.
	(module_state::{write_readme,maybe_defrost,do_import,finish_module):
	Adjust.
	gcc/
	* doc/invoke.texi (C++ Modules): Document bmi repo.

From-SVN: r261265
2018-06-07 08:11:08 +00:00
Nathan Sidwell
08fb292ffb Better pex-unix.
libiberty/
	* pex-unix.c (VFORK_STRING): Replace with ...
	(IS_FAKE_VFORK): ... this.
	(pex_child_error): Delete, fold into ...
	(pex_unix_exec_child): ... here.  Inform parent, when really vforking.
	gcc/cp/
	* module.c (module_mapper::module_mapper): Merge error message.
	gcc/testsuite/
	* g++.dg/modules/bad-mapper-1.C: Adjust.
	* g++.dg/modules/bad-mapper-{2,3}.C: New.

From-SVN: r261236
2018-06-06 14:50:38 +00:00
Nathan Sidwell
01ea6fd01e module.c (module_mapper::module_mapper): Ignore sigpipe.
gcc/cp/
	* module.c (module_mapper::module_mapper): Ignore sigpipe.
	(module_mapper::kill): Restore sigpipe.
	(module_mapper::{response_unexpected,get_response}): Cope with EOF.
	gcc/testsuite/
	* g++.dg/modules/bad-mapper-1.C: New.

From-SVN: r261230
2018-06-06 12:56:04 +00:00
Nathan Sidwell
d567ecd87b invoke.texi (C++ Modules): Clarify and extend.
gcc/
	* doc/invoke.texi (C++ Modules): Clarify and extend.

From-SVN: r261182
2018-06-05 06:19:25 +00:00
Nathan Sidwell
d44d2034f2 Self relative direct import pathnames.
gcc/cp/
	* module.c (relativize_import): New.
	(module_state::write_readme): Call it.
	(module_state::read_imports): Make import relative to importer,
	query mapper if needed.

From-SVN: r261170
2018-06-04 20:36:00 +00:00
Nathan Sidwell
b612969469 Cookies for mapping files
Cookies for mapping files
	gcc/cp/
	* module.c (module_mapper::response_eol): Add ignore arg.
	(module_mapper::module_mapper): Cookie on file mapper.
	gcc/
	* invoke.texi (C++ Modules): Document file mapper cookie.
	gcc/testsuite/
	* g++.dg/modules/map-1_b.C: Use specific mapper.
	* g++.dg/modules/map-1_b.map: New.

From-SVN: r261149
2018-06-04 13:58:45 +00:00
Nathan Sidwell
6ec2b0b310 diagnostic.c (diagnostic_report_current_module): Don't claim module was imported.
gcc/
	* diagnostic.c (diagnostic_report_current_module): Don't claim
	module was imported.
	* doc/invoke.texi (C++ Modules): Update module-mapper docs.
	gcc/cp/
	* module.c (module_mapper::module_mapper): Change syntax for
	option.
	(module_mapper::response_token): Add all parm.
	(module_mapper::bmi_response): Use it.
	(module_state::check_read): Fix error reporting.
	(finish_module): Warn if not exporting due to errors.
	gcc/testsuite/
	* lib/prune.exp (prune_gcc_output): Adjust module import regexp/
	* g++.dg/modules/map-1_[ab].C: Adjust module-mapper arg.
	* g++.dg/modules/atom-decl-2.C: Add expected warning
	* g++.dg/modules/mod-decl-1.C: Likewise.
	* g++.dg/modules/mod-decl-3.C: Likewise.
	* g++.dg/modules/proclaim-1.C: Likewise.

From-SVN: r261126
2018-06-03 10:36:07 +00:00
Nathan Sidwell
fc427595a4 module.c (module_mapper): Robustify.
gcc/cp/
	* module.c (module_mapper): Robustify.

From-SVN: r261076
2018-06-01 18:21:52 +00:00
Nathan Sidwell
bbd26cb7a5 cpp.c (cb_file_change): Adjust for line map inclusion changes.
gcc/fortran/
	* cpp.c (cb_file_change): Adjust for line map inclusion changes.

From-SVN: r261074
2018-06-01 16:16:47 +00:00
Nathan Sidwell
f7f05e5abb Fix formatting
From-SVN: r261071
2018-06-01 15:05:15 +00:00
Nathan Sidwell
0a1dc4634b fix typo
From-SVN: r261070
2018-06-01 14:52:15 +00:00
Nathan Sidwell
575c78ea5b Module mapping file is back
Module mapping file is back
	gcc/
	* doc/invoke.text (C++ Modules): Document mapping file.
	gcc/cp/
	* cxx-module-mapper.sh: Strip -fmodule-preamble=.
	* module.c (elf::get_error): Detect no file name.
	(module_state): Add imported field.
	(module_state::is_{imported,mapping}): New.
	(module_mapper::module_mapper): Read mapping file.
	(module_mapper::get_response): Distingish empty from end.
	(module_state::get_module): Copy a mapping.
	(module_state::insert_mapping): New.
	(module_state::read_imports): Adjust.
	(module_state::do_import): Set imported.
	(import_module, declare_module): Adjust.
	(module_state::atom_preamble): Adjust.
	gcc/testsuite/
	* g++.dg/modules/map-1{_a.C,_b.C,.map}: New.

From-SVN: r261069
2018-06-01 14:49:53 +00:00
Nathan Sidwell
220228d7e5 invoke.texi (C++ Modules): Show mapper cookie.
gcc/
	* doc/invoke.texi (C++ Modules): Show mapper cookie.
	gcc/cp/
	* module.c (module_mapper::fini): Assert.
	(module_mapper::module_mapper): Remove dup2.
	(module_mapper::reset): Delete.

From-SVN: r261053
2018-06-01 01:12:36 +00:00
Nathan Sidwell
fcfbdfedd6 invoke.texi (C++ Modules): Rename -fmodule-server to -fmodule-mapper.
gcc/
	* doc/invoke.texi (C++ Modules): Rename -fmodule-server to
	-fmodule-mapper.
	gcc/c-family/
	* c.opt (fmodule-mapper): Renamed from fmodule-server.
	gcc/cp/
	* cxx-module-mapper.sh: Renamed from cxx-module-server.sh.
	* Make-lang.in: Update.
	* module.c (struct module_mapper): Renamed from module_server.

From-SVN: r261052
2018-06-01 00:58:19 +00:00
Nathan Sidwell
5d4324c792 Merge trunk r261033.
From-SVN: r261035
2018-05-31 19:31:22 +00:00
Nathan Sidwell
bdbddca312 module.c (bytes_in::begin): Add location_t arg.
gcc/cp/
	* module.c (bytes_in::begin): Add location_t arg.
	(elf_in::begin): Add location args.
	(trees_in::{tree_node,finish}): Use error_at.
	(module_server::module_server): Likewise.
	(module_state::read*): Adjust.
	(module_state::{do_import,lazy_load}): Don't set input_location.
	(finish_module): Likewise.

From-SVN: r261033
2018-05-31 19:15:50 +00:00
Nathan Sidwell
3c4c38e045 ASYNC loading & server cookie.
gcc/cp/
	* cp-tree.h (reseat_module_loc, module_from_loc): Delete.
	(atom_module_preamble): Declare.
	* cxx-module-server.sh (cmd): Fix ASYNC response.
	* lex.c (reseat_module_loc, module_from_loc): Delete.
	* module.c (module_state::from_loc): Is a field.
	(module_server): Require locations throughout.  Redesign
	interface.  Add cookie.
	(module_state::read_config): Use from_loc.
	(module_state::read): Don't set module_purview here ...
	(module_state::find_module): ... do it here.
	(module_state::do_import): Add check_crc flag.  Don't query server
	here.
	(import_module, declare_module): Query server here (ts).
	(module_state::atom_preamble): New.
	(atom_module_preamble): Call it.
	(finish_module): Adjust.
	* parser.c (cp_parser_peek_module_name): Fold into ...
	(cp_parser_module_name): ... here.
	(cp_parser_module_declaration): No injected atom end marker.
	(cp_parser_module_preamble): Rename to ...
	(cp_parser_get_module_preamble_tokens): ... this.  Don't append
	end marker.  Return end loc.
	(cp_parser_parse_module_preamble): New.
	(cp_parser_declaration_seq_opt): Adjust.
	(cp_parser_fill_main): Skip preamble.
	(c_parse_file): Do preamble tokenization and parsing here.
	gcc/
	* doc/invoke.texi (C++ Modules): Document server cookie.
	libcpp/
	* include/cpplib.h (cpp_relocate_peeked_tokens): Declare.
	* include/line-map.h (linemap_save_pre_module)
	(linemap_restore_pre_module): Declare.
	(LINEMAP_MODULE_SET_FROM): Delete.
	* lex.c (cpp_relocate_peeked_tokens): New.
	* line-map.c (linemap_module_loc): Set from direcly.
	(linemap_save_pre_module, linemap_restore_pre_module): New.
	gcc/testsuite/
	* g++.dg/modules/flag-1_b.C
	* g++.dg/modules/freeze-1_d.C
	* g++.dg/modules/import-2.C
	* g++.dg/modules/indirect-1_c.C
	* g++.dg/modules/mod-stamp-1_d.C

From-SVN: r261032
2018-05-31 19:01:26 +00:00
Nathan Sidwell
41fa9be2c3 Module location
Module location
	libcpp/
	* include/cpplib.h (cpp_module_file): Delete.
	* include/line-map.h (MAP_MODULE_P, LINEMAP_MODULE_SET_FROM): New.
	(linemap_module_loc): Declare.
	* files.c (cpp_module_file): Delete.
	* line-map.c (linemap_module_loc): New.
	gcc/cp/
	* cp-tree.h (module_file_nest): Delete.
	(make_module_loc, reseat_module_loc, module_from_loc): Declare.
	* lex.c (module_file_nest): Delete.
	(make_module_loc, reseat_module_loc, module_from_loc): New.
	* module.c (struct module_state): Replace imp_loc and self_loc
	with plain loc.
	(module_state::{push,pop}_location): Delete.
	(module_state::from_loc): New.
	(module_state::find_module): Set module loc here.
	(module_state::do_import): Adjust loc setting.
	(module_state::lazy_load): Likewise.
	(finish_module): Likewise.
	gcc/
	* diagnostic.c (diagnostic_report_current_module): Show module imports.
	gcc/testsuite/
	* lib/prune.exp: Prune 'module imported at'.
	* g++.dg/modules/atom-check-1_b.C: Adjust.
	* g++.dg/modules/circ-1_c.C: Adjust.
	* g++.dg/modules/flag-1_b.C: Adjust.
	* g++.dg/modules/import-2.C: Adjust.
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-decl-2_b.C: Adjust.
	* g++.dg/modules/mod-stamp-1_d.C: Adjust.

From-SVN: r260955
2018-05-30 15:17:29 +00:00
Nathan Sidwell
e25c5000e7 module.c (struct module_state): Replace loc with imp_loc & self_loc.
gcc/cp/
	* module.c (struct module_state): Replace loc with imp_loc &
	self_loc.  Rename imported to direct.
	(module_state::occupied): Delete.
	(module_state::read{_,config}): Replace crc_ptr with bool flag.
	(module_state::do_import): ... here.  Break out ...
	(module_state::find_module): ... this part.  Absorb ...
	(module_state::occupy): ... this.  Delete.
	(module_state::get_module): Change default insert.  Check vec_name
	for occupation.
	(module_state::write_imports): Adjust.
	(import_module, declare_module): Adjust.

From-SVN: r260953
2018-05-30 11:43:48 +00:00
Nathan Sidwell
46aed83060 Included from index becomes included_at location
Included from index becomes included_at location
	libcpp/
	* include/line-map.h (line_map_ordinary): Replace included_from
	index with included_at source_location.
	(ORDINARY_MAP_INCLUDER_FILE_INDEX, LAST_SOURCE_LINE_LOCATION)
	(LAST_SOURCE_LINE, LAST_SOURCE_COLUMN): Delete.
	(INCUDED_FROM): Delete.
	(INCLUDED_AT, linemap_included_at): New.
	(MAIN_FILE_P): Adjust.
	* directives.c (do_linemarker): Use linemap_included_at.
	* line-map.c (include_at_map): New.
	(line_check_files_exited): Use it.
	(LAST_SOURCE_LINE_LOCATION): New (moved from header).
	(linemap_add, linemap_dump, linemap_dump_location): Adjust.
	gcc/
	* diagnostic.c (diagnostic_report_current_module): Use
	linemap_included_at.  Adjust line & col discovery.
	gcc/c-family/
	* c-common.c (try_to_locate_new_include_insertion_point): Use
	linemap_included_at.
	* c-lex.c (fe_file_change): Use INCLUDED_AT.
	* c-ppoutput.c (pp_file_change): Likewise.

From-SVN: r260904
2018-05-29 19:36:39 +00:00
Nathan Sidwell
0b718d65e3 line-map.h (enum lc_reason): Add LC_HWM, LC_CXX_MODULE.
libcpp/
	* include/line-map.h (enum lc_reason): Add LC_HWM, LC_CXX_MODULE.
	* line-map.c (linemap_dump): Adjust.
	gcc/
	* diagnostic.c (diagnostic_report_current_module): Reroll loop.

From-SVN: r260898
2018-05-29 15:38:58 +00:00
Nathan Sidwell
fe7ac3b36b cxx-module-server.sh: Add batching and ASYNC support.
gcc/cp/
	* cxx-module-server.sh: Add batching and ASYNC support.
	gcc/
	* doc/invoke.texi (C++ Modules): More protocol explanation

From-SVN: r260897
2018-05-29 14:51:28 +00:00
Nathan Sidwell
f21d10fe75 Server protocol batching
Server protocol batching
	gcc/
	* doc/invoke.texi (C++ Modules): Document protocol batching.
	gcc/cp/
	* cp-tree.h (maybe_peek_import): Delete.
	* lex.c (atom_preamble_prefix_peek): Drop import peeking.
	* parser.c (cp_parser_module_preamble): Likewise.
	* module.c (module_server::{send_command,get_response}): Deal with
	batching.
	(module_state::peek_import_query, maybe_peek_import): Delete.
	(module_state::next_line): New.
	gcc/tesutsuite/
	* g++.dg/modules/atom-peek-1_[abc].C: Delete.

From-SVN: r260779
2018-05-25 20:41:36 +00:00
Nathan Sidwell
9126f24a4e Merge trunk r260753.
From-SVN: r260755
2018-05-25 11:38:00 +00:00
Nathan Sidwell
40e65748e1 Direct import lambda returns!
gcc/cp/
	* module.c (depset::decl_key): Remove assert.
	(trees_{in,out}::core_vals): Serialize type context, lambda expr and
	decl size & value.
	(trees_out::tree_decl): Spot voldemort returns. Ident by index.
	(trees_in::tree_node): Ident by index.
	(trees_in::finish_type): Don't set type context here.
	(depset::hash::add_dependency): Namespaces are also ok.
	* decl.c (fndecl_declared_return_type): Default to auto.
	* decl2.c (no_linkage_error): Ignore imported decls.
	* name-lookup.h (lookup_by_ident): Ident is index.
	(get_lookup_ident): Declare.
	* name-lookup.c (get_binding_or_decl): New.
	(lookup_by_ident): Use it.  Ident is index.
	(get_lookup_ident): New.
	gcc/testsuite/
	* g++.dg/modules/vmort-1_[ab].C: New.
	* g++.dg/modules/lambda-1_[ab].C: New.

From-SVN: r260752
2018-05-25 11:09:08 +00:00
Nathan Sidwell
a77f090960 name-lookup.c (extract_module_decls): Don't strip template of result.
gcc/cp/
	* name-lookup.c (extract_module_decls): Don't strip template of
	result.
	gcc/
	* doc/invoke.texi (C++ Modules): Consider batching.

From-SVN: r260699
2018-05-24 23:37:15 +00:00
Nathan Sidwell
f202f3075e invoke.texi (C++ ModuleS): Update server docs.
gcc/
	* doc/invoke.texi (C++ ModuleS): Update server docs.
	gcc/cp/
	* cxx-module-server.sh: Add INCLUDE.
	* semantics.c (deferred_access): Move GTY.
	* module.c (module_state::global_vec): Move GTY.
	(module_state::modules): Likewise.
	* parser.c (cp_parser_peek_module_name): Remove incomplete
	partition work.

From-SVN: r260680
2018-05-24 17:44:45 +00:00
Nathan Sidwell
710c7351f7 DECL_DISCRIMINATOR for local classes, merge local var disc.
gcc/cp/
	* cp-tree.h (language_function): Remove x_local_names.
	(DECL_DISCRIMINATOR_P): Allow IMPLICIT_TyPEDEF too.
	(DECL_DISCRIMINATOR_SET_P): Delete.
	(local_classes): Delete declaration.
	(determine_local_discriminator): Declare.
	* class.c (local_classes): Delete.
	(init_class_processing): Don't init it.
	* decl.c (local_names): Delete.
	(local_entities): New.
	(push_local_name): Replace with ...
	(determine_local_discriminator): ... this.
	(cp_finish_decl): Adjust.
	(save_function_data, finish_function): Remove local_name handling.
	* decl2.c (finish_anon_union): Set discriminator.
	* mangle.c (write_unnamed_type_name): Use discriminator_for_local_entity.
	(local_class_index): Delete.
	(discriminator_for_local_entity): Use DECL_DISCRIMINATOR for both
	cases.
	(write_local_name): Adjust.
	* name-lookup.c (do_pushtag): Use determine_local_discriminator.
	gcc/testsuite/
	* g++.dg/abi/anon5.C: New.

From-SVN: r260679
2018-05-24 17:41:46 +00:00
Nathan Sidwell
648ea5e549 diagnostic-code.h (fullname): Delete.
gcc/
	* diagnostic-code.h (fullname): Delete.
	* diagnostic.c (fullname): Delete.
	* toplev.c (general_init): Don't set it.
	gcc/cp/
	* module.c: Include opts.h.
	(module_state::get_option_string): New.
	(module_state::write_{readme,config}): Write option string.
	(module_state::read_config): Check it.
	(module_state::write): Adjust.
	(module_server::module_server): Adjust.
	gcc/testsuite/
	* g++.dg/modules/flag-1_[ab].C: New.

From-SVN: r260611
2018-05-23 14:52:03 +00:00
Nathan Sidwell
3cc90ebb99 Now with a Sneakoscope!
gcc/cp/
	* module.c (depset::hash): Add a sneakoscope.
	(module_state::find_dependencies): Turn it on.
	(trees_out::tree_decl): Check it.
	gcc/testsuite/
	* g++.dg/modules/local-1_[ab}.C: New.

From-SVN: r260607
2018-05-23 13:02:12 +00:00
Nathan Sidwell
28cf4b7259 cxx-module-server.sh: Remove --no-default.
gcc/cp/
	* cxx-module-server.sh: Remove --no-default.
	* module.c (module_server::send_command): New.
	(module_server::{reset,handshake,import_export_query,export_done}):
	Use it.
	gcc/testsuite/
	* g++.dg/modules/atom-peek-1_[bc].C: Adjust scans.
	* g++.dg/modules/indirect-1_c.C: Likewise.

From-SVN: r260602
2018-05-23 11:08:56 +00:00
Nathan Sidwell
f0ed9e2769 cxx-module-server.sh: Add --no-compile, --no-default and --mapping options.
gcc/cp/
	* cxx-module-server.sh: Add --no-compile, --no-default and
	--mapping options.

From-SVN: r260557
2018-05-22 20:50:24 +00:00
Nathan Sidwell
6cddd66a51 module.c (depset::defn_key): Add is_def parm.
gcc/cp/
	* module.c (depset::defn_key): Add is_def parm.
	(depset::hash::add_definition): Delete.
	(depset::hash::add_dependency): Add either decl or defn.
	(depset::hash::add_binding): Use add_dependency.
	(cluster_cmp): Swap defns and decls.
	(cluster_tag): Delete ct_voldemort, ct_no_decl.
	(module_state::{read,write}_cluster): Voldemorts are implicit.
	(module_state::write): Adjust.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_b.C: Adjust module scan.

From-SVN: r260554
2018-05-22 19:51:30 +00:00
Nathan Sidwell
cc76fbdc42 Revert lazy definition patches.
Revert lazy definition patches.  Once one gets into template land
	it's all very brittle.  We end up with an unmaintained difference
	betweek 'we need the definition right now', and 'we need the
	definition at some point'.  I end up not being able to maintin the
	SCC dependency graph, and my head melted, looking a the rat hole
	that was appearing.  Until proved otherwise, there are other
	things to get on with.
	gcc/cp/
	* cp-tree.h (DECL_MODULE_LAZY_DEFN, HAS_DECL_MODULE_LAZY_DEFN_P)
	(MAYBE_DECL_MODULE_LAZY_DEFN): Delete.
	(struct lang_decl_min): Remove lazy_module_defn field.
	(lazy_load_defn): Delete decl.
	* constexpr.c (cxx_eval_call_expression): Remove lazy loading.
	* decl2.c (decl_defined_p, mark_used): Likewise.
	* module.c (depset::hash::add_definition): Remove DEFERRED parm.
	(trees_in::{pre,}seed): Delete.
	(trees_out::seeding{,_p}): Delete.
	(trees_out::unmark_trees): Seeding not needed.
	(trees_out::{begin,end}): Delete seeding variants.
	(trees_out::seed): Remove.
	(trees_out::insert): Return val, remove seeding.
	(trees_{in,out}::lang_decl_vals): Remove seeding.
	(has_definition): Return bool.
	(ct_seed_decl, ct_self_used): Delete.
	(module_state::{read,write}_cluster): Remove lazy handling.
	(module_state::{find_dependencies,write}): Adjust.
	(module_state::check_read): Adjust.
	(module_state::lazy_load, lazy_load_defn): Delete.
	* ptree.c (cxx_print_decl): Remove lazy defn index.

From-SVN: r260545
2018-05-22 18:26:28 +00:00
Nathan Sidwell
0983d83fa9 Almost lazy function definitions.
gcc/cp/
	* constexpr.c (cxx_eval_call_expression): Maybe lazy load.
	* decl2.c (decl_defined_p): Lazy definitions are ok.
	(mark_used): Try and lazy load.
	* module.c (module_state::lazy_load): Lazy load a definition.
	(trees_out::seed): Mark template result.
	(trees_in::tree_node): Adjust mark_used.
	(module_state::write_cluster): Adjust.
	(module_state::read_cluster): Accept ct_self_used.
	(lazy_load_defn): New.

From-SVN: r260542
2018-05-22 17:46:27 +00:00
Nathan Sidwell
91b1da9c17 module.c (trees_out::seed): Reimplement mechanim.
gcc/cp/
	* module.c (trees_out::seed): Reimplement mechanim.
	(trees_out::{begin,end}): Don't turn seeding on/off here.
	(trees_out::unmark_trees): Add logging.
	(trees_in::preseed): Fix addition calculation.
	(module_state::write_cluster): Adjust lazy defn seeding.
	(module_state::read_cluster): Add lazy defn seeding.
	(module_State::find_dependencies): Adjust.

From-SVN: r260505
2018-05-22 12:44:25 +00:00
Nathan Sidwell
4751aa9760 directives.c (struct if_stack): Add hash_loc field.
libcpp/
	* directives.c (struct if_stack): Add hash_loc field.
	(PEEKED): Replace with ...
	(PEEK_INVISIBLE): ... this.  Inverted sense.
	(DIRECTIVE_TABLE): Update.
	(linemarker_dir): Add PEEK_INVISIBLE.
	(_cpp_handle_directive): Correctly handle if nests.

From-SVN: r260498
2018-05-22 00:55:05 +00:00
Nathan Sidwell
41be7e117e cp-tree.h (HAS_DECL_MODULE_LAZY_DEFN_P): New.
gcc/cp/
	* cp-tree.h (HAS_DECL_MODULE_LAZY_DEFN_P): New.
	(MAYBE_DECL_MODULE_LAZY_DEFN): Use it.
	* module.c (trees_in::{pre,}seed): Adjust.
	(trees_out::{begin,end}): New overloads.
	(trees_out::unmark_trees): Adjust.
	(trees_out::{preseed,insert}): Correct force marking.
	(trees_in::tree_node): Robustify.
	(module_state::write_cluster): Fix name, better messages,
	(module_state::read_cluster): Use ct_no_decl.
	(module_state::write): Use HAS_DECL_MODULE_LAZY_DEFN_P.
	(module_state::check_read): Use decl if it makes sense.

From-SVN: r260484
2018-05-21 20:08:21 +00:00
Nathan Sidwell
e32b3703d9 Write lazy decls (no reading yet)
Write lazy decls (no reading yet)
	gcc/cp/
	* module.c (elf_out::strtab::named_decl): Add IS_DEFN parm.
	(elf_out::named_decl): Likewise.
	(elf_out::strtab::write): Adjust.
	(FIXED_LIMIT): New.
	(trees_out::set_seed): Delete.
	(trees_out::{pre,un,}seed): New.
	(trees_out::insert): Adjust for seeding.
	(trees_out::tree_ref): Likewise.
	(cluster_tag): Add ct_lazy.
	(module_state::write_cluster): Preseed decls of lazy defns.
	(module_state::find_dependencies): Adjust seeding changes.
	(module_state::write): Determine lazy defn section numbers.

From-SVN: r260473
2018-05-21 15:20:23 +00:00
Nathan Sidwell
b560fccfca internal.h (_cpp_handle_directive): Add HASH_LOC arg.
libcpp/
	* internal.h (_cpp_handle_directive): Add HASH_LOC arg.
	* directives.c (_cpp_handle_directive): Add HASH_LOC arg, store it.
	* init.c (read_original_filename): Adjust _cpp_handle_directive call.
	* lex.c (_cpp_lex_token): Likewise.
	* traditional.c (_cpp_scan_out_logical_line): Likewise.
	* directives-only.c (_cpp_preprocess_dir_only): Likewise.

From-SVN: r260426
2018-05-20 23:05:33 +00:00
Nathan Sidwell
6c09266f2c Import peeking
Import peeking
	gcc/c-family/
	* c-lex.c (c_lex_with_flags) <case CPP_STRING>: Check
	C_LEX_STRING_IS_HEADER. 
	* c-pragma.h (C_LEX_STRING_IS_HEADER): New flag.
	gcc/cp/
	* cp-tree.h (HEADER_STRING_LITERAL_P): Delete.
	(maybe_peek_import): Declare.
	* cxx-module-server.sh: Adjust.
	* lex.c (atom_preamble_prefix_peek): Add peeking state.
	* module.c (module_server::peek_import_query): New.
	(make_flat_name): New.  Broken out of ...
	(module_state::do_import): ... here.  Call it.
	(maybe_peek_import): New.
	* parser.c (cp_parser_peek_module_name): New.
	(cp_parser_module_name): Use it.
	(cp_parser_import_declaration): Adjust.
	(cp_parser_module_preamble): Do peeking.
	gcc/
	* doc/invoke.texi (C++ Modules): Tweak server protocol
	gcc/testsuite/
	* g++.dg/modules/atom-peek-1_[abc].C: New.
	* g++.dg/modules/mod-decl-1.C: Adjust diags.
	* g++.dg/modules/p0713-2.C: Likewise.
	* g++.dg/modules/proclaim-1.C: Likewise.

From-SVN: r260425
2018-05-20 18:52:41 +00:00
Nathan Sidwell
a7cec387e3 Diagnose pragmas ending preamble.
libcpp/
	* lex.c (cpp_peek_token_with_location): Set peeked_location to
	incoming location.  Fix pragma unwind.
	gcc/cp/
	* cxx-module-server.sh: Add new commands.
	* lex.c (atom_preamble_prefix_peek): Note trailing pragma.
	gcc/
	* doc/invoke.text (C++ Modules): More server commands.
	gcc/testsuite/
	* g++.dg/modules/atom-pragma-[123].C: New.

From-SVN: r260421
2018-05-20 14:35:16 +00:00
Nathan Sidwell
e73b6e460a Parse after tokenizing
Parse after tokenizing
	libcpp/
	* lex.c (cpp_peek_token_with_location): Adjust for compiler warning.
	gcc/cp/
	* parser.c (module_preamble_end_loc): Rename to ...
	(module_marker_loc): ... here.
	(cp_parser_module_declaration): Reimplement.
	(cp_parser_import_declaration): Adjust.
	(cp_parser_module_preamble): Don't parse here.  Add artificial end
	marker.
	(cp_parser_declaration_seq_opt): Adjust for atom.
	(cp_parser_fill_main): Whole buffer is to be parsed.
	(c_parse_file): Don't set end_loc here.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-1.C: Adjust diagnostics.
	* g++.dg/modules/atom-preamble-1.C: Likewise.
	* g++.dg/modules/mod-decl-1.C: Likewise.
	* g++.dg/modules/p0713-[23].C: Likewise.

From-SVN: r260403
2018-05-19 20:23:42 +00:00
Nathan Sidwell
d1e670b753 module.c (trees_out::maybe_insert_typeof): New.
gcc/cp/
	* module.c (trees_out::maybe_insert_typeof): New.
	(trees_out::{force_,maybe_,}insert): Merge, adjust callers.
	(trees_out::tree_decl): Use maybe_insert_typeof.
	(module_state::write_cluster): Likewise.
	gcc/testsuite/
	* g++.dg/modules/indirect-3_c.C: Adjust scans.

From-SVN: r260375
2018-05-18 18:49:36 +00:00
Nathan Sidwell
49bf756d92 module.c (module_state::write_cluster): Break apart unnamed numbering from marking.
gcc/cp/
	* module.c (module_state::write_cluster): Break apart unnamed
	numbering from marking.
	(module_state::write): Break apart cluster sizing from section
	numbering.

From-SVN: r260368
2018-05-18 15:40:40 +00:00
Nathan Sidwell
e961bbec63 module.c (trees_out::mark_node): Lose walk_into parm.
gcc/cp/
	* module.c (trees_out::mark_node): Lose walk_into parm.  Adjust
	all callers.
	(module_state::write_cluster): Assert binding already marked.

From-SVN: r260367
2018-05-18 15:30:36 +00:00
Nathan Sidwell
65313e56cd module.c (module_state::mark_definition): Remove include_decl parm.
gcc/cp/
	* module.c (module_state::mark_definition): Remove include_decl
	parm.
	(module_state::mark_{template,function,var,class,enum}_def): Likewise.

From-SVN: r260366
2018-05-18 14:21:58 +00:00
Nathan Sidwell
e3f06a88ce module.c (trees_in::{preseed,seed}): New.
gcc/cp/
	* module.c (trees_in::{preseed,seed}): New.
	(trees_out::seeding): New member.
	(trees_out::seeding_p): New predicate.
	(trees_out::unmark_trees): Add trees_in parm to preseed.
	(trees_out::end): Add trees_in parm.
	(trees_out::set_seed): New.
	(trees_out::tree_decl): Check seeding_p.
	(module_state::find_dependencies): Preseed the decl of a defn.
	gcc/testsuite/
	* g++.dg/modules/defer-1.C :New.

From-SVN: r260364
2018-05-18 13:19:24 +00:00
Nathan Sidwell
709c63f289 module.c (depset::hash::add_definition): Add DEFERRABLE parm.
gcc/cp/
	* module.c (depset::hash::add_definition): Add DEFERRABLE parm.
	(has_definition): Return tristate.
	(depset::hash::add_{dependency,binding}): Adjust.
	(module_state::find_dependencies): Refactor.

From-SVN: r260360
2018-05-18 12:55:41 +00:00
Nathan Sidwell
3553f5c515 Add lazy_module_defn cookie.
* cp-tree.h (DECL_MODULE_LAXY_DEGN, MAYBE_DECL_MODULE_LAZY_DEFN): New.
	(struct lang_decl_min): Add lazy_module_defn field.
	* module.c (trees_{in,out}::lang_decl_vals): Serialize it.
	* ptree.c (cxx_print_decl): Print it.

From-SVN: r260356
2018-05-18 11:37:09 +00:00
Nathan Sidwell
e5276184e9 cp-tree.h (ovl_op_flags, [...]): Reindent.
gcc/cp/
	* cp-tree.h (ovl_op_flags, ovl_op_code): Reindent.
	* lex.c (atom_preamble_prefix_peek): FIXME.
	* parser.c (cp_parser_module_preamble): FIXME.
	* module.c (bytes_out::streaming_p (): New.
	(trees_out::streaming_p): Delete.
	(tt_backref): Delete.  Update uses to know -ve == backref
	(module_state::write_cluster): Some refactoring.

From-SVN: r260355
2018-05-18 11:32:36 +00:00
Nathan Sidwell
af817e67f1 Preamble rescanning!
gcc/
	* configure.ac: Look for execv.
	* config.in, configure: Rebuilt.
	* toplev.h (original_argc, original_argv): Declare.
	* toplev.c (original_argc, original_argv): Declare.
	(toplev::main): Set them.
	doc/invoke.texi (EE) Rename to ...
	(fmodule-preamble): ... this.
	(C++ Modules): Document RESET message.  Document N,N.
	gcc/c-family/
	* c.opt (EE): Rename to ...
	(fmodule-preamble) ... here.
	(fmodule-preamble=): New hidden option.
	* c-ppoutput.c (scan_translation_unit): Use cpp_pop_directives.
	gcc/cp/
	* cp-tree.h (atom_preamble_prefix_peek): Add from-parser parm.
	(maybe_repeat_preamble): Declare.
	* cp-lang.c (atom_preamble_fsm): Adjust.
	* cxx-module-server.sh (RESET): New command.
	* lang-specs.h (@c++): Adjust EE->fmodule-preamble.
	* lex.c (atom_preamble_prefix_peek): Add from-parser parm.  Check
	flag_module_preamble.  Call maybe_repeat_preamble.
	* module.c: #include "toplev.h"
	(module_server_name): Is const.
	(module_server::module_server): Copy command.  Support N,N for two
	pipes.
	(module_server::make): Adjust.
	(module_server::reset): New.
	(module_server::fini): Add reset arg.  Reset.
	(maybe_repeat_preamble): New.
	(handle_module_option): Adjust.
	* parser.c (cp_parser_module_preamble): Adjust.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-[1-8].C: Adjust options.
	* g++.dg/modules/atom-rescan-1.C: New.
	* g++.dg/modules/atom-no-rescan-1.C: New.

From-SVN: r260293
2018-05-16 15:02:48 +00:00
Nathan Sidwell
40de5561b3 Detect cpp directives at end of preamble
Detect cpp directives at end of preamble
	libcpp/
	* include/cpplib.h (cpp_peek_token_with_location): Declare.
	(cpp_pop_directives): Declare.
	* internal.h (struct cpp_reader): Add peeked_directive field.
	* directives.c (PEEKED): New.
	(DIRECTIVE_TABLE): Add it.
	(_cpp_handle_directive): Set peeked_directive.
	(cpp_pop_directives): New.
	* lex.c (cpp_peek_token): Wrapper around ...
	(cpp_peek_token_with_location): ... this.
	gcc/cp/
	* cp-lang.c (atom_preamble_fsm): Update for new state transitions.
	* lex.c (atom_preamble_prefix_peek): Check peeked directives.
	* parser.c (cp_parser_module_preamble): Update.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-1.C: Add diag
	* g++.dg/modules/cpp-preamble-[678].C: New.

From-SVN: r260268
2018-05-15 19:54:23 +00:00
Nathan Sidwell
bacd73bd51 cpplib.h (cpp_in_macro_expansion_p): Declare.
libcpp/
	* include/cpplib.h (cpp_in_macro_expansion_p): Declare.
	* macro.c (in_macro_expansion_p): Rename to ...
	(cpp_in_macro_expansion_p): ... here.  Externalize.
	(cpp_get_token_1): Adjust.
	* internal.h: Update docs.
	gcc/
	* langhooks.h (struct lang_hooks): Adjust preprocess_preamble.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Pass token location to
	preamble hook.
	gcc/cp/
	* cp-lang.c (atom_preamble_fsm): Pass token loc through.
	* cp-tree.h (atom_preamble_prefix_next): Take token loc.
	* lex.c (atom_preamble_prefix_next): Take token loc.  Warn if
	ending inside macro.
	* parser.c (cp_parser_module_preamble): Adjust.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-5.C: New.

From-SVN: r260267
2018-05-15 17:15:01 +00:00
Nathan Sidwell
ed44286d86 langhooks.h (struct lang_hooks): Adjust preprocess_preamble.
gcc/
	* langhooks.h (struct lang_hooks): Adjust preprocess_preamble.
	gcc/cp/
	* cp-tree.h (atom_preamble_prefix_{peek,next}): Declare.
	* cp-lang.c (atom_preambls_fsm): Adjust args.  Use
	atom_preamble_prefix_{peek,next}.
	* lex.c (atom_preamble_prefix_len): Turn into ...
	(atom_preamble_prefix_peek): ... this.
	(atom_preamble_prefx_next): New.
	* parser.c (cp_parser_module_preamble): Adjust.
	gcc/c-family/
	* c-ppoutput.c (scan_translation_unit): Adjust
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-2_c.C: New.
	* g++.dg/modules/cpp-preamble-4.C: New.

From-SVN: r260265
2018-05-15 16:11:23 +00:00
Nathan Sidwell
7df8a2e301 Make-lang.in: Dont sed server version
gcc/cp/
	* Make-lang.in: Dont sed server version
	* module.c: Use fixed server version.
	* cxx-module-server.sh: Likewise.

From-SVN: r260262
2018-05-15 14:21:53 +00:00
Nathan Sidwell
35e6a6f67a module.c (trees_out::dep_walk_p): Replace with ...
gcc/cp/
	* module.c (trees_out::dep_walk_p): Replace with ...
	(trees_out::{streaming,depending}_p): ... these.  Update callers.

From-SVN: r260261
2018-05-15 14:16:40 +00:00
Nathan Sidwell
bd297aa6f5 Objectify module server.
gcc/cp/
	* module.c (class module_server): New.
	(server_read, server_write, server_pex, server_size)
	(server_buffer, server_pos, server_end)
	(server_response, server_token, server_word, server_unexpected)
	(server_error, server_init, server_fini): Move into module_server class.
	(server_module_filename): Delete.
	(module_state::do_import): Use module_server::import_query.
	(finish_module): Use module_server::export_{query,done}.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_c.C: Tweak.

From-SVN: r260235
2018-05-14 16:40:30 +00:00
Nathan Sidwell
275c0c3cf0 invoke.texi (C++ Modules): Clarify server docs.
gcc/
	* doc/invoke.texi (C++ Modules): Clarify server docs.
	gcc/cp/
	* cxx-module-server.sh: Robustify.
	* module.c (server_module_filename): Send from location.
	gcc/testsuite/
	* g++.dg/modules/import-2.C: Tweak.

From-SVN: r260225
2018-05-14 11:53:22 +00:00
Nathan Sidwell
82c7c22ebb Redo the server protocol.
gcc/cp/
	*cxx-module-server.sh: Update protocol.
	* module.c (elf_out::end): Protect from NULL stream.
	(server_size, server_buffer, server_pos, server_end): New.
	(server_response, server_token, server_word): New.
	(server_end_p): New.
	(server_malformed): Delete.
	(server_init, server_module_filename, server_done): Adjust.
	(module_state::do_import): Adjust.
	gcc/
	* doc/invoke (C++ Modules): Update server protocol.

From-SVN: r260217
2018-05-13 22:15:45 +00:00
Nathan Sidwell
f8ce9741d2 module.c (module_server): Make pointer to non-const.
gcc/cp/
	* module.c (module_server): Make pointer to non-const.
	(server_fini, handle_module_option): Add const_cast.
	(server_init): Write into module_server.  strdup if it came from
	environment.

From-SVN: r260201
2018-05-12 21:48:50 +00:00
Nathan Sidwell
8c143867bc Rename oracle->server, thanks Richard Smith
Rename oracle->server, thanks Richard Smith
	gcc/
	* doc/invoke.texi (fmodule-oracle): Rename.
	gcc/c-family/
	* c.opt (fmodule-oracle): Rename.
	gcc/cp/
	* Make-lang.in (cxx-module-oracle): Rename.
	* cxx-module-oracle.sh: Rename.
	* module.c (ORACLE_VERSION, module_oracle, oracle_read)
	(oracle_write, oracle_pex): Rename.
	(oracle_fini, oracle_init, oracle_response, oracle_unexpected)
	(oracle_malformed, oracle_module_filename, oracle_done): Rename.

From-SVN: r260200
2018-05-12 21:30:52 +00:00
Nathan Sidwell
9d44b6ca29 Direct import filenames are stored.
gcc/cp/
	* module.c (bytes_out::str): Add overload.
	(bytes_in::str): Robustify.
	(module_state::{read,write}_imports): New.
	(noisy_p): New.
	(module_state::announce, oracle_init): Use noisy_p.
	(oracle_module_file): Rename to ...
	(oracle_module_filename): ... here.  Adjust parms, return
	filename.
	(module_state::write_readme): Write import filename.
	(module_state::{read,write}_config): Use {read,write}_imports.
	(module_state::do_import): Add FILENAME arg, adjust.
	(finish_module): Adjust.
	gcc/testsuite/
	* g++.dg/modules/import-1_e.C: Adjust scan.
	* g++.dg/modules/indirect-1_c.C: Verify no query on indirect import.

From-SVN: r260199
2018-05-12 21:13:22 +00:00
Nathan Sidwell
b86f7e4ca6 Remove remaining knowledge of module file names.
gcc/cp/
	* module.c (MOD_FNAME_SFX, MOD_FNAME_DOT): Delete.
	(module_state): Remove srcname.
	(module_state::print_map): Delete.
	(oracle_query_module, oracle_stream, find_module_file): Merge to ...
	(oracle_module_file): ... this.
	(make_module_file, find_file): Delete.
	(module_state::do_import): Adjust.
	(finish_module): Likewise.

From-SVN: r260189
2018-05-11 21:38:16 +00:00
Nathan Sidwell
484acf33ea Kill -fmodule-output -- use the oracle.
gcc/c-family/
	* c.opt (fmodule-output): Delete.
	gcc/
	* doc/invoke.texi (C++ Dialect Options): Delete -fmodule-output.
	(C++ Modules): Likewise.
	gcc/cp
	* module.c (module_output): Delete.
	(module_state::do_import): Don't check it.
	(finish_module): Likewise.
	(handle_module_options): Likewise.
	gcc/testsuite/
	* g++.dg/modules/fmod-out-1_[ab].C: Delete.

From-SVN: r260188
2018-05-11 21:16:28 +00:00
Nathan Sidwell
170a5a26a8 Kill -fmodule-file -- use the oracle.
gcc/c-family/
	* c.opt (fmodule-map-dump): Delete.
	(fmodule-file): Delete.
	gcc/cp/
	* module.c (module_file_args, module_map_dump): Delete.
	(parse_module_mapping): Delete.
	(add_module_mapping): Delete.
	(init_module_processing): Delete module map init.
	(handle_module_option): Delete module map options.
	gcc/
	* doc/invoke.texi (C++ Dialect Options): Delete -fmodule-file.
	(C++ Modules): Likewise.
	gcc/testsuite/
	* g++.dg/modules/fmod-file-1_[ab].C: Delete.
	* g++.dg/modules/fmod-out-1_[ab].C: Adjust.

From-SVN: r260187
2018-05-11 21:10:54 +00:00
Nathan Sidwell
94f9a05537 Kill -fmodule-path and CXX_MODULE_PATH -- use the oracle.
gcc/
	* doc/invoke.texi (C++ Dialect Options): Remove -fmodule-path.
	(C++ Modules): Likewise.
	* incpath.h (INC_CXX_MPATH): Delete.
	(clean_cxx_module_path): Delete.
	* incpath.c (clean_cxx_module_path): Delete.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Don't clean_cxx_module_path.
	* c.opt (fmodule-path): Delete.
	gcc/cp/
	* module.c (module_path, module_path_max): Drop.
	(find_file): Adjust.
	(init_module_processing): Drop module path init.
	(handle_module_option): Drop module_path.

From-SVN: r260185
2018-05-11 20:27:04 +00:00
Nathan Sidwell
344cd94c53 Make-lang.in (cxx-module-oracle): Sed version.
gcc/cp/
	* Make-lang.in (cxx-module-oracle): Sed version.
	(cxx_module-wrapper): Delete.
	* cxx-module-oracle: Allow dev versions.
	* cxx_module-wrapper: Delete.
	* module.c (ORACLE_VERSION): New.
	(oracle_init): Use MODULE_STAMP if available.

From-SVN: r260184
2018-05-11 20:16:15 +00:00
Nathan Sidwell
b517e6bc17 A more conventional protocol
A more conventional protocol
	gcc/
	* doc/invoke.texi (C++ Modules): Update oracle protocol.
	gcc/cp/
	* cxx-module-oracle.sh: Update protocol.
	* module.c (oracle_response): Parse response.
	(oracle_unexpected, oracle_malformed): New.
	(oracle_init): Check version.
	(oracle_query_module): Update.

From-SVN: r260183
2018-05-11 19:54:46 +00:00
Nathan Sidwell
1a6bded3c7 Kill module wrapper -- you should use the oracle.
gcc/
	* doc/invoke.texi (C++ Dialect Options): Remove -fmodule-wrapper.
	* gcc.h (driver::maybe_putenv_CXX_MODULE_WRAPPER): Delete decl.
	* gcc.c (maybe_putenv_CXX_MODULE_WRAPPER): Delete.
	(driver::main): Don't call it.
	gcc/cp/
	* module.c (module_wrapper): Delete.
	(find_module_file): Drop wrapper spawning.
	(init_module_processing): Drop wrapper initialization.
	(handle_module_option): Drop wrapper option.
	gcc/c-family/
	* c.opt (fmodule-wrapper=): Delete.
	gcc/testsuite/
	* g++.dg/modules/modules.exp (DEFAULT_MODFLAGS): Drop -fmodule-wrapper.
	* g++.dg/modules/main-[123]-aux.cc: Delete.
	* g++.dg/modules/main-[123]-map: Delete.
	* g++.dg/modules/main-[123]_a.C: Delete.

From-SVN: r260178
2018-05-11 18:26:27 +00:00
Nathan Sidwell
1f35b25295 config.in: Rebuilt too.
gcc/c
	* config.in: Rebuilt too.

From-SVN: r260177
2018-05-11 18:15:55 +00:00
Nathan Sidwell
9c727609e6 diagnostic-core.h (fullname): Declare.
gcc/
	* diagnostic-core.h (fullname): Declare.
	* diagnostic.c (fullname): Define.
	* toplev.c (general_init): Set it.
	gcc/cp/
	* cxx-module-oracle.sh: More messages.
	* module.c (oracle_init): When defaulting, expect to be next to
	cc1plus.
	(oracle_stream): Always try and init the oracle.
	gcc/testsuite/
	* g++.dg/modules/main_a.C: Adjust for oracle use.

From-SVN: r260173
2018-05-11 17:43:05 +00:00
Nathan Sidwell
eb99e474b3 configure.ac: Check for AF_UNIX and AF_INET6.
gcc/
	* configure.ac: Check for AF_UNIX and AF_INET6.
	* configure: Rebuilt.
	* doc/invoke.texi (C++ Modules): Update oracle.
	gcc/cp/
	* module.c: Check HOST_HAS_AF_{UNIX,INET6}.

From-SVN: r260164
2018-05-11 15:36:40 +00:00
Nathan Sidwell
e77f781514 module.c: Include socket headers.
gcc/cp/
	* module.c: Include socket headers.
	(oracle_init): Create and connect local or ipv6 socket.
	gcc/
	* doc/invoke.texi (C++ Modules): Document oracle socket options.

From-SVN: r260152
2018-05-11 04:15:24 +00:00
Nathan Sidwell
f22c96561c module.c (module_prefix): Delete.
gcc/cp/
	* module.c (module_prefix): Delete.
	(make_module_filename): Don't handle it.
	(handle_module_option): Nor here.
	gcc/c-family/
	* c.opt (fmodule-prefix): Delete.
	gcc/
	* doc/invoke.texi (C++ Dialect Options): Remove -fmodule-prefix.
	(C++ Modules): Remove -fmodule-prefix

From-SVN: r260148
2018-05-11 00:42:28 +00:00
Nathan Sidwell
df456c5afd Make-lang.in (cxx-module-oracle): New rule.
Oracle!
	gcc/cp/
	* Make-lang.in (cxx-module-oracle): New rule.
	* cxx-module-oracle.sh: New.
	* module.c (module_oracle): New flag.
	(oracle_read, oracle_write, oracle_pex): New vars.
	(oracle_init, oracle_fini, oracle_response, oracle_query_module)
	(oracle_done, oracle_stream): New.
	(find_module_file, finish_module): Use oracle.
	(handle_module_option): Store oracle option.
	gcc/
	* doc/invoke.texi (C++ Dialect Options): Add -fmodule-oracle.
	(C++ Modules): Document oracle.
	gcc/c-family/
	* c.opt (fmodule-oracle=): New.

From-SVN: r260142
2018-05-11 00:06:22 +00:00
Nathan Sidwell
87ea734144 module.c (module_state::get_module): Add insert arg.
gcc/cp/
	* module.c (module_state::get_module): Add insert arg.
	(module_state::{read,write}_config): Stream direct imports first.
	gcc/testsuite/
	* g++.dg/modules/import-1_[ce].C: Adjust.
	* g++.dg/modules/mod-imp-1_[cd].C: Adjust.

From-SVN: r260098
2018-05-09 21:57:32 +00:00
Nathan Sidwell
e809bac59e Add -EE
Add -EE
	gcc/cp/
	* cp-lang.c (atom_preamble_fsm): New.
	(LANG_HOOKS_PREPROCESS_PREAMBLE): Override.
	* cp-tree.h (atom_preamble_prefix_len): Declare.
	* lang-specs.h (@c++): Pass -EE when preprocessing.
	* lex.c (atom_preamble_prefix): New.  Broken out of ...
	* parser.c (cp_parser_module_preamble): ... here.  Use it.
	* module.c (handle_module_option): EE implies atom.
	gcc/c-family/
	* c-ppoutput.c: Include langhook.h.
	(scan_translation_unit): Use lang_hooks.preprocess_preamble.
	* c.opt (EE): New.
	gcc/
	* langhooks-def.h (LANG_HOOKS_PREPROCESS_PREAMBLE): Define.
	(LANG_HOOKS_INITIALIZER): Add it.
	* langhooks.h (struct lang_hooks): Add preprocess_preamble.
	* doc/cppopts.texi (EE): Document.
	* doc/invoke.texi (Preprocessor Options): Add -EE.
	(C++ Modules): Document -EE.
	gcc/testsuite/
	* g++.dg/modules/cpp-preamble-[123].C: New.

From-SVN: r260095
2018-05-09 20:35:30 +00:00
Nathan Sidwell
078aae37b0 parser.c (module_preamble_end_loc): New var.
gcc/cp/
	* cp/parser.c (module_preamble_end_loc): New var.
	(cp_parser_module_declaration): Check it.
	(cp_parser_import_declaration): Likewise.
	(cp_parser_module_preamble): Deal with FILENAME enabling.
	(cp_parser_declaration_seq_op): Set it.
	(cp_parser_declaration): Parse out-of-preamble module & import
	decls.
	(cp_parser_initial_pragma): Don't check modules here.
	(c_parse_file): Set module_preamble_end_loc.
	gcc/c-family/
	* c-lex.c (c_lex_with_flags): Remove C_LEX_FILENAME handling.
	* c-pragma.h (C_LEX_FILENAME): Delete.
	gcc/testsuite/
	* g++.dg/modules/atom-decl-[123].C: Adjust.
	* g++.dg/modules/atom-preamble-3.C
	* g++.dg/modules/atom-preamble-4.C: New.
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/p0713-[23].C: Adjust.

From-SVN: r260084
2018-05-09 15:49:04 +00:00
Nathan Sidwell
fe8ad2822d parser.c (cp_parser_module_preamble): Check for macros
gcc/cp/
	* parser.c (cp_parser_module_preamble): Check for macros
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-3.C: New.

From-SVN: r260064
2018-05-09 00:27:19 +00:00
Nathan Sidwell
5a055838ea parser.c (cp_parser_module_preamble): New.
gcc/cp/
	* parser.c (cp_parser_module_preamble): New.
	(cp_parser_fill_main): Remove atom parsing here.
	(c_parse_file): Adjust.
	gcc/testsuite/
	* g++.dg/modules/atom-preamble-1.C: New.
	* g++.dg/modules/atom-preamble-2_[ab].C: New.

From-SVN: r260059
2018-05-09 00:07:07 +00:00
Nathan Sidwell
54e18b16be module.c (depset): Add is_unnamed and refs_unnamed flags.
gcc/cp/
	* module.c (depset): Add is_unnamed and refs_unnamed flags.
	(depset::hash::add_dependency): Set them here.
	(cluster_cmp): Change order again.
	(module_state::write_cluster): Check refs_unnamed here.
	gcc/testsuite.
	* g++.dg/modules/scc-1.C: Readjust.

From-SVN: r260016
2018-05-07 23:15:33 +00:00
Nathan Sidwell
15b74ca364 module.c (depset::tarjan::connect): Use section==0 for done, not top bit of cluster.
gcc/cp/
	* module.c (depset::tarjan::connect): Use section==0 for done, not
	top bit of cluster.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_b.C: Fix scan.

From-SVN: r260014
2018-05-07 21:52:05 +00:00
Nathan Sidwell
c135d18247 module.c (FIXED_LIMIT): Remove.
Horcruxes!
	gcc/cp/
	* module.c (FIXED_LIMIT): Remove.
	(trees_out::{,maybe_}insert): Make public.
	(trees_out::maybe_mark_unnamed): Delete.
	(trees_out::tree_ref): Remove voldemort handling.
	(trees_in::tree_node): Likewise.
	(tree_tag): Remove tt_voldemort.
	(trees_out::maybe_tag_decl_type): Move back into ..
	(trees_out::tree_decl): ... here.
	(cluster_tag): Add voldemort & horcruxes.
	(module_state::{read,write}_cluster): Deal with horcruxes.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_[ab].C: Adjust scans.

From-SVN: r259980
2018-05-06 18:52:26 +00:00
Nathan Sidwell
41e56c3c6f module.c (trees_out::maybe_tag_decl_type): New, broken out of ...
gcc/cp/
	* module.c (trees_out::maybe_tag_decl_type): New, broken out of ...
	(trees_out::tree_decl): ... here. Call it.
	(trees_out::tree_ref): Use it.
	gcc/testsuite/
	* g++.dg/modules/unnamed-1_[ab].C: New.

From-SVN: r259956
2018-05-04 18:56:42 +00:00
Nathan Sidwell
d6497afa81 ptree.c (cxx_print_decl): Show module.
gcc/cp/
	* ptree.c (cxx_print_decl): Show module.
	* module.c (tree_tags): Add tt_voldemort.
	(FIXED_LIMIT): New.
	(trees_out::maybe_mark_unnamed): New.
	(module_state::unnamed): New field.
	(module_state::{read,write}_unnamed): New.
	(module_state::{read,write}_config): Serialize unnamed count.
	(module_state::{read,write}_cluster): Determine unnamedness.
	(trees_out::tree_ref): Check for unnamed.
	(trees_in::tree_node): Add tt_voldemort.
	(depset::hash::add_dependency): Don't add decl to its binding.
	(cluster_cmp): Reorder, again.
	(cluster_tag): Add ct_unnamed.
	(module_state::{read,write}): Adjust.
	gcc/testsuite/
	* g++.dg/modules/namespace-2.C: Adjust scan.
	* g++.dg/modules/unnamed-[12].C: New.
	* g++.dg/modules/scc-1.C: Unadjust.

From-SVN: r259951
2018-05-04 18:04:50 +00:00
Nathan Sidwell
912099f99b module.c (module_state::mark_definition): Add include_decl arg.
gcc/cp/
	* module.c (module_state::mark_definition): Add include_decl arg.
	(module_state::mark_{template,function,var,class,enum}_def): Likewise.
	(cluster_cmp): Reorder decl < defn < bind.
	(enum cluster_tag): New.
	(module_state::{read,write}_cluster): Use it.
	gcc/testsuite/
	* g++.dg/modules/scc-1.C: Adjust.

From-SVN: r259933
2018-05-04 13:41:42 +00:00
Nathan Sidwell
81dfe8bba3 c-cppbuiltin.c (c_cpp_builtins): Update __cpp_modules value, define __cpp_modules_{ts,atom} as selected.
gcc/c-family
	* c-cppbuiltin.c (c_cpp_builtins): Update __cpp_modules value,
	define __cpp_modules_{ts,atom} as selected.
	gcc/testsuite/
	* g++.dg/modules/atom-check-1_a.C: Check for __cpp_modules_atom.
	* g++.dg/modules/atom-check-1_b.C: Check for __cpp_modules_ts.

From-SVN: r259908
2018-05-03 20:03:22 +00:00
Nathan Sidwell
0ae5a0e09d module.c (cluster_size): Delete.
gcc/cp/
	* module.c (cluster_size): Delete.
	(module_state::write_{cluster,namespaces,bindings}): Adjust.
	(module_state::write): Precalculate section numbers.

From-SVN: r259905
2018-05-03 19:53:27 +00:00
Nathan Sidwell
d9fc5786a3 cxx-module-wrapper.sh: Require bash.
gcc/cp/
	* cxx-module-wrapper.sh: Require bash.

From-SVN: r259870
2018-05-02 23:48:38 +00:00
Nathan Sidwell
2c6a0d6fdf Fragment depsets more.
gcc/cp/
	* module.c (depset): Replace container & decls with key.  Adjust
	hashing etc.
	(depset::{binding,decl,defn}_key): New.
	(depset::is_{binding,decl,defn}): New.
	(depset::hash::{maybe_insert,find}): Take a key.
	(depset::hash::add_definition): Reimplement.
	(depset::hash::add_dependency): Reimplement.
	(depset::hash::add_binding): Reimplement.
	(cluster_cmp): Extend.
	(module_state::write_{cluster,namespaces,bindings}): Adjust.
	(module_state::{add_writables,find_dependencies}): Adjust.

From-SVN: r259869
2018-05-02 23:45:54 +00:00
Nathan Sidwell
0cc4985577 module.c (depset::tarjan): Replace binds, spaces & defs fields with plain result field.
gcc/cp/
	* module.c (depset::tarjan): Replace binds, spaces & defs fields
	with plain result field.
	(depset::tarjan::connect): Don't categorize SCCs here.
	(cluster_size): New.
	(module_state::write_cluster): Take SIZE arg.
	(module_state::write): Use cluster_size, split out namespaces here.

From-SVN: r259841
2018-05-02 14:50:45 +00:00
Nathan Sidwell
185740cd54 module.c (trees_out::tree_{type,decl,ctx}): Separate need_body and owner args.
gcc/cp/
	* module.c (trees_out::tree_{type,decl,ctx}): Separate need_body
	and owner args.
	(trees_{in,out}::core_vals): Don't stream TYPE_CONTEXT.
	(trees_in::finish_type, module_state::read_class_def): Reconstruct
	it here.
	(trees_out::tree_binfo): Use tree_ctx.

From-SVN: r259804
2018-05-01 17:50:05 +00:00
Nathan Sidwell
df7dc01b86 module.c (trees_out::tree_decl): Write innermost args.
gcc/cp/
	* module.c (trees_out::tree_decl): Write innermost args.
	gcc/testsuite/
	* g++.dg/modules/indirect-4_[abc].C: New.

From-SVN: r259798
2018-05-01 14:23:02 +00:00
Nathan Sidwell
76d79f2b6d module.c (module_state::occupy): Do not set filename here.
gcc/cp/
	* module.c (module_state::occupy): Do not set filename here.
	(search_module_path): Rename to ...
	(find_file): ... here.  Search for bmis too.
	(find_module_file): Use find_file.
	(add_module_mapping, finish_module): Adjust.
	gcc/
	* doc/invoke.texi (C++ Modules): Document search path and prefix.

From-SVN: r259794
2018-05-01 13:21:17 +00:00
Nathan Sidwell
70d3357617 Make-lang.in (c++.install-common): Install wrapper into libexecsubdir.
gcc/cp/
	* Make-lang.in (c++.install-common): Install wrapper into
	libexecsubdir.

From-SVN: r259792
2018-05-01 12:25:07 +00:00
Nathan Sidwell
5be54af24b Merge trunk r184995.
From-SVN: r259791
2018-05-01 12:13:25 +00:00
Nathan Sidwell
bb7520fad2 module.c (trees_out::tree_decl): Adjust for member templates.
gcc/cp/
	* module.c (trees_out::tree_decl): Adjust for member templates.
	(trees_out::tree_node): Don't deal with templates here.
	(trees_in::tree_node): Adjust template instantiations here.
	(module_state::mark_template_def): Adjust.
	gcc/testsuite/
	* g++.dg/modules/indirect-2_b.C: Adjust module scan.
	* g++.dg/modules/indirect-3_[abc].C: New.

From-SVN: r259776
2018-04-30 19:37:11 +00:00
Nathan Sidwell
458e983aec Merge trunk r259710.
From-SVN: r259715
2018-04-27 15:41:00 +00:00
Nathan Sidwell
0814464474 cp-tree.h (DECL_TEMPLATE_INFO): Correct comment.
gcc/cp/
	* cp-tree.h (DECL_TEMPLATE_INFO): Correct comment.
	* module.c: Update description, general format cleanups.
	(elf_out::SECTION_ALIGN): New.
	(elf_out::pad): Use it.
	* pt.c (build_template_decl): Make static.

From-SVN: r259673
2018-04-26 12:55:33 +00:00
Nathan Sidwell
0e457bc3e2 module.c (maybe_get_template): Delete.
gcc/cp/
	* module.c (maybe_get_template): Delete.
	(trees_out::tree_decl): Move dependency building into named-decl
	handling.  Don't walk into namespaces.

From-SVN: r259653
2018-04-25 15:19:51 +00:00
Nathan Sidwell
2c97a830e8 module.c (trees_out::tree_node): Reorder.
gcc/cp/
	* module.c (trees_out::tree_node): Reorder.

From-SVN: r259652
2018-04-25 15:09:03 +00:00
Nathan Sidwell
dd2dff5b2a module.c (trees_out::tree_decl): Deal with templated types.
gcc/cp/
	* module.c (trees_out::tree_decl): Deal with templated types.
	(tree_in::tree_node): Likewise.
	gcc/testsuite/
	* g++.dg/modules/indirect-2_[abc].C: Add template class.

From-SVN: r259618
2018-04-24 21:04:25 +00:00
Nathan Sidwell
6258bc9377 module.c (enum tree_tag): Add tt_template.
gcc/cp/
	* module.c (enum tree_tag): Add tt_template.
	(trees_out::tree_decl): Emit tt_template as needed.
	(trees_in::tree_node): Read tt_template.
	gcc/testsuite/
	* g++.dg/modules/class-3_b.C: Adjust.
	* g++.dg/modules/indirect-1_b.C: Adjust.
	* g++.dg/modules/indirect-2_[abc].C: New.

From-SVN: r259616
2018-04-24 20:01:18 +00:00
Nathan Sidwell
f3c5a93379 module.c (trees_out::core_vals): Check module of type context.
gcc/cp/
	* module.c (trees_out::core_vals): Check module of type context.
	(trees_out::tree_decl): Assert we can find the named decl.
	(module_state:read_config): Move defrosting to ...
	(module_state::read): ... here.

From-SVN: r259615
2018-04-24 17:55:59 +00:00
Nathan Sidwell
e66221bfb9 indirect-1_[abc].C: Add exported constant.
gcc/testsuite/
	* g++.dg/modules/indirect-1_[abc].C: Add exported constant.

From-SVN: r259583
2018-04-23 21:59:16 +00:00
Nathan Sidwell
53e2feb9c5 name-lookup.c (lookup_by_ident): Look in enumerals.
gcc/cp/
	* name-lookup.c (lookup_by_ident): Look in enumerals.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_[abc].C: Add enum.

From-SVN: r259581
2018-04-23 21:12:53 +00:00
Nathan Sidwell
75fa50ebbe module.c (trees_{in,out}::core_vals): More FUNCTION_DECL fields.
gcc/cp/
	* module.c (trees_{in,out}::core_vals): More FUNCTION_DECL fields.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_[abc].C: Add virtual class.

From-SVN: r259573
2018-04-23 20:13:28 +00:00
Nathan Sidwell
a81bad5c89 Fix regexp
From-SVN: r259569
2018-04-23 18:49:59 +00:00
Nathan Sidwell
adfa8fea1b module.c (dumper::pop): Don't print trailing line.
gcc/cp/
	* module.c (dumper::pop): Don't print trailing line.

From-SVN: r259568
2018-04-23 18:47:56 +00:00
Nathan Sidwell
68dcc2e478 module.c (trees_{in,out}::core_vals): Allow NULL-context VAR_DECLS.
gcc/cp/
	* module.c (trees_{in,out}::core_vals): Allow NULL-context VAR_DECLS.
	gcc/testsuite/
	* g++.dg/modules/indirect-1_[abc].C: Add class.

From-SVN: r259567
2018-04-23 18:41:11 +00:00
Nathan Sidwell
e46102bcbf module.c (enum tree_tag): Remove tt_namespace.
gcc/cp/
	* module.c (enum tree_tag): Remove tt_namespace.
	(trees_out::tree_{value,decl,type,ref,ctx}): New.  Broken out of ...
	(trees_out::tree_node): ... here.  Use them.
	(trees_out::core_vals): Use tree_ctx.
	(module_state::write_cluster): Use tree_ctx.
	* name-lookup.h (find_imported_namespace): Delete.
	* name-lookup.c (find_imported_namespace): Delete.
	gcc/testsuite/
	* g++.dg/modules/class-3_d.C: Adjust scans.
	* g++.dg/modules/indirect-1_[abc].C: New.

From-SVN: r259566
2018-04-23 17:53:52 +00:00
Nathan Sidwell
f653d828b5 module.c (module_state::importing): New.
gcc/cp/
	* module.c (module_state::importing): New.
	(module_state::init): Lazy_open is not just for laziness.
	(module_state::read_config): Call maybe_defrost.
	(module_state::maybe_defrost): New, broken out of ...
	(module_state::load_section): ... here.  Call it.
	(module_state::freeze_an_elf): Look in importing stack too.
	gcc/testsuite/
	* g++.dg/modules/nest-1_[abc].C: New.

From-SVN: r259560
2018-04-23 13:28:33 +00:00
Nathan Sidwell
3ad20118db c-lex.c (c_lex_with_flags): Check C_LEX_FILENAME.
gcc/c-family/
	* c-lex.c (c_lex_with_flags): Check C_LEX_FILENAME.  Deal with
	CPP_HEADER_NAME.
	* c-pragma.h (C_LEX_FILENAME): New.
	gcc/cp/
	* parser.c (cp_parser_fill_main): Ask for C_LEX_FILENAME.
	(cp_parser_import_declaration): Parse legacy import names.
	* cp-tree.h (HEADER_STRING_LITERAL_P): New.
	libcpp/
	* include/cpplib.h (cpp_enable_filename_token): Declare.
	* macro.c (cpp_enable_filename_token): Define.
	pfile->state.angled_headers.
	gcc/testsuite/
	* g++.dg/modules/atom-inc-1.C: New.

From-SVN: r259331
2018-04-11 20:08:08 +00:00
Nathan Sidwell
f20b266ab1 module.c (module_state::lazy_depth): Remove.
gcc/cp/
	* module.c (module_state::lazy_depth): Remove.
	(module_state::lazy_open): Make countdown value.
	(module_state::init): Use getrlimit to default PARAM_LAZY_MODULES.
	gcc/
	* doc/invoke.texi (C++ Modules): Document lazy loading.
	* params.def (PARAM_LAZY_MODULE_FILES): Rename to ...
	(PARAM_LAZY_MODULES): ... here.
	gcc/testsuite/
	* g++.dg/modules/freeze-1_d.C: Fix.

From-SVN: r259328
2018-04-11 18:15:49 +00:00
Nathan Sidwell
6928c7acb7 Protect against too-many lazy loadings.
gcc/
	* params.def (PARAM_LAZY_MODULE_FILES): Define.
	gcc/cp/
	* module.c: Include params.h
	(elf::has_error): Return the error code.
	(elf_in): Add device, inode & size fields.
	(elf_in::{is_frozen,freeze,defrost}): New.
	(module_state): Add lru, lazy_lru, lazy_open fields.
	(module_state::{load_section,freeze_an_elf}): New.
	(module_state::{read,lazy_load}): Adjust.
	(module_state::check_read): Check for EMFILE.
	(module_state::do_import): Adjust.
	gcc/testsuite/
	* g++.dg/modules/freeze-1_[a-d].C: New.

From-SVN: r259297
2018-04-10 19:52:02 +00:00
Nathan Sidwell
b04261be89 parser.c (cp_parser_declaration_seq_opt): Remove ATOM handling here.
gcc/cp/
	* parser.c (cp_parser_declaration_seq_opt): Remove ATOM handling here.

From-SVN: r259295
2018-04-10 18:05:28 +00:00
Nathan Sidwell
56f93b6057 Incremental tokenization of ATOM preamble.
gcc/c-family/
	* c-pragma.h (C_LEX_STRING_FILENAME): New.
	gcc/cp/
	* cp-tree.h (module_file_nest): Declare.
	* lex.c (module_file_nest): Define.
	* module.c (module_state::{push,pop}_location): Use it.
	* parser.c (cp_lexer_fill_main): Rename to ...
	(cp_parser_file_main): ... this.  Take parser not lexer.  Read &
	parse one atom declaration at a time.
	(cp_parser_declaration_seq_opt): Disable atom preamble here.
	(c_parse_file): Adjust.
	libcpp/
	* files.c (cpp_module_file): New.
	* include/cpplib.h (cpp_module_file): Declare.

From-SVN: r259293
2018-04-10 17:58:30 +00:00
Nathan Sidwell
fd7e642ed0 parser.c (cp_lexer_new_main): Replace with ...
gcc/cp/
	* parser.c (cp_lexer_new_main): Replace with ...
	(cp_lexer_fill_main): ... this.  Move initial pragma processing to
	...
	(c_parse_file): ... here.
	(cp_parser_new): Adjust.

From-SVN: r259251
2018-04-09 19:35:51 +00:00
Nathan Sidwell
79d33f1627 parser.c (cp_lexer_get_preprocessor_token): Take cpp-flags directly.
gcc/cp/
	* parser.c (cp_lexer_get_preprocessor_token): Take cpp-flags
	directly.
	(cp_lexer_new_main, cp_parser_initial_pragma): Adjust.

From-SVN: r259248
2018-04-09 18:08:53 +00:00
Nathan Sidwell
9b84a0a22b cp-tree.h (modules_p, [...]): New predicates.
gcc/cp/
	* cp-tree.h (modules_p, modules_atom_p): New predicates.
	* decl.c (cxx_init_decl_processing): Use modules_p.
	* decl2.c (c_parse_final_cleanups): Likewise.
	* lex.c (init_reswords):
	* module.c (module_state::write_readme): Use modules_atom_p.
	(module_state::{read,write}_config): Likewise.
	(handle_module_option): Don't handle OPT_fmodules_atom here,
	* name-lookup,c (reuse_namespace, make_namespace_finish): Use
	modules_p.
	* optmize.c (maybe_clone_body): Likewise.
	* semantics.c (expand_or_defer_fn_1): Likewise.
	* parser.c (cp_parser_diagnose_invalid_type_name)
	(cp_parser_declaration_seq_opt, cp_parser_declaration): Use
	modules predicates.
	(cp_parser_initial_pragma): Reject pragma with modules.
	(c_parse_file): Adjust error message.
	gcc/c-family/
	* c.opt (fmodules-ts, fmodules-atom): Adust.
	(fno-modules): New.
	gcc/
	* doc/invoke.texi (fno-modules): Document.

From-SVN: r259246
2018-04-09 17:52:15 +00:00
Nathan Sidwell
ebaa09e3d4 module.c (init_module_processing): Disallow PCH.
gcc/cp/
	* module.c (init_module_processing): Disallow PCH.
	gcc/c-family/
	* c-pch.c (c_common_valid_pch): Never valid with modules.

From-SVN: r259245
2018-04-09 17:08:13 +00:00
Nathan Sidwell
2f702c9350 module.c (module_state::{read,write}_config): Check ATOM/TS matches.
gcc/cp/
	* module.c (module_state::{read,write}_config): Check ATOM/TS
	matches.
	gcc/testsuite/
	* g++.dg/modules/atom-check-1_[ab].C: New.

From-SVN: r259243
2018-04-09 16:03:44 +00:00
Nathan Sidwell
d33214adac module.c (module_state::write_readme): New.
gcc/cp/
	* module.c (module_state::write_readme): New.  Broken out of ...
	(module_state::write_context): ... here.  Absorb remainder into ...
	(module_state::write_config): ... here.
	(module_state::read_context): Merge into ...
	(module_state::read_config): ... here.
	(module_state::{read,write}): Adjust.

From-SVN: r259242
2018-04-09 15:56:07 +00:00
Nathan Sidwell
7301320baf module.c (module_state::release): Simplify.
gcc/cp/
	* module.c (module_state::release): Simplify.
	(module_state::check_read): Release if done.
	gcc/testsuite/
	* g++.dg/modules/import-2.C: Expect no bmi.
	* g++.dg/modules/modules.exp (dg-module-bmi): Always delete the bmi.

From-SVN: r259241
2018-04-09 15:33:37 +00:00
Nathan Sidwell
0456ff13e8 module.c (module_state::read): Allocate elf_in here.
gcc/cp/
	* module.c (module_state::read): Allocate elf_in here.
	(module_state::do_import): Adjust.
	gcc/testsuite/
	* g++.dg/modules/import-2.C: New.

From-SVN: r259235
2018-04-09 14:42:45 +00:00
Nathan Sidwell
7d3acce1a6 module.c (trees_out::tree_node): Avoid uninitialized false positive.
gcc/cp/
	* module.c (trees_out::tree_node): Avoid uninitialized false
	positive.

From-SVN: r259232
2018-04-09 11:27:11 +00:00
Nathan Sidwell
40c28b84f3 Merge trunk r259189.
From-SVN: r259197
2018-04-06 22:38:12 +00:00
Nathan Sidwell
f9a1ba9bab Lazy loading!
gcc/cp/
	* cp-tree.h (union mc_slot): New.
	(struct module_cluster): Use it.
	(lazy_load_binding): Take an mc_slot.
	* module.c (module_state::release): End the elf source.
	(module_state::read_function_def): Save and restore
	current_function_decl.
	(module_state::read): Enable lazy loading.
	(module_state::lazy_load): Take an mc_slot, adjust.
	(lazy_load_binding): Likewise.
	* name-lookup.c (module_binding_slot): Return an mc_slot pointer.
	(fixed_module_binding_slot): New.
	(name_lookup::search_namespace_only): Lazily load.
	(do_pushdecl): Use fixed_module_binding_slot.
	(merge_global_decl): Adjust.
	(import_module_binding): Install lazy cookie.
	(set_module_binding): Adjust.  Kill stale & wrong global module
	bits.
	(lookup_by_ident): Lazily load.
	(reuse_namespace): Use fixed_module_binding_slot.
	(make_namespace_finish): Likweise.
	(add_imported_namespace, find_imported_namespace): Adjust.
	gcc/c-family/
	* c.opt (fmodule-lazy): Default on.
	gcc/testsuite/
	* g++.dg/modules/lazy-1_[ab].C: New.

From-SVN: r259189
2018-04-06 19:37:28 +00:00
Nathan Sidwell
af0db6abc7 module.c (elf::E_BAD_LAZY): New error.
gcc/cp/
	* module.c (elf::E_BAD_LAZY): New error.
	(elf::has_error): New.
	(elf::get_error): Return string.
	(elf::end): Return bool.
	(elf_in::forget_section): New.
	(module_state::check_error): New.
	(module_state::do_module_import): Use it.
	(module_state::lazy_load): New.
	(module_state::{read,write}_decls): Absorb into callers.
	(module_state::read_{context,config,namespaces,bindings,cluster}): Lose
	from parm.
	(module_state::lazy_depth): New.
	(lazy_load_binding): New.
	(finish_module): Adjust.
	* cp-tree.h (lazy_load_binding): Declare.
	gcc/testsuite/
	* g++.dg/modules/circ-1_c.C: Adjust errors.
	* g++.dg/modules/mod-stamp-1_d.C: Adjust errors.

From-SVN: r259180
2018-04-06 17:23:32 +00:00
Nathan Sidwell
166cd09228 module.c (elf_in::keep_sections): New.
gcc/cp/
	* module.c (elf_in::keep_sections): New.
	(elf_in::read): Add type arg.
	(elf_in::find): Remove type arg.
	(elf_in::begin): Coalesce error messages.
	(module_state::loading): New field.
	(module_state::{read,write}_config): Serialize section range ...
	(module_state::{read,write}_namespace): ... not here.
	(module_state::read_decls): Do not read the actual decls.
	(module_state::read): ... do them here.

From-SVN: r259176
2018-04-06 15:09:56 +00:00
Nathan Sidwell
2a87dcaf24 module.c (trees_{in,out}, depset): Reorder definitions.
gcc/cp/
	* module.c (trees_{in,out}, depset): Reorder definitions.

From-SVN: r259175
2018-04-06 13:53:37 +00:00
Nathan Sidwell
b541938459 module.c (module_state::{read,write}_binfos): Merge loops.
gcc/cp/
	* module.c (module_state::{read,write}_binfos): Merge loops.

From-SVN: r259174
2018-04-06 13:38:36 +00:00
Nathan Sidwell
a85bdfd1dd modules.c (trees_{in,out}::tree_binfo): Delete.
gcc/cp/
	* modules.c (trees_{in,out}::tree_binfo): Delete.
	(module_state::{read,write}_binfos): New.
	(module_state::{read,write}_class_def): Use them.

From-SVN: r259170
2018-04-06 13:18:31 +00:00
Nathan Sidwell
97efb6eb2e invoke.texi (C++ Modules): New section.
gcc/
	* doc/invoke.texi (C++ Modules): New section.
	gcc/c-family/
	* c.opt (-fmodule-lazy): New option.
	gcc/cp/
	* module.c (module_state::read_decls): Prepare for laziness.

From-SVN: r259154
2018-04-05 21:03:34 +00:00
Nathan Sidwell
e90a8fbb38 module.c (module_state::tng_*): Rename.
gcc/cp/
	* module.c (module_state::tng_*): Rename.

From-SVN: r259151
2018-04-05 18:45:51 +00:00
Nathan Sidwell
e49b9c0f23 module.c (enum tree_tag): Delete tt_definition, tt_binding.
gcc/cp/
	* module.c (enum tree_tag): Delete tt_definition, tt_binding.
	(trees_in::tag_{binding,definition}): Delete.
	(trees_out::{,maybe_}tag_definition): Delete.
	(trees_{in,out}::define_{function,var,class,enum}): Delete.
	(trees_in::tree_node): Remove tt_definition handling.
	(trees_in::read, trees_out::write): Delete.

From-SVN: r259148
2018-04-05 18:30:55 +00:00
Nathan Sidwell
1e5321ce86 module.c (module_state::write_namespace): Delete.
gcc/cp/
	* module.c (module_state::write_namespace): Delete.
	(module_state::{write_bindings,read_bindings}): Likewise.

From-SVN: r259144
2018-04-05 18:21:25 +00:00
Nathan Sidwell
7e16c39dca module.c (TNG): Delete.
gcc/cp/
	* module.c (TNG): Delete.
	(module_state::{tng_read_bindings,write): Constant fold TNG.
	(trees_out::tree_node, trees_in::finish_type): Likewise.

From-SVN: r259143
2018-04-05 18:16:56 +00:00
Nathan Sidwell
a780f851b7 module.c (refs_tng): Replace with TNG.
gcc/cp/
	* module.c (refs_tng): Replace with TNG.

From-SVN: r259142
2018-04-05 18:12:34 +00:00
Nathan Sidwell
17708cb962 Switch over to new binding scheme.
gcc/cp/
	* module.c (TNG): Enable.

From-SVN: r259141
2018-04-05 17:57:31 +00:00
Nathan Sidwell
1b68817d9a module.c (module_state::{read,write,mark}_template_def): Deal with CLASSTYPE_DECL_LIST.
gcc/cp/
	* module.c (module_state::{read,write,mark}_template_def): Deal
	with CLASSTYPE_DECL_LIST.
	(trees_out::tree_node): Check implicit TEMPLATE_DECLs.

From-SVN: r259139
2018-04-05 17:29:51 +00:00
Nathan Sidwell
71a1a1c825 module.c (trees_out::tree_node): Reorder by-name checks.
gcc/cp/
	* module.c (trees_out::tree_node): Reorder by-name checks.
	* name-lookup.c (pushdecl_top_level): Replace IS_FRIEND parm with
	MAYBE_INIT.  Set DECL_CONTEXT.  Finish if requested.
	(pushdecl_top_level_and_finish): Use pushdecl_top_level.
	* name-lookup.h (pushdecl_top_leve): Adjust declaration.

From-SVN: r259131
2018-04-05 15:45:50 +00:00
Nathan Sidwell
e39c76629f module.c (module_state::{read,write,mark}_template_def): New.
gcc/cp/
	* module.c (module_state::{read,write,mark}_template_def): New.
	(module_state::{read_write_mark}_definition): Call them.
	(depset::hash::add_dependency): Don't depend on no-context decls.
	(trees_out::tree_node): Don't try and name no-context decls.

From-SVN: r259102
2018-04-04 19:39:16 +00:00
Nathan Sidwell
4137ba72a9 module.c (module_state::{read,write}_class_def}): Fixup vptr-containing logic.
gcc/cp/
	* module.c (module_state::{read,write}_class_def}): Fixup
	vptr-containing logic.
	(trees_in::tree_binfo): Forward walk.

From-SVN: r259095
2018-04-04 17:06:51 +00:00
Nathan Sidwell
f9a77777e8 module.c (enum tree_tag): Replace tt_tinfo_pseudo with tt_tinfo_typedef.
gcc/cp/
	* module.c (enum tree_tag): Replace tt_tinfo_pseudo with
	tt_tinfo_typedef.  Add tt_vtable.
	(module_state::mark_class_def): Mark vtables.
	(trees_out::tree_node): Move TINFO processing to decl section.
	Replace tinfo_psuedo handling with tinfo_typedef handling.  Add
	vtable special.
	(trees_in::tree_node): Likewise.
	* rtti.c (struct tinfo_s): Note type is const qualified variant.
	gcc/testsuite/
	* g++.dg/aaa/class-3_d.C: Adjust message.

From-SVN: r259086
2018-04-04 15:46:01 +00:00
Nathan Sidwell
4a0bf2e4a5 module.c (module_state::read_definition): New.
gcc/cp/
	* module.c (module_state::read_definition): New.
	(module_state::read_{function,var,class,enum}_def): New.
	(module_state::tng_read_cluster): New.
	(module_state::tng_read_bindings): Call it.
	(trees_in::tree_node): Check refs_tng.

From-SVN: r259081
2018-04-04 14:12:27 +00:00
Nathan Sidwell
326ccacb78 module.c (module_state::write_var_def): Write definition.
gcc/cp/
	* module.c (module_state::write_var_def): Write definition.

From-SVN: r259079
2018-04-04 14:01:39 +00:00
Nathan Sidwell
c2fa008ce2 module.c (trees_out::mark_node): Allow preseeding.
gcc/cp/
	* module.c (trees_out::mark_node): Allow preseeding.
	(trees_out::tree_node): Fix as_base.

From-SVN: r259078
2018-04-04 13:50:25 +00:00
Nathan Sidwell
3d9cf8d0da module.c (tt_type_name, tt_named): Rename to ...
gcc/cp/
	* module.c (tt_type_name, tt_named): Rename to ...
	(tt_named_type, tt_named_decl): ... here.  Adjust uses.
	(module_state::mark_class_def): Mark fake base.
	(module_state::write_class_def): Write fake base.
	(trees_{in,out}::tree_node): Avoid goto again.
	(trees_in::finish_type): Protect fake base serialize.
	* Make-lang.in (version.o): Depend on cp dir.
	gcc/testsuite/
	* g++.dg/aaa/class-3_d.C: Adjust message.

From-SVN: r259054
2018-04-03 19:38:17 +00:00
Nathan Sidwell
ac376b8485 module.c (bytes_in::{use,i,u,wi,str}): Use set_overrun.
gcc/cp/
	* module.c (bytes_in::{use,i,u,wi,str}): Use set_overrun.
	(module_state::tng_write_cluster): Sort cluster here ...
	(module_state::tng_write_bindings): ... not here.
	(module_state::tng_read_bindings): Set refs_tng.
	(trees_{in,out}::define_class): Don't deal with refs_tng here.
	(trees_out::tree_binfo): Protect from dep_walk_p.  Force insert
	new tag.

From-SVN: r259045
2018-04-03 17:43:12 +00:00
Nathan Sidwell
82d5d5099b Reorder for better logging
Reorder for better logging
	gcc/cp/
	* module.c (trees_{in,out}::core_vals): Stream name-like members
	early.
	(module_state::do_import): Set module purview before streaming.
	* name-lookup.c (set_module_binding): Don't barf on null.

From-SVN: r259035
2018-04-03 15:06:33 +00:00
Nathan Sidwell
427ffd419f Fix enum types, more globals
Fix enum types, more globals
	gcc/cp/
	* module.c (module_state::maybe_add_global): New.
	(module_state::init): Use it.
	(trees_{in,out}::core_vals): Special case TYPE of unscoped enum.

From-SVN: r259028
2018-04-03 13:21:59 +00:00
Nathan Sidwell
5d819c0f65 Read new .bindings section
Read new .bindings section
	gcc/cp/
	* module.c (elf::get_num_sections): New.
	(module_state::tng_{read,write}_namespaces): Serialize section range.
	(module_state::tng_read_bindings): New.
	(module_State::tng_{read,write}_bindings): Adjust.
	(trees_in::define_enum, trees_in::tag_binding): Adjust.
	* name-lookup.h (push_module_binding): Rename to ...
	(set_module_binding): ... here.
	(import_module_binding): Declare.
	* name-lookup.c (import_module_binding): New.
	(push_module_binding): Rename to ...
	(set_module_binding): ... here.  Adjust.

From-SVN: r259013
2018-04-02 16:28:21 +00:00
Nathan Sidwell
3349b9f298 Kill old .bindings section
Kill old .bindings section
	gcc/cp/
	* module.c (module_state::record_namespace): Delete.
	(module_state::write_namespace): Remove bind parm.  Adjust.
	(module_state::read_namespace): Delete.
	(module_state::tng_read_namespaces): New.
	(module_state::write_bindings): Don't write bindings section.
	(module_state::read_bindings): Use tng_read_bindings).
	* name-lookup.c (make_namepace): Public namespaces are exported.
	(push_namespace): Adjust.

From-SVN: r259010
2018-04-02 15:08:03 +00:00
Nathan Sidwell
0060a23b3d module.c (trees_{in,out}::define_class): Check refs_tng.
gcc/cp/
	* module.c (trees_{in,out}::define_class): Check refs_tng.
	(trees_out::tree_binfo): Add definition dependency.
	(trees_{in,out}::tree_node): Don't write binfos in refs_tng mode.
	(trees_in::finish_type): Chek refs_tng.

From-SVN: r259008
2018-04-02 12:45:52 +00:00
Nathan Sidwell
d339a79c03 module.c (trees_{in,out}::tree_binfo): Serialize entire path.
gcc/cp/
	* module.c (trees_{in,out}::tree_binfo): Serialize entire path.
	(trees_{in,out}::tree_node): Adjust.
-- This line, and those below, will be ignored--
M    ChangeLog.modules
M    gcc/cp/module.c

From-SVN: r259005
2018-04-02 11:24:40 +00:00
Nathan Sidwell
b2ff215988 module.c (has_definition): VAR_DECLs too.
gcc/cp/
	* module.c (has_definition): VAR_DECLs too.
	{module_state::mark_{,function_,var_,class_,enum_}definition): New.
	(trees_out::walk_into): Turn into ...
	(trees_out::mark_node): ... this.  Adjust callers.
	(module_state::write{_function_,class_,var_}_def): Define.
	(module_state::find_dependencies): Look in definitions.

From-SVN: r258979
2018-03-30 16:03:14 +00:00
Nathan Sidwell
c2a68e6ec4 module.c (maybe_get_template): New.
gcc/cp/
	* module.c (maybe_get_template): New.
	(depset::hash::maybe_add_definition): Return a depset.
	(depset::hash::add_dependency): Don't deal with template here.
	(module_state::write_{function,class}): New stubs.
	(module_state::write_enum): New.
	(module_state::write_definition): New.
	(module_state::tng_write_cluster): Write binding header.
	(module_state::add_writables): Don't return a bool. No need to
	nadger namespace ownership.
	(module_state::find_dependencies): Adjust.
	(bind_cmp, space_cmp): New.
	(ns_cmp): Delete.
	(module_state::tng_write_bindings): Sort here.
	(trees_out::tree_node): Check dependency of containers.
	(module_purview_p): Defend against early checks.
	* name-lookup.c (extract_module_decls): Don't special-case
	namespaces.
	(push_namespace): Set EXPORT & OWNER inside a module.
	gcc/testsuite/
	* g++.dg/modules/namespace-2.C: Adjust.
	* g++.dg/modules/namespace-3.C: New.
	* g++.dg/modules/scc-1.C: Adjust.
	* g++.dg/modules/scc-2.C: New.

From-SVN: r258922
2018-03-28 13:47:45 +00:00
Nathan Sidwell
d69bac2c41 gcc/cp/
* module.c
	(depset::hash::{add_writables,find_dependencies}): Moved to ...
	(module_state::{add_writables,find_dependencies}): ... here.  Adjust.
	(depset::hash::write_bindings): Moved to ...
	(module_state::tng_write_bindings): ... here.  Adjust.
	(depset::hash::{add_decls,get_work}): New.

From-SVN: r258891
2018-03-27 16:32:44 +00:00
Nathan Sidwell
a866845eba module.c (hash_definition): New.
gcc/cp/
	* module.c (hash_definition): New.
	(struct depset::tarjan): New.
	(depset::tarjan_connect, depset::hash::find_sccs): Delete.
	(depset::hash::maybe_add_definition): New.
	(module_state::tng_write_namespaces): New.
	(depset::hash::{maybe_namespace,write_namespaces): Delete.
	(module_state::tng_write_bindings): Adjust.

From-SVN: r258888
2018-03-27 15:36:59 +00:00
Nathan Sidwell
9df26320f9 module.c (depset::traits): Hash & compare using name too.
gcc/cp/
	* module.c (depset::traits): Hash & compare using name too.

From-SVN: r258880
2018-03-27 13:14:15 +00:00
Nathan Sidwell
4912622649 module.c (refs_tng): Temporary modal hack.
gcc/cp
	* module.c (refs_tng): Temporary modal hack.
	(tree_tag): Rename tt_import to tt_named.
	(module_state::write_cluster): Fix iteration.
	(module_state::tng_write_bindings): Set and clear refs_tng.
	(trees_out::tree_node): Refs by name when applicable.
	(trees_out::tree_node): Use tt_named.
	gcc/testsuite/
	* g++.dg/modules/by-name-1.C: New.
	* g++.dg/modules/class-3_b.C: Adjust.
	* g++.dg/modules/scc-1.C: More checking.

From-SVN: r258878
2018-03-27 12:48:02 +00:00
Nathan Sidwell
359d2b709d module.c (depset::table): Rename to ...
gcc/cp/
	* module.c (depset::table): Rename to ...
	(depset::hash): ... here.
	(trees_out::deps_only): Rename to ...
	(trees_out::dep_walk_p): ... here.

From-SVN: r258863
2018-03-26 19:25:45 +00:00
Nathan Sidwell
9a730f78a0 module.c (depset::table::find_exports): Renamed ...
gcc/cp/
	* module.c (depset::table::find_exports): Renamed ...
	(depset::table::add_writables): .. here.  Return bool, add
	exported namespaces.
	(depset::table::append): Add namespaces to worklist.
	(mdule_state::write_namespace): Use TREE_PUBLIC.
	* name-lookup.c (extract_module_decls): Only extract decls in our
	purview.
	(make_namespace): Remove FIXME.
	(push_namespace): Set MODULE_OWNER if exporting.
	gcc/testsuite/
	* g++.dg/modules/namespace-2.C: New.

From-SVN: r258862
2018-03-26 19:08:53 +00:00
Nathan Sidwell
33fe57484e scanlang.exp (scan-lang-dump-not): new.
gcc/testsuite/
	* lib/scanlang.exp (scan-lang-dump-not): new.

From-SVN: r258861
2018-03-26 18:44:50 +00:00
Nathan Sidwell
a7007fa0a1 module.c (depset::visited): Use depset::cluster.
gcc/cp/
	* module.c (depset::visited): Use depset::cluster.  Adjust users.

From-SVN: r258860
2018-03-26 16:59:51 +00:00
Nathan Sidwell
f5222315d7 module.c (elf_out::strtab::named_decl): Cope with TYPE constext.
gcc/cp/
	* module.c (elf_out::strtab::named_decl): Cope with TYPE constext.
	(elf_out::strtab::write_named_decl): Likewise.
	(module_state::write_cluster): Adjust dump.
	(fixup_unscoped_enum_owner): New.
	* decl.c (finish_enum_value_list): Call
	fixup_unscoped_enum_owner, as necessary.
	* cp-tree.h (fixup_unscoped_enum_owner): Declare.
	gcc/testsuite/
	* g++.dg/modules/scc-1.C: New.

From-SVN: r258858
2018-03-26 16:03:34 +00:00
Nathan Sidwell
f910de9768 module.c (elf_out::strtab): Add name-by-decl.
gcc/cp/
	* module.c (elf_out::strtab): Add name-by-decl.
	(module_state::write_cluster): Find naming decl, and use it.

From-SVN: r258857
2018-03-26 14:57:08 +00:00
Nathan Sidwell
c0b34001cf module.c (class depset): Make a class, add accessors.
gcc/cp/
	module.c (class depset): Make a class, add accessors.  Implicitly
	hold name as first decl.
	(depset::table::{maybe_insert,find}): New.
	(depset::table::{append,find_exports,find_dependencies}): Adjust.
	(depset::table::{write_bindings,write_namespaces}): Adjust.
	(module_state::write_cluster): Adjust.

From-SVN: r258855
2018-03-26 14:27:13 +00:00
Nathan Sidwell
bbae241447 Add depset analysis (incomplete)
Add depset analysis (incomplete)
	gcc/cp/
	* module.c (struct depset): New.
	(module_state::tng_write_bindings, write_cluster): New.
	(trees_out::{decls,mark_decls,mark_trees,unmark_trees): New.
	(trees_out::{begin,end,walk_into,force_insert): New.
	(module_state::write): Call tng_write_bindings.
	(trees_out::{core_vals,lang_decl_vals,lang_type_vals,tree_node_raw,
	tree_node): Deal with deps_only.

From-SVN: r258853
2018-03-26 12:03:53 +00:00
Nathan Sidwell
dbe8a375ad Allow dump '-'
Allow dump '-'
	gcc/
	* dumpfile.c (dump_open): New. Allow '-' for stdout.
	(dump_open_alternate_stream, dump_start, dump_begin): Call it.
	(dump_finish): Identify std{out,err} by stream.
	* doc/invoke.texi (fdump-rtl): Document stdout/stderr.

From-SVN: r258806
2018-03-23 14:07:22 +00:00
Nathan Sidwell
30fe466fe6 rename tests
From-SVN: r258600
2018-03-16 17:28:21 +00:00
Nathan Sidwell
0e9aad7352 Remove -fmodules, forcing -fmodules-{ts,atom}
Remove -fmodules, forcing -fmodules-{ts,atom}
	gcc/cp/
	* parser.c (cp_parser_diagnose_invalid_type_name): Adjust error.
	gcc/c-family/
	* c.opt (fmodules): Remove.
	gcc/
	* doc/invoke (fmodules): Remove.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Iterate over -fmodules-{ts,atom}.
	* g++.dg/modules: Mark tests that are -fmodules-ts only.

From-SVN: r258598
2018-03-16 15:49:15 +00:00
Nathan Sidwell
17ba69c224 missed changelog
From-SVN: r258597
2018-03-16 15:46:24 +00:00
Nathan Sidwell
629e899389 Implement Atom module & import placement
Implement Atom module & import placement
	gcc/
	* doc/invoke.texi (-fmodules): Document -fmodules-atom.
	gcc/c-family/
	* c.opt (fmodules-atom): Renamed from fmodules++.
	gcc/cp/
	* cp-tree.h (import_module): Add parameter.
	* module.c (import_module): Add exporting param.
	(handle_module_option): Adjust.
	* parser.c (cp_parser_module_declaration): Remove fmodules++
	global module parsing.
	(cp_parser_import_declaration): Adjust.
	(cp_parser_declaration_seq_opt): Parse imports under -fmodules++ ...
	(cp_parser_declaration): and not here.
	gcc/testsuite/
	* g++.dg/modules/mod++-decl-0_[abc].C: Adjust.
	* g++.dg/modules/mod++-decl-2.C: Adjust.
	* g++.dg/modules/mod++-decl-3.C: New.

From-SVN: r258573
2018-03-15 19:52:48 +00:00
Nathan Sidwell
6f702e9b9a Implement p0713 - identifiying module source
Implement p0713 - identifiying module source
	gcc/cp/
	* parser.c (cp_parser_module_declaration): Allow global module
	preamble.  Return bool.
	(cp_parser_declaration_seq_opt): Adjust.
	gcc/testsuite/
	* g++.dg/modules/circ-1_d.C: Adjust.
	* g++.dg/modules/global-1_a.C: Adjust.
	* g++.dg/modules/main-[123]-aux.cc: Adjust.
	* g++.dg/modules/main-aux.cc: Adjust.
	* g++.dg/modules/mod-decl-[13].C: Adjust.
	* g++.dg/modules/mod-decl-5_b.C: Adjust.
	* g++.dg/modules/mod-exp-1_b.C: Adjust.
	* g++.dg/modules/mod-sym-2.C: Adjust.
	* g++.dg/modules/proclaim-1.C: Adjust.
	* g++.dg/modules/static-1_a.C: Adjust.
	* g++.dg/modules/p0713-[123].C: New: Adjust.

From-SVN: r258558
2018-03-15 15:22:41 +00:00
Nathan Sidwell
645b78f080 module.c (add_module_mapping): Fix double increment.
gcc/cp/
	* module.c (add_module_mapping): Fix double increment.

From-SVN: r258104
2018-03-01 16:32:43 +00:00
Nathan Sidwell
72038ba204 Merge trunk r258084.
From-SVN: r258088
2018-02-28 21:50:54 +00:00
Nathan Sidwell
37e9408873 Makefile.in (REVISION_c): Don't exec REVISION.
gcc/
	* Makefile.in (REVISION_c): Don't exec REVISION.
	* REVISION: Simple text file.
	gcc/cp/
	* Make-lang.in (MODULE_STAMP): New var.
	(REVISION_s): Wedge stamp into it here.
	(CFLAGS-cp/module.o): Adjust.

From-SVN: r258084
2018-02-28 21:01:46 +00:00
Nathan Sidwell
1742e520c5 Using flags on overloads.
gcc/cp/
	* cp-tree.h (OVL_HAS_USING_P): New.
	* tree.c (alloc_ovl): New, broken out of ...
	(ovl_make): ... this.  Use it.  Maybe set OVL_HAS_USING_P.
	(ovl_copy): Use alloc_ovl.  Copy OVL_HAS_USING_P.
	(ovl_insert): Set OVL_HAS_USING_P appropriately.
	(lookup_maybe_add): Comment on OVL_HAS_USING_P.
	* name-lookup.c (name_lookup::add_overload)
	(get_class_binding_direct): Check OVL_HAS_USING_P.
	gcc/testsuite/
	* g++.dg/lookup/using60.C: New.

From-SVN: r258083
2018-02-28 20:35:16 +00:00
Nathan Sidwell
dd7641c8e9 Makefile.in: Exec REVISION maybe.
gcc/
	* Makefile.in: Exec REVISION maybe.
	* REVISION: New.
	gcc/cp/
	* Make-lang.in: Directly set MODULE_STAMP.

From-SVN: r258072
2018-02-28 16:14:25 +00:00
Nathan Sidwell
a9964db717 Map tag recognised in and out of comments
Map tag recognised in and out of comments
	gcc/cp/
	* module.c
	gcc/testsuite/
	* g++.dg/modules/hello.cc: Clone to ...
	* g++.dg/modules/main{,-[123]}-aux.cc: ... here.
	* g++.dg/modules/main-[123]_a.C: New.
	* g++.dg/modules/main-[123]-map: New.
	* g++.dg/modules/main-map: Delete.
	* g++.dg/modules/main_a.C: Update.

From-SVN: r258065
2018-02-28 13:55:56 +00:00
Nathan Sidwell
732173bd94 module.c (version_string): Rename.
gcc/cp/
	* module.c (version_string): Rename.
	(module_state::write_context): Write compiler version.

From-SVN: r258032
2018-02-27 12:50:36 +00:00
Nathan Sidwell
f3a1ebeed0 Use TREE_VISITED
Use TREE_VISITED
	gcc/cp/
	* module.c (trees_out::fixed_refs): New.
	(trees_out::{begin,end}): New.
	(module_state::init): Use TREE_VISITED.
	(trees_out::{maybe_insert,tree_node}): Likewise.

	gcc/cp/
	* module.c: More commenting.
	(trees_{in,out}::define_class): Don't do AsBase here.
	(trees_in::finish_type, trees_out::tree_node}: Do it here.
	(get_module_owner): Cleanup.

From-SVN: r257749
2018-02-16 17:42:08 +00:00
Nathan Sidwell
f5ca048020 module.c: More commenting.
gcc/cp/
	* module.c: More commenting.
	(trees_{in,out}::define_class): Don't do AsBase here.
	(trees_in::finish_type, trees_out::tree_node}: Do it here.
	(get_module_owner): Cleanup.

From-SVN: r257733
2018-02-16 12:41:31 +00:00
Nathan Sidwell
281cbeae77 Module ownership on containers
Module ownership on containers
	gcc/cp/
	* cp-tree.h (decl_set_module, module_context): Delete.
	(get_module_owner, set_module_owner)
	(set_implicit_module_owner): Declare.
	* decl.c (grokfndecl, grokvardecl, grokdeclarator): Call
	set_module_owner.
	* error.c (dump_module_suffix): Use get_module_owner.
	* mangle.c (maybe_write_module): Likewise.
	* method.c (implicitly_declare_fn): Use set_implicit_module_owner.
	* module.c (module_context, decl_set_module): Delete.
	(trees_in::define_function): Adjust.
	(trees_{in,out}::lang_decl_bools): Set module_owner.
	(trees_{in,out}::tree_node_raw): Adjust.
	(trees_out::tree_node): Adjust.
	(get_module_owner, set_module_owner)
	(set_implicit_module_owner): Define.
	* name-lookup.c (do_pushtag): Use set_module_owner.
	* pt.c (lookup_template_class_1, instanitate_decl): Use
	set_implicit_module_owner.

From-SVN: r257708
2018-02-15 20:28:48 +00:00
Nathan Sidwell
a6c53ec363 module.c (trees_out::tree_node): Reorder.
gcc/cp/
	* module.c (trees_out::tree_node): Reorder.

From-SVN: r257694
2018-02-15 15:59:58 +00:00
Nathan Sidwell
3b3a3633d5 module.c: Commenting and a few cleanups.
gcc/cp/
	* module.c: Commenting and a few cleanups.

From-SVN: r257693
2018-02-15 15:32:53 +00:00
Nathan Sidwell
0c154178c4 module.c (elf): Make more constants private.
gcc/cp/
	* module.c (elf): Make more constants private.
	(elf_in::find): Swap args, default to PROGBITS.
	(elf_out::add): Replace type and flags with string_p arg.
	(bytes_in::begin, bytes_out::end): Adjust.
	(data::set_crc): Store zero for no-crc.

From-SVN: r257689
2018-02-15 14:11:39 +00:00
Nathan Sidwell
26de8c61c5 Module map files have more syntax
Module map files have more syntax
	gcc/cp/
	* cxx-module-wrapper.sh: Accept src filename, don't search
	MODULE_PATH.
	* module.c (module_state::srcname): New.
	(module_state::print_map): New.
	(make_module_name): Rename to ...
	(make_module_filename): ... here.  Don't assume trailing NUL.
	(find_module_file): Pass srcname.
	(parse_module_mapping): New.
	(add_module_mapping): Call it.  Detect too-deeply nested.
	gcc/c-family/
	* c.opt (fmodule-map-dump): New.
	gcc/
	doc/invoke.texi: Document new module-map file syntax
	gcc/testsuite/
	* g++.dg/modules/hello.c: Adjust.
	* g++.dg/modules/main_a.c: Adjust.
	* g++.dg/modules/main-map: New.
	* g++.dg/modules/modules.exp: Set CXX_MODULE_PATH.

From-SVN: r257688
2018-02-15 13:26:24 +00:00
Nathan Sidwell
10f44c52f5 Module path is for mapping files.
Module path is for mapping files. Replace -fmodule-root with
	-fmodule-prefix.
	gcc/cp/
	* cxx-module-wrapper.sh: Adjust.
	* module.c (module_state::lazy_{init,fini}): Drop the lazy.
	(module_state::maybe_early_init): Move into init.
	(module_prefix, module_file_args, module_wrapper): New.
	(make_module_name): New.
	(module_state::occupy): Call it.
	(module_to_filename): Delete.
	(search_module_path): Adjust for finding module-maps.
	(find_module_file): New.
	(add_module_mapping): Reimplement.
	(init_module_processing): Process module_file_args array.
	(module_state::do_import, finish_module): Adjust.
	(maybe_prepend_dir): Delete.
	(handle_module_option): Adjust.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Adjust clean_cxx_module_path
	call.
	* c.opt (fmodule-root=): Delete.
	(fmodule-prefix=): New.
	gcc/
	* doc/invoke.texi (fmodule-root): Replace with ...
	(fmodule-prefix): ... this.
	* incpath.c (clean_cxx_module_path): Drop root appending. Drop
	multilib handling.
	* incpath.h (clean_cxx_module_path): Adjust.
	gcc/testsuite/
	* g++.dg/modules/fmod-file-1_b.C: Adjust.
	* g++.dg/modules/main_a.C: Adjust.
	* g++.dg/modules/modules.exp: Adjust.

From-SVN: r257652
2018-02-14 02:51:41 +00:00
Nathan Sidwell
8381951985 AS_BASE is by reference.
gcc/cp/
	* module.c (trees_out::define_class): Break AS_BASE loop during
	streaming.
	(trees_{in,out}::tree_node): Use tt_as_base.

From-SVN: r257595
2018-02-12 18:08:35 +00:00
Nathan Sidwell
03ac6da6ef Mapping files are recursive.
gcc/cp/
	* module.c (maybe_prepend_dir): New.
	(add_module_mapping): Recurse.  Deal with relative paths.
	(handle_module_option): Move file reading into add_module_mapping.
	gcc/
	* doc/invoke.texi (fmodule-file): Document.

From-SVN: r257592
2018-02-12 17:36:26 +00:00
Nathan Sidwell
3987b40362 BINFOs imported by reference.
gcc/cp/
	* module.c (trees_{in_out}::tree_binfo): New.
	(trees_out::maybe_insert): New.
	(trees_out::insert): Use it.
	(trees_{in,out}::define_class): Stream remaining binfo contents.
	(trees_{in,out}::start): Don't expect BINFOs.
	(trees_{in,out}::core_vals): Likewise.
	(trees_{in,out}::tree_node): Use tt_binfo.
	(trees_out::tree_node): Stream a class's child binfos.
	(trees_in::finish_type): Likewise.

From-SVN: r257589
2018-02-12 16:56:28 +00:00
Nathan Sidwell
224994bdfe Add module map file reading.
gcc/cp/
	* module.c (add_module_mapping): New, swallow ...
	(add_module_file): ... insertion bits.  Move other bits to ...
	(handle_module_option): ... here.  Read module map file.
	gcc/c-family/
	* c.opt (fmodule-file): Document new semantics.
	gcc/
	* doc/invoke.texi (fmodule-file): Document new semantics.
	gcc/testsuite/
	* g++.dg/modules/fmod-file-1_[ab].C: New.
	* g++.dg/modules/fmod-out-1_[ab].C: New.
	* g++.dg/modules/modules.exp (decode_mod_spec): Augment.

From-SVN: r257570
2018-02-11 21:18:42 +00:00
Nathan Sidwell
e76f8845b1 Keep module-file map in module hash
Keep module-file map in module hash
	gcc/cp/
	* module.c (module_state): Add empty_p, get_module members.
	Rename set_name, delete set_location.
	(module_file_map, module_file): Delete.
	(module_state::do_import): Use get_module, set filename here.
	(declare_module): No need to set filename here.
	(add_module_file): Use module_state::get_module.

From-SVN: r257569
2018-02-11 20:09:55 +00:00
Nathan Sidwell
819b67030d Move module option processing into module.c.
gcc/cp/
	* cp-objcp-common.c (add_module_file): Move to module.c
	(cp_handle_option): Call handle_module_option.
	* cp-tree.h (module_output, module_files_map, module_files): Move
	to module.c
	* module.c (module_state::maybe_early_init): New.
	(module_output, module_files): Make static.
	(module_files_map): From cp-tree.h.
	(init_module_processing): Call maybe_early_init.
	(add_module): Moved from cp-objcp-common.c.
	(handle_module_option): New.

From-SVN: r257561
2018-02-11 15:15:56 +00:00
Nathan Sidwell
999664b4e3 Move module option processing out of c-common.
c-family/
	* c-common.h (module_output, module_files_map, module_files): Move
	to cp-tree.h.
	* c-common.c (module_output, module_files): Move to module.c
	* c-opts.c (add_module_file): Move to cp-objcp-common.c.
	(c_common_handle_option): Move modules options to
	cp-objcp-common.c.
	cp/
	* cp-objcp-common.c (add_module_file): Moved from c-opts.c.
	(cp_handle_option): New, from c_common_handle_option.
	* cp-objcp-common.h (LANG_HOOKS_HANDLE_OPTION): Point at
	cp_handle_option.
	* cp-tree.h (module_output, module_files_map, module_files): Moved
	from c-common.h.
	* cp-module.c (module_output, module_files): Moved from c-common.c.

From-SVN: r257560
2018-02-11 14:56:19 +00:00
Nathan Sidwell
df267409c3 module.c: Update more comments.
gcc/cp/
	* module.c: Update more comments.

From-SVN: r257532
2018-02-09 17:42:50 +00:00
Nathan Sidwell
2fc50cf0de module.c: Update a lot of comments.
gcc/cp/
	* module.c: Update a lot of comments.

From-SVN: r257530
2018-02-09 16:18:18 +00:00
Nathan Sidwell
6f9d9ad90e module.c (trees_in::tree_node): Absorb ...
gcc/cp/
	* module.c (trees_in::tree_node): Absorb ...
	(trees_in::tree_node_special): ... this.

From-SVN: r257449
2018-02-07 12:29:16 +00:00
Nathan Sidwell
eccd4bfe0b module.c (trees_in::tree_node_special): Deserialize tt_node here ...
gcc/cp/
	* {trees_in::tree_node_special): Deserialize tt_node here ...
	(trees_in::tree_node): ... not here.

From-SVN: r257448
2018-02-07 12:22:56 +00:00
Nathan Sidwell
eed40d4c2d module.c (trees_out::tree_node_special): Move into tree_node.
gcc/cp/
	* module.c (trees_out::tree_node_special): Move into tree_node.

From-SVN: r257428
2018-02-06 19:48:31 +00:00
Nathan Sidwell
d772730223 module.c (trees_{in,out}::core_vals): Serialize decl name & context here.
gcc/cp/
	* module.c (trees_{in,out}::core_vals): Serialize decl name &
	context here.
	(trees_in::tree_node_raw): Don't set name & context here.
	(trees_{in,out}::tree_node): Don't serialize decl name and context
	here.

From-SVN: r257427
2018-02-06 19:17:34 +00:00
Nathan Sidwell
270e68000c Remove old import machinery.
gcc/cp/
	* module.c (trees_in::tree_node_raw): Set module owner.
	(trees_{in,out}::tree_node): Remove importing here.

From-SVN: r257426
2018-02-06 19:04:30 +00:00
Nathan Sidwell
a26fd6b0a6 Imports use special tags
Imports use special tags
	gcc/cp/
	* module.c (module_context): Cope with C++ anon types.
	(trees_{in,out}::tree_node_special): Deal with imports here ...
	(trees_{in,out}::tree_node): ... not here.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust.

From-SVN: r257425
2018-02-06 18:45:29 +00:00
Nathan Sidwell
d5abe33049 Kill namespace module slot hackery
Kill namespace module slot hackery
	gcc/cp/
	* name-lookup.c (module_binding_slot): Make CREATE a bool.  Remove
	namespace hackery.
	(find_namespace_partition): Delete.
	(merge_global_decl): Do not expect a namespace.  Remove such
	handling.
	(push_module_binding): Likewise.

From-SVN: r257423
2018-02-06 17:43:21 +00:00
Nathan Sidwell
de648a0708 Namespaces use special tags
Namespaces use special tags
	gcc/cp/
	* module.c (trees_{in,out}::tree_node_special): Deal with
	namespaces.
	* name-lookup.h (find_imported_namespace): Declare.
	* name-lookup.c (find_imported_namespace): New.

From-SVN: r257421
2018-02-06 17:16:40 +00:00
Nathan Sidwell
122e39232d Less implicit tree numbering, negative indices for back refs
Less implicit tree numbering, negative indices for back refs
	gcc/cp/
	* module.c (ptr_uint_traits, ptr_uint_hash_map): Rename ...
	(ptr_int_traits, ptr_int_hash_map): ... here.  Map to ints.
	(uint_ptr_traits, uint_ptr_hash_map): Delete.
	(enum record_tag): Delete.
	(enum tree_tag): New.
	(trees_{in,out}::insert): Return int.
	(trees_{in,out}::tree_node_special): Adjust.
	(trees_{in,out}::tree_node): Adjust.
	(trees_out::write, trees_in::read): Adjust.
	gcc/testsuite/
	* g++.dg/modules/class-3_[bd].C: Adjust.

From-SVN: r257418
2018-02-06 16:33:22 +00:00
Nathan Sidwell
95eaf6bb17 decl2 (c_parse_final_cleanups): Only finish_module if we started it.
gcc/cp/
	* decl2 (c_parse_final_cleanups): Only finish_module if we started
	it.
	* module.c (module_hash_state): Move earlier.
	(module_state): Add hash and modules static members.
	(module_state::set_import): Replace do_import.
	(module_state::lazy_init): Create the hash table and default
	module.
	(trees_in::tree_node_raw): Don't remap a public namespace.
	(module_purview_p, module_interface_p): Adjust.
	(module_state::do_import): Move more stuff to lazy_init.
	(import_module): Deal with setting current module flags.
	(finish_module): Adjust.

From-SVN: r257396
2018-02-05 21:00:38 +00:00
Nathan Sidwell
4103006ce7 Fix bootstrap
Fix bootstrap
	gcc/cp/
	* module.c (elf): Clean up consts.
	(module_state::record_namespace): Comment args.
	(module_state::read_namespace): Comment unused vars.
	(trees_in::finish_tree): Fix logic error.
	(trees_in::tree_node_special): Fix undefined var.

From-SVN: r257391
2018-02-05 17:49:47 +00:00
Nathan Sidwell
854d1fafd7 Module purview is implicit.
gcc/cp/
	* cp-tree.h (lang_decl): Remove module_purview_p field.
	* mangle.c (maybe_write_module): Fix signed/unsigned mismatch.
	* module.c (trees_in::finish): Adjust.
	(trees{in,out}::lang_decl_bools): Drom module_purview_p field.
	(decl_set_module): Done set DECL_MODULE_PURVIEW_P.
	* name-lookup.c (extract_module_decls): check MODULE_PURVIEW_P.
	(make_namespace_finish): Remove inline_p arg.  Adjust callers.
	* pt.c (build_template_decl): Don't copy MODULE_PURVIEW_P.
	* rtti.c (tinfo_base_init): Don't clear MODULE_PURVIEW_P.

From-SVN: r257381
2018-02-05 03:02:52 +00:00
Nathan Sidwell
fc91e75d38 name-lookup.c (make_namespace_finish): Always create the scope.
gcc/cp/
	* name-lookup.c (make_namespace_finish): Always create the scope.
	(add_imported_namespace): Check namespace inlineness here.

From-SVN: r257380
2018-02-05 02:29:04 +00:00
Nathan Sidwell
bf24b8d6d8 module.c (decl_set_module): Set DECL_MODULE_OWNER.
gcc/cp/
	* module.c (decl_set_module): Set DECL_MODULE_OWNER.
	* rtti.c (tinfo_base_init): Clear DECL_MODULE_OWNER.

From-SVN: r257369
2018-02-04 23:52:07 +00:00
Nathan Sidwell
d9360032bb decl.c (grokfndecl): Protect decl_set_module call.
gcc/cp/
	* decl.c (grokfndecl): Protect decl_set_module call.
	* name-lookup,c (do_pushtag): Likewise.
	* module.c (decl_set_module): Assert namespace context.

From-SVN: r257368
2018-02-04 23:41:37 +00:00
Nathan Sidwell
9169f1c33e cp-tree.h: Adjust comments.
gcc/cp/
	* cp-tree.h: Adjust comments.
	* module.c (module_purview_p, module_interface_p): Adjust.

From-SVN: r257359
2018-02-03 23:37:55 +00:00
Nathan Sidwell
049563cdcb Deserializing uses an array (Nathan is a dumbass)
Deserializing uses an array (Nathan is a dumbass)
	gcc/cp/
	* module.c (trees_in): Delete count and tree_map. Add back_refs.
	(trees_in::next): Delete.
	(trees_in::insert): Append to array.
	(trees_in::tree_node_special): Adjust.
	(trees_in::tree_node): Likewise.

From-SVN: r257358
2018-02-03 23:13:39 +00:00
Nathan Sidwell
718b488d96 module.c (nodel_ptr_hash): New.
gcc/cp/
	* module.c (nodel_ptr_hash): New.
	(non_null_hash): Delete.
	(ptr_uint_traits, uint_ptr_traits): Adjust.
	(module_state_hash): Use nodel_ptr_hash.
	(module_hash): Do not GTY.
	(module_state::do_import, finish_module): Adjust.

From-SVN: r257352
2018-02-02 22:13:37 +00:00
Nathan Sidwell
aa4d14d760 Use TREE_VEC for structured module names.
gcc/cp/
	* cp-tree.h (module_name_parts): Replace with ...
	(module_vec_name): ... this.
	* mangle.c (maybe_write_modules): Adjust.
	* module.c (module_state): Replace name_parts with vec_name.
	(module_state::set_name): Add maybe_vec parm, construct TREE_VEC.
	(module_vec_name): Replace ...
	(module_name_parts): ... this.
	(module_state::do_import): Construct flat name.
	* parser.c (cp_parser_module_name): Construct TREE_VEC.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-1.C: Add error.

From-SVN: r257351
2018-02-02 21:39:05 +00:00
Nathan Sidwell
884f5d6c88 MODULE_PURVIEW bug fixing.
gcc/cp/
	* decl2.c (c_parse_final_cleanups): Reset current_module.
	* module.c (module_state::do_import): New, swallow ...
	(do_module_import): ... this.  Update callers.
	* name-lookup.c (name_lookup::search_namespace_only): Fix search
	of SLOT_CURRENT.
	(do_pushdecl): Fix assert.
	(merge_global_decl, push_module_binding, lookup_by_ident): Fix
	module remap thinko.

From-SVN: r257349
2018-02-02 20:29:11 +00:00
Nathan Sidwell
6b42c381bd Module purview has MODULE_PURVIEW number.
gcc/cp/
	* module.c (module_state::read): Use MODULE_PURVIEW.
	(trees_{in,out}::tree_node): Adjust.
	(do_module_import, import_module): Likewise.
	* name-lookup.c (module_binding_slot): Adjust.
	(do_pushdecl): Always push to MODULE_SLOT_CURRENT.
	(merge_global_decl): Remap MODULE_PURVIEW.
	(lookup_by_ident, add_imported_namespace): Likewise.

From-SVN: r257347
2018-02-02 19:30:35 +00:00
Nathan Sidwell
35ffb8ac04 Rename MODULE_INDEX->MODULE_OWNER
Rename MODULE_INDEX->MODULE_OWNER
	gcc/cp/
	* cp-tree.h (MODULE_NONE, MODULE_PURVIEW, MODULE_IMPORT_BASE)
	(MODULE_LIMIT): New, renamed from MODULE_INDEX_$FOO.
	(DECL_MODULE_OWNER): New, renamed from DECL_MODULE_INDEX.
	(MAYBE_DECL_MODULE_OWNER): Likewise.
	(struct lang_decl_base): Rename module_index to module_owner.
	* error.c, mangle.c, module.c, name-lookup.c, pt.c: Adjust.

From-SVN: r257346
2018-02-02 18:43:29 +00:00
Nathan Sidwell
92ed9ea863 Keep namespaces on global slot.
gcc/cp/
	* cp-tree.h (MODULE_SLOT_CURRENT, MODULE_SLOT_GLOBAL): Renamed
	from MODULE_SLOT_TU, MODULE_SLOT_GLOBALS.
	* name-lookup.h (set_module_namespace): Undeclare.
	(add_imported_namespace): Declare.
	* name-lookup.c (module_binding_slot): Remove assert, propagate
	external namespace to GLOBAL slot on creation.
	(update_binding): Don't add namespaces to level.
	(reuse_namespace): New.
	(make_namespace): New, absorb ...
	(create_namespace): ... this. Delete.
	(make_namespace_finish): New.
	(push_namespace): Adjust.
	(add_imported_namespace): New.  Absorb ...
	(set_module_namespace): ... this. Delete.
	* module.c (module_state::read_namespace): Adjust.
	gcc/testsuite/
	* g++.dg/modules/namespace-1_[abc].C: New.

From-SVN: r257345
2018-02-02 18:24:50 +00:00
Nathan Sidwell
670e2c615b Fix circularity detection, and other errors
Fix circularity detection, and other errors
	gcc/cp/
	* module.c (elf::E_BAD_DATA, elf::E_BAD_IMPORT): New.
	(elf::set_error): Default to E_BAD_DATA.
	(elf::end, elf_out::end): Return error string.
	(module_state::set_location): New.
	(module_state::{push,pop}_location): Adjust.
	(do_module_import): Fixup circularity and other errors.
	(declare_module, finish_module): Adjust.
	gcc/testsuite/
	* g++.dg/modules/circ-1_[abcd].C: New.
	* g++.dg/modules/mod-decl-1.C: Adjust errors.
	* g++.dg/modules/mod-decl-2_b.C: Adjust errors.
	* g++.dg/modules/mod-decl-5_b.C: Adjust errors.
	* g++.dg/modules/mod-stamp-1-d.C: Adjust errors.

From-SVN: r257332
2018-02-02 14:17:34 +00:00
Nathan Sidwell
8ca150c404 Alloc a slot for global module
Alloc a slot for global module
	gcc/cp/
	* cp-tree.h (MODULE_INDEX_NONE, MODULE_INDEX_PURVIEW): New.
	(MODULE_SLOT_TU, MODULE_SLOT_GLOBALS): New.
	(MODULE_INDEX_IMPORT_BASE): Increment.
	* module.c (do_module_import): Push reserved slot.
	* name-lookup.c (module_binding_slot): Reserve slots below
	MODULE_INDEX_IMPORT_BASE.

From-SVN: r257317
2018-02-01 22:10:19 +00:00
Nathan Sidwell
d4a642ea89 Alloc aslot for global module
Alloc aslot for global module
	gcc/cp/
	* cp-tree.h (MODULE_INDEX_NONE, MODULE_INDEX_PURVIEW): New.
	(MODULE_SLOT_TU, MODULE_SLOT_GLOBALS): New.
	(MODULE_INDEX_IMPORT_BASE): Increment.
	* module.c (do_module_import): Push reserved slot.
	* name-lookup.c (module_binding_slot): Reserve slots below
	MODULE_INDEX_IMPORT_BASE.

From-SVN: r257316
2018-02-01 21:34:19 +00:00
Nathan Sidwell
7d6c6d504f Bindings point to decls
Bindings point to decls
	gcc/cp/
	* module.c (data::check_crc): Only check.
	(data::get_crc): New.
	(elf_in::find): Return section index.
	(bytes_in::begin): Add by-section-number variant.
	(module_state): Add lazy counter (unused).
	(module_state::write_bindings): Emit decl section number.
	(module_state::read_bindings): Adjust, swallow ...
	(module_state::read_decls): ... this.  Delete.

From-SVN: r257309
2018-02-01 19:37:41 +00:00
Nathan Sidwell
5fe9df591a Read and parse the binding section in module_state.
gcc/cp/
	* module.c (modules_state::record_namespace): New.
	(module_state::write_namespace): Adjust, renamed from ...
	(module_state::walk_namespace): ... here.
	(module_state::read_namespace): New.
	(module_state::{read,write}_bindings): Adjust.
	(module_state::finish_module): Adjust.
	* name-lookup.h (set_module_namespace): Declare.
	* name-lookup.c (merge_global_decl): Adjust.
	(create_namespace): New.
	(set_module_namespace): New, use it.
	(push_namespace): Use create_namespace.

From-SVN: r257306
2018-02-01 18:29:55 +00:00
Nathan Sidwell
0e0b7d01da name-lookup.h (extract_module_decls): Renamed from extract_module_bindings.
gcc/cp/
	* name-lookup.h (extract_module_decls): Renamed from
	extract_module_bindings.  Adjust signature.
	* name-lookup.c (extract_module_decls): Likewise.
	* module.c (module_state::walk_namespace): New, absorb ...
	(trees_out::walk_namespace): ... this.  Delete.
	(trees_out::write): Reimplement, absorb ...
	(trees_out::{tag_binding,bindings}): ... these.  Delete.
	(module_state::write_bindings): Adjust.

From-SVN: r257297
2018-02-01 14:43:13 +00:00
Nathan Sidwell
037887476b Merge trunk r257292.
From-SVN: r257295
2018-02-01 13:11:41 +00:00
Nathan Sidwell
d5c5f1d8ad module.c (cpms_{in,out}): Rename to ...
gcc/cp/
	* module.c (cpms_{in,out}): Rename to ...
	(trees_in, trees_out): ... here.

From-SVN: r257276
2018-01-31 23:53:13 +00:00
Nathan Sidwell
6037ce045c module.c (module_state::global_{trees,vec,crc}): New, moved from ...
gcc/cp/
	* module.c (module_state::global_{trees,vec,crc}): New, moved from ...
	(globals{,_arys,_crc}): ... these globale scope vars.
	(cpms_in): Add global_vec member.

From-SVN: r257269
2018-01-31 21:18:02 +00:00
Nathan Sidwell
8750806684 Derive cpm_{in,out} from bytes_{in,out}
Derive cpm_{in,out} from bytes_{in,out}
	gcc/cp/
	* module.c (cpms_{in,out}): Derive from bytes_{in,out}.  Adjust
	all uses of r & w.

From-SVN: r257267
2018-01-31 20:55:06 +00:00
Nathan Sidwell
f047b78c97 Kill cpm_stream.
gcc/cp/
	* module.c (class cpm_stream): Delete.
	(class cpms_{in,out}): Adjust.

From-SVN: r257263
2018-01-31 20:45:40 +00:00
Nathan Sidwell
371a089802 Move elf out of cpms_in, cpms_out.
gcc/cp/
	* module.c (module_state::{read,write}_bindings): New.
	(module_stste::read_decls): New.
	(cpms_{in,out}::get_elf): Delete.
	(cpms_out::{write,bindings}): Adjust.
	(cpms_in::read): Adjust.

From-SVN: r257261
2018-01-31 20:22:04 +00:00
Nathan Sidwell
c8b562a93b Add module_stat read & write
Add module_stat read & write
	gcc/cp/
	* module.c (module_state::{read,write}): New.
	(cpms_in::read): Adjust.
	(do_import_module, finish_module): Adjust.

From-SVN: r257259
2018-01-31 19:52:55 +00:00
Nathan Sidwell
a9852d55fd module.c: Move cpm_stream, cpms_in, cpms_out earlier.
gcc/cp/
	* module.c: Move cpm_stream, cpms_in, cpms_out earlier.

From-SVN: r257257
2018-01-31 19:43:19 +00:00
Nathan Sidwell
7ea36a9b68 Move some reading to module_state.
gcc/cp/
	* module.c (module_state::read_{context,config}): New, swallow ...
	(cpms_in::imports,header): ... these.  Delete.
	(cpms_in::read): Adjust.
	(do_import_module): Adjust.

From-SVN: r257256
2018-01-31 19:28:55 +00:00
Nathan Sidwell
740cc1273e Move some writing to module_state.
gcc/cp/
	* module.c (module_state::write_{context,config}): New, swallow
	...
	(cpms_out::imports,header): ... these.  Delete.
	(cpms_out::write): Adjust.
	(finish_module): Adjust.

From-SVN: r257255
2018-01-31 19:04:32 +00:00
Nathan Sidwell
27baa1bfe7 Move global tree init.
gcc/cp/
	* module.c (module_state::lazy_init): New, swallow ...
	(cpm_serial::lazy_globals): ... this.   Adjust callers.

From-SVN: r257251
2018-01-31 18:51:05 +00:00
Nathan Sidwell
107828d16f Reorder class declarations
Reorder class declarations
	gcc/cp/
	* module.c (bytes, bytes_in, bytes_out): Move before module_state.

From-SVN: r257246
2018-01-31 18:09:46 +00:00
Nathan Sidwell
283230aba6 Simplify import interface
Simplify import interface
	gcc/cp/
	* module.c (MODULE_INDEX_IMPORTING, MODULE_INDEX_ERROR): Delete.
	(MODULE_INDEX_UNKNOWN): New.
	(module_state): Initialize mod to MODULE_INDEX_UNKNOWN.
	(cpms_in::read): Return void.
	(do_module_import): Return pointer to module object.
	(cpms_in::imports): Adjust.
	(import_module, declare_module, finish_module): Adjust.

From-SVN: r257245
2018-01-31 17:50:44 +00:00
Nathan Sidwell
0dfb816e35 Module_state owns elf and elf owns stream
Module_state owns elf and elf owns stream
	gcc/cp/
	* module.c (elf): Add begin, end members.
	(elf_in, elf_out): Adjust.
	(module_state::announce): New.
	(cpms_{in,out}::get_elf): Adjust.
	(cpms_{in,out}::{begin,end}): Delete.
	(do_module_import, finish_module): Adjust.

From-SVN: r257244
2018-01-31 17:02:23 +00:00
Nathan Sidwell
03a88b6d1f Commonize module location
Commonize module location
	gcc/cp/
	* module.c (module_state::{push,pop}_location): Set and restore
	input_location.
	(make_module_file): Lose module_root prepending.
	(do_module_import): Always set module location.
	(declare_module): Create location and filename.
	(finish_module): Adjust.

From-SVN: r257241
2018-01-31 16:02:36 +00:00
Nathan Sidwell
b57a84551b Staticize instrumentation
Staticize instrumentation
	gcc/cp/
	* module.c (bytes_out): Staticize spans, lengths, is_set.
	(bytes_out::instrument): Make static.
	(cpms_out): Staticize unique, refs, nulls, records.
	(cpms_out::instrument): Make static.  Adjust.

From-SVN: r257239
2018-01-31 15:09:57 +00:00
Nathan Sidwell
dfe4e1f8b6 Separate dumper object
Separate dumper object
	gcc/cp/
	* cp-tree.h (dump, print_other_binding_stack): Undeclare.
	* name-lookup.c (print_other_binding_stack): Make static.
	* module.c (class dumper): New.
	(cpm_serial): Remove dumping machinery here.  Adjust all uses.
	gcc/testsuite/
	* g++.dg/modules/mod-imp-1_[abcd].C: Adjust dump scans.

From-SVN: r257236
2018-01-31 14:44:47 +00:00
Nathan Sidwell
e2b29f51f7 Start refactoring cpm_serial
Start refactoring cpm_serial
	gcc/cp/
	* module.c (cpms_{in,out}::elf): Pointer to elf object,
	(cpms_{in,out}::get_elf): New.  Use it.
	(do_module_import, finish_module): Adjust.

From-SVN: r257231
2018-01-31 12:11:57 +00:00
Nathan Sidwell
152e2388c3 module.c (data::release): Return NULL, update users.
gcc/cp/
	* module.c (data::release): Return NULL, update users.
	(cpms_in::{mod_ix,crc}): Delete, adjust users.

From-SVN: r257201
2018-01-30 19:29:31 +00:00
Nathan Sidwell
c7e8d635cb Reorder source
Reorder source
	gcc/cp/
	* module.c (struct data): First.
	(class elf, elf_in & elf_out): Next.

From-SVN: r257200
2018-01-30 19:10:39 +00:00
Nathan Sidwell
eab54b2ad2 module.c (module_state): Remove name_hash, crc_known, set_crc, set_location.
gcc/cp/
	* module.c (module_state): Remove name_hash, crc_known, set_crc,
	set_location.
	(cpms_in::{read,header}): Add crc_ptr arg.
	(do_module_import): Expected CRC is a pointer.
	(cpms_in::imports): Adjust.

From-SVN: r257198
2018-01-30 19:01:38 +00:00
Nathan Sidwell
00f9ca5209 Push remaps as they happen.
gcc/cp/
	* module.c (cpms_{in,out}::imports): Write in ascending order.

From-SVN: r257197
2018-01-30 18:33:01 +00:00
Nathan Sidwell
9e69db3cd9 Move remap vector into module state.
gcc/cp/
	* module.c (module_state): Add remap;
	(cpms_in): Remove remap_num, remap_vec.
	(module_state::release): New.
	(cpms_in::{imports,tree_node,read}): Adjust.
	(finish_module): Release module state.

From-SVN: r257196
2018-01-30 18:23:52 +00:00
Nathan Sidwell
77fb822160 module.c (bytes_out::end): Create PROGBITS or STRTAB.
gcc/cp/
	* module.c (bytes_out::end): Create PROGBITS or STRTAB.
	(cpms_out::write): README is a STRTAB.

From-SVN: r257192
2018-01-30 17:21:55 +00:00
Nathan Sidwell
97c9bbe2a8 Remove SYMTAB knowledge, the README is better.
gcc/cp/
	* module.c (elf_out::symtab): Delete.
	(elf_out::end): Adjust.
	(cpms_out::imports): Don't create symtab.

From-SVN: r257191
2018-01-30 16:51:56 +00:00
Nathan Sidwell
936de93203 Section structure completish.
gcc/cp/
	* module.c (elf::isection): Add flags.
	(elf_out::add): Add section flags.
	(bytes_out::end): Likewise,
	(elf_out::end): Adjust.
	(cpms_out::bindings): Generate bindings section too.
	(cpms_out::write): Add imports to README.  Make string section.
	(cpms_in::read): Adjust.

From-SVN: r257189
2018-01-30 16:47:14 +00:00
Nathan Sidwell
1188296cbe Config in header
Config in header
	gcc/cp/
	* module.c (cpms_{in,out}::tag_conf): Delete.
	(cpms_{in,out}::header): Serialize host & target conf.
	(cpms_in::read, cpms_out::write): Adjust.

From-SVN: r257187
2018-01-30 14:04:36 +00:00
Nathan Sidwell
9f6a5ff969 Globals in header
Globals in header
	gcc/cp/
	* module.c (module_state::set_name): Kill string names.
	(cpms_{in,out}::tag_globals): Delete.
	(cpms_{in,out}::header): Do globals.  Add outer crc.
	(cpms_in::read): Absorb cpms_in::read_item.
	(search_module_path, do_module_import): Kill string names.

From-SVN: r257185
2018-01-30 13:42:47 +00:00
Nathan Sidwell
cb214728d2 Import table is separate section
Import table is separate section
	gcc/cp/
	* module.c (bytes): Reorganize CRC calcs.
	(struct elf::symbol): New.
	(struct elf_out::symtab): New.
	(elf_out::end): Deal with symbol table.
	(bytes_{in,out}::{begin,end}): Adjust crc calcs.
	(cpms_{in,out}::imports): New.
	(cpms_{in,out}::tag_import): Delete.
	(cpms_in::read, cpms_out::write): Adjust.

From-SVN: r257162
2018-01-29 20:56:41 +00:00
Nathan Sidwell
678d4e1076 Header is separate section
Header is separate section
	gcc/cp/
	* module.c (module_state_hash::equal): Remove string names.
	(elf_in::find): Find by name.
	(elf_in::name): New.
	(class elf_out::strtab): Rename type.
	(elf_out::strings): New member.
	(elf_in::begin): Veriy string table.  Create default.
	(elf_out::end): Write string table here.
	(bytes_in::begin, bytes_out::end): Always PROGBITS.
	(cpm_stream::rt_eof): Delete.
	(cpms_{in,out}::header): Repimlement.
	(cpms_in::read, cpms_out::write): Adjust.

From-SVN: r257157
2018-01-29 17:07:14 +00:00
Nathan Sidwell
a6716a1a68 Remove string-literal module names :(
Remove string-literal module names :(
	gcc/cp/
	* cp-tree.h (validate_module_name): Remove.
	* module.c (validate_module_name): Delete.
	(bytes_{in,out}::module_name): Delete, adjust callers.
	* parser.c (cp_parser_module_name): Adjust.
	(cp_parser_module_declaration, cp_parser_import_declaration)
	(cp_parser_module_proclamation): Adjust.
	gcc/testsuite/
	* g++.dg/modules/mod++-decl-3_[ab].C: Delete.

From-SVN: r257153
2018-01-29 15:30:53 +00:00
Nathan Sidwell
5252341951 {read,write}_module become member fns
{read,write}_module become member fns
	gcc/cp/
	* module.c (cpms_{in,out}::elf}: Direct member. Adjust ctors.
	(cpms_{in,out}::{begin,end}): New.
	(cpms_in::read, cpms_out::write): New.
	(read_module, write_module): Delete.
	(do_module_import, finish_module): Adjust.

From-SVN: r257151
2018-01-29 15:12:49 +00:00
Nathan Sidwell
db6e851467 README section
README section
	gcc/cp/
	* module.c (version2date, version2time, version2string): Moved
	from cpm_serial.
	(struct_data): Broken out of elf.
	(struct elf::isection): Remove link field.  Adjust all uses.
	(class elf_out::strings): New.
	(elf_out::add): New.
	(bytes_out::printf): New.
	(cpm_stream::dump, cpms_in::header): Adjust version handling.
	(write_module): Write README section.

From-SVN: r257148
2018-01-29 14:34:04 +00:00
Nathan Sidwell
d10c4838b4 Fix layering violation
Fix layering violation
	gcc/cp/
	* module.c (elf): Rename bad -> set_error.
	(elf_out, elf_in): Update.
	(cpm_serial, cpm_writer, cpm_reader): Rename to ...
	(bytes, bytes_out, bytes_in): ... here.
	(bytes_{in,out}): Remove source, sink members.
	(bytes_in): Rename overran -> get_overrun.  Add end, set_overrun.
	Delete bad, get_error.  Adjust users.
	(cpms_in, cpms_out): Add elf field.  Adjust.

From-SVN: r257140
2018-01-29 12:01:19 +00:00
Nathan Sidwell
09d2950be3 Simplify buffer filling & drainging
Simplify buffer filling & drainging
	gcc/cp/
	* module.c (cpm_serial): Add begin, end, use, unuse.
	(cpm_writer): Add use, unuse, begin, end.  Delete reserve, flush,
	seek, tell, checkpoint.
	(cpm_reader): Add overrun, use, begin, overran.  Delete fill,
	checkpoint.
	(cpm_{reader,writer}): Update all seralizers.
	(cpms_{in,out}): Remove checkpointing.

From-SVN: r257106
2018-01-26 20:36:49 +00:00
Nathan Sidwell
0fabc76b1e CRC at section level
CRC at section level
	gcc/cp/
	* module.c (elf::data): Add crc routines.
	(cpm_serial): Remove crc routines.
	(cpm_in, cpm_out): Don't calculate crcs.
	(read_module, write_module): Adjust (incomplete).

From-SVN: r257103
2018-01-26 18:40:22 +00:00
Nathan Sidwell
05143ffa2e BMI is ELF
BMI is ELF
	gcc/cp/
	* module.c (get_version): Moved from cpm_stream::version.
	(struct non_null_hash, ptr_uint_traits, ptr_uint_hash_map)
	uint_ptr_traits, uint_ptr_hash_map): New.
	(elf, elf_in, elf_out): New classes.
	(cpm_serial, cpm_in, cpm_out): Modify (incomplete).
	(cpms_in, cpms_out): Adjust.
	(read_module, write_module, finish_module): Adjust.

From-SVN: r257099
2018-01-26 16:25:28 +00:00
Nathan Sidwell
bb667da354 comments
From-SVN: r257026
2018-01-24 17:59:50 +00:00
Nathan Sidwell
41d56717cf Global tree via crc
Global tree via crc
	gcc/cp/
	* module.c (cpm_stream): Add globals & globals_crc.
	(cpm_stream::next): Add default arg.
	(cpm_stream::cpm_stream): Lazily init globals vector.
	(cpms_{in,out}::mark_present, globals): Delete.
	(cpms_{in,out}::tag_globals): Reimplement.
	(cpms_in::tree_node_special): Read global tree directly.
	* name-lookup.c (extract_module_bindings): Skip RTTI types.

From-SVN: r257024
2018-01-24 16:40:52 +00:00
Nathan Sidwell
50356907cb module.c (module_state): Replace direct_import with imported & exported flags.
gcc/cp/
	* module.c (module_state): Replace direct_import with imported &
	exported flags.
	(module_state::do_import): Adjust.
	(enum import_kind): Delete.
	(do_module_import): Adjust.
	(cpms_{in.out}::tag_import): Adjust.
	(module_interface_p, import_module, declare_module)
	(finish_module): Adjust.

From-SVN: r257015
2018-01-24 12:21:44 +00:00
Nathan Sidwell
d2fb4f2cbb Static bindings not visible in imports
Static bindings not visible in imports
	gcc/cp/
	* name-lookup.h (decapsulate_binding): Delete.
	(module_binding_vec, extract_module_bindings): Declare.
	* module.c (cpms_{in,out}::tag_binding): Reimplement.
	(cpms_out::bindings): Likewise.
	* name-lookup.c (decapsulate_binding): Delete.
	(extract_module_bindings): New.
	gcc/testsuite/
	* g++.dg/modules/mod++-decl-0_c.C: Remove XFAIL.
	* g++.dg/modules/static-1_[abc].C: New.

From-SVN: r256992
2018-01-23 17:52:53 +00:00
Nathan Sidwell
8919cd65dc tree.c (ovl_insert): No need to sort by USING_P.
gcc/cp/
	* tree.c (ovl_insert): No need to sort by USING_P.
	(ovl_iterator::reveal_node): Likewise.

From-SVN: r256962
2018-01-22 20:45:19 +00:00
Nathan Sidwell
ae3cc5e68d Broken
From-SVN: r256950
2018-01-22 15:11:02 +00:00
Nathan Sidwell
1ac6195f3b Update bug reporting instructions
Update bug reporting instructions
	gcc/
	* configure.ac (ACX_BUGURL): Set new url
	* diagnostic.c (diagnostic_action_after_output): Special ICE
	instructions.
	* configure: Rebuilt.

From-SVN: r256946
2018-01-22 14:48:51 +00:00
Nathan Sidwell
a15e60ea47 Kill mangle_namespace.
gcc/cp/
	* cp-tree.h (CPTI_MANGLE, mangle_namespace): Delete.
	* decl.c (cxx_init_decl_processing): Don't create it.
	* module.c (cpms_out::bindings): Don't skip it.
	* name-lookup.c (suggest_alternatives_for): Likewise.

From-SVN: r256901
2018-01-19 21:29:20 +00:00
Nathan Sidwell
a743efc3e8 Import ident by type not index.
gcc/cp/
	* name-lookup.h (get_ident_in_namespace, get_ident_in_class,
	find_by_ident_in_namespace, find_by_ident_in_class): Delete.
	(lookup_by_ident): Declare.
	* name-lookup.c (get_ident_in_namespace, get_ident_in_class): Delete.
	(find_by_ident_in_namespace, find_by_ident_in_class): Replace with ...
	(lookup_by_ident): ... this.
	* module.c (cpms_{in,out}::ident_imported_decl): Delete.
	(cpms_out::tree_node): Write imported decl info directly.
	(cpms_in::tree_node): Use lookup_by_ident.

From-SVN: r256900
2018-01-19 21:07:09 +00:00
Nathan Sidwell
8c8388f02f module.c (cpms_{in.out}::tree_node_special): New, broken out of ...
gcc/cp/
	* module.c (cpms_{in.out}::tree_node_special): New, broken out of ...
	(cpms_{in,out}::tree_node): ... here.  Call them.

From-SVN: r256898
2018-01-19 19:50:57 +00:00
Nathan Sidwell
6c66698e0a Merge trunk r256894.
From-SVN: r256897
2018-01-19 18:52:46 +00:00
Nathan Sidwell
9ccd7ea09b Make-lang.in: Set MODULE_STAMP if non-branch experimental.
gcc/cp/
	* Make-lang.in: Set MODULE_STAMP if non-branch experimental.

From-SVN: r256893
2018-01-19 16:06:49 +00:00
Nathan Sidwell
51067667ab Beginnings of global module correctness
Beginnings of global module correctness
	gcc/cp/
	* cp-tree.h (struct mc_index): New.
	(module_cluster): Use it.
	(MODULE_VECTOR_SLOTS_PER_CLUSTER): New.
	(GLOBAL_MODULE_INDEX, THIS_MODULE_INDEX, IMPORTED_MODULE_BASE): Delete.
	(MODULE_INDEX_IMPORT_BASE): New.
	(DECL_MODULE_PURVIEW_P, MAYBE_DECL_MODULE_PURVIEW_P): New.
	(MAYBE_DECL_MODULE_INDEX): Adjust.
	(MODULE_INDEX_BITS): New.
	(struct lang_decl_base): Add module_purview_p field.
	* decl2.c (c_parse_final_cleanups): Adjust.
	* error.c (dump_module_suffix): Adjust.
	* mangle.c (maybe_write_module): Adjust.
	* module.c (MODULE_INDEX_IMPORTING, MODULE_INDEX_ERROR): New.
	(module_state::freeze): Delete.
	(this_module): Delete.  Replace with (*modules)[0].
	(cpms_in::alloc_remap_vec): Adjust.
	(cpms_in::tag_import): Use MODULE_INDEX_ERROR.
	(cpms_{in,out}::tag_binding): Lose MAIN_P parm.  Adjust.
	(cpms_in::define_function): Remove GLOBAL_MODULE_INDEX handling.
	(cpms_in::read_item): Use MODULE_INDEX_IMPORTING.
	(cpms_in::finish): Remove NODE_MODULE parm.  use
	MAYBE_DECL_MODULE_PURVIEW_P.
	(cpms_{in,out}::lang_decl_bools): Read & write module_purview_p.
	(cpms_in::tree_node_raw): Lose NODE_MODULE parm.  Set module
	directly.
	(cpms_{in,out}::tree_node): Adjust module identification.
	(cpms_out::bindings): Bindings are on a single slot.
	(module_loc): Delete.
	(decl_set_module): Set purview as needed.
	(module_purview_p, module_interface_p): Adjust.
	(read_module): Simplify.
	(do_module_import): Adjust for lack of global module slot.  Use
	MODULE_INDEX_ERROR, MODULE_INDEX_IMPORTING.  Detect already
	declared module here.
	(import_module): Adjust.
	(declare_module): Don't detect already declared here.
	(write_module): Adjust.
	(finish_module): Adjust.
	* name-lookup.c (module_binding_slot): Reimplement.
	(name_lookup::process_module_binding)
	(name_lookup::search_namespace_only, name_lookup::add_module_fns)
	(name_lookup::adl_namespace_only, do_pushdecl): Adjust.
	(merge_global_decl): Kludge into reworking.
	(push_module_binding): Likewise.
	* name-lookup.h (merge_global_decl): Add module parm.
	* pt.c (build_template_decl): Propagate purview.
	* ptree.c (cxx_print_xnode): Adjust.
	* rtti.c (tinfo_base_init): Kludge into working.
	(get_tinfo_desc): Drop unnecessary push/pop abi namespace.
	(emit_tinfo_decl): Simplify.
	gcc/testsuite/
	* g++.dg/modules/global-1_[ab].C: New
	* g++.dg/modules/mod++-decl-0_b.C: Remove xfail.

From-SVN: r256892
2018-01-19 16:05:49 +00:00
Nathan Sidwell
b7530dc806 Merge access & discriminator.
gcc/cp/
	* cp-tree.h (struct lang_decl_base): Rename u2sel to spare.
	(struct lang_decl_min): Replace lang_decl_u2 union with plain
	tree.
	(LANG_DECL_U2_CHECK): Delete.
	(DECL_DISCRIMINATOR_SET_P, DECL_DISCRIMINATOR): Adjust.
	(DECL_CAPTURED_VARIABLE, DECL_ACCESS, THUNK_VIRTUAL_OFFSET): Adjust.
	* decl.c (push_local_name): Represent discriminator as INTEGER_CST.
	(duplicate_decls): Copy DECL_ACCESS. fix formatting.
	* mangle.c (discriminator_for_local_entity): Extract integer value.
	* module.c (cpms_{in,out},lang_decl_bools): Drop u.base.u2sel.
	(cpms_{in,out}::lang_decl_vals): Drop u.min.u2 handling.
	* semantics.c (finish_omp_threadprivate): Drop u.base.u2sel copying.

From-SVN: r256843
2018-01-18 11:56:45 +00:00
Nathan Sidwell
c96a4298d2 Merge trunk r256078.
From-SVN: r256080
2018-01-02 16:50:44 +00:00
Nathan Sidwell
9f97937f5f decl.c (grokdeclarator): Set typedef's module/export.
Typedefs!
	gcc/cp/
	* decl.c (grokdeclarator): Set typedef's module/export.
	gcc/testsuite/
	* g++.dg/modules/tdef-2_[abc].C: New.

	gcc/testsuite/
	* g++.dg/modules/tdef-1_[ab].C: New.

From-SVN: r256078
2018-01-02 16:28:38 +00:00
Nathan Sidwell
d57b5c2ab4 tdef-1_[ab].C: New.
gcc/testsuite/
	* g++.dg/modules/tdef-1_[ab].C: New.

From-SVN: r256077
2018-01-02 15:36:43 +00:00
Nathan Sidwell
deee8a1718 decl.c (grokvardecl): Set exporting.
Variables!
	gcc/cp/
	* decl.c (grokvardecl): Set exporting.
	* module.c (dump_nested_name): Dump integer values.
	(cpms_{in,out}::define_var): New.
	(cpms_{in,out}::tag_definition): Deal with vars.
	(cpms_out::maybe_tag_definition): Likewise.
	(cpms_out::core_bools): Externalize static vars.
	(cpms_out::lang_decl_bools): Likewise for not-really-extern.
	gcc/testsuite/
	* g++.dg/modules/var-1_[ab].C: New.

From-SVN: r255903
2017-12-20 21:09:21 +00:00
Nathan Sidwell
588b1919e1 module.c (module_state::set_name): Don't deal with crc.
Enumerations!
	gcc/cp/
	* module.c (module_state::set_name): Don't deal with crc.
	(module_state::set_crc): New.
	(cpm_serial::get_crc): Don't obscure zero.
	(cpm_writer::tell): New.
	(cpms_out::crc_tell): New.
	(cpms_{in,out}::define_enum): New.
	(cpms_out::header): Save crc location.
	(cpms_in::header): Use set_crc.
	(cpms_out::tag_eof): Adjust.
	(cpms_out::maybe_tag_definition): Deal with enums.
	(cpms_{in,out}::tag_definition): Deal with enums.
	(cpms_{in,out}::core_vals): Do not write enum bits.
	(do_module_import): Use set_crc.
	* name-lookup.c (push_module_binding): Fix assert.
	gcc/testsuite/
	* g++.dg/modules/enum-1_[ab].C: New.

From-SVN: r255897
2017-12-20 16:44:12 +00:00
Nathan Sidwell
3c16940325 Merge trunk r255836.
From-SVN: r255838
2017-12-19 20:20:10 +00:00
Nathan Sidwell
595f797500 Merge trunk r255166.
From-SVN: r255168
2017-11-27 14:09:37 +00:00
Nathan Sidwell
ed8512b419 Non-type template parms, & nested template classes.
gcc/cp/
	* module.c (cpms_{in,out}::core_vals): Deal with CONST_DECLs.
	gcc/testsuite/
	* g++.dg/modules/tplmem-3_[ab].C: New.

From-SVN: r255060
2017-11-22 14:07:31 +00:00
Nathan Sidwell
ebe5a3f87e Member types
Member types
	gcc/testsuite/
	* g++.dg/modules/nested-2_[ab].C: New

From-SVN: r255015
2017-11-21 16:51:06 +00:00
Nathan Sidwell
5477b59fe3 Nested classes.
gcc/cp/
	* module.c (cpm_reader::wi): Promote before shifting.
	(cpms_out::define_class): Maybe define all members.
	(cpms_out::maybe_tag_definition): Only implicit typedefs are
	defined.
	(cpms_{in.out}::core_vals): Don't stream value cache.
	gcc/testsuite/
	* g++.dg/modules/nested-1_[abc].C: New

From-SVN: r255014
2017-11-21 16:30:00 +00:00
Nathan Sidwell
37479f2394 Merg trunk r254959.
From-SVN: r254962
2017-11-20 18:02:29 +00:00
Nathan Sidwell
328625fc42 Template member functions.
gcc/cp/
	* cp-tree.h (TI_PENDING_TEMPLATE_FLAG): Add TI_CHECK.
	* module.c (cpms_out::maybe_tag_definition): Check DECL_INITIAL,
	write clones.
	(cpms_in::tag_definition): Don't zap clones.
	(cpms_in::finish): Clear TI_PENDING_TEMPLATE_FLAG.
	(cpms_{in,out}::core_vals): Check tcc_unary, tcc_binary.
	* optimize.c (maybe_clone_body): Don't alias when modules.
	gcc/testsuite/
	* g++.dg/modules/tplmem-1_[ab].C: New.

From-SVN: r254959
2017-11-20 16:28:38 +00:00
Nathan Sidwell
34f712760a module.c (cpms_out::tree_node): Fix conv-op identifiers.
gcc/cp/
	* module.c (cpms_out::tree_node): Fix conv-op identifiers.
	gcc/testsuite/
	* g++.dg/modules/convop-1_[ab].C: New.

From-SVN: r254891
2017-11-17 18:38:07 +00:00
Nathan Sidwell
01cabaf626 cp-tree.h (check_constexpr_fundef, [...]): Declare.
Constexprs!
	gcc/cp/
	* cp-tree.h (check_constexpr_fundef, find_constexpr_fundef): Declare.
	* constexpr.c (find_constexpr_fundef): New.
	(register_constexpr_fundef): Split checking off to ...
	(check_constexpr_fundef): ... here.  Call
	register_constexpr_fundef.
	* decl.c (): Adjust.
	* module.c (cpms_{in,out}::define_function): Serialize constexpr
	body.
	(cpms_{in,out}::core_vals): Serialize function-scope var initializers.
	gcc/testsuite/
	* g++.dg/modules/cexpr-[12]_[ab].C: New.

From-SVN: r254841
2017-11-16 18:44:23 +00:00
Nathan Sidwell
200d92b986 Merge trunk r254823.
From-SVN: r254824
2017-11-16 15:09:10 +00:00
Nathan Sidwell
a7efb6655a Merge trunk r254819.
From-SVN: r254822
2017-11-16 14:47:33 +00:00
Nathan Sidwell
e87c7f0382 Virtual bases!
gcc/cp/
	* Make-lang.in: module.o depends on revision
	* class.c (layout_class_type): Unnamed types do not get base
	types.
	* cxx-module-wrapper.sh: Invoke make.  Strip bad args.
	* module.c (module_context): Allow NULL context.
	(cpms_{in,out}::define_class): Deal with classtype_as_base.
	(cpms_{in,out}::tag_definition): Allow raw class.
	(cpms_{in,out}:ident_imported_decl: Rework class scope.
	(cpms_out::tree_node): Deal with NULL module context.
	* name-lookup.c (maybe_lazily_declare): Break out of ...
	(get_class_binding): ... here.  Call it.
	(get_ident_in_class, find_by_ident_in_class): New.
	* name-lookup.h	(get_ident_in_class, find_by_ident_in_class): Declare.
	gcc/testsuite/
	* g++.dg/modules/class-7_[abc].C: New.
	* g++.dg/modules/main.cc: Move to ...
	* g++.dg/modules/main_a.C: ... here. Adjust.
	* g++.dg/modules/modules.exp: Remove main.cc exceptionalism.

From-SVN: r254399
2017-11-03 20:59:40 +00:00
Nathan Sidwell
bcd2f9cb7b module.c (module_state): Add filename & loc.
gcc/cp/
	* module.c (module_state): Add filename & loc.
	(module_state::{set,push,pop}_location): New.
	(cpm_stream): Add state member.  Adjust.
	(cpms_{in,out}): Adjust.
	(cpms_in::{header,tag_conf}): Adjust.
	(read_module, write_module): Lose fname arg.
	(search_moule_path): Don't prefix .
	(do_module_import, finish_module): Set location.
	gcc/
	* diagnostic.c (maybe_line_and_column): New.
	(diagnostic_get_location_text, diagnostic_report_current_module):
	Use it.
	gcc/testsuite/
	Markup no-column tests.

From-SVN: r254107
2017-10-26 15:37:20 +00:00
Nathan Sidwell
9643841fc6 cxx-module-wrapper.sh: Cleanups.
gcc/cp
	* cxx-module-wrapper.sh: Cleanups.
	* module.c (cpm_stream::global_tree_arys): Add integer_types.
	(cpms_{in,out}::tree_node): Robustify.
	(read_module): Note end of importing.
	(search_module_path): Note if wrapper failed to install.
	* name-lookup.c (merge_global_decl): Zap anticipated decl here ...
	(push_module_binding): ... not here.
	gcc/
	* incpath.c (clean_cxx_module_path): Correct env var name.
	gcc/c-family/
	* c.opt (fmodules++): Add Driver.
	gcc/testsuite/
	* g++.dg/modules/{main.c,hello.cc}: New.
	* g++.dg/modules/modules.exp: Special case main.cc

From-SVN: r254048
2017-10-24 15:38:16 +00:00
Nathan Sidwell
163682c195 Wrapper program
Wrapper program
	gcc/
	* doc/invoke.texi (fmodule-root, fmodule-path, fmodule-wrapper):
	Document.
	* gcc.c (driver::maybe_putenv_CXX_MODULE_WRAPPER): New.
	(driver::main): Call it.
	* gcc.h (driver::maybe_putenv_CXX_MODULE_WRAPPER): Declare.
	* incpath.h (clean_cxx_module_path): Add multilib parm.
	* incpath.c (add_path): Initialize length.
	(clean_cxx_module_path): Append multilib fragment.  Add '.'.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Pass multilib suffx to
	clean_cxx_module_path.
	* c.opt (fmodules): Notify driver.
	(fmodule-hook): Rename to  ...
	(fmodule-wrapper): ... here.
	gcc/cp/
	* Make-lang.in (cxx-module-wrapper): New program.
	* cxx-module-wrapper.sh: New.
	* module.c: Include libiberty.h, tree-diagnostic.h.
	(read_module): Add announcement.
	(module_to_filename): Identifier mapping does not depend on
	module_path.
	(search_module_path): Shell out to wrapper function.
	(do_module_import): Adjust.
	(init_module_processing): Default flag_module_wrapper.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Adjust.

From-SVN: r254023
2017-10-23 19:19:38 +00:00
Nathan Sidwell
10504718bb Template class!
gcc/cp/
	* decl.c (xref_tag_1): Don't decl_set_module here.
	* module.c (cpms_in::define_function): Check templatedness.
	(cpms_{in,out}::define_class): Add maybe_template arg. Add
	templatey bits.
	(cpms_out::maybe_tag_definition): Deal with template classes.
	{cpms_{in,out}::tag_definition): Add maybe_template arg, adjust.
	{cpms_{in,out}::core_vals): Write record template_info.
	* name-lookup.c (set_class_binding): Protect against empty
	member_vec.
	(do_pushtag): Call decl_set_module here.
	* pt.c (build_template_decl): Copy module bits here ...
	(push_template_decl_real): ... not here.
	gcc/testsuite/
	* g++.dg/modules/mod-tpl-2_[ab].C: New.

From-SVN: r253963
2017-10-20 22:28:56 +00:00
Nathan Sidwell
bdc335392e Early CRC not time stamps.
gcc/cp/
	* decl.c (xref_tag_1): Don't decl_set_module here.
	* module.c (module_state::set_name): CRC too.
	(cpm_serial::get_crc): New.
	(cpm_writer::seek): New.
	(cpm_{reader,writer}::bytes4): Rename to ...
	(cpm_{reader,writer}::raw): ... this.  Adjust all users.
	(cpm_reader::get_crc): Delete.
	(module_state::stamp): Replace with ...
	(module_state::crc): ... this.
	(cpms_in::cpms_in): Drop stamp arg.
	(cpms_{in,out}::header): Deal with CRC not timestamp.
	(time2str, timestamp_mismatch): Delete.
	(cpms_{in,out}::tag_eof): Deal with crc.
	(cpms_{in,out}::tag_import): Drop timestamp.
	(read_module, do_module_import): Likewise. Use CRC.
	gcc/testsuite/
	* g++.dg/modules/mod-stamp-1_d.C: Adjust.

From-SVN: r253962
2017-10-20 22:22:34 +00:00
Nathan Sidwell
579d1325de Merge trunk r253954.
From-SVN: r253957
2017-10-20 19:29:31 +00:00
Nathan Sidwell
f6b53630bd tree.h (MARK_TS_TYPE_NON_COMMON): New.
Templates!
	gcc/
	* tree.h (MARK_TS_TYPE_NON_COMMON): New.
	gcc/cp/
	* cp-objcp-common.c (cp_common_init_ts): Fix
	TEMPLATE_TEMPLATE_PARM, TEMPLATE_TYPE_PARM,
	BOUND_TEMPLATE_TEMPLATE_PARM marking.
	* cp-tree.h (canonical_type_parameter): Declare.
	* module.c (cpms_{in,out}::define_function): Add maybe_template
	parm, adjust.
	(cpms_out::maybe_tag_definition): Allow function templates.
	(cpms_{in,out}:tag_definition): Allow templates.
	(cpms_{in,out}::core_vals): Stream more nodes.
	(cpms_{in,out}::lang_decl_vals): Stream more nodes.
	(cpms_in::finish_type): Deal with TEMPLATE_TYPE_PARM,
	TEMPLATE_TEMPLATE_PARM.
	* pt.c (canonical_type_parameter): Make extern, simplify.
	(push_template_decl_real): Propagate exportednes.
	gcc/testsuite/
	* g++.dg/modules/mod-tpl-1_[ab].C: New.

From-SVN: r253722
2017-10-13 11:56:31 +00:00
Nathan Sidwell
bc312c35ae cp-tree.h (TS_CP_BINDING, [...]): Delete.
gcc/cp/
	* cp-tree.h (TS_CP_BINDING, TS_CP_WRAPPER, LAST_TS_CP_ENUM): Delete.
	(union lang_tree_node): Adjust GTY desc.
	(cp_tree_node_structure): Take a tree_code.
	* decl.c (cp_tree_node_structure): Take a tree_code.
	* module.c (cpms_{out,in}::core_vals): Order clauses from
	tree-core.h, use cp_tree_node_structure for C++.

From-SVN: r253689
2017-10-12 17:43:13 +00:00
Nathan Sidwell
3e328935bb Module name can be a string const (-fmodules++)
Module name can be a string const (-fmodules++)
	gcc/cp/
	* cp-tree.h (cp_expr): Add constant operator* and operator->.
	(validate_module_name): New.
	(declare_module, import_module): Take cp_expr.
	* error.c (dump_module_suffix): Adjust.
	* module.c (module_state): Add name_hash.  Adjust.
	(module_state_hash): Allow string consts.
	(module_state::set_name): Likewise.
	(cpm_{writer,reader}::module_name): New.
	(dump_nested_name): Name can be a string const.
	(cpms_{out,in}::header): Adjust.
	(cpms_{out,in}::tag_import): Adjust.
	(validate_module_name): New.
	(module_to_filename): Allow string consts.
	(make_module_file): Adjust.
	(do_module_import): Adjust.
	(import_module, declare_module): Adjust.
	* parser.c (cp_parser_module_name): Return cp_expr, allow
	string-cst.
	(cp_parser_module_declaration, cp_parser_import_declaration,
	cp_parser_module_proclamation): Adjust.
	gcc/testsuite/
	* g++.dg/modules/modules.exp (dg-module-bmi): Renamed.
	* g++.dg/modules/mod++-decl-3_[ab].C: New.

From-SVN: r253683
2017-10-12 15:32:28 +00:00
Nathan Sidwell
96d02bc2b1 Add -fmodule-path, -fmodule-root.
gcc/
	* incpath.h (INC_CXX_MPATH): New.
	(clean_cxx_module_path): Declare.
	* incpath.c (clean_cxx_module_path): New.
	gcc/cp/
	* cp-tree.h (init_module_processing): Declare.
	* decl.c (cxx_init_decl_processing): Call init_module_processing.
	* module.c (module_path, module_path_max): New vars.
	(MOD_FNAME_PFX): Delete.
	(module_to_filename): Reimplement.
	(search_module_path, make_module_file): New.
	(do_module_import): Adjust.
	(init_module_processing): New.
	(finish_module): Adjust.
	gcc/c-family/
	* c-opts.c (c_common_handle_option): Process OPT_fmodule_path_.
	(c_common_post_options): Clean module path.
	* c.opt (fmodule-root=, fmodule-path=, fmodule-hook=): New.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Adjust module name logic.

From-SVN: r253675
2017-10-12 11:13:15 +00:00
Nathan Sidwell
b6128ea03d Merge trunk r253654.
From-SVN: r253655
2017-10-11 18:46:53 +00:00
Nathan Sidwell
41dce3cc0f restore acceidentally reverted fragment
From-SVN: r253596
2017-10-10 16:56:51 +00:00
Nathan Sidwell
254f64988f Revert unintented partial commit
From-SVN: r253592
2017-10-10 16:43:04 +00:00
Nathan Sidwell
c91bb177e8 Merge trunk r253585.
From-SVN: r253588
2017-10-10 15:58:00 +00:00
Nathan Sidwell
adc3e2d5a8 c_common_handle_option: Handle fmodules++.
gcc/c-family/
	* c_common_handle_option: Handle fmodules++.
	* c.opt (fmodules): Make Uinteger.
	(fmodules++, fmodules-ts): New.
	gcc/cp/
	* parser.c (cp_parser_consume_semicolon_at_end_of_statement):
	Return success bool.
	(cp_parser_translation_unit): Adjust cp_parser_declaration_seq_opt
	call.
	(cp_parser_declaration_seq_opt): Add top_level parm, look for
	module-decl here.
	(cp_parser_module_declaration): Handle -fmodules++ syntax.
	(cp_parser_module_export): No need to handle module-declaration
	here ...
	(cp_parser_declaration): ... or here.
	gcc/
	* doc/invoke.texi (-fmodules++): Document.
	gcc/testsute/
	* g++.dg/modules/mod++-decl-0_[abc].C: New.
	* g++.dg/modules/mod++-decl-[12].C: New.
	* g++.dg/modules/mod-decl-1.C: Adjust expected error.

From-SVN: r253180
2017-09-25 23:41:24 +00:00
Nathan Sidwell
1361ebf680 Merge trunk 252831.
From-SVN: r252844
2017-09-15 20:11:07 +00:00
Boris Kolpackov
c9d956f552 Add -fmodule-output & -fmodule-file options.
gcc/c-family/
	* c.opt (-fmodule-output): New option.
	(-fmodule-file): New option.
	* c-common.h (module_output): Declare.
	(module_files): Declare.
	* c-common.c (module_output): New variable.
	(module_files): New variable.
	* c-opts.c (add_module_file): New function.
	* c-opts.c: Handle -fmodule-output and -fmodule-file.
	gcc/cp/
	* module.c (finish_module): If specified, use module_output as output
	file name.
	* module.c (do_module_import): Check module_files for a module name
	to file mapping before falling back to default.
	gcc/
	* doc/invoke.texi (C++ Dialect Options): Document -fmodule-output
	and -fmodule-file.

From-SVN: r250389
2017-07-20 14:26:42 +00:00
Nathan Sidwell
39dd9e4067 Merge trunk r250272.
From-SVN: r250273
2017-07-17 12:19:29 +00:00
Nathan Sidwell
e8ad501a6d Merge trunk r250159.
From-SVN: r250186
2017-07-13 15:18:27 +00:00
Nathan Sidwell
79f74f570d cp-tree.h (CLASSTYPE_CONSTRUCTORS, [...]): Use lookup_fnfields_slot_nolazy.
gcc/cp/
	* cp-tree.h (CLASSTYPE_CONSTRUCTORS, CLASSTYPE_DESTRUCTOR): Use
	lookup_fnfields_slot_nolazy.
	* search.c (lookup_fnfields_idx_nolazy): Don't use
	CLASSTYPE_CONSTRUCTORS, CLASSTYPE_DESTRUCTOR.

From-SVN: r249937
2017-07-03 19:29:52 +00:00
Nathan Sidwell
2476f920c9 class.c (type_has_user_declared_move_constructor, [...]): Delete, replace with:
gcc/cp/
	* class.c (type_has_user_declared_move_constructor,
	type_has_user_declared_move_assign): Delete, replace with:
	(classtype_has_user_move_assign_or_ctor_p): ... this.
	* cp-tree.h (type_has_user_declared_move_constructor,
	type_has_user_declared_move_assign): Delete, replace with:
	(classtype_has_user_move_assign_or_ctor_p): ... this.
	* method.c (maybe_explain_implicit_delete): Update.
	(lazily_declare_fn): Update.
	* tree.c (type_has_nontrivial_copy_init): Update.
	* search.c (lookup_fnfields_slot_nolazy): Don't try and complete
	the type.
	* pt.c (check_explicit_specialization): Use regular lookup.

From-SVN: r249936
2017-07-03 18:47:30 +00:00
Nathan Sidwell
d96559a024 class.c (maybe_warn_about_overly_private_class): Ignore copy/move ctors.
gcc/cp/
	* class.c (maybe_warn_about_overly_private_class): Ignore
	copy/move ctors.
	* semantics.c (classtype_has_nothrow_assign_or_copy_p): Use
	lookup_fnfields_slot for ctors.

From-SVN: r249932
2017-07-03 17:52:03 +00:00
Nathan Sidwell
42cfd553fe module.c (cpms_{out,in}::start): Don't deal with identifiers here.
gcc/cp/
	* module.c (cpms_{out,in}::start): Don't deal with identifiers
	here.
	(cpms_{out,in}::tree_node): Deal with identifiers specially.

From-SVN: r249921
2017-07-03 14:07:20 +00:00
Nathan Sidwell
c41a54ce0f Merge trunk r249852.
From-SVN: r249910
2017-07-03 13:26:06 +00:00
Nathan Sidwell
9f555fc654 Merge trunk r249835.
From-SVN: r249837
2017-06-30 12:17:47 +00:00
Nathan Sidwell
12bdfdeabc Merge trunk r249794.
From-SVN: r249796
2017-06-29 15:24:04 +00:00
Nathan Sidwell
f240af2a4c cp-tree.h (class_method_index_for_fn): Delete.
gcc/cp/
	* cp-tree.h (class_method_index_for_fn): Delete.
	* decl2.c (check_classfn): Use lookup_fnfields_slot, reimplement
	diagnostics.
	* name-lookup.h (lookup_all_conversions): Declare.
	* name-lookup.c (lookup_all_conversions): New.
	* pt.c (retrieve_specialization): Use lookup_fnfields_slot,
	lookup_all_conversions.
	* search.c (class_method_index_for_fn): Delete.
	gcc/testsuite/
	* g++.dg/concepts/memfun-err.C: Adjust.
	* g++.dg/cpp0x/decltype9.C: Adjust.
	* g++.dg/lookup/decl1.C: Adjust.
	* g++.dg/other/pr28432.C: Adjust.
	* g++.dg/parse/crash12.C: Adjust.
	* g++.dg/parse/enum3.C: Adjust.
	* g++.dg/parse/operator6.C: Adjust.
	* g++.dg/template/crash69.C: Adjust.
	* g++.dg/template/error27.C: Adjust.
	* g++.dg/template/error28.C: Adjust.
	* g++.dg/template/memfriend6.C: Adjust.
	* g++.old-deja/g++.mike/err1.C: Adjust.
	* g++.old-deja/g++.mike/p811.C: Adjust.
	* g++.old-deja/g++.other/crash25.C: Adjust.
	* g++.old-deja/g++.other/dtor4.C: Adjust.
	* g++.old-deja/g++.pt/t37.C: Adjust.

From-SVN: r249793
2017-06-29 15:13:27 +00:00
Nathan Sidwell
d114f65c55 Merge trunk r249779.
From-SVN: r249781
2017-06-29 11:43:58 +00:00
Nathan Sidwell
5b548b799b class.c (finish_struct): Use OVL_P.
gcc/cp/
	* class.c (finish_struct): Use OVL_P.
	* cp-tree.h (THIS_NAME, IN_CHARGE_NAME, VTBL_PTR_TYPE,
	VTABLE_DELTA_NAME, VTABLE_PFN_NAME): Delete.
	* decl.c (initialize_predefined_identifiers): Encode them here
	directly.  Rename cdtors consistently.
	(cxx_init_decl_processing): Name vtbl_ptr_type directly.
	* search.c (class_method_index_for_fn): No need to frob cdtor names.

From-SVN: r249779
2017-06-29 11:08:58 +00:00
Nathan Sidwell
b1fa94f301 cdtor name cleanup. expunge lookup_fnfields_1 use.
gcc/
	* builtins.c (fold_builtin_FUNCTION) Use
	lang_hooks.decl_printable_name.
	gcc/cp/
	* call.c (build_new_method_call_1) Update cdtor handling.
	* class.c (get_basefndecls): Use lookup_fnfields_slot.
	* cp-tree.h (lookup_fnfields_1): Don't declare.
	* decl.c (register_dtor_fn): Use lookup_fnfields_slot.
	(grokfndecl): Set cdtor name.
	* method.c (implicitly_declare_fn): Adjust cdtor flag setting.
	* pt.c (check_explicit_specialization): Adjust cdtor checking, use
	lookup_fnfields_slot_nolazy.
	* search.c (lookup_fnfields_1): Make static.
	* semantics.c (classtype_has_nothrow_assign_or_copy_p): Use
	lookup_fnfields_slot.
	gcc/testsite/
	* g++.dg/cpp1y/builtin_FUNCTION.C: New.
	* g++.dg/plugin/decl-plugin-test.C: Adjust.

From-SVN: r249765
2017-06-28 22:37:15 +00:00
Nathan Sidwell
cd98475286 Merge trunk r249746.
From-SVN: r249747
2017-06-28 16:38:09 +00:00
Nathan Sidwell
4d6547528c cp-tree.h (SET_CLASS_TYPE_P): Use RECORD_OR_UNION_CHECK.
gcc/cp/
	* cp-tree.h (SET_CLASS_TYPE_P): Use RECORD_OR_UNION_CHECK.
	(NON_UNION_CLASS_TYPE_P): Just check for RECORD_TYPE.
	* call.c (check_dtor_name): Adjust constructor_name check.
	(name_as_c_string): Move const cast.
	(build_new_method_call_1): Use constructor_name from basetype.
	* class.c (get_vfield_name): Measure constructor_name length.
	(build_self_reference): Don't use constructor_name here.
	* cxx-pretty-print.c (is_destructor): Delete.
	(pp_cxx_unqualified_id): Remove bogus dtor code.
	* decl.c (grokdeclarator): Minor cleanup.
	* method.c (implicitly_declare_fn): Use ctor_identifier and
	dtor_identifier.
	* name-lookup.c (constructor_name): Reimplement.
	(constructor_name_p): Likewise.
	(push_class_level_binding_1): Don't use constructor_name here.
	* parser.c (cp_parser_direct_declarator): Reformat to avoid
	nesting ifs.
	* pt.c (tsubst_decl <FUNCTION_DECL>): Move var decls to
	initialization point.  Don't unnecessarily check for ctor name.
	gcc/c-family/
	* c-common.c (resort_field_decl_cmp): Don't declare.

From-SVN: r249746
2017-06-28 16:33:11 +00:00
Nathan Sidwell
411ea20f1d Merge trunk r249702.
gcc/c-family/
	* c-common.h (field_decl_cmp, resort_sorted_fields): Delete.
	* c-common.c (field_decl_cmp, resort_data,
	resort_field_decl_cmp): Move to c-decl.c.
	gcc/c/
	* c-decl.c (field_decl_cmp, resort_data,
	resort_field_decl_cmp): Moved from c-common.c

From-SVN: r249705
2017-06-27 18:16:07 +00:00
Nathan Sidwell
11692a542d Replace lang_type::sorted_fields with lang_type::bindings.
gcc/cp/
	* cp-tree.h (lang_type): Delete sorted_fields.  Add bindings
	field.
	(CLASSTYPE_SORTED_FIELDS): Replace with ...
	(CLASSTYPE_BINDINGS): ... this.
	* name-lookup.c (lookup_class_member): Reimplement.
	(count_fields): Delete.
	(sorted_fields_type_new): Delete.
	(add_class_member): New.
	(add_fields_to_record_type): Replace with ...
	(add_class_members): ... this.
	(add_enum_fields_to_record_type): Delete.
	(create_classtype_sorted_fields): Replace with ...
	(set_class_bindings): ... this.
	(insert_late_enum_def_into_classtype_sorted_fields): Replace with
	...
	(insert_late_enum_def_bindings): ... this.
	* name-lookup.h (create_classtype_sorted_fields)
	insert_late_enum_def_into_classtype_sorted_fields): Replace with
	...
	(set_class_bindings, insert_late_enum_def_bindings): ... this.
	* ptree.h (cxx_print_type): Don't print SORTED_FIELDS.
	* search.c (lookup_field_1): Check CLASSTYPE_BINDINGS.
	* decl.c (finish_enum_value_list): Use
	insert_late_enum_def_bindings.
	* class.c (finish_struct_1): Use set_class_bindings.
	* module.c (cpms_in::define_class): Likewise.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/c-family/c-common.h
M    gcc/c-family/c-common.c
M    gcc/c/c-decl.c
M    gcc/c/c-lang.h
M    gcc/cp/ptree.c
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h
M    gcc/cp/module.c
M    gcc/cp/decl.c
M    gcc/cp/class.c
M    gcc/cp/search.c

From-SVN: r249666
2017-06-26 19:52:37 +00:00
Nathan Sidwell
b42ddf51d9 Start moving class name lookup around
Start moving class name lookup around
	gcc/cp/
	* class.c (count_fields, add_fields_to_record_type)
	add_enum_fields_to_record_type, sorted_fields_type_new,
	create_classtype_sorted_fields,
	insert_late_enum_def_into_classtype_sorted_fields): Move to ...
	* name-lookup.c: ... here.
	(lookup_class_member): New.  Broken out of ...
	* search.c (lookup_field_1): ... here.  Call it.
	* name-lookup.h (lookup_class_member)
	create_classtype_sorted_fields,
	insert_late_enum_def_into_classtype_sorted_fields): Declare.
((--This line, and those below, will be ignored--

M    gcc/cp/name-lookup.h
M    gcc/cp/class.c
M    gcc/cp/search.c
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    ChangeLog.modules

From-SVN: r249661
2017-06-26 17:42:46 +00:00
Nathan Sidwell
a9cf7782f6 Merge trunk r249657.
From-SVN: r249658
2017-06-26 16:51:14 +00:00
Nathan Sidwell
5eb957a398 cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
gcc/cp/
	* cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
	* module.c (cpms_{out,in}::lang_decl_bools: Likewise.
	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Don't set
	DECL_ASSIGNMENT_OPERATOR_P.

From-SVN: r249654
2017-06-26 14:46:43 +00:00
Nathan Sidwell
9491b1d747 delete
From-SVN: r249653
2017-06-26 14:44:54 +00:00
Nathan Sidwell
c966f92798 Makefile.in (MODULE_STAMP): Set here
gcc/
	* Makefile.in (MODULE_STAMP): Set here
	(REVISION, REVISION_c): Override.
	gcc/cp/
	* Make-lang.in (MODULE_STAMP): Not here.

From-SVN: r249652
2017-06-26 14:44:27 +00:00
Nathan Sidwell
1a3e85ce84 missed changelog
From-SVN: r249646
2017-06-26 12:32:10 +00:00
Nathan Sidwell
f8ac9f9c33 cp-tree.h (DECL_COMPLETE_CONSTRUCTOR_P): Directly compare identifier.
gcc/cp/
	* cp-tree.h (DECL_COMPLETE_CONSTRUCTOR_P): Directly compare
	identifier.
	(DECL_BASE_CONSTRUCTOR_P, DECL_COMPLETE_DESTRUCTOR_P,
	DECL_BASE_DESTRUCTOR_P, DECL_DELETING_DESTRUCTOR_P): Likewise.
	(DECL_ASSIGNMENT_OPERATOR_P): Use IDENTIFIER_ASSIGN_OP_P.
	* decl.c (grok_op_properties): Adjust identifier checking.
	* init.c (expand_default_init): Adjust identifier descision.
	* method.c (implicitly_declare_fn): Don't use
	DECL_ASSIGNMENT_OPERATOR_P.
	* search.c (lookup_fnfields_1): Use IDENTIFIER_CTOR_P,
	IDENTIFIER_DTOR_P.
	* call.c (in_charge_arg_for_name): Reimplement.
	(build_special_member_call): Use IDENTIFIER_CDTOR_P,
	IDENTIFIER_DTOR_P.

From-SVN: r249587
2017-06-23 12:29:19 +00:00
Nathan Sidwell
3dd962a721 Merge trunk r249572.
From-SVN: r249573
2017-06-22 19:02:58 +00:00
Nathan Sidwell
1f0a82ed14 Reorder IDENTIFIER flags
Reorder IDENTIFIER flags
	gcc/cp/
	* cp-tree.h (enum cp_identifier_kind): New.
	(IDENTIFIER_KIND_BIT_0, IDENTIFIER_KIND_BIT_1)
	IDENTIFIER_KIND_BIT_2): New.
	(IDENTIFIER_MARKED): Move to TREE_LANG_FLAG_4.
	(IDENTIFIER_VIRTUAL_P, IDENTIFIER_REPO_CHOSEN): Add
	IDENTIFIER_CHECK.
	(C_IS_RESERVED_WORD): Replace with ...
	(IDENTIFIER_KEYWORD_P): ... this.
	(IDENTIFIER_CTOR_OR_DTOR_P): Replace with ...
	(IDENTIFIER_CDTOR_P): ... this.
	(IDENTIFIER_CTOR_P, IDENTIFIER_DTOR_P): New.
	(IDENTIFIER_OPNAME_P): Replace with ...
	(IDENTIFIER_ANY_OP_P): ... this.
	(IDENTIFIER_ASSIGN_OP_P): New.
	(IDENTIFIER_TYPENAME_P): Replace with ...
	(IDENTIFIER_CONV_OP_P): ... this.
	(NEW_DELETE_OPNAME_P): Replace with ...
	(IDENTIFIER_NEWDEL_OP_P): ... this.
	(DECL_CONV_FN_P, DECL_OVERLOADED_OPERATOR_P): Adjust.
	(get_identifier_kind_name, set_identifier_kind): Declare.
	* lex.c (get_identifier_kind_name, set_identifier_kind): New.
	(init_operators): Adjust to avoid keywords, use
	set_identifier_kind. Copy TYPE_EXPR slot.
	(init_reswords): Call set_identifier_kind.
	(unqualified_name_lookup_error): Adjust.
	* operators.def (TYPE_EXPR): Remove.
	* decl.c (struct predefined_identifier): Move into ...
	(initialize_predefined_identifiers): ... here.  Call
	set_identifier_kind.
	(grokfndecl, check_var_type, grokdeclarator): Adjust.
	(grok_op_properties): Use IDENTIFIER_ANY_ASSIGN_OP to halve search
	space.  Adjust.
	* call.c (name_as_c_string): Adjust.
	(build_new_method_call_1): Likewise.
	* cp-cilkplus.c (is_conversion_operator_function_decl_p):
	Likewise.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Adjust.
	* dump.c (cp_dump_tree): Adjust.
	* error.c (dump_decl_name): Adjust.
	* mangle.c (write_unqualified_id, write_member_name)
	write_expression): Adjust.
	(mangle_conv_op_name_for_type): Use set_identifier_kind.
	* name-lookup.c (do_class_using_decl): Adjust.
	(lookup_name_fuzzy, lookup_name_real_1): Likewise.
	* parser.c (cp_lexer_get_preprocessor_token)
	cp_parser_direct_declarator): Likewise.
	* pt.c (push_template_decl_real, tsubst_decl, tsubst_baselink)
	tsubst_copy, tsubst_copy_and_build): Adjust.
	* ptree.c (cxx_print_identifier): Print identifier kind.
	* search.c (lookup_field_r, lookup_member)
	lookup_fnfields_idx_nolazy): Adjust.
	* semantics.c (finish_id_expression): Adjust..
	* typeck.c (cp_build_addr_expr_1): Adjust.

From-SVN: r249570
2017-06-22 17:47:39 +00:00
Nathan Sidwell
ef36381f21 Merge trunk r249464.
From-SVN: r249465
2017-06-21 17:50:30 +00:00
Nathan Sidwell
ece30ddd03 c-ada-spec.c (decl_sloc): Ignore builtin fields.
gcc/c-family/
	* c-ada-spec.c (decl_sloc): Ignore builtin fields.
	gcc/cp/
	* class.c (layout_class_type): Anon aggregates can never be bases.
	(finish_struct_1, dump_class_hierarchy_1): CLASSTYPE_AS_BASE can
	be null.
	* cp-tree.h (enum cp_tree_index): Add CPTI_AS_BASE_IDENTIFIER.
	(as_base_identifier): New.
	(module_context): Declare.
	* decl.c (initialize_predefined_identifiers): Initialize as_base.
	* error.c (dump_module_suffix): Use module_context.
	* mangle.c (maybe_write_module): Likewise.
	* module.c (module_context): New.
	(dump_nested_name): Distingush NULL context.
	(cpms_{in,out}::globals): Take array directly.
	(cpms_{in,out}::tree_node_raw): New, broken out of ...
	(cpms_{in,out}::tree_node): ... here.  Call it.  Use
	module_context.
	(cpms_in::finish): Add module number.  Adjust.
	(cpms_{in,out}::tag_trees): Write translation unit decl.

From-SVN: r249464
2017-06-21 16:54:25 +00:00
Nathan Sidwell
cadc8fe889 Merge trunk r249268.
From-SVN: r249269
2017-06-16 15:55:37 +00:00
Nathan Sidwell
ec1b8da11f Merge trunk r249217.
libcc1/
	* libcp1plugin.c (supplement_binding): Don't call
	maybe_remove_implicit_alias.

From-SVN: r249218
2017-06-15 12:31:24 +00:00
Nathan Sidwell
1bc969cd7a First bug report!
gcc/cp/
	* cp-tree.h (CPTI_MANGLE): New.
	(mangle_namespace): New.
	(maybe_remove_implicit_alias): Delete.
	* decl.c (cxx_init_decl_processing): Create mangle namespace.
	* decl2.c (generate_mangling_alias): Use mangle_namespace.
	* mangle.c (maybe_remove_implicit_alias): Delete.
	(mangle_decl): Use mangle_namespace. Remove alias here.
	* module.c (cpms_out::bindings): Ignore mangle_namespace.
	* name-lookup.h (set_namespace_binding): Declare.
	* name-lookup.c (supplement_binding_1): Don't deal with implicit
	aliases here.
	(set_namespace_binding): New.  Broken out of ...
	(set_global_binding): ... this.  Call it.
	(suggest_alternatives_for): Ignore mangle namespace.
	gcc/testuite/
	* g++.dg/module/bug-1_[ab].C: New.

From-SVN: r249216
2017-06-15 12:02:31 +00:00
Nathan Sidwell
f235906370 Classes complete - Vcall indices and friends added.
gcc/cp/
	* module.c (cpms_{out,in}::tree_pair_vec): New.
	(cpms_{out,in}::define_class): Stream vcall indices and friend
	list.
	gcc/testsuite/
	* g++.dg/module/class-6_[abc].C: New.

From-SVN: r249205
2017-06-14 19:36:49 +00:00
Nathan Sidwell
8f78d25e6c Merge trunk r249076.
From-SVN: r249118
2017-06-12 11:17:23 +00:00
Nathan Sidwell
5d5fd93e59 Vtable streaming. Change keyed_classes representation.
gcc/cp/
	* class.c (finish_struct_1): Adjust keyed_classes pushing.
	* cp-tree.h (CPTI_KEYED_CLASSES): Delete.
	(keyed_classes): Now a vector.
	* decl.c (keyed_classes): Define.
	(cxx_init_decl_processing): Initialize it.
	(record_key_method_defined): Adjust pushing.
	* decl2.c (decl_needed_p): Formatting fixes.
	(c_parse_final_cleanups): Reset current module.
	Call finish_module earlier.  Adjust keyed_classes iteration.
	* pt.c (instantiate_class_template_1): Adjust keyed_classes
	pushing.
	* module.c (cpms_{out,in}::define_class): Adjust key method
	streaming.
	(cpms_{out,in}::lang_type_bools): Don't srtream interface flags.
	gcc/testsuite/
	* g++.dg/modules/class-5_[abc].C: New.

From-SVN: r249076
2017-06-09 19:36:55 +00:00
Nathan Sidwell
a48e9755dc Typeinfo streaming
Typeinfo streaming
	gcc/cp/
	* cp-tree.h (DECL_TINFO_P): Also for TYPE_DECLs.
	(get_pseudo_tinfo_index, get_pseudo_tinfo_type): Declare.
	* rtti.c (enum tinfo_kind): Add TK_DERIVED_TYPES,
	TK_VMI_CLASS_TYPES, TK_MAX, delete TK_FIXED.
	(tinfo_names): New.
	(typeid_ok_p): Lool at TYPE_MAIN_VARIANT.
	(get_pseudo_to_index): Only determine index, don't create type.
	(get_tinfo_desc): New.  Create the pseudo type.  Set DCL_TINFO_P.
	(create_pseudo_type_info): Delete.
	(get_pseudo_ti_init): Use get_tinfo_desc.
	(get_pseudo_tinfo_index, get_pseudo_tinfo_type): New.
	(create_tinfo_types): Only allocate the vector.
	* module.c (cpms_{out,in}::insert): New.
	(cpm_stream::global_tree_arys): Add sizetype_tab.
	(cpms_out::tag_binding): Don't stream DECL_TINFO_P bindings.
	(cpms_{out,in}::define_class): Don't stream
	CLASSTYPE_TYPEINFO_VAR.  Stream CLASSTYPE_VTABLES.
	(cpms_{out,in}::core_vals): Stream CONSTRUCTORs.
	(cpms_{out,in}::tree_node): Detect DECL_TINFO_P things.

From-SVN: r249065
2017-06-09 17:08:40 +00:00
Nathan Sidwell
5745e25416 module.c (cpms_in::read_item, [...]): More diagnostics.
gcc/cp/
	* module.c (cpms_in::read_item, cpms_in::tree_node): More
	diagnostics.
	(cpms_{out,in}::start, cpms_{out,in}::core_vals): Fix call
	handling.
	gcc/testsuite/
	* g++.dg/modules/class-4_[ab].C: New.

From-SVN: r249021
2017-06-08 15:16:01 +00:00
Nathan Sidwell
1ae7e42233 module.c: Implement dump printf.
gcc/cp/
	* module.c: Implement dump printf.

From-SVN: r249011
2017-06-08 12:50:53 +00:00
Nathan Sidwell
3b331161cc Merge trunk r248972.
From-SVN: r248973
2017-06-07 14:18:47 +00:00
Nathan Sidwell
ffc3321c3e module.c (cpms_{out,in}::core_vals): Stream block vars & abstract origin.
gcc/cp/
	* module.c (cpms_{out,in}::core_vals): Stream block vars &
	abstract origin.

From-SVN: r248972
2017-06-07 13:48:40 +00:00
Nathan Sidwell
47f0631554 Inline ctors/dtors
Inline ctors/dtors
	gcc/cp/
	* module.c (cpms_in::define_function): Deal with non-namespace
	fn definitions.
	(cpms_{out,in}::define_class): Define member fns.
	(cpms_in::tag_definition): Clone fn.
	* semantics.c (expand_or_defer_fn_1): Keep cloned fns body when
	modules.
	gcc/testsuite/
	* g++.dg/modules/class-3_[abcd].C: Augment.

From-SVN: r248937
2017-06-06 22:31:08 +00:00
Nathan Sidwell
6eb646424c Member functions
Member functions
	gcc/cp/
	* class.c (resort_type_method_vec): Avoid signed/unsigned compare.
	* module.c (cpms_out::maybe_tag_definition): New.
	(cpms_{out,in}::tag_definition): Always tag, return tagged thing.
	(cpms_{out,in}::chained_decls, tree_vec): New.
	(cpms_{out,in}::define_class): Stream methods, as_base.
	(cpms_{out,in}::core_vals): Stream ARGUMENTs here.
	(cpms_in::tree_node): Cope with immediate definitions.
	gcc/testsuite/
	g++.dg/modules/class-3_[abcd].C: Augment.

From-SVN: r248933
2017-06-06 20:47:22 +00:00
Nathan Sidwell
7bfad527f7 More PoD struct
More PoD struct
	gcc/cp/
	* module.c (cpms_{out,in}::ident_imported_decl): New.
	(cpms_{out,in}::lang_type_vals): New.
	(cpms_{out,in}::core_vals): Blocks and statements.
	(cpms_{out,in}::tree_node): More general import referencing.
	* name-lookup.c (name_lookup::add_module_fns): New.
	(name_lookup::adl_namespace_only): Use it.
	gcc/testsuite/
	* g++.dg/modules/class-3_[abc].C: New.

From-SVN: r248928
2017-06-06 17:58:00 +00:00
Nathan Sidwell
66d5fe8a6b More Pod struct
More Pod struct
	gcc/cp/
	* cp-tree.h (default_hash_traits): Make non-deletable.
	(cpms_out::non_null): New hash trait.
	(cpms_in::traits): Use simple_hashmap_traits.
	(cpms_in::define_class, cpms_in::finish_type): Propagate
	completeness.
	(cpms_in::finish_type): Deal with pointer/ref to.
	(cpms_{out,in}::core_vals): Stream ints, pointer/ref to.
	(cpms_{out,in}::tree_node): Interstitial typedef.
	gcc/testsuite/
	* g++.dg/modules/class-1_[abc].C: Extend.
	* g++.dg/modules/class-2_[ab].C: New.

From-SVN: r248882
2017-06-05 17:31:26 +00:00
Nathan Sidwell
7fcbdccad8 Pod struct
Pod struct
	gcc/cp/
	* cp-tree.h (create_classtype_sorted_fields): Declare.
	* class.c (finish_struct_1): Adjust sorted field call.
	(insert_into_classtype_sorted_fields): Rename to ...
	(create_classtype_sorted_fields): ... here.  Export
	* module.c (cpms_{out,in}::tree_vec): New.
	(cpms_{out,in}::define_function): New.
	(cpms_{out,in}::define_class): New.
	(cpms_{out,in}::tag_definition): Adjust.
	(cpms_{out,in}::core_vals): Stream binfo, field_decl.
	gcc/testsuite/
	* g++.dg/modules/class-1_[abcd].C: Add field accesses.

From-SVN: r248840
2017-06-02 16:52:13 +00:00
Nathan Sidwell
310ab7528f Merge r248828.
From-SVN: r248829
2017-06-02 14:16:31 +00:00
Nathan Sidwell
dc311b5ba5 modules.c (cpms_out::core_vals, [...]): Don't stream structure fields etc.
gcc/cp/
	* modules.c (cpms_out::core_vals, cpms_in::core_vals): Don't
	stream structure fields etc.

From-SVN: r248828
2017-06-02 13:29:20 +00:00
Nathan Sidwell
8038f6e12a Incomplete or empty classes.
gcc/cp/
	* cp-tree.h (ovl_iterator::export_tail): New.
	(TYPE_GET_PTRMEMFUNC_TYPE, TYPE_SET_PTRMEMFUNC_TYPE): Delete.
	(TYPE_PTRMEMFUNC_TYPE): New.
	(maybe_add_lang_type_raw): Add ptrmem_p arg.
	(fit_ptrmem_type_decl): Declare.
	(ovl_insert): Add export_tail.
	* decl.c (build_ptrmemfunc_type): Use fit_ptrmem_type_decl,
	adjust.
	(xref_tag_1): Call decl_set_module.
	* lex.c (maybe_add_lang_type_raw): Add ptrmem_p arg.  Adjust.
	(fit_ptrmem_type_decl): New.
	(cxx_make_type): Adjust.
	* module.c (name_string): New. Use it everywhere.
	(cpm_reader::fill): Check ferror.
	(cpms_out::tag_binding): Skip builtins.  Write types.
	(cpms_out::lang_type_bools, cpms_in::lang_type_bools): New.
	* name-lookup.c (STAT_EXPORTS): New.
	(name_lookup::process_module_binding): Use it.
	(update_binding): Set it.
	(newbinding_bookkeeping): New. Broken out of ...
	(do_pushdecl): ... here.  Call it.
	(push_module_binding): And call it here.  Set STAT_EXPORTS.
	* rtti.c (create_pseudo_type_info): Mark as builtins.
	(get_pseudo_ti_index): Likewise.
	(emit_support_tinfos): Use regular lookup to find type.  Set
	builtins location.
	* tree.c (ovl_insert): Add export_tail arg.
	gcc/testsuite/
	* g++.dg/modules/class-1_[abcd].C: New.

From-SVN: r248797
2017-06-01 17:40:46 +00:00
Nathan Sidwell
4167fe4f2d * module.c: Instrumentation.
From-SVN: r248761
2017-05-31 19:14:48 +00:00
Nathan Sidwell
0bd22cf3aa Merge trunk r248748.
From-SVN: r248750
2017-05-31 17:40:32 +00:00
Nathan Sidwell
e5ca94a1ce Merge trunk r248694.
From-SVN: r248697
2017-05-30 19:46:34 +00:00
Nathan Sidwell
1361d1c421 Merge trunk r248694.
From-SVN: r248696
2017-05-30 19:38:29 +00:00
Nathan Sidwell
89e27a4737 module.c (cpms_out::tag_binding, [...]): Mark type too.
gcc/cp/
	* module.c (cpms_out::tag_binding, cpms_in::tag_binding): Mark
	type too.
	(cpms_out::bindings): Adjust.
	* name-lookup.c (push_module_binding): Add type arg.

From-SVN: r248690
2017-05-30 17:13:53 +00:00
Nathan Sidwell
25c9ee3443 cp-tree.h (lang_decl_base): Lose decomposition_p flag.
gcc/cp/
	* cp-tree.h (lang_decl_base): Lose decomposition_p flag.
	(lang_decl) Update GTY tags.
	(enum lang_decl_selector): New.  Replace magic consts with this.
	(DECL_DECOMPOSITION_P): Update.
	(SET_DECL_DECOMPOSITION_P): Delete.
	(maybe_add_lang_decl_raw): Second arg is bool.
	(retrofit_lang_decl): Lose selector arg.
	(fit_decomposition_lang_decl): Declare.
	* decl.c (cp_finish_decomp): Use fit_decomposition_lang_decl.
	(grokdeclarator): Likewise.
	* lex.c (maybe_add_lang_decl_raw): Change 2nd arg to bool. Don't
	to copying here.
	(set_decl_linkage, fit_decomposition_lang_decl): New.
	(retrofit_lang_decl): Lose selector arg.
	(cxx_dup_lang_specific_decl): Use selector directly.
	* module.c (cpms_out::lang_decl_bools, cpms_in::lang_decl_bools)
	cpms_out::lang_decl_vals, cpms_in::lang_decl_vals): Use
	lang_decl_selector.
	(cpms_in::tree_node): Adjust maybe_add_lang_decl call.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/decl.c
M    gcc/cp/cp-tree.h
M    gcc/cp/module.c
M    gcc/cp/lex.c

From-SVN: r248689
2017-05-30 15:41:37 +00:00
Nathan Sidwell
e751f7a436 REVISION: Add file.
gcc/
	* REVISION: Add file.
	gcc/c-family/
	* c-cppbuiltin.c (c_cpp_builtins): Update __cpp_modules=201704.

From-SVN: r248682
2017-05-30 11:42:46 +00:00
Nathan Sidwell
70d964ea98 Merge trunk r248578.
From-SVN: r248579
2017-05-29 20:10:47 +00:00
Nathan Sidwell
e624170cb6 Merge trunk r248574.
From-SVN: r248575
2017-05-29 15:35:32 +00:00
Nathan Sidwell
9ee9e034a6 Merge trunk r248571.
From-SVN: r248572
2017-05-29 13:32:27 +00:00
Nathan Sidwell
1de0e4e2ef cp-tree.h: Comment cleanup.
gcc/cp/
	* cp-tree.h: Comment cleanup.
	* name-lookup.c: Likewise.
	* tree.c: Likewise.

From-SVN: r248516
2017-05-26 14:51:38 +00:00
Nathan Sidwell
1ab3c0972e Merge trunk 248485.
gcc/cp/
	* lex.c (maybe_retrofit_lang_decl): Add sel parm.

From-SVN: r248509
2017-05-26 13:09:37 +00:00
Nathan Sidwell
d5c1fa2f56 cp-tree.h (ovl_iterator): Make unduplicatable.
gcc/cp/
	* cp-tree.h (ovl_iterator): Make unduplicatable.
	(ovl_iterator::pop): New.
	(lkp_iterator::operator++): Adjust.

From-SVN: r248459
2017-05-25 14:27:05 +00:00
Nathan Sidwell
cdf1ecb779 Merge trunk r248454.
From-SVN: r248455
2017-05-25 11:09:12 +00:00
Nathan Sidwell
e9425553af Merge trunk r248436.
From-SVN: r248453
2017-05-25 10:59:02 +00:00
Nathan Sidwell
9ec17a4e43 name-lookup.c (lookup_name): Reimplement state preservation and restoration.
gcc/cp/
	* name-lookup.c (lookup_name): Reimplement state preservation and
	restoration.
	* tree.c (lookup_mark): Add asserts.
	gcc/testsuite/
	* g++.dg/lookup/koenig14.C: New.

From-SVN: r248436
2017-05-24 23:21:25 +00:00
Nathan Sidwell
f9d60b967b Merge trunk r248406.
From-SVN: r248409
2017-05-24 12:33:52 +00:00
Nathan Sidwell
945dff4cfe call.c (build_operator_new_call, [...]): Open code ADL lookup.
gcc/cp/
	* call.c (build_operator_new_call, build_new_op_1): Open code ADL
	lookup.
	* name-lookup.h (lookup_function_nonclass): Delete.
	(lookup_arg_dependent): Adjust return type.
	* name-lookup.c (name_lookup): Absorb adl_lookup.
	(name_lookup::search_adl): New.
	(lookup_function_nonclass): Delete.
	(lookup_arg_dependent): Adjust.

From-SVN: r248405
2017-05-24 11:25:52 +00:00
Nathan Sidwell
46050cb1d9 Merge trunk r248389.
From-SVN: r248391
2017-05-23 23:02:53 +00:00
Nathan Sidwell
9c1f94d4d7 name-lookup.c (name_lookup::name_lookup): Lose F parm.
gcc/cp/
	* name-lookup.c (name_lookup::name_lookup): Lose F parm.
	(name_lookup::ambiguous, add_value, add_type): New.
	(name_lookup::merge_binding): Delete.
	(name_lookup::find_and_mark): Move from adl_lookup.
	(name_lookup::process_binding): Adjust.
	(adl_lookup::search_adl): New.
	(do_lookup_arg_dependent): Call it.
	(qualified_namespace_lookup): Return found flag.
	(unqualified_namespace_lookup): Delete.
	(lookup_name_real_1, push_namepace): Adjust.

From-SVN: r248389
2017-05-23 21:39:42 +00:00
Nathan Sidwell
39745f2fc7 Merge trunk r248377.
From-SVN: r248378
2017-05-23 17:29:42 +00:00
Nathan Sidwell
fb0ad78e68 Merge trunk r248365.
From-SVN: r248367
2017-05-23 14:12:54 +00:00
Nathan Sidwell
452e24013c Merge trunk r248338.
gcc/cp/
	* name-lookup.c (add_using_namespace): Remove FROM arg.
	(notify_debug_using_namespace): New.
	(finish_namespace_using_directive, push_namespace): Notify debug.
	gcc/testsuite/
	* g++.dg/lookup/strong-using-6.C: Delete.

From-SVN: r248340
2017-05-22 16:37:30 +00:00
Nathan Sidwell
9cf247f54b config-lang.in: Update.
gcc/cp/
	* config-lang.in: Update.
	* name-lookup.c (add_using_directive): Rename to ...
	(add_using_namespace): ... here.  Add FROM arg.
	(do_toplevel_using_directive): Fold into add_using_namespace.
	(finish_namespace_using_directive, finish_local_using_directive)
	push_namespace): Adjust.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/name-lookup.c
M    gcc/cp/config-lang.in

From-SVN: r248338
2017-05-22 16:02:39 +00:00
Nathan Sidwell
e4fc10e1c6 Merge trunk r248329.
From-SVN: r248331
2017-05-22 12:15:52 +00:00
Nathan Sidwell
e5aad7415c re PR c++/80830 (ICE in tsubst_copy, at cp/pt.c:14569)
gcc/testsuite/
	PR c++/80830
	* g++.dg/lookup/friend20.C: New testcase.

From-SVN: r248329
2017-05-22 12:05:41 +00:00
Nathan Sidwell
c0d77de7f4 Merge trunk r248295.
From-SVN: r248296
2017-05-19 17:29:54 +00:00
Nathan Sidwell
c043f3de66 cp-tree.h: Misc cleanups.
gcc/cp/
	* cp-tree.h: Misc cleanups.
	* name-lookup.c (pushdecl_top_level): Fix description.
	gcc/
	* dumpfile.h: Whitespace cleanups.
	* system.h (ATTRIBUTE_NTC_PURE): Delete.
	gcc/testsuite/
	* g++.dg/tree-ssa/ssa-dse-2.C: Restore.

From-SVN: r248292
2017-05-19 15:37:34 +00:00
Nathan Sidwell
4605ee6961 Merge trunk r248285.
From-SVN: r248286
2017-05-19 14:28:46 +00:00
Nathan Sidwell
4555531fc1 Merge trunk r248271.
From-SVN: r248272
2017-05-19 13:22:09 +00:00
Nathan Sidwell
1fd80386f3 context.h (context::set_passes): New.
LANG_HOOK_REGISTER_DUMPS
	gcc/
	* context.h (context::set_passes): New.
	* context.c (context::context): Do not create pass manager.
	* toplev.c (general_init): Create pass manager here.  Call
	register dump lang hook.
	* doc/invoke.texi: Document -fdump-lang option family.
	* dumpfile.c (dump_files): Remove module and class dumps here.
	(FIRST_AUTO_NUMBERED_DUMP): Adjust.
	* dumpfile.h (tree_dump_index): Remove TDI_lang, TDI_class.
	* langhooks-def.h (lhd_register_dumps): Declare.
	(LANG_HOOKS_REGISTER_DUMPS): Define.
	(LANG_HOOKS_INITIALIZER): Add it.
	* langhooks.c (lhd_register_dumps): Define.
	* langhooks.h (struct lang_hooks): Add register_dumps.
	gcc/c-family/
	* c-opts.c (class_dump_file, class_dump_flags): Delete.
	(c_common_parse_file): Remove class dump handling.
	(get_dump_info): Likewise.
	gcc/cp/
	* class.c (class_dump_id): Define.
	(dump_class_hierarchy, dump_vtable, dump_vtt): Use it.
	* cp-objcp-common.c (cp_register_dumps): New.
	* cp-objcp-common.h (cp_register_dumps): Declare.
	(LANG_HOOKS_REGISTER_DUMPS): Override.
	* cp-tree.h (class_dump_id, module_dump_id): Declare.
	* module.c (module_dump_id): Define.
	(read_module, write_module): Use it.
	gcc/testsuite/
	* g++.dg/inherit/covariant7.C: Adjust.
	* g++.dg/modules/ Adjust scans.

From-SVN: r248203
2017-05-18 14:12:48 +00:00
Nathan Sidwell
ea28945915 cp-tree.h (lookup_add, [...]): Swap args.
gcc/cp/
	* cp-tree.h (lookup_add, lookup_maybe_add): Swap args.
	* name-lookup.c (name_lookup::merge_binding)
	adl_lookup::add_functions): Adjust.
	* pt.c (check_explicit_specialization, do_class_deduction):
	Adjust.
	* tree.c (lookup_add, lookup_maybe_add): Adjust.
(--This line, and those below, will be ignored--

M    gcc/cp/tree.c
M    gcc/cp/cp-tree.h
M    gcc/cp/pt.c
M    gcc/cp/name-lookup.c
M    ChangeLog.modules

From-SVN: r248196
2017-05-18 12:32:24 +00:00
Nathan Sidwell
abbf6a30a9 Merge trunk r248192.
From-SVN: r248194
2017-05-18 11:10:48 +00:00
Nathan Sidwell
a9d9f8c660 Merge trunk r248159.
From-SVN: r248162
2017-05-17 17:02:19 +00:00
Nathan Sidwell
384fca9cec Merge trunk r248151.
* cp-tree.h (ovl_insert): Swap first two args.  Update all uses.

From-SVN: r248154
2017-05-17 14:02:12 +00:00
Nathan Sidwell
28731428a1 Merge trunk r248144.
From-SVN: r248145
2017-05-17 11:26:55 +00:00
Nathan Sidwell
c42dff058d Merge trunk r248126.
From-SVN: r248127
2017-05-16 19:41:37 +00:00
Nathan Sidwell
5a933bc12f Merge trunk r248121.
From-SVN: r248126
2017-05-16 19:33:55 +00:00
Nathan Sidwell
69bdfcb892 Merge trunk r248116.
From-SVN: r248118
2017-05-16 16:01:13 +00:00
Nathan Sidwell
d3b7edd474 Merge trunk r248109.
From-SVN: r248116
2017-05-16 15:35:32 +00:00
Nathan Sidwell
530121e5b0 Merge trunk r248059.
From-SVN: r248061
2017-05-15 13:27:06 +00:00
Nathan Sidwell
ebecdad087 module.c (cpms_in::tag_definition): Robustify.
gcc/cp/
	* module.c (cpms_in::tag_definition): Robustify.

From-SVN: r248059
2017-05-15 12:26:34 +00:00
Nathan Sidwell
88023d1c88 module.c (cpms_{in,out}): Rename {read,write}_tree to tree_node.
gcc/cp/
	* module.c (cpms_{in,out}): Rename {read,write}_tree to tree_node.

From-SVN: r247990
2017-05-12 18:46:52 +00:00
Nathan Sidwell
977cb87fce module.c (cpms_{in,out}): Rename read/write fns.
gcc/cp/
	* module.c (cpms_{in,out}): Rename read/write fns.

From-SVN: r247989
2017-05-12 18:44:30 +00:00
Nathan Sidwell
1ab346a40b More inline bodies
More inline bodies
	gcc/cp/
	* module.c (cpms_{in,out}::write_core_vals): Read/write
	statement lists & LABEL_DECLs.
	gcc/testsuite/
	* g++.dg/modules/fn-inline-1_c.C: More test.

From-SVN: r247987
2017-05-12 18:28:02 +00:00
Nathan Sidwell
96beb6a27e Inline function bodies
Inline function bodies
	gcc/cp/
	* module.c (cpms_out::write_tree, cpms_in::read_tree): Read/write
	exprs
	(cpms_in::tag_definition): Insert inline function.
	gcc/testsuite/
	* g++.dg/modules/fn-inline-1_[ab].C: New.

From-SVN: r247983
2017-05-12 17:05:57 +00:00
Nathan Sidwell
64f4de7946 Merge trunk r247968.
From-SVN: r247982
2017-05-12 17:05:27 +00:00
Nathan Sidwell
f66a048a5b module.c (cpm_reader::read_tree): Change interface, adjust callers.
gcc/cp/
	* module.c (cpm_reader::read_tree): Change interface, adjust
	callers.

From-SVN: r247968
2017-05-12 12:53:31 +00:00
Nathan Sidwell
0db20e1273 module.c (cpm_writer): Instrument bool distribution.
gcc/cp/
	* module.c (cpm_writer): Instrument bool distribution.
	(cpms_out::tag_definition, cpms_in::tag_definition): New.
	(cpms_out, cpms_in): Transfer more stuff.

From-SVN: r247965
2017-05-12 11:56:29 +00:00
Nathan Sidwell
7c50ce43b2 Merge trunk r247911.
From-SVN: r247912
2017-05-11 15:29:58 +00:00
Nathan Sidwell
9ea9003325 Merge trunk r247864.
From-SVN: r247865
2017-05-10 21:43:22 +00:00
Nathan Sidwell
580f14ba91 Merge trunk r247834.
From-SVN: r247846
2017-05-10 16:56:08 +00:00
Nathan Sidwell
de6dc88a58 Rename -fdump-front-end to -fdump-lang.
gcc/
	* dumpfile.h (TDF_KIND_MASK, TDF_KIND): New.  Adjust.
	* dumpfile.c (dump_files): Rename file suffix.
	(get_dump_file_name, dump_enable_all): Adjust.
	* doc/invoke.texi: Rename option.
	gcc/testsuite/
	* g++.dg/modules: Adjust tests.

From-SVN: r247811
2017-05-09 19:36:13 +00:00
Nathan Sidwell
265a96c8c4 module.c (cpms_in::finish): Merge global decls.
gcc/cp/
	* module.c (cpms_in::finish): Merge global decls.
	(cpms_in::finish_function, cpms_in::finish_namespace): Delete.
	* name-lookup.h (push_module_namespace): Replace with ...
	(merge_global_decl): ... this.
	* name-lookup.c (push_module_namespace): Morph into ...
	(merge_global_decl): ... this.
	(push_module_binding): Don't re-add found things.

From-SVN: r247809
2017-05-09 17:43:39 +00:00
Nathan Sidwell
9fb501c112 tree.h (TREE_CHECK6, [...]): Delete.
gcc/
	* tree.h (TREE_CHECK6, tree_check6): Delete.

From-SVN: r247802
2017-05-09 15:44:18 +00:00
Nathan Sidwell
e8badd9900 Merge trunk r247787.
gcc/cp/
	* tree.c (type_has_nontrivial_copy_init): Use ovl_iterator.

From-SVN: r247788
2017-05-09 11:51:51 +00:00
Nathan Sidwell
f929e308a3 Error message module designation.
gcc/cp/
	* error.c (dump_module_suffix): New.
	(dump_simple_decl, dump_function_name): Use it.
	gcc/testsuite/
	* g++.dg/modules/err-1_[abcd].C: New.

From-SVN: r247787
2017-05-09 11:35:27 +00:00
Nathan Sidwell
f19e591a7d Merge trunk r247749.
From-SVN: r247751
2017-05-08 17:44:58 +00:00
Nathan Sidwell
4bcf7e8331 Implement 'export module foo;'
Implement 'export module foo;'
	gcc/cp/
	* cp-tree.h (declare_module): Add interface flag.
	(import_export_module): Rename to ...
	(import_module): ... here.  Lose export flag.
	* module.c (import_module): Determine exportness from export
	depth.
	(declare_module): Add interface flag, don't check attribs.
	* parser.c (check_module_outermost): Don't check export depth.
	(cp_parser_module_declaration): Don't deal with imports.
	(cp_parser_import_declaration): New.
	(cp_parser_module_export, cp_parser_declaration): Adjust.
	gcc/testsuite/
	* g++.dg/modules/import-1_[a-g].C: New.

From-SVN: r247749
2017-05-08 17:26:06 +00:00
Nathan Sidwell
832e0e7e4e Implement DR2061
Implement DR2061
	gcc/cp/
	* name-lookup.c (push_inline_namespace): New.
	(push_namespace): Use it.  Check inline consistency here ...
	* parser.c (cp_parser_namespace_definition): ... not here.
	gcc/testsuite/
	* g++.dg/cpp0x/dr2061.C: New.
	* g++.dg/parse/namespace-alias-1.C: Augment.

From-SVN: r247740
2017-05-08 13:56:14 +00:00
Nathan Sidwell
d3e3dd49ca cp-tree.h, [...]: Rename ovl2_iterator to lkp_iterator.
gcc/cp/
	* cp-tree.h, call.c, class.c, name-lookup.c, parser.c, pt.c,
	semantics.c, tree.c: Rename ovl2_iterator to lkp_iterator.

From-SVN: r247736
2017-05-08 11:11:28 +00:00
Nathan Sidwell
318f1d4246 name-lookup.h (push_namespace): Return int.
gcc/cp/
	* name-lookup.h (push_namespace): Return int.
	* name-lookup.c (push_namespace): Return count of depth pushed.
	* parser.c (cp_parser_namespace_definition): Accumulate depth pushed.

From-SVN: r247735
2017-05-08 11:07:06 +00:00
Nathan Sidwell
924e0eb5d9 Merge trunk r247654.
From-SVN: r247656
2017-05-05 20:14:29 +00:00
Nathan Sidwell
402cf7223e Merge trunk r247646.
From-SVN: r247651
2017-05-05 17:46:35 +00:00
Nathan Sidwell
48423d1e63 Merge trunk r247636.
From-SVN: r247637
2017-05-05 15:04:35 +00:00
Nathan Sidwell
1b6eaa318a Indirect import lookup by tagging
Indirect import lookup by tagging
	gcc/cp/
	* cp-tree.h (MAYBE_DECL_MODULE_INDEX): New.
	(DECL_GLOBAL_MODULE_P, DECL_THIS_MODULE_P): Delete.
	* mangle.c (maybe_write_module): Adjust.
	* module.c (cpms_out::write_tree, cpms_in::read_tree): Mark
	imported decls by tag.
	* name-lookup.h (key_module_instance, find_module_instance):
	Declare.
	* name-lookup.c (module_binding_slot): Allow search only.
	(key_module_instance): New.
	(find_module_instance): Use key.
	gcc/testsuite/
	* g++.dg/modules/mod-indirect-1_[a-e].C: New.

From-SVN: r247636
2017-05-05 14:50:44 +00:00
Nathan Sidwell
8b99b4e2a2 Merge trunk r247612.
gcc/testsuite/
	* g++.dg/lookup/using17.C: Adjust error message.

From-SVN: r247616
2017-05-04 18:54:54 +00:00
Nathan Sidwell
046c9c5bd9 Overload bindings
Overload bindings
	gcc/cp/
	* module.c (cpms_in::tag_binding, cpms_out::tag_binding): Binding
	can be overload.
	(cpms_out::write_bindings): Write whole slot.
	(cpms_in::finish): Look for import match.
	(cpms_in::read_lang_decl_bools, cpms_out::write_lang_decl_bools)
	cpms_in::read_lang_decl_vals, cpms_out::write_lang_decl_vals):
	Implement.
	* name-lookup.c (push_module_binding): Binding can be overload.
	(find_module_instance): New.
	* name-lookup.h (find_module_instance): Declare.
	gcc/testsuite/
	* g++.dg/modules/mod-impl-1_[abcd]: Add overloads.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h
M    gcc/cp/module.c
M    gcc/testsuite/g++.dg/modules/mod-impl-1_a.C
M    gcc/testsuite/g++.dg/modules/mod-impl-1_b.C
M    gcc/testsuite/g++.dg/modules/mod-impl-1_c.C
M    gcc/testsuite/g++.dg/modules/mod-impl-1_d.C

From-SVN: r247611
2017-05-04 17:59:55 +00:00
Nathan Sidwell
f3917f0de3 Merge trunk r247593.
From-SVN: r247595
2017-05-04 13:05:14 +00:00
Nathan Sidwell
e60010ec61 cp-tree.h (LOOKUP_SEEN_P): Map to TREE_VISITED.
gcc/cp/
	* cp-tree.h (LOOKUP_SEEN_P): Map to TREE_VISITED.
	(LOOKUP_FOUND_P, OVL_LOOKUP_P): Move to lang_flag_4

From-SVN: r247593
2017-05-04 12:44:40 +00:00
Nathan Sidwell
92a0efd3d3 Modules via index, working again!
gcc/cp/
	* module.c (cpms_in::tag_binding): Set module index.
	gcc/testsuite/
	* g++.dg/modules/mod-impl-1_a.C: Remove xfail.

From-SVN: r247568
2017-05-03 20:39:41 +00:00
Nathan Sidwell
4ec0aa9a73 Namespace partitions.
gcc/cp/
	* cp-tree.h (MODULE_NAMESPACE_P, GLOBAL_MODULE_NAMESPACE_P)
	CURRENT_MODULE_NAMESPACE_P): Delete.
	(pop_module_namespace, push_module_namespace): Delete.
	* module.c (cpms_out::write_bindings, cpms_in::finish_namespace):
	Remove module namespace hacks.
	(push_module_namespace, pop_module_namespace): Delete.
	(module_to_ext): Swallow into ...
	(module_to_filename): ... here.
	(declare_module): Don't create module namespace symbol.
	* name-lookup.c (module_binding_slot): Fixup global module
	insertion.
	(is_nested_namespce, is_ancestor): Remove module namespace hacks.
	* parser.c (check_module_outermost, cp_parser_module_export)
	cp_parser_module_proclamation,
	cp_parser_namespace_definition): Likewise
	gcc/testsuite/
	* g++.dg/modules/mod-sym-[123].C: Remove xfails.
	* g++.dg/modules/mod-impl-1_a.C: Revert to run test.
((--This line, and those below, will be ignored--

M    gcc/cp/name-lookup.c
M    gcc/cp/module.c
M    gcc/cp/parser.c
M    gcc/cp/cp-tree.h
M    gcc/testsuite/g++.dg/modules/mod-sym-1.C
M    gcc/testsuite/g++.dg/modules/mod-sym-2.C
M    gcc/testsuite/g++.dg/modules/mod-sym-3.C
M    gcc/testsuite/g++.dg/modules/mod-impl-1_a.C
M    ChangeLog.modules

From-SVN: r247567
2017-05-03 20:30:40 +00:00
Nathan Sidwell
395d5f4405 Namespace partitions.
gcc/cp/
	* cp-tree.h (OVL_EXPORT_P): New. Move OVL_LOOKUP_P.
	(DECL_MODULE_EXPORT_P): Allow any DECL.
	(module_import_bitmap): Declare.
	* decl.c (cxx_init_decl_processing): Export global_namespace.
	* module.c (module_import_bitmap): New.
	(do_module_import): Install as global module, if needed.
	(declare_module): Freeze global imports.
	* name-lookup.c: Include bitmap.h.
	(name_lookup::process_binding): Take split bindings.
	(name_lookup::process_module_binding): New.
	(name_lookup::search_namespace_only): Adjust.
	* tree.c (ovl_insert): Sort by export_p too.

From-SVN: r247565
2017-05-03 19:29:12 +00:00
Nathan Sidwell
bb051f869d Merge trunk r247550.
From-SVN: r247551
2017-05-03 15:21:21 +00:00
Nathan Sidwell
92e6d5994e Namespace partitions.
gcc/cp/
	* cp-tree.h (MODULES_PER_BINDING_CLUSTER): Delete.
	(MODULE_VECTOR_NUM_CLUSTERS, MODULE_VECTOR_CLUSTER_BASE)
	MODULE_VECTOR_CLUSTER_LAST, MODULE_VECTOR_CLUSTER): New.
	(make_module_vec): Declare.
	* module.c (cpms_out::write_bindings): Look into MODULE_VECTOR.
	* name-lookup.c (modue_binding_slot): New.
	(name_lookup::merge_binding, name_lookup::process_binding): New.
	(name_lookup::search_qualified): Add usings parm.
	(name_lookup::search_namespace_only): Look into MODULE_VECTOR.
	(do_pushdecl): Create module slot.
	(find_namespace_partition): New, from ...
	(push_module_namespace): ... here.  Call it.
	(push_module_binding): Create module slot.
	(push_namespace): Adjust.
	* ptree.c (cxx_print_xnode): Print MODULE_VECTOR.
	* tree.c (make_module_vec): New.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/module.c
M    gcc/cp/tree.c
M    gcc/cp/ptree.c

From-SVN: r247549
2017-05-03 14:02:16 +00:00
Nathan Sidwell
c2fb763c13 cp-tree.h (saved_scope): Add this_module.
gcc/cp/
	* cp-tree.h (saved_scope): Add this_module.
	(current_module): New.
	* module.c (cpms_in): Add remapping vector.  Remove scope.
	(cpms_in::tag_import): Update remapping vector.
	(cpms_out::tag_binding, cpms_in::tag_binding): Write/read module
	no.
	* name-lookup.c (do_push_to_top_level): Set current_module.

From-SVN: r247511
2017-05-02 16:06:00 +00:00
Nathan Sidwell
b47d070228 invoke.texi (-fdump-front-end): Document.
gcc/doc/
	* invoke.texi (-fdump-front-end): Document.

From-SVN: r247500
2017-05-02 14:52:43 +00:00
Nathan Sidwell
3142930726 Read/write direct namespace bindings part 2.
gcc/cp/
	* module.c (cpms_out::tag_binding): Write the tag.
	(cpms_in::read_item): Detect rt_binding, set modules slot.
	(cpms_out::write_context_binding): Delete.
	(cpms_out::write_bindings): Simplify.
	(cpms_in::finish_function): Don't push function here.
	(cpms_in::finish_namespace): Adjust.
	(do_module_import): Adjust.
	* name-lookup.h (write_module_namespace): Declare.
	* name-lookup.c (write_module_namespace): New.

From-SVN: r247499
2017-05-02 14:42:05 +00:00
Nathan Sidwell
f8a6f2f19b Read/write direct namespace bindings
Read/write direct namespace bindings
	gcc/cp/
	* cp-tree.def (module_vector): New tree type.
	* cp-tree.h (module_cluster, tree_module_vec): New tree.
	(enum cp_tree_node_structure_enum): Add TS_CP_MODULE_VECTOR.
	(lang_tree_node): Add tree_module_vec.
	* decl.c (cp_tree_node_structure): Detect MODULE_VECTOR.
	* module.c (cpms_out::tag_binding, cpms_in::tag_binding): New.
	(cpms_out::write_context_binding): New.
	(cpms_out::walk_namespace): Replace with ...
	(cpms_out::write_bindings): ... this.
	* name-lookup.h (push_module_binding): Declare.
	* name-lookup.c (push_module_binding): New.

From-SVN: r247496
2017-05-02 12:45:48 +00:00
Nathan Sidwell
fa5197daa4 augment comment
From-SVN: r247454
2017-05-01 23:35:22 +00:00
Nathan Sidwell
0825e35b2a tree.c (type_hash_default): Adjust ARRAY_TYPE hash.
gcc/
	* tree.c (type_hash_default): Adjust ARRAY_TYPE hash.

From-SVN: r247451
2017-05-01 23:20:47 +00:00
Nathan Sidwell
1e7d43535f Import timestamp & crc
Import timestamp & crc
	gcc/cp
	* module.c (module_state): Add crc & stamp.
	(enum import_kind): New.
	(cpms_out::header, cpms_in::header): Check timestamps.
	(time2str, timestamp_mismatch): New.
	(cpms_out::tag_import, cpms_in::tag_import): Xfer indirect imports
	too.
	(read_module, do_module_import): Check timestamp & crc.
	gcc/testsuite/
	* g++.dg/modules/mod-stamp-1_[abcd].C: New.

From-SVN: r247442
2017-05-01 17:48:35 +00:00
Nathan Sidwell
ca120352cb Proper mangle for module. Still have namespace hack though.
gcc/cp/
	* cp-tree.h (DECL_GLOBAL_MODULE_P, DECL_THIS_MODULE_P): Protect
	DECL_LANG_SPECIFIC.
	(decl_set_module, module_name, module_name_parts): New.
	* decl.c (duplicate_decls): Check moduleness.
	(grokfndecl): Set moduleness.
	* mangle.c (maybe_write_module): New.
	(write_name): Call it.
	* module.c (module_state::set_name): New.
	(decl_set_module, module_name, module_name_parts): New.
	gcc/testsuite/
	* g+.dg/modules.exp (dg-module-do, module_do_it): Adjust.
	* g++.dg/modules/mod-impl-1_a.C: Adjust & XFAIL.
	* g++.dg/modules/mod-impl-1_c.C: Likewise.
	* g++.dg/modules/mod-sym-1.C: Likewise.
	* g++.dg/modules/mod-sym-2.C: Likewise.
	* g++.dg/modules/mod-sym-3.C: Likewise.

From-SVN: r247437
2017-05-01 13:01:54 +00:00
Nathan Sidwell
f6d09c360e cp-tree.h (struct_lang_base): Add module_index.
gcc/cp/
	* cp-tree.h (struct_lang_base): Add module_index.  Shrink
	selector.
	(DECL_MODULE_INDEX, DECL_GLOBAL_MODULE_P, DECL_THIS_MODULE_P):
	New.
	(EXPORTED_P): Rename to ..
	(DECL_EXPORTED_P): ... here.
	* modules.c: Adjust EXPORTED_P uses.

From-SVN: r247396
2017-04-28 18:59:12 +00:00
Nathan Sidwell
b3d14ad561 Module indices and separated import/export info
Module indices and separated import/export info
	gcc/cp/
	* cp-tree.h (GLOBAL_MODULE_INDEX, THIS_MODULE_INDEX)
	IMPORTED_MODULE_BASE): New.
	(import_module, export_module): Replace with ...
	(import_export_module): ... this.
	* module.c: #include bitmap.h.
	(enum import_kind): Delete.
	(struct module_state): New.
	(modules, module_map, this_module): New.
	(imported_modules): Delete.
	(cpms_in::state): New member.  Update constructor.
	(cpms_in::tag_import, cpms_out::tag_import): Take is_export arg.
	(cpms_in::read_item): Assign module index.
	(module_user, is_interface): Delete.
	(dopen, dclose): Delete.  Move to call sites.
	(read_module): Return module index.
	(do_module_import): Reimplement.
	(import_module, export_module): Replace with ...
	(import_export_module): ... this.
	(declare_module, write_module, finish_module): Adjust.
	* parser.c (cp_parser_module_declaration): Adjust,
	gcc/testsuite/
	* g++.dg/modules/mod-decl-5_b.C: Adjust.
(--This line, and those below, will be ignored--

M    gcc/cp/module.c
M    gcc/cp/parser.c
M    gcc/cp/cp-tree.h
M    gcc/testsuite/g++.dg/modules/mod-decl-5_b.C
M    ChangeLog.modules

From-SVN: r247392
2017-04-28 14:56:52 +00:00
Nathan Sidwell
98c9c55edf Kill rt_import popping madness
Kill rt_import popping madness
	gcc/cp/
	* module.c (cpm_serial::rt_export): New tag.
	(cpms_in::tag_import): Do the importing right now.
	(cpms_in::read_item): ... not here.
	(read_module): Pass in dump file name, open it if needed.

From-SVN: r247348
2017-04-27 17:33:18 +00:00
Nathan Sidwell
22e8865ec0 Kill walk_namespaces
Kill walk_namespaces
	gcc/cp/
	* cp-tree.h (walk_namespaces): Delete.
	* decl.c (walk_namespaces_r, walk_namespaces): Delete.

From-SVN: r247345
2017-04-27 15:04:19 +00:00
Nathan Sidwell
f0b7c7bbaf Rework module namespace walking
Rework module namespace walking
	gcc/cp/
	* name-lookup.h: (decapsulate_binding): Declare.
	* name-lookup.c: (decapsulate_binding): New.
	* module.c (cpms_out::walk_namespace): Iterate over namespace
	bindings, not decls.
	(imported_modules): Key by lang_identifier.  Adjust
	allocation/deletion.

From-SVN: r247344
2017-04-27 15:02:11 +00:00
Nathan Sidwell
e9187e4200 Refix unhidden extern C Revert 2017-04-26 extern_c_slot patch.
Refix unhidden extern C
	Revert 2017-04-26 extern_c_slot patch.
	gcc/cp/
	* name-lookup (do_pushdecl): Call check_extern_c_conflict when
	unhiding.
	gcc/testsuite/
	* g++.dg/lookup/extern-c-redecl.C: Adjust.
	* g++.dg/lookup/extern-c-hidden.C: New test.

From-SVN: r247336
2017-04-27 13:44:32 +00:00
Nathan Sidwell
8d7efa7ef2 Merge trunk r247281.
gcc/
	* tree.c (type_hash_default): Hash TYPE_TYPELESS_STORAGE.
	gcc/objc/
	* objc-gnu-runtime-abi-01.C (objc_add_static_instance): Use
	pushdecl langhook.

From-SVN: r247325
2017-04-27 12:16:23 +00:00
Nathan Sidwell
2102e57e2d name-lookup.c (extern_c_slot): New.
gcc/cp/
	* name-lookup.c (extern_c_slot): New.
	(check_extern_c_conflict): Use it.
	(unhidden_extern_c): New.
	(do_puhdecl): Call it.

From-SVN: r247280
2017-04-26 16:44:33 +00:00
Nathan Sidwell
d6768188fa Die IDENTIFIER_GLOBAL_BINDINGS! Die!
gcc/
	* ipa-devirt.c (default_hash_traits <type_pair>): Add
	GTY((skip))s.
	gcc/cp/
	* cp-tree.h (lang_identifier): Remove namespace_bindings.
	(default_hash_traits<lang_identifier *>): Specialization.
	(IDENTIFIER_NAMESPACE_BINDINGS): Delete.
	(lang_decl_ns): Add bindings map.
	(DECL_NAMESPACE_BINDINGS): New.
	* lex.c (maybe_add_lang_decl_raw): Allocate namespace binding map.
	* name-lookup.c (create_namespace_binding): Delete.
	(find_namespace_binding): Split into ...
	(find_or_create_namespace_slot, find_namespace_slot): ... these.
	Update all callers.
	(extern_c_fns): Change to identifier map.
	* ptree.c (cxx_print_identifier): Remove
	IDENTIFIER_NAMESPACE_BINDINGS.

From-SVN: r247278
2017-04-26 14:09:56 +00:00
Nathan Sidwell
fffa8f684c name-lookup.c (find_namespace_binding): Return slot pointer.
gcc/cp/
	* name-lookup.c (find_namespace_binding): Return slot
	pointer. Adjust all callers.
	(update_binding): Add slot pointer arg.  Adjust.
	(check_extern_c_conflict): Cons up list of fns.
	(c_linkage_bindings): Use extern_c_fns map.

From-SVN: r247255
2017-04-25 16:15:41 +00:00
Nathan Sidwell
3476928127 name-lookup.c (extern_c_fns): New hash.
gcc/cp/
	* name-lookup.c (extern_c_fns): New hash.
	(check_extern_c_conflict): Reimplement using hash map.
	(do_pushdecl): Move check_extern_c_conflict later.

From-SVN: r247245
2017-04-25 14:30:46 +00:00
Nathan Sidwell
a323be85cc Namespace stat hack via special overload
Namespace stat hack via special overload
	gcc/cp
	* name-lookup.c (STAT_HACK_P, STAT_TYPE, STAT_DECL)
	MAYBE_STAT_DECL, MAYBE_STAT_TYPE): New.
	(stat_hack): New.
	(find_namespace_value, name_lookup::search_namespace_only)
	update_binding, do_pushdecl, set_identifier_type_value_with_scope,
	set_global_value, lookup_type_scope_1, do_pushtag): Adjust.
((--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/name-lookup.c

From-SVN: r247185
2017-04-25 11:02:34 +00:00
Nathan Sidwell
f939909286 name-lookup.c (add_local_decl): Delete.
gcc/cp/
	* name-lookup.c (add_local_decl): Delete.
	(name_lookup::add): Fold into ...
	(name_lookup::search_namespace_only): ... here.
	(update_binding): Allow pushing the same artificial type.
	(do_pushdecl): Explicitly set namespace type.
	(push_local_binding): Use add_decl_to_level.
	(set_identifier_type_Value_with_scope): Use update_binding for
	namespaces.

From-SVN: r247112
2017-04-24 20:35:40 +00:00
Nathan Sidwell
7da6084ad9 name-lookup.c (do_nonmember_using_decl): Pass in pointers to value and type nodes.
gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Pass in pointers to
	value and type nodes.
	(do_local_using_directive): Use current_binding_level directly.
	(do_toplevel_using_directive): Adjust.
	(lookup_type_current_level): Delete.

From-SVN: r247106
2017-04-24 17:03:09 +00:00
Nathan Sidwell
7b72950993 name-lookup.c (diagnose_name_conflict): Check decl context.
gcc/cp/
	* name-lookup.c (diagnose_name_conflict): Check decl context.
	(do_nonmember_using_decl): Simplify.
	gcc/testsuite/
	* g++.dg/lookup/using13.C: Adjust error.
	* g++.dg/lookup/using59.C: Likewise,

From-SVN: r247100
2017-04-24 14:16:34 +00:00
Nathan Sidwell
534f7d8bbc cp-tree.h (SET_IDENTIFIER_GLOBAL_VALUE): Update.
gcc/cp/
	* cp-tree.h (SET_IDENTIFIER_GLOBAL_VALUE): Update.
	* name-lookup.h (set_namespace_value): Rename to ....
	(set_global_value): ... here.
	* name-lookup.c (update_namespace_binding): Delete.
	(set_namespace_value): Rename to ....
	(set_global_value): ... here.  Update binding directly.

From-SVN: r247096
2017-04-24 13:00:20 +00:00
Nathan Sidwell
6813379fbf cp-tree.h (ovl_lookup_keep, [...]): Rename to ...
gcc/cp/
	* cp-tree.h (ovl_lookup_keep, ovl_lookup_mark, ovl_lookup_add,
	ovl_lookup_maybe_add): Rename to ...
	(lookup_keep, lookup_mark, lookup_add, lookup_maybe_add): ... these.

From-SVN: r247013
2017-04-20 06:55:21 +00:00
Nathan Sidwell
853ad69d56 Keep overloads correctly ordered
Keep overloads correctly ordered
	gcc/cp/
	* cp-tree.h (ovl_iterator::unhide): Reimplement.
	(ovl_iterator::replace, ovl_iterator::ovl_unhide): Delete.
	(ovl_iterator::remove_node, ovl_iterator::unhide_node): Declare.
	(ovl_insert, ovl_lookup_maybe_add): Declare.
	* name-lookup.c (adl_lookup::add_functions): Adjust.
	(do_lookup_arg_dependent): Adjust.
	(do_nonmember_using_decl): Adjust.
	* pt.c (make_constrained_auto, do_class_deduction): Adjust.
	* tree.c (ov_move_unhidden, ovl_add): Delete.
	(ovl_copy, ovl_insert): New.
	(ovl_iterator::unhide_node, ovl_iterator::remove_node): New.
	(ovl_lookup_mark, ovl_lookup_add): Adjust.
	(ovl_lookup_maybe_add): New.
	(ovl_lookup_keep, ovl_skip_hidden): Adjust.
	(ovl_iterator::ovl_unhide, ovl_iterator::replace): Delete.
	* class.c (add_method): Adjust.

From-SVN: r247012
2017-04-20 06:33:21 +00:00
Nathan Sidwell
761e550abc Kill per-namespace static_decls.
gcc/cp/
	* cp-tree.h (static_decls): Declare.
	(wrapup_globals_for_namespace,
	diagnose_inline_vars_for_namespace): Replace with ...
	(wrapup_namespace_globals): ... this.
	* decl.c (static_decls): Define.
	(wrapup_globals_for_namespace,
	diagnose_inline_vars_for_namespace): Replace with ...
	(wrapup_namespace_globals): ... this.
	(cxx_init_decl_processing): Initialize static_decls.
	* decl2.c (c_parse_final_cleanups): Adjust.
	* name-lookup.h (cp_binding_level): Remove static_decls member.
	* name-lookup.c (add_decl_to_level): Adjust.
	(begin_scope): Adjust.

From-SVN: r246931
2017-04-14 21:02:39 +00:00
Nathan Sidwell
810dfd85ff backport: name-lookup.c (add_namespace_decl): Delete.
Merge namespace and local scope binding update
	gcc/cp/
	* name-lookup.c (add_namespace_decl): Delete.
	(namespace_push_binding, local_push_binding): Merge into ...
	(update_binding): ... this.
	(do_pushdecl): Adjust.

From-SVN: r246928
2017-04-14 11:44:27 +00:00
Nathan Sidwell
5dbb7fbad9 lex.c (unqualified_name_lookup_error): Use pushdecl.
Cleanups
	gcc/cp/
	* lex.c (unqualified_name_lookup_error): Use pushdecl.
	* name-lookup.h (push_local_binding): Delete.
	* name-lookup.c (add_decl_to_level): New, combining
	add_namespace_decl, add_local_decl.
	(namespace_push_binding, local_push_binding): Adjust.
	(do_pushdecl): Adjust.
	(push_local_binding): Make static.

From-SVN: r246920
2017-04-13 20:30:56 +00:00
Nathan Sidwell
4c5bc6f9fc Unify binding push part 7
Unify binding push part 7
	gcc/cp/
	* name-lookup.c (namespace_push_binding): Merge duplicate code
	from local_push_binding.  Chain the decl.
	(do_pushdecl): Adjust.

From-SVN: r246916
2017-04-13 18:58:46 +00:00
Nathan Sidwell
71b63835b7 Cleanup pushdecl interface
Cleanup pushdecl interface
	gcc/cp/
	* cp-lang.c (cxx_pushdecl): New.
	(LANG_HOOKS_PUSHDECL): Override.
	* name-lookup.h (pushdecl): Remove overload. Add default arg.
	* name-lookup.c (pushdecl): Likewise.
	gcc/c/
	* c-tree.h (pushdecl): Declare.
	gcc/c-family/
	* c-common.c (c_register_builtin_type): Use pushdecl lang hook.
	* c-common.h (pushdecl): Don't declare.

From-SVN: r246915
2017-04-13 18:17:59 +00:00
Nathan Sidwell
377d8946dd Some cleanups
Some cleanups
	gcc/cp/
	* name-lookup.c (update_local_overload): Drop oldval parm.
	(replace_local_overload_binding): Delete.  Fold into only caller.
	(fixup_unhidden_decl): Likewise.
	(augment_local_overload_binding): Likewise.

From-SVN: r246913
2017-04-13 17:37:50 +00:00
Nathan Sidwell
0dc1f35119 Unifying binding push part 5
Unifying binding push part 5
	gcc/cp/
	* name-lookup.c (find_local_binding): New.  Broken out of ...
	(find_local_value): ... this.  Use it.
	(update_local_overload): New.  Broken out of ...
	(replace_local_overload_binding): ... this.  Use it.
	(do_pushdecl): Keep local binding around.
	(local_push_binding): Consume supplement_binding, add_local_decl.

From-SVN: r246912
2017-04-13 17:17:17 +00:00
Nathan Sidwell
23bc933bdf Unifying binding push part 5
Unifying binding push part 5
	gcc/cp/
	* name-lookup.c (skip_anticipated_builtins): Kill.
	(namespace_push_binding): Consume supplement_binding.
	(do_pushdecl): Skip hidden builtin here.  Adjust.
	gcc/testsuite/
	* g++.dg/lookup/using59.C: New.

From-SVN: r246905
2017-04-13 14:17:44 +00:00
Nathan Sidwell
6f5b99c355 Unifying binding push part 4
Unifying binding push part 4
	gcc/cp/
	* name-lookup.c (namespace_push_binding, local_push_binding):
	Don't dup decls here. Deal with using.
	(do_pushdecl): Adjust.
	gcc/testsuite/
	* g++.dg/lookup/using58.C: New.

From-SVN: r246895
2017-04-12 19:26:49 +00:00
Nathan Sidwell
327cbef4e7 Separating namespace bindings part 18
Separating namespace bindings part 18
	gcc/cp/
	* name-lookup.c (create_local_binding) New.
	(do_local_push_overload): Turn into ...
	(local_push_binding): ... this.
	(do_pushdecl): Adjust.

From-SVN: r246878
2017-04-12 15:39:09 +00:00
Nathan Sidwell
4cc4d77d7d Separating namespace bindings part 17
Separating namespace bindings part 17
	gcc/cp/
	* name-lookup.c (create_namespace_binding) New.
	(find_namespace_binding): Use it.
	(do_namespace_push_overload): Convert to ...
	(namespace_push_binding): ... this.
	(do_pusdecl): Adjust

From-SVN: r246872
2017-04-12 13:23:13 +00:00
Nathan Sidwell
17b2e5f7be Separating namespace bindings part 16
Separating namespace bindings part 16
	gcc/cp/
	* name-lookup.c (do_pusdecl): Skip using decls.  Retain namespace.

From-SVN: r246870
2017-04-12 11:31:10 +00:00
Nathan Sidwell
56c5e38777 Separating namespace bindings part 15
Separating namespace bindings part 15
	gcc/cp/
	* cp-tree.h (PUSH_GLOBAL, PUSH_LOCAL, PUSH_USING): Delete.
	* lex.c (unqualified_name_lookup_error): Adjust push_local_binding
	call.
	* name-lookup.h (push_local_binding): Flags is now bool.
	* name-lookup.c (matching_using_decl_p): Rename to ...
	(matching_fn_p): ... here.  Update callers.
	(set_local_extern_decl_linkage): New.  Broken out of ...
	(do_pushdecl): ... here.  Call it.
	(push_local_binding, augment_local_overload_binding)
	do_local_push_overload, do_local_using_decl): Flags is now bool.
	gcc/testsuite/
	* g++.dg/lookup/extern-redecl1.C: New.
	* g++.dg/parse/ctor9.c: tweak.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/testsuite/g++.dg/parse/ctor9.C
A    gcc/testsuite/g++.dg/lookup/extern-redecl1.C
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/lex.c
M    gcc/cp/name-lookup.h

From-SVN: r246852
2017-04-11 17:54:10 +00:00
Nathan Sidwell
1f7da887cf Separating namespace bindings part 14
Separating namespace bindings part 14
	gcc/cp/
	* friend.c (do_friend): Use pushdecl directly.
	* name-lookup.h (lookup_name_innermost_nonclass_level): Delete.
	* name-lookup.c (find_local_value): New.  Broken out of ...
	(lookup_name_innermost_nonclass_level_1): ... here.  Call
	it.  Rename to ...
	(lookup_name_innermost_nonclass_level): ... this.  Delete external
	entry point.
	(do_pushdecl): Start handling binding levels directly.  Check
	local class friend injection rule.  More cleanup.
	gcc/testsuite/
	* g++.dg/lookup/friend12.C: Augment & adjust.
	* g++.old-deja/g++.jason/scoping12.C: Adjust.

From-SVN: r246841
2017-04-11 14:36:55 +00:00
Nathan Sidwell
4f3bce8e57 Separating namespace bindings part 12
Separating namespace bindings part 12
	gcc/cp/
	* name-lookup.c (do_pushdecl): Move overload pushing next to
	non-overload pushing.

From-SVN: r246836
2017-04-11 11:17:29 +00:00
Nathan Sidwell
c48a58d497 Separating namespace bindings part 11
Separating namespace bindings part 11
	gcc/cp/
	* name-lookup.c (check_local_shadow): Move lookup code to here ...
	(do_pushdecl): ... from here.

From-SVN: r246822
2017-04-10 20:24:44 +00:00
Nathan Sidwell
be1946ecc8 Separating namespace bindings part 10
Separating namespace bindings part 10
	gcc/cp/
	* name-lookup.c (do_pushdecl): Reorder & delete more obsolete code.

From-SVN: r246821
2017-04-10 20:02:22 +00:00
Nathan Sidwell
5b6b46ea07 Separating namespace bindings part 9
Separating namespace bindings part 9
	gcc/cp/
	* name-lookup.c (do_pushdecl): Delete a tonne of obsolete code.

From-SVN: r246815
2017-04-10 18:00:54 +00:00
Nathan Sidwell
62132f560d Fix bogus scope handling
Fix bogus scope handling
	gcc/cp/
	* call.c (make_temporary_var_for_ref_to_temp): Push temp into
	current scope.
	* decl.c (xref_tag_1): Pass ts_lambda to pushtag.
	* name-lookup (do_pushtag): Deal with ts_lambda scope.
	gcc/testsuite
	* g++.dg/cpp0x/forw_enum9.C: Fix testcase.

From-SVN: r246771
2017-04-07 17:57:25 +00:00
Nathan Sidwell
bc22b5b765 Separating namespace bindings part 8
Separating namespace bindings part 8
	gcc/cp/
	* name-lookup.c (do_pushdecl): Kill obsolete C-era code!

From-SVN: r246740
2017-04-06 18:55:26 +00:00
Nathan Sidwell
5a451db8ed Separating namespace bindings part 6
Separating namespace bindings part 6
	gcc/cp/
	* name-lookup.c (check_local_shadow, set_decl_context_in_fn):
	Break
	out and simplify from ...
	(do_pushdecl): ... here.  Call them.

From-SVN: r246736
2017-04-06 17:16:41 +00:00
Nathan Sidwell
e66251710d Separating namespace bindings part 6
Separating namespace bindings part 6
	gcc/c-family/
	* c-common.h (pushdecl_top_level): Delete.
	gcc/cp/
	* name-lookup.h (pushdecl_top_level): Delete non-friendly version.
	* name-lookup.c (check_extern_c_conflict): New.
	(lookup_extern_c_fun_in_all_ns): Delete.
	(do_pushdecl): Call it.  Rename variables sanely.
	(pushdecl_top_level): Delete non-friendly version.

From-SVN: r246727
2017-04-06 12:19:24 +00:00
Nathan Sidwell
a44a61a8c3 Separating namespace bindings part 5
Separating namespace bindings part 5
	gcc/cp/
	* name-lookup.h (getdecls): Rename to ...
	(get_local_decls): ... here.
	* name-lookup.c (pop_bindings_and_leave_scope): Adjust.
	(do_pushdecl): Add some asserts.
	(getdecls): Rename to ...
	(get_local_decls): ... here.  Assert local scope.
	* decl.c (poplevel): Adjust.
	(start_preparsed_function): Don't set current_function_decl, until
	decl is pushed.
	(store_parm_decls): Adjust.
	* parser.c (synthesize_implicit_template_parm): Adjust.

From-SVN: r246718
2017-04-05 19:11:34 +00:00
Nathan Sidwell
cb9e3b43ff Separating namespace bindings part 4
Separating namespace bindings part 4
	gcc/cp/
	* cp-lang.c (LANG_HOOKS_GETDECLS): Override.
	(get_global_decls): New.
	* decl.c (poplevel): Assert not in namespace.  Simplify.
	* name-lookup.c (pop_binding): Rename to ...
	(pop_local_binding): ... here.
	(pop_bindings_and_leave_scope): Adjust.
	(getdecls): Assert not in namespace.
	* name-lookup.h (pop_binding): Rename to ...
	(pop_local_binding): ... here.

From-SVN: r246709
2017-04-05 15:39:48 +00:00
Nathan Sidwell
a08ab803c9 Separating namespace bindings part 3
Separating namespace bindings part 3
	gcc/cp/
	* name-lookup.c (do_local_push_overload): New, split out of ...
	(push_overloaded_decl_1): ... this.  Delete.
	(push_overloaded_decl): Delete.
	(do_pushdecl): Adjust.

From-SVN: r246705
2017-04-05 14:47:32 +00:00
Nathan Sidwell
20436d4091 Separating namespace bindings part 2
Separating namespace bindings part 2
	gcc/cp/
	* name-lookup.c (compparms_for_decl_and_using_decl): Replace with
	...
	(matching_using_decl_p): ... this.
	(do_namespace_push_overload): New, split out of ...
	(push_overloaded_decl_1): ... this.
	(do_pushdecl): Adjust.
	(do_nonmember_using_decl): Adjust.

From-SVN: r246704
2017-04-05 14:26:23 +00:00
Nathan Sidwell
4f4e53d0dd name-lookup.h (get_global_value_if_present) is_typename_at_global_scope): Delete.
gcc/cp/
	* name-lookup.h (get_global_value_if_present)
	is_typename_at_global_scope): Delete.
	* class.c (build_vtbl_initializer): Adjust.
	* decl.c (grokdeclarator)
	* except.c (do_get_exception_ptr, do_begin_catch, do_end_catch)
	do_allocate_exception, do_free_exception, build_throw): Adjust.
	* init.c (throw_bad_array_new_length): Adjust.
	* rtti.c (throw_bad_cast, throw_bad_typeid): Adjust.

From-SVN: r246692
2017-04-04 18:56:47 +00:00
Nathan Sidwell
efc9fd75f9 cp-tree.h (CPTI_INIT_LIST_IDENTIFIER, [...]): New.
gcc/cp/
	* cp-tree.h (CPTI_INIT_LIST_IDENTIFIER, init_list_identifier):
	New.
	* decl.c (initialize_predefined_identifiers): Initialize
	initializer_list identifier.
	* call.c (is_std_init_list): Adjust.
	* name-lookup.c (do_pushtag): Likewise.
	* pt.c (listify): Likewise.

From-SVN: r246687
2017-04-04 17:53:59 +00:00
Nathan Sidwell
3864609ddb Separating namespace bindings part 1
Separating namespace bindings part 1
	gcc/cp/
	* name-lookup.h (namespace_binding, set_namespace_binding):
	Replace with ...
	(get_namespace_value, set_namespace_value): ... these.
	(get_global_value_if_present, is_typename_at_global_scope):
	Adjust.
	* cp-tree.h (IDENTIFIER_GLOBAL_VALUE)
	SET_IDENTIFIER_GLOBAL_VALUE): Adjust.
	(IDENTIFIER_NAMESPACE_VALUE, SET_IDENTIFIER_NAMESPACE_VALUE):
	Delete.
	* pt.c (listify): Use get_namespace_value.
	* decl.c (poplevel): Use get_namespace_value.
	* name-lookup.c (cp_binding_level_find_binding_for_name): Replace
	with ...
	(find_namespace_binding): ... this.
	(update_namespace_binding, find_namespace_value)
	add_namespace_decl, add_local_decl): New.
	(name_lookup::search_namespace_only)
	adl_lookup::assoc_namespace_only): Adjust.
	(binding_for_name, add_decl_to_level): Delete.
	(fixup_unhidden_decl, do_pushdecl, push_local_binding)
	check_for_out_of_scope_variable,
	set_identifier_type_value_with_scope, push_overloaded_decl_1):
	Adjust.
	(namespace_binding_1, namespace_binding): Replace with ...
	(get_namespace_value): ... this.
	(set_namespace_binding_1, set_namespace_binding): Replace with ...
	(set_namespace_value): ... this.
	(do_toplevel_using_decl, lookup_type_scope_1)
	lookup_name_innermost_nonclass_level_1, do_push_nested_namespace,
	push_namespace): Adjust.

From-SVN: r246685
2017-04-04 17:24:32 +00:00
Nathan Sidwell
1395cb732a Merge trunk r246647.
gcc/cp/
	* pt.c (): Adjust guiding decl code.
	libcc1/
	* libcp1plugin.cc (safe_pushdecl_maybe_friend): Adjust.
	(plugin_make_namespace_inline): Adjust.
	(plugin_add_using_namespace): Likewise.

From-SVN: r246649
2017-04-03 15:39:39 +00:00
Nathan Sidwell
6e529924ba Remove usings graph.
gcc/cp/
	* cp-tree.h (lang_decl_ns): Replace tree list ns_using, ns_users
	with tree vector usings & inlinees.
	(DCL_NAMES_SPACE_USING, DECL_NAMESPACE_INLINEES): Update.
	(TREE_INDIRECT_USING): Delete.
	* decl.c (cxx_init_decl_processing): Tweak.
	* name-lookup.h (cp_binding_level): using_directives is a vec.
	* name-lookup.c (name_lookup::do_queue_usings, queue_usings)
	search_namespace, search_usings, queue_namespace,
	search_unqualified, assoc_namespace_only): inlinees and usings are
	vectors.  Remove old TREE_LIST code.
	(namespace_ancestor_1, namespace_ancestor, add_using_namespace_1)
	add_using_namespace): Delete.
	(qualified_namespace_lookup): Tweak.
	(add_using_directive): New.
	(do_toplevel_using_directive, do_local_using_directive): Adjust.
	(push_namespace): Adjust.
	* tree.c (decl_anon_ns_mem_p): Reimplement.
	(cp_free_lang_data): Update.
((--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/decl.c
M    gcc/cp/tree.c
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h

From-SVN: r246647
2017-04-03 11:23:16 +00:00
Nathan Sidwell
811cb44e3e Reimplement unqualified namespace lookup
Reimplement unqualified namespace lookup
	gcc/cp/
	* name-lookup.c (name_lookup::state, name_lookup::preserve_state)
	name_lookup::restore_state): New.
	(name_lookup::queue_namespace)
	name_lookup::do_queue_usings, name_lookup::queue_usings,
	name_lookup::search_unqualified): New.
	(unqualified_namespace_lookup_1): Kill.
	(unqualified_namespace_lookup): Adjust.
	(lookup_using_namespace): Kill.
	gcc/testsuite/
	* g++.dg/lookup/lambda1.C: New.
((--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/name-lookup.c
A    gcc/testsuite/g++.dg/lookup/lambda1.C

From-SVN: r246623
2017-03-31 18:49:12 +00:00
Nathan Sidwell
49e67a014c name-lookup.c (name_lookup::scopes): Make static.
gcc/cp/
	* name-lookup.c (name_lookup::scopes): Make static. Adjust uses.
	(name_lookup::search_namespace_only): Broken out of ...
	(name_lookup::search_namespace): ... here.  Call it.
	* tree.c (ovl_cache): New.
	(ovl_make, ovl_lookup_keep): Use it.

From-SVN: r246615
2017-03-31 12:49:23 +00:00
Nathan Sidwell
be149ec9e5 dump.c (cp_dump_tree): Allow nested overloads.
gcc/cp/
	* dump.c (cp_dump_tree): Allow nested overloads.

From-SVN: r246593
2017-03-30 17:57:42 +00:00
Nathan Sidwell
66596af6a4 Add SCOPE_DEPTH
Add SCOPE_DEPTH
	gcc/cp/
	* cp-tree.h (SCOPE_DEPTH): New.
	* decl.c (cxx_init_decl_processing): Set current_namespace.
	* name-lookup.h (is_nested_namespace): Declare.
	(is_associated_namespace): Delete.
	* name-lookup.c (is_nested_namespace): New.
	(is_ancestor): Use is_nested_namespace for namespaces.
	(set_decl_namespace): Use is_nested_namespace.
	(namespace_ancestor_1): Likewise.
	(is_associated_namespace): Delete.
	(push_namespace): Set SCOPE_DEPTH.
	* pt.c (check_specialization_namespace): Use is_nested_namespace.
	(check_unqualified_spec_or_inst): Likewise.

From-SVN: r246592
2017-03-30 17:57:17 +00:00
Nathan Sidwell
ab7d9531a8 Reimplement qualified namespace lookup
Reimplement qualified namespace lookup
	gcc/cp/
	* name-lookup.c (cp_binding_level_find_binding_for_name): Remove
	premature optimiation.
	(find_binding): Delete.
	(name_lookup): Add flags, move scopes from adl_lookup.
	(name_lookup::search_namespace, search_usings, search_qualified):
	New.
	(tree_vec_contains): Kill.
	(qualified_namespace_lookup): Kill old O(N^2) code.

From-SVN: r246591
2017-03-30 15:25:26 +00:00
Nathan Sidwell
1c074986ac pt.c (determine_specialization): Use 2-d iterator
gcc/cp/
	* pt.c (determine_specialization): Use 2-d iterator

From-SVN: r246590
2017-03-30 15:24:43 +00:00
Nathan Sidwell
8627712c3d cp-tree.h (LOOKUP_MARKED_P, [...]): Rename to ...
gcc/cp/
	* cp-tree.h (LOOKUP_MARKED_P, RECORD_MARKED_P): Rename to ...
	(LOOKUP_SEEN_P, LOOKUP_FOUND_P): ... here.  Update everywhere.

From-SVN: r246571
2017-03-29 14:44:48 +00:00
Nathan Sidwell
39aad24534 name-lookup.c (arg_assoc::assoc_expr): Refactor.
gcc/cp/
	* name-lookup.c (arg_assoc::assoc_expr): Refactor.
	(do_lookup_arg_dependent): Renamed from lookup_arg_dependent_1.
	(lookup_arg_dependent): Adjust.
	(qualified_namespace_lookup): Renamed from
	qualified_lookup_using_namespace.

From-SVN: r246568
2017-03-29 12:57:02 +00:00
Nathan Sidwell
1278c39cde Kill DECL_NAMESPACE_ASSOCATIONS
Kill DECL_NAMESPACE_ASSOCATIONS
	gcc/cp/
	* cp-tree.h (DECL_NAMESPACE_INLINE_P): Renamed.
	(DECL_NAMESPACE_ASSCIATIONS): Delete.
	(DECL_NAMESPACE_INLINEES): New.
	* name-lookup.c (adl_lookup::assoc_namespace_only): New.
	(adl_lookup::assoc_namespace): Find parent, walk from there.
	(is_associated_namespace): Walk inline namespace tree.
	(push_namepace): Add to INLINEES not ASSOCIATIONS.

From-SVN: r246565
2017-03-29 12:01:27 +00:00
Nathan Sidwell
764954a3eb lambda.c (maybe_add_lambda_conv_op): Use namespace_bindings_p.
gcc/cp/
	* lambda.c (maybe_add_lambda_conv_op): Use namespace_bindings_p.
	* method.c (implicitly_declare_fn): Likewise.
	* search.c (node_debug_info_needed): Likewise.

From-SVN: r246564
2017-03-29 10:36:40 +00:00
Nathan Sidwell
3af6140de8 name-lookup.h (finish_namespace_using_directive): Rename from ...
gcc/cp/
	* name-lookup.h (finish_namespace_using_directive): Rename from
	...
	(finish_toplevel_using_directive): ... here.
	* name-lookup.c: Likewise.
	* parser.c (cp_parser_using_directive): Adjust.

From-SVN: r246562
2017-03-29 10:21:12 +00:00
Nathan Sidwell
a4aea4c7c6 Cleanup pushdecl_top_level
Cleanup pushdecl_top_level
	gcc/cp/
	* cp-tree.h (pushdecl_top_level_maybe_friend)
	pushdecl_top_level_and_finish): Delete.
	* decl.c (cp_make_fname_decl): Adjust.
	* decl2.c (get_guard, handle_tls_init): Likewise.
	* pt.c (tsubst_friend_class): Likewise.
	* rtti.c (get_tinfo_decl, tinfo_base_init): Likewise.
	* name-lookup.h (pushdecl_top_level, pushdecl_top_level_init):
	Declare.
	* name-lookup.c (pushdecl_top_level_1): Rename to ...
	(push_decl_top_level): ... here.
	(pushdecl_top_level_init): New.
	(pushdecl_top_level_maybe_friend): Delete.
	(pushdecl_top_level_and_finish): Delete.
(--This line, and those below, will be ignored--

M    gcc/cp/name-lookup.h
M    gcc/cp/pt.c
M    gcc/cp/cp-tree.h
M    gcc/cp/decl.c
M    gcc/cp/rtti.c
M    gcc/cp/name-lookup.c
M    gcc/cp/decl2.c
M    ChangeLog.modules

From-SVN: r246552
2017-03-28 19:16:21 +00:00
Nathan Sidwell
4203e66ad5 Cleanup pushdecl
Cleanup pushdecl
	gcc/cp/
	* cp-tree.h (pushdecl, pushdecl_maybe_friend): Delete.
	(pushtag): Delete.
	* decl.c (cp_make_fname_decl): Call pushdecl_outermost_localscope.
	* lambda.c (insert_capture_proxy): Likewise.
	* friend.c (do_friend): Call overloaded pushdecl.
	* name-lookup.h (pushdecl_with_scope): Delete.
	(pushdecl, pushtag, pushdecl_outermost_localscope): Declare.
	* name-lookup.c (pushdecl_maybe_friend_1): Rename to ...
	(do_pushdecl): ... here.
	(pushdecl_maybe_friend): Replace with overloaded pushdecl.
	(pushdecl): Adjust.
	(pushdecl_with_scope_1): Rename to do_pushdecl_with_scope. Adjust.
	(pushdecl_with_scope): Delete.
	(pushdecl_outermost_localscope): New.
	(pushdecl_namespace_level): Adjust.
	(do_pushtag): Renamed from pushtag_1.
	(pushtag): Adjust.

From-SVN: r246551
2017-03-28 18:47:14 +00:00
Nathan Sidwell
c47cda83ac Cleanup namespace push/pop part 2
Cleanup namespace push/pop part 2
	gcc/cp/
	* module.c (cpms_in::finish_namespace): Adjust.
	(push_module_namespace): Adjust.
	* name-lookup.c (push_namespace, pop_namespace): Reimplement.
	(make_namespace_inline): Delete.
	* name-lookup.h (push_namespace): Change prototype.
	* parser.c (cp_parser_namespace_definition): Adjust.

From-SVN: r246544
2017-03-28 16:52:42 +00:00
Nathan Sidwell
88434e14d1 Cleanup namespace push/pop
Cleanup namespace push/pop
	gcc/cp/
	* cp-tree.h (CPTI_GLOBAL, CPTI_GLOBAL_IDENTIFIER)
	(CPTI_GLOBAL_TYPE)
	CPTI_ANON_IDENTIFIER): New.
	(global_namespace, global_identifier, global_type_node)
	anon_identifier): New.
	* decl.c (global_type_node, global_scope_name): Delete.
	(initialize_predefined_identifiers): Add new idents.
	(cxx_init_decl_processing): Adjust.
	* name-lookup.h (global_namespace, global_scope_name)
	global_type_node): Delete.
	* name-lookup (global_namespace, anonymous_namespace_name)
	get_anonomous_namespace_name): Delete.
	(do_push_nested_namespace, do_pop_nested_namespace): New.
	(push_nested_namespace, pop_nested_namespace): Reimplement.
((((--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/name-lookup.h
M    gcc/cp/cp-tree.h
M    gcc/cp/decl.c
M    gcc/cp/name-lookup.c

From-SVN: r246539
2017-03-28 15:24:20 +00:00
Nathan Sidwell
cddc4035a9 Cleanup using-directives
Cleanup using-directives
	gcc/cp/
	* cp-tree.h (LOOKUP_MARKED_P): Rename from NAME_MARKED_P, update
	all.
	* name-lookup.h (finish_toplevel_using_directive)
	finish_local_using_directive): Declare.
	(do_using_directive, parse_using_directive): Delete.
	* name-lookup.c (do_using_directive): Delete.
	(do_toplevel_using_directive): Reimplement.
	(do_local_using_directive, do_local_using_directive_1): New.
	(parse_using_directive): Delete.
	(push_using_directive, push_using_directive_1): Delete.
	(finish_toplevel_using_directive, finish_local_using_directive):
	New.
	* pt.c (tsubst_expr): Adjust.
	* parser.c (cp_parser_using_directive): Adjust.
(--This line, and those below, will be ignored--

M    gcc/testsuite/g++.dg/lookup/strong-using-6.C
M    gcc/cp/tree.c
M    gcc/cp/cp-tree.h
M    gcc/cp/pt.c
M    gcc/cp/name-lookup.c
M    gcc/cp/name-lookup.h
M    gcc/cp/parser.c
M    ChangeLog.modules

From-SVN: r246535
2017-03-28 14:17:06 +00:00
Nathan Sidwell
d5716a7681 Kill strong using
Kill strong using
	gcc/
	* doc/extend.texi (Namespace Association): Document removal.
	gcc/cp/
	* name-lookup (parse_using_directive): Remove strong handling.
	gcc/testsuite/
	* g++.dg/lookup/strong-using-6.C: New.

From-SVN: r246531
2017-03-28 11:53:51 +00:00
Nathan Sidwell
2d2dab31cd Simplify ADL part 2
Simplify ADL part 2
	gcc/cp
	* cp-tree.h (RECORD_MARKED_P): New.
	* tree.c (ovl_lookup_keep): Allow NULL.
	* name-lookup.c (struct adl_lookup): New.
	(struct arg_lookup): Delete.

From-SVN: r246501
2017-03-27 14:01:01 +00:00
Nathan Sidwell
9d61795051 tree.h (TREE_CHECK6): New.
gcc/
	* tree.h (TREE_CHECK6): New.
	(tree_check6): New.
	gcc/cp/
	* cp-tree.h (NAME_MARKED_P): Add UNION_TYPE.
	* name-lookup.c (arg_lookup): Replace namespace & class vectors
	with visited.
	(arg_assoc_namespace, arg_assoc_class): Use NAME_MARKED_P.
	(lookup_arg_dependent_1): Unmark namespaces and classes.

From-SVN: r246466
2017-03-24 17:46:11 +00:00
Nathan Sidwell
51565f2112 cp-tree.h (ovl2_iterator::operator++): Tweak.
gcc/cp/
	* cp-tree.h (ovl2_iterator::operator++): Tweak.

From-SVN: r246465
2017-03-24 16:58:44 +00:00
Nathan Sidwell
0b4796777d Tweak
From-SVN: r246464
2017-03-24 16:46:15 +00:00
Nathan Sidwell
08fa8ee703 Simplify ADL part 1
Simplify ADL part 1
	gcc/cp/
	* cp-tree.h (OVL_LOOKUP_P, NAME_MARKED_P): New.
	(OVL_TRANSIENT_P): Morph into ...
	(OVL_USED_P): ... this.
	(ovl_add_transient): Kill.
	(ovl_maybe_keep): Replace with ...
	(ovl_lookup_keep): ... this.
	(ovl_lookup_mark, ovl_lookup_add): Declare.
	* tree.c (ovl_add): Rename arg.  Set OVL_LOOKUP_P.
	(ovl_add_transient): Kill.
	(ovl_lookup_mark, ovl_lookup_add): New.
	(ovl_maybe_keep): Rename to ...
	(ovl_lookup_keep): ... this.  Adjust.
	* name-lookup.c (name_lookup::add): Use ovl_add directly.
	(struct arg_lookup): Kill args and fn_set.
	(add_function): Replace with ...
	(add_functions): ... this.
	(arg_assoc_namespace, arg_assoc_class_only): Use it.
	(lookup_arg_dependent_1): Use new API.
	* pt.c (tsubst_copy): Assert OVERLOAD is marked used.
	* semantics.c (finish_call_expr): Adjust.

From-SVN: r246463
2017-03-24 16:45:05 +00:00
Nathan Sidwell
d74e0ac93d Fixup transient_p bug
Fixup transient_p bug
	gcc/cp/
	* tree.c (ovl_add): Set TRANSIENT_P here.
	(ovl_add_transient): Not here.

From-SVN: r246432
2017-03-24 02:10:16 +00:00
Nathan Sidwell
f1f91f036b cp-tree.h (type_unknown_p): Make inline.
gcc/cp/
	* cp-tree.h (type_unknown_p): Make inline.  Lose TREE_LIST case.
	* tree.c (type_unknown_p): Delete.
	* name-lookup.c (arg_assoc): Lose TREE_LIST case.

From-SVN: r246427
2017-03-23 20:23:21 +00:00
Nathan Sidwell
f066562ac5 cp-tree.h (OVL_P, [...]): New.
gcc/cp/
	* cp-tree.h (OVL_P, OVL_PLURAL_P): New.
	* name-lookup.c (name_lookup::add, diagnose_name_conflict)
	pushdecl_maybe_friend_1, push_overloaded_decl_1,
	do_nonmember_using_decl, push_class_level_binding_1,
	set_decl_namespace, lookup_arg_dependent_1): Use OVL_P.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c

From-SVN: r246421
2017-03-23 17:18:12 +00:00
Nathan Sidwell
ebd076f807 Two dimensional OVERLOADs
Two dimensional OVERLOADs
	gcc/cp/
	* cp-tree.h (OVL_FIRST): Call ovl_first.
	(ovl_iterator): Add allow_inner, adjust.
	(ovl2_iterator): New.
	(ovl_first): New.
	* name-lookup.c (name_lookup::add): Create 2d overload.
	(do_nonmember_using_decl): 2D overload.
	(lookup_arg_dependent_1, cp_emit_debug_info_for_using): Likewise.
	* call.c (add_candidates): Likewise.
	* class.c (resolve_address_of_overloaded_function): Likewise.
	* parser.c (cp_parser_template_name): Likewise.
	* pt.c (type_dependent_expression_p): Likewise.
	(print_candidates_1): Likewise.
	* ptree.c (cxx_print_xnode): Allow inner overload.
	* semantics.c (finish_call_expr): Keep overload, 2D overload.
	* tree.c (ovl_scope): Allow inner overload.
	gcc/testsuite/
	* g++.dg/lookup/using57.C: New.

From-SVN: r246420
2017-03-23 16:47:17 +00:00
Nathan Sidwell
744509bac9 add comment
From-SVN: r246393
2017-03-22 17:30:57 +00:00
Nathan Sidwell
ada2f51267 name-lookup.c (lookup_qualified_name): Unwrap singleton overload.
gcc/cp/
	* name-lookup.c (lookup_qualified_name): Unwrap singleton
	overload.
	(lookup_name_real_1): Remove ovl_hidden assert.
	(lookup_arg_dependent_1): Don't skip hidden here.
	* parser.c (cp_parser_lookup_name): Don't unwrap singleton
	overload here.

From-SVN: r246390
2017-03-22 16:29:00 +00:00
Nathan Sidwell
29524cc00a name-lookup.c (lookup_name_real_1): Don's skip hidden here.
gcc/cp/
	* name-lookup.c (lookup_name_real_1): Don's skip hidden here.
	Simplify singleton overload extraction.
	* tree.c (ovl_add): Assert no unexpected 2 dimensional overloads.
	gcc/
	* system.h (ATTRIBUTE_NTC_PURE): Define.
	* tree.h (tree_fits_shwi_p, tree_fits_uhwi_p): Use it.

From-SVN: r246344
2017-03-22 02:41:37 +00:00
Nathan Sidwell
c49455c0c2 Refactor lookup part 1
Refactor lookup part 1
	gcc/cp/
	* name-lookup.c (struct name_lookup): New.
	(struct scope_binding): Delete.
	(EMPTY_SCOPE_BINDING): Delete.
	(build_ambigious): New.
	(name_lookup::add): New.
	(do_nonmember_using_decl): Take pointer to cxx_binding.  Adjust.
	(do_local_using_decl, do_toplevel_using_decl): Adjust.
	(merge_functions, same_entity_p, ambiguous_decl): Delete.
	(suggest_alternatives_for): Adjust lookup functions.
	(unqualified_namespace_lookup_1): Use name_lookup.
	(lookup_qualified_name): Likewise.
	(lookup_using_namespace, qualified_lookup_using_namespace): Take a
	name_lookup.
	gcc/testsuite/
	* g++.dg/lookup/using17.C: Adjust error message.

From-SVN: r246338
2017-03-21 23:58:56 +00:00
Nathan Sidwell
3d134dc800 Keep hidden overloads at start of list
Keep hidden overloads at start of list
	gcc/cp
	* cp-tree.h (OVL_HIDDEN_P): New.
	(ovl_iterator::hidden_p, unhide): New.
	(DECL_HIDDEN_P): New.
	(hidden_name_p, remove_hidden_names): Delete.
	(ovl_skip_hidden): Declare.
	* decl.c (builtin_function_1): Set DECL_ANTICIPATED before
	pushing.
	(xref_tag_1): Replace hidden_name_p with DECL_HIDDEN_P.
	* name-lookup.c (anticipated_builtin_p)
	skip_anticipated_buitins): New.
	(supplement_binding_1): Use anticipated_builtin_p.
	(replace_local_overload_binding): New. Broken out of
	augment_local_overload_binding.
	(fixup_unhidden_decl): New.
	(pushdecl_maybe_friend_1): Deal with unhiding decl.  Set
	DECL_ANTICIPATED before really pushing.
	(augment_local_overload_binding): Call
	replace_local_overload_binding.
	(push_overloaded_decl_1): Deal with unhiding decl.
	(do_nonmember_using_decl): Use anticipated_builtin_p.
	(ambiguous_decls): Use ovl_skip_hidden.
	(lookup_name_real_1): Use DECL_HIDDEN_P, ovl_skip_hidden.
	(arg_assoc_namespace): Use DECL_HIDDEN_P.
	(lookup_arg_dependent_1): Use ovl_skip_hidden.
	* pt.c (instantiate_class_template): Use DECL_HIDDEN_P.
	* tree.c (ovl_move_unhidden): New.
	(ovl_add): Deal with hiddenness.
	(ovl_add_transient): Adjust.
	(hidden_name_p, remove_hidden_names): Delete.
	(ovl_skip_hidden): New.
	(ovl_iterator::ovl_unhide): New.
	gcc/testsuite/
	* g++.dg/lookup/friend19.C: New.
	* g++.dg/lookup/using56.C: New.
(--This line, and those below, will be ignored--

A    gcc/testsuite/g++.dg/lookup/friend19.C
A    gcc/testsuite/g++.dg/lookup/using56.C
M    gcc/cp/pt.c
M    gcc/cp/cp-tree.h
M    gcc/cp/decl.c
M    gcc/cp/name-lookup.c
M    gcc/cp/tree.c

From-SVN: r246332
2017-03-21 18:37:35 +00:00
Nathan Sidwell
be271c2922 New OVERLOAD representation part 6
New OVERLOAD representation part 6
	gcc/cp/
	* cp-tree.h: Move ovl handling fns to original location.
	* tree.c (ovl_add): Use ovl_make.
	(ovl_add_transient): Use ovl_add.

From-SVN: r246198
2017-03-16 14:40:26 +00:00
Nathan Sidwell
14e655206c New OVERLOAD representation part 5
New OVERLOAD representation part 5
	gcc/cp/
	* cp-tree.h (OVL_NEXT): Delete. Update uses.
	(OVL_CHAIN): Check for overload.

From-SVN: r246195
2017-03-16 13:57:17 +00:00
Nathan Sidwell
3e775337d3 New OVERLOAD representation part 4
New OVERLOAD representation part 4
	gcc/cp/
	* cp-tree.h (OVL_CURRRENT): Delete.
	(ovl_make): Declare.
	* tree.c (ovl_make): New.
	* constraint.cc (finish_shorthand_constraint): Use ovl_make.
	* typeck.c (build_x_unary_op): Likewise.

From-SVN: r246194
2017-03-16 13:31:42 +00:00
Nathan Sidwell
65369f7a1e New OVERLOAD representation part 3
New OVERLOAD representation part 3
	gcc/cp/
	* cp-tree.h: Remove OVLNEW pieces.
	* tree.c: Likewise.

From-SVN: r246193
2017-03-16 13:05:45 +00:00
Nathan Sidwell
9121170048 New OVERLOAD representation part 2
New OVERLOAD representation part 2
	gcc/cp/
	* cp-tree.h (OVL_VIA_USING_P, OVL_TRANSIENT_P, OVL_SINGLE_P): New
	names.
	* error.c, name-lookup.c, parser.c, search.c, tree.c: Adjust uses.

From-SVN: r246192
2017-03-16 12:50:55 +00:00
Nathan Sidwell
87e9483105 New OVERLOAD representation part 1
New OVERLOAD representation part 1
	gcc/cp/
	* cp-tree.h (OVL_LENGTH, OVL_USINGS, OVL_FIRST, OVL_NAME)
	OVL_SINGLE, OVL_ELT, OVL_HAS_USING, OVL_HAS_HIDDEN): New.
	(ovl_iterator): Implement new-style iterator.
	* tree.c (tree_ovl_elt_check_failed): New.
	(ovl_maybe_keep): Fixup bracing.
	(ovl_scope): Add new smarts.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/tree.c
M    gcc/cp/cp-tree.h

From-SVN: r246172
2017-03-15 19:38:07 +00:00
Nathan Sidwell
f061d25698 Vectorize OVERLOAD part 9
Vectorize OVERLOAD part 9
	gcc/cp/
	* cp-tree.h (build_new_function_call): Lose koenig_p arg.
	(OVL_HAS_USING): New.
	* call.c (build_new_function_call): Lose koenig_p arg.
	* name-lookup.c (augment_local_overload_binding): New.  Broken out
	of ...
	(push_overloaded_decl_1): ... here.  Call it.
	(do_nonmember_using_decl): Lose augment arg.
	(do_local_using_decl): Use augment_local_overload_binding.
	(do_toplevel_using_decl): Adjust do_nonmember_using_decl call.
	* search.c (lookup_field_r): Use OVL_HAS_USING.
	* pt.c (do_class_deduction): Adjust build_new_function_call call.
	* semantics.c (finish_call_expr): Likewise.

From-SVN: r246171
2017-03-15 18:40:14 +00:00
Nathan Sidwell
2a3c375552 Vectorize OVERLOAD part 8
Vectorize OVERLOAD part 8
	gcc/cp/
	* cp-tree.h (ovl_add_transient): Declare.
	* tree.c (ovl_add_transient): New.
	(remove_hidden_names): Build transient.
	* name-lookup.c (do_nonmember_using_decl): Add AUGMENT parm,
	adjust.
	(do_local_using_decl): Ask for newvals from
	do_nonmember_using_decl, iterate over that list.
	(do_toplevel_using_decl): Ask for augmented vals.
	(add_function): Return void.  Remove extraneous
	checks.  Update callers.
	* semantics.c (finish_call_expr): Always call ovl_maybe_keep.

From-SVN: r246169
2017-03-15 17:13:38 +00:00
Nathan Sidwell
715d46e75b Vectorize OVERLOAD part 7
Vectorize OVERLOAD part 7
	gcc/cp/
	* name-lookup.c (hidden_name_p, remove_hidden_names): Move
	declarations to ...
	* cp-tree.h (hidden_name_p, remove_hidden_names): ... here.
	* call.c (build_new_function_call): Remove hidden pruning.
	* name-lookup.c (hidden_name_p, remove_hidden_names): Move to
	tree.c.
	(lookup_name_real_1): Adjust hidden_name_p call.
	(lookup_arg_dependent_1): Adjust remove_hidden_names call.
	* tree.c (hidden_name_p, remove_hidden_names): Moved from
	name-lookup.h.  Adjust.

From-SVN: r246164
2017-03-15 14:35:02 +00:00
Nathan Sidwell
bd628b05a9 Vectorize OVERLOAD part 6
Vectorize OVERLOAD part 6
	gcc/cp/
	* cp-tree.h (OVL_TRANSIENT): Rename from OVL_ARG_DEPENDENT.
	* tree.c (ovl_maybe_keep): Adjust.
	* name-lookup.c (set_namespace_binding_1): Use OVL_SINGLE.
	(lookup_name_real_1): Use OVL_FIRST.
	(add_function): Set OVL_TRANSIENT.
	(lookup_arg_dependent_1): Use OVL_FIRST.
	(cp_emit_debug_info_for_using): Use iterator.

From-SVN: r246159
2017-03-15 12:47:37 +00:00
Nathan Sidwell
774664816a Add OVERLOAD iterator part 8
Add OVERLOAD iterator part 8
	gcc/cp/
	* name-lookup.c (do_nonmember_using_decl): Use iterators

From-SVN: r246158
2017-03-15 12:01:48 +00:00
Nathan Sidwell
16a74d2d8c Add OVERLOAD iterator part 6
Add OVERLOAD iterator part 6
	gcc/cp/
	* name-lookup.c (pushdecl_maybe_friend_1): Use OVL_FIRST.
	(push_overloaded_decl_1): Use iterators.
	(consider_binding_level): Use OVL_FIRST.

From-SVN: r246157
2017-03-15 11:35:15 +00:00
Nathan Sidwell
8e03e2876d Add OVERLOAD iterator part 6
Add OVERLOAD iterator part 6
	gcc/cp/
	* decl2.c (check_class_fn): Use iterators.
	* semantics.c (omp_reduction_lookup): Likewise.
	(finish_omp_reduction_clause): Don't OVL_FIRST here.

From-SVN: r246141
2017-03-14 20:33:37 +00:00
Nathan Sidwell
3a1ebda2c2 Vectorize OVERLOAD part 5
Vectorize OVERLOAD part 5
	gcc/cp/
	* cp-tree.h (ovl_maybe_keep): Declare.
	* tree.c (ovl_maybe_keep): New.
	* semantics.c (finish_call_expr): Call it.
	(finish_omp_clauses): Use new accessrs.
	* class.c (handle_using_decl): Use new accessors.
	(resolve_address_of_overloaded_function): Likewise.
	* pt.c (print_candidates_1, print_candidates): Reimplement.

From-SVN: r246140
2017-03-14 19:50:31 +00:00
Nathan Sidwell
3b2cfc7e53 Vectorize OVERLOAD part 5
Vectorize OVERLOAD part 5
	* cp-tree.h (OVL_SINGLE): New.
	* constraint.cc (resove_constraint_check): Use new iterator.
	(normalize_template_id_expression): Use OVL_FIRST.
	* cvt.c (build_expr_type_conversions): Likewise.
	* error.c (dump_decl): Use OVL_SINGLE.
	* parser.c (cp_parser_nested_name_specifier_opt): Likewise.
	* tree.c (is_overloaded_fn): Likewise.

From-SVN: r246139
2017-03-14 17:57:25 +00:00
Nathan Sidwell
0a12cc87c9 Add OVERLOAD iterator part 5
Add OVERLOAD iterator part 5
	gcc/cp/
	* cp-tree.h (ovl_iterator::via_using_p): New.
	(ovl_iterator::replace): New.
	(clone_function_decl): Add via_using parm.
	* tree.c (ovl_iterator::replace): New.
	* class.c (add_method): Use ovl_iterator.
	(clone_function_decl): Add via_using parm.  Pass it to add_method.
	(clone_costructors_and_destructors): Pass via_using.
	* pt.c (tsubst_decl, instantiate_template_1): Update
	clone_function_decl call.

From-SVN: r246136
2017-03-14 16:15:58 +00:00
Nathan Sidwell
2703163e54 Change add_method signature
Change add_method signature
	gcc/cp/
	* cp-tree.h (add_method): Change 3rd arg.
	* class.c (add_method): Change 3rd arg to bool. Update.
	(handle_using_decl, one_inheriting_sig, one_inherited_ctor)
	clone_function_decl, finish_struct): Update add_method calls.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.
	* method.c (lazily_declare_fn): Likewise.
	* semantics.c (finish_member_declaration): Likewise.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/semantics.c
M    gcc/cp/lambda.c
M    gcc/cp/cp-tree.h
M    gcc/cp/class.c
M    gcc/cp/method.c

From-SVN: r246123
2017-03-14 13:36:43 +00:00
Nathan Sidwell
ed16a4f609 Kill get_first_fn part 3
Kill get_first_fn part 3
	gcc/cp/
	* cp-tree.h (get_first_fn): Delete.
	* pt.c (iterative_hash_template_arg, tsubst_copy_and_build): Use
	get_ovl.
	(tsubst_baselink): Use OVL_NAME.
	* typeck.c (invalid_nonstatic_memfn_p, build_x_unary_op)
	cp_build_addr_expr_1): Use get_ovl.
	(finish_class_member_access_expr): Use OVL_NAME.
	* tree.c (dependent_name): Recode.
	(get_first_fn): Delete.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/tree.c
M    gcc/cp/typeck.c
M    gcc/cp/pt.c
M    gcc/cp/cp-tree.h

From-SVN: r246104
2017-03-13 18:24:18 +00:00
Nathan Sidwell
2474ff1496 Kill get_first_fn part 2
Kill get_first_fn part 2
	gcc/cp/
	* cp-tree.h (get_ovl): Add want_first parm, make pure.
	* constexpr.c (potential_constant_expression_1): Adjust get_ovl.
	* lambda.c (lambda_function): Likewise.
	* error.c (dump_decl): Use identifier_p.
	* mangle.c (write_expression): Use OVL_NAME.
	* name-lookup.c (pushdecl_class_level): Likewise.
	* parser.c (cp_parser_postfix_expression)
	cp_parser_expression_statement, cp_parser_direct_declarator,
	cp_parser_constructor_declarator_p): Use get_ovl.
	* search.c (lookup_member0: Likewise.
	* typeck2.c (cxx_incomplete_type_diagnostic): Likewise.
	* semantics.c (perform_koenig_lookup): Use OVL_NAME.
	(finish_call_expr, finish_id_expression): Use get_ovl.
	* tree.c (get_ovl): Add want_first arg, adjust.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/lambda.c
M    gcc/cp/semantics.c
M    gcc/cp/name-lookup.c
M    gcc/cp/tree.c
M    gcc/cp/mangle.c
M    gcc/cp/search.c
M    gcc/cp/typeck2.c
M    gcc/cp/constexpr.c
M    gcc/cp/error.c
M    gcc/cp/parser.c
M    gcc/cp/cp-tree.h

From-SVN: r246102
2017-03-13 17:52:38 +00:00
Nathan Sidwell
e635900fff Kill get_first_fn part 1
Kill get_first_fn part 1
	gcc/cp/
	* call.c (add_list_candidates, build_new_method_call_1): Use
	OVL_FIRST directly.
	* constraint.cc (function_concept_check_p): Likewise.
	* name-lookup.c (validate_nonmember_using_decl): Likewise.
	* constexpr.c (potential_constant_expression_1): Use ovl_fns &
	OVL_FIRST.
	* lambda.c (lambda_function): Likewise.
	* decl.c (grokdeclarator): Use OVL_NAME.
	* error.c (dump_decl): Likewise.
	* friend.c (do_friend): Likewise.
	* mangle.c (write_expression): Likewise.

From-SVN: r246099
2017-03-13 16:30:24 +00:00
Nathan Sidwell
03becee564 Kill get_fns
Kill get_fns
	gcc/cp/
	* cp-tree.h (get_ovl): New.
	(get_fns): Delete.
	* parser.c (cp_parser_nested_name_specifier_opt): Update.
	* search.c (shared_member_p): Update.
	* semantics.c (omp_reduction_lookup): Update.

From-SVN: r246097
2017-03-13 15:22:08 +00:00
Nathan Sidwell
d1567b5046 Kill ovl_cons
Kill ovl_cons
	gcc/cp/
	* cp-tree.h (ovl_cons): Delete.
	* tree.c (ovl_cons): Delete.
	* class.c (add_method): Use ovl_add.
	* name-lookup.c (push_overloaded_decl_1): Likewise.
	* pt.c (check_explicit_specialization, do_class_deduction):
	Likewise.
	* typeck.c (build_x_unary_op): Likewise.

From-SVN: r246095
2017-03-13 14:43:52 +00:00
Nathan Sidwell
e363f1042d Kill build_overload
Kill build_overload
	gcc/cp/
	* cp-tree.h (ovl_add): Declare.
	(build_overload): Delete.
	* tree.c (ovl_add): New.
	(build_overload): Delete.
	* class.c (add_method): Use ovl_add.
	* constraint.cc (finish_shorthand_constraint): Likewise.
	* name-lookup.c (do_nonmember_using_decl, merge_functions)
	remove_hidden_names, add_function): Likewise.
	* pt.c (make_constrained_auto): Likewise.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h
M    gcc/cp/name-lookup.c
M    gcc/cp/class.c
M    gcc/cp/tree.c
M    gcc/cp/pt.c
M    gcc/cp/constraint.cc

From-SVN: r246094
2017-03-13 14:19:37 +00:00
Nathan Sidwell
9152fd207f Rename OVL_USED
Rename OVL_USED
	* gcc/cp/
	* cp-tree.h (OVL_USED): Rename to ...
	(OVL_VIA_USING): ... here.
	* class.c (add_method): Update.
	* tree.c (ovl_scope): Update.
	* search.c (lookup_field_r): Update.
	* name-lookup.c (push_overloaded_decl_1)
	do_nonmember_using_decl): Update.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/class.c
M    gcc/cp/tree.c
M    gcc/cp/cp-tree.h
M    gcc/cp/search.c
M    gcc/cp/name-lookup.c

From-SVN: r246093
2017-03-13 13:42:00 +00:00
Nathan Sidwell
3384344885 Add OVERLOAD iterator part 4
Add OVERLOAD iterator part 4
	gcc/cp/
	* tree.c (cp_tree_equal): Use ovl_iterator.

From-SVN: r246092
2017-03-13 13:20:10 +00:00
Nathan Sidwell
0c118822f5 Vectorize OVERLOAD part 4
Vectorize OVERLOAD part 4
	gcc/cp/
	* cp-tree.h (ovl_iterator::ref): New.
	* semantics.c (finish_omp_reduction_clause): Use OVL_FIRST.
	* tree.c (is_overloaded_fn, get_fns): Likewise.

From-SVN: r246086
2017-03-13 12:51:48 +00:00
Nathan Sidwell
160e6d485f Add OVERLOAD iterator part 6
Add OVERLOAD iterator part 6
	gcc/cp/
	* search.c (lookup_field_fuzzy_info::fuzzy_lookup_fn)
	lookup_conversion_operator, lookup_fnfields_idx_nolazy,
	lookup_conversions_r): Use new accessors.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/search.c

From-SVN: r246057
2017-03-10 20:44:02 +00:00
Nathan Sidwell
d723447607 Add OVERLOAD iterator part 5
Add OVERLOAD iterator part 5
	gcc/cp/
	* decl2.c (mark_used): Use new accessors.
	* dump.c (cp_dump_tree): Likewise.
	* error.c (dump_decl, dump_expr, location_of): Likewise.
	* init.c (build_offset_ref): Likewise.
	* parser.c (cp_parser_nested_name_specifier_opt)
	cp_parser_lookup_name): Likewise.
	* pt.c (check_explicit_specialization, check_template_shadow)
	tsubst_baselink): Likewise.
	* ptree.c (cxx_print_xnode): Likewise.
((--This line, and those below, will be ignored--

M    gcc/cp/parser.c
M    gcc/cp/ptree.c
M    gcc/cp/error.c
M    gcc/cp/dump.c
M    gcc/cp/decl2.c
M    gcc/cp/init.c
M    gcc/cp/pt.c
M    ChangeLog.modules

From-SVN: r246056
2017-03-10 20:31:46 +00:00
Nathan Sidwell
ef4e9096ea Add OVERLOAD iterator part 4
Add OVERLOAD iterator part 4
	gcc/cp/
	* cp-tree.h (OVL_FIRST, OVL_NAME): New accessors.
	* call.c (build_user_type_conversion_1)
	print_error_for_call_failure, add_candidates): Use them.
	* class.c (method_name_cmp, resort_method_name_cmp)
	resort_type_method_vec, finish_struct_methods, warn_hidden,
	resolve_address_of_overloaded_function,
	note_name_declared_in_class): Likwise.
	* cxx-pretty-print.c (pp_cxx_unqualified_id, pp_cxx_qualified_id)
	cxx_pretty_printer::id_expression,
	cxx_pretty_printer::expression): Likewise.
	* decl.c (poplevel): Likewise.
	* mangle.c (write_member_name): Likewise.
	* method.c (strip_inheriting_ctors): Likewise.
	* typeck.c (cp_build_addr_expr_1): Likewise.
(((--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/mangle.c
M    gcc/cp/cp-tree.h
M    gcc/cp/typeck.c
M    gcc/cp/class.c
M    gcc/cp/decl.c
M    gcc/cp/method.c
M    gcc/cp/cxx-pretty-print.c
M    gcc/cp/parser.c
M    gcc/cp/call.c

From-SVN: r246050
2017-03-10 19:29:25 +00:00
Nathan Sidwell
e3a5c1af37 Makefile-supplied timestamp.
gcc/cp
	* Make-lang.in: Provide MODULE_STAMP.
	* module.c (cpm_stream::version): Use MODULE_STAMP, not __DATE__ &
	__TIME__.

From-SVN: r246048
2017-03-10 19:23:36 +00:00
Nathan Sidwell
5e2a84cd17 Add OVERLOAD iterator part 3
Add OVERLOAD iterator part 3
	gcc/cp/
	* name-lookup.c (pushdecl_maybe_friend_1)
	lookup_extern_c_fun_in_all_ns, c_linkage_bindings,
	set_decl_namespace, pushdecl_top_level_and_finish (tree x,
	merge_functions, remove_hidden_names, arg_assoc_namespace,
	arg_assoc, lookup_arg_dependent_1, cp_emit_debug_info_for_using):
	Use new iterator.
	* pt.c (retrieve_specialization, iterative_hash_template_arg)
	determine_specialization, check_explicit_specialization,
	resolve_overloaded_unification, resolve_nondeduced_context,
	type_dependent_expression_p, dependent_template_p,
	do_class_deduction): Likewise.
((--This line, and those below, will be ignored--

M    gcc/cp/pt.c
M    gcc/cp/name-lookup.c
M    ChangeLog.modules

From-SVN: r246041
2017-03-10 16:28:56 +00:00
Nathan Sidwell
2705f9bd91 Add OVERLOAD iterator part 2
Add OVERLOAD iterator part 2
	gcc/cp/
	* class.c (handle_using_decl)
	maybe_warn_about_overly_private_class, modify_all_vtables,
	get_basefndecls, warn_hidden, add_implicitly_declared_members,
	adjust_clone_args, deduce_noexcept_on_destructors, default_ctor_p,
	in_class_defaulted_default_constructor, user_provided_p,
	type_has_user_provided_constructor,
	type_has_user_provided_or_explicit_constructor,
	type_has_virtual_destructor, type_has_move_constructor,
	type_has_move_assign, type_has_user_declared_move_constructor,
	type_build_ctor_call, type_build_dtor_call,
	type_requires_array_cookie, explain_non_literal_class,
	finish_struct, resolve_address_of_overloaded_function): Use new
	iterator.
	* decl2.c (maybe_warn_sized_delete): Likewise.
	* parser.c (cp_parser_template_name): Tweak loop exit test.
	* semantics.c (finish_call_expr): Likewise.
	* typeck.c (check_template_keyword): Likewise.
(--This line, and those below, will be ignored--

M    gcc/cp/typeck.c
M    gcc/cp/class.c
M    gcc/cp/semantics.c
M    gcc/cp/decl2.c
M    gcc/cp/parser.c
M    ChangeLog.modules

From-SVN: r246033
2017-03-10 15:25:34 +00:00
Nathan Sidwell
c4482ae71e Add OVERLOAD iterator, part 1 Add MAYBE_BASELINK_FUNCTIONS
Add OVERLOAD iterator, part 1
	Add MAYBE_BASELINK_FUNCTIONS
	gcc/cp/
	* cp-tree.h (struct ovl_iterator): New.
	(MAYBE_BASELINK_FUNCTIONS): New.
	* call.c (build_op_call_1, add_candidates)
	build_op_delete_call): Use new iterator.
	* lambda.c (maybe_generic_this_capture): Likewise.
	* method.c (inherited_ctor_binfo, binfo_inherited_from): Likewise.
	* parser.c (lookup_literal_operator)
	cp_parser_template_name): Likewise.
	* search.c (shared_member_p, look_for_overrides_here)
	lookup_conversions_r): Likewise.
	* semantics.c (finish_call_expr)
	classtype_has_nothrow_assign_or_copy_p): Likewise.
	* typeck.c (check_template_keyword): Likewise.
	* tree.c (is_overloaded_fn, get_fns): Use MAYBE_BASELINK_FUNCTIONS.
((((--This line, and those below, will be ignored--

M    gcc/cp/parser.c
M    gcc/cp/cp-tree.h
M    gcc/cp/lambda.c
M    gcc/cp/semantics.c
M    gcc/cp/name-lookup.c
M    gcc/cp/tree.c
M    gcc/cp/search.c
M    gcc/cp/typeck.c
M    gcc/cp/call.c
M    gcc/cp/method.c
M    ChangeLog.modules

From-SVN: r246031
2017-03-10 14:37:21 +00:00
Nathan Sidwell
b6b84b649e cp-tree.h (NAMESPACE_CHECK): Delete.
gcc/cp/
	* gcc/cp/cp-tree.h (NAMESPACE_CHECK): Delete.
	(MODULE_NAMESPACE_P, GLOBAL_MODULE_NAMESPACE)
	NAMESPACE_INLINE_P): Adjust.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h

From-SVN: r246030
2017-03-10 14:32:56 +00:00
Nathan Sidwell
4416f027e4 modules.exp: Protect DEFAULT_CXXFLAGS.
gcc/testsuite/
	* g++.dg/modules/modules.exp: Protect DEFAULT_CXXFLAGS.

From-SVN: r246028
2017-03-10 14:25:09 +00:00
Nathan Sidwell
887d73bb72 Add crc checkpointing.
gcc/cp/
	* module.c (cpm_serial::crc): New.
	(cpm_serial::bit_flush): Compute crc.
	(cpm_serial::crc_unsigned_n, crc_buffer, crc_unsigned): New.
	(cpm_reader::checkpoint, cpm_writer::checkpoint): New.
	(cpm_reader, cpm_writer): Add checkpointing to io.
	(cpms_in, cpms_out): Likewise.

From-SVN: r245920
2017-03-06 13:14:42 +00:00
Nathan Sidwell
20589ff6be Optimize crc.
Optimize crc.  Push to trunk
	gcc/
	* tree.h (crc32_unsigned_n): Declare.
	(crc32_unsigned, crc32_unsigned): Make inline.
	* tree.c (crc32_unsigned_bits): Replace with ...
	(crc32_unsigned_n): ... this.
	(crc32_unsigned, crc32_byte): Remove.
	(crc32_string): Remove unnecessary braces.

From-SVN: r245902
2017-03-05 17:22:30 +00:00
Nathan Sidwell
603a379c42 Redo bool read/write
Redo bool read/write
	gcc/cp/
	* module.c (cpm_serial::bit_flush): New.
	(cpm_writer::bytes4, cpm_writer::bflush: New.
	(cpm_reader::bytes4, cpm_reader::bflush, cpm_reader::bfill): New.
	(cpm_reader::fill): Rename from reserve.  Update callers.
	(cpm_writer::b, cpm_reader::b): Reimplement.
	(cpm_writer::flush_bits, cpm_reader::flush_bits): Delete.
	(cpms_out::write_tree_ary, cpms_in::read_tree_ary): Call bflush.
	(cpms_out::write_tree, cpms_in::read_tree): Likewise.

From-SVN: r245899
2017-03-05 02:03:34 +00:00
Nathan Sidwell
ab634a905a Cleanup test pruning. Push to trunk.
gcc/testsuite/g++.dg
	* g++-dg.exp (find-cxx-tests): New.
	(main): Call it to discover direct tests rather than explicit pruning.

From-SVN: r245898
2017-03-05 01:56:42 +00:00
Nathan Sidwell
8dd29152f7 Cleanup retrofit_lang_decl. Push to trunk.
gcc/cp/
	* cp-tree.h (add_lang_decl_raw, add_lang_type_raw): Rename.
	* lex.c (maybe_add_lang_decl_raw, maybe_add_lang_type_raw): Return
	bool.  Don't assert.
	(retrofit_lang_decl, cxx_make_type): Adjust.
	* module.c (cpms_in::read_tree): Verify lang_decl/type insertion
	valid.
	* class.c (alter_access): Directly call retrofit_lang_decl.
	* decl.c (push_local_name, duplicate_decls): Likewise.
	* pt.c (push_template_decl_real, txubs_omp_clauses): Likewise.
	* semantics.c (omp_privatize_field): Likewise.

From-SVN: r245884
2017-03-03 20:11:45 +00:00
Nathan Sidwell
f5d82a3eaf Renaming stuff.
gcc/cp/
	* module.c: Remove anon namespace, rename seriator, reader,
	writer, streamer, in & out.

From-SVN: r245881
2017-03-03 17:05:36 +00:00
Nathan Sidwell
7a1e9ceaf0 Black triangle achieved
Black triangle achieved
	gcc/cp/
	* cp-tree.h (GLOBAL_MODULE_NAMESPACE_P): New.
	(add_lang_decl_raw, add_lang_type_raw): Declare.
	* lex.c (add_lang_decl_raw): New.  Broken out of ...
	(retrofit_lang_decl): ... here.  Call it.
	(add_lang_type_raw): New.  Broken out of ...
	(cxx_make_type): ... here.  Call it.
	* module.c (out::write_decl_lang_bools, in::read_decl_lang_bools): New.
	(in::~in, in::set_scope): Correct.
	(out::write_tree, in::read_tree): Start lang_type/decl handling.
	(in::finish_type): Fix canonical type handling.
	(in::finish_function): Insert into symbol table.
	(in::finish_function): Preserve scope.
	gcc/testsuite/
	* g++.dg/modules/modules.exp: Add link & execute capability.
	* g++.dg/modules/mod-decl-2_b.C: Remove XFAILs.
	* g++.dg/modules/mod-decl-2_c.C: Remove XFAILs.
	* g++.dg/modules/mod-impl-1_a.C: New.
	* g++.dg/modules/mod-impl-1_b.C: New.
	* g++.dg/modules/mod-impl-1_c.C: New.
	* g++.dg/modules/mod-impl-1_d.C: New.

From-SVN: r245829
2017-03-02 04:08:48 +00:00
Nathan Sidwell
fbc745958b module.c (in::finish_type): New.
gcc/cp/
	* module.c (in::finish_type): New.
	(in::finish): Call it.
	(out::write_core_vals, in::read_core_vals): Ensure canonical_type
	and type_main_variant are dumped early.
	gcc/testsuite/
	* g++/modules/mod-exp-1_b.C: Extend.

From-SVN: r245551
2017-02-17 20:38:55 +00:00
Nathan Sidwell
6b0c005087 Canonicalize canonical type hashing
Canonicalize canonical type hashing
	gcc/
	* tree.h (type_hash_default): Declare.
	* tree.c (type_hash_list, attribute_hash_list): Move into
	type_hash_default.
	(build_type_attribute_qual_variant): Break out hash code calc into
	type_hash_default.
	(type_hash_default): New.  Generic type hash computation.
	(build_range_type_1, build_array_type_1, build_function_type)
	build_method_type_directly, build_offset_type, build_complex_type,
	make_vector_type): Call it.
	gcc/c-family/
	* c-common.c (complete_array_type): Use type_hash_default.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/c-family/c-common.c
M    gcc/tree.c
M    gcc/tree.h

From-SVN: r245550
2017-02-17 20:31:08 +00:00
Nathan Sidwell
35a9915049 Namespace decls!
gcc/cp/
	* module.c (out::write_tree_ary, in::read_tree_ary): New.
	(out::tag_trees, in::tag_trees): Repurpose.
	(in::finish_namespace, in::finish_function): New.
	(out::write_tree, in::read_tree): Adjust.
	(in::finish): Adjust.

From-SVN: r245519
2017-02-16 20:59:42 +00:00
Nathan Sidwell
93f99ba8f1 Some actual tree writing & reading
Some actual tree writing & reading
	gcc/cp/
	* module.c (out::write_core_bools, out::write_core_vals): New.
	(in::read_core_bools, in::read_core_vals): New.
	(in::set_scope): New.
	(out::write_tree, in::read_tree): Call core readers/writers.

From-SVN: r245512
2017-02-16 16:51:03 +00:00
Nathan Sidwell
4301521a67 Node length & allocation. Global trees.
gcc/cp/
	* module.c (streamer::tags): Rename to ...
	(streamer::record_tag): ... here.  Fixup.
	(out::tag_trees, out::start, out::write_loc): New.
	(in::tag_trees, in::start, in::finish, in::read_loc): New.
	(out::write_tree, in::read_tree): Adjust.
	(write_module): Write global trees.

From-SVN: r245506
2017-02-16 12:59:03 +00:00
Nathan Sidwell
037c4bb6a7 Start of tree reading & writing. Module namespace fix.
gcc/cp/
	* cp-tree.h (pop_module_namespace, push_module_namespace): Add
	flag.
	* parser.c (check_module_outermost, cp_parser_module_export)
	cp_parser_module_proclamation, cp_parser_namespace_definition):
	Adjust.
	* module.c (pop_module_namespace, push_module_namespace): Add
	flag.
	(reader::read_tree, writer::write_tree): Initial stubs.
	(read_module, write_module, do_import_module, declare_module):
	Adjust.
	gcc/testsuite/
	* g++.dg/modules/mod-exp-1_a.C: New.
	* g++.dg/modules/mod-exp-1_b.C: New.
	* g++.dg/modules/mod-sym-1.C: Add cases.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
A    gcc/testsuite/g++.dg/modules/mod-exp-1_a.C
A    gcc/testsuite/g++.dg/modules/mod-exp-1_b.C
M    gcc/testsuite/g++.dg/modules/mod-sym-1.C
M    gcc/cp/cp-tree.h
M    gcc/cp/module.c
M    gcc/cp/parser.c

From-SVN: r245487
2017-02-15 16:56:41 +00:00
Nathan Sidwell
c97a03f7a6 Make-lang.in (CFLAGS-cp/module.o): New var.
gcc/cp/
	* Make-lang.in (CFLAGS-cp/module.o): New var.
	* module.c (reader): Add peek_u.
	(reader::str): Force ending NUL.
	(writer::flush_bits): Avoid infinite recursion.
	(streamer): Extend tags, add next.
	(out, in): Add some readers/writers.
	(read_module, do_import_module, write_module): Augment.
	gcc/testsuite/
	* g++.dg/modules/mod-imp-1_a.C
	* g++.dg/modules/mod-imp-1_b.C
	* g++.dg/modules/mod-imp-1_c.C
	* g++.dg/modules/mod-imp-1_d.C

From-SVN: r245433
2017-02-14 15:38:35 +00:00
Nathan Sidwell
670ace869f Start actually writing & reading module files.
Start actually writing & reading module files. (headers only)
	gcc/cp/
	* module.c (seriator, reader, writer, streamer, in, out): New
	classes.
	(read_module, do_import_module, write_module, finish_module): Adjust.

From-SVN: r245347
2017-02-10 21:11:41 +00:00
Nathan Sidwell
e86b6262fe gengtype-lex.l (<in_struct>): Add '/'.
gcc/
	* gengtype-lex.l (<in_struct>): Add '/'.

From-SVN: r245346
2017-02-10 21:07:43 +00:00
Nathan Sidwell
92ddc50544 Dump file
Dump file
	gcc/
	* dumpfile.h (tree_dump_index): Add TDI_lang.
	(TDF_LANG): New.
	* dumpfile.c (dump_files): Add front-end.
	(dump_option_value_info): Add lang.  Adjust all.
	gcc/cp/
	* cp-tree.h (import_module): Lose is_export parm.
	* module.c: Include dumpfile.h
	(dopen, dclose): New.
	(import_add): Absorb into ...
	(do_import_module): ... here.  Broken out of ...
	(import_module): ... here.  Call it.
	(export_module, declare_module): Adjust.
	(read_module, write_module): Write dump.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-decl-2_b.C: Adjust.
	* g++.dg/modules/mod-decl-5_b.C: Adjust.

From-SVN: r245313
2017-02-09 19:28:41 +00:00
Nathan Sidwell
60811f7a8f cp-tree.h (DECL_CHECK): New.
gcc/cp/
	* cp-tree.h (DECL_CHECK): New.
	(NAMESPACE_MODULE_P): Rename to ...
	(MODULE_NAMESPACE_P): ... here.
	(CURRENT_MODULE_NAMESPACE_P): New.
	(MODULE_EXPORT_P): New.
	(import_module): Add is_export param.
	* module.c (mstream, mfname): Delete.
	(imported_modules): Make hash_map.
	(enum import_kind): New.
	(push_module_namespace, pop_module_namespace): Adjust.
	(import_add, import_module, export_module): Adjust.
	(read_module, write_module): New.
	(declare_module, finish_module): Adjust.
	* name-lookup.c (is_ancestor): Adjust.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-5_b.C: Adjust
	* g++.dg/modules/modules.exp: Remote host, tweak module deletion.

From-SVN: r245308
2017-02-09 16:02:45 +00:00
Nathan Sidwell
c51761ad72 name-lookup.c (is_ancestor): Pop from module namespace root.
gcc/cp/
	* name-lookup.c (is_ancestor): Pop from module namespace root.
	gcc/testsuite/
	* g++.dg/modules/mod-sym-3.C: New.

From-SVN: r245283
2017-02-08 19:48:29 +00:00
Nathan Sidwell
0238e4b100 Module namespaces
Module namespaces
	gcc/cp
	* cp-tree.h (NAMESPACE_MODULE_P): New.
	(push_module_namespace, pop_module_namespace): Declare.
	* module.c (MOD_SYM_PFX, MOD_SYM_DOT): New.
	(module_namespace_name): New.
	(push_module_namespace, pop_module_namespace): New.
	(module_to_ext): New. Broken out of ...
	(module_to_filename): ... here. Call it.
	(declare_module): Push to module namespace.
	* parser.c (check_module_outermost): Deal with module namespace.
	(cp_parser_module_export, cp_parser_module_proclaimation)
	cp_parser_namespace_definition): Likewise.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-sym-1.C: New.
	* g++.dg/modules/mod-sym-2.C: New.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h
M    gcc/cp/module.c
M    gcc/cp/parser.c
M    gcc/testsuite/g++.dg/modules/mod-decl-1.C
A    gcc/testsuite/g++.dg/modules/mod-sym-1.C
A    gcc/testsuite/g++.dg/modules/mod-sym-2.C

From-SVN: r245282
2017-02-08 18:51:31 +00:00
Nathan Sidwell
2c7be4a684 Cleanup inline namespace creation.
gcc/cp
	* name-lookup.h (make_namespace_inline): Declare.
	* name-lookup.c (do_toplevel_using_directive): New.
	(do_using_directive): Call it.
	(make_namespace_inline): New.
	* parser.c (cp_parser_namespace_definition): Call it.

From-SVN: r245281
2017-02-08 18:20:04 +00:00
Nathan Sidwell
6f44c46971 PR c++/79369 inline namespaces
PR c++/79369 inline namespaces
	gcc/cp
	* cp-tree.h (NAMESPACE_CHECK): New.
	(NAMESPACE_INLINE_P): New.
	* name-lookup.h (push_namespace): Return int.
	* name-lookup.c (push_namespace): Return int. Adjust.
	* parser.c (cp_parser_namespace_definition): Reorder nested
	parsing.  Check inline redefinition.
	gcc/testsuite/
	* g++.dg/cpp0x/pr65558.C: Adjust error loc.
	* g++.dg/cpp0x/pr79369.C: New.
	* g++.dg/cpp1z/nested-namespace-def1.C: Adjust.

From-SVN: r245252
2017-02-07 18:02:05 +00:00
Nathan Sidwell
4cba0e0761 Module files open/closed.
Module files open/closed.  Testsuite extension
	gcc/cp/
	* module.c (mstream, mfname): New.
	(module_to_filename): New.
	(import_module, declare_module, finish_module): Open/close module
	file.
	gcc/testsuite/
	* g++.dg/modules/modules.exp (mod_spec_to_file, dg-module-if)
	check_module_specs, cleanup_module_files): New.
	* g++.dg/modules/mod-decl-0.C: Adjust
	* g++.dg/modules/mod-decl-1.C: Adjust
	* g++.dg/modules/mod-decl-2_a.C: Adjust
	* g++.dg/modules/mod-decl-3.C: New.
	* g++.dg/modules/mod-decl-3_a.C: Delete.
	* g++.dg/modules/mod-decl-3_b.C: Delete.
	* g++.dg/modules/mod-decl-4.C: Adjust
	* g++.dg/modules/mod-decl-5_a.C: Adjust
	* g++.dg/modules/mod-decl-5_b.C: Adjust
	* g++.dg/modules/proclaim-1.C: Adjust
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/testsuite/g++.dg/modules/mod-decl-0.C
M    gcc/testsuite/g++.dg/modules/modules.exp
M    gcc/testsuite/g++.dg/modules/mod-decl-1.C
M    gcc/testsuite/g++.dg/modules/mod-decl-2_a.C
D    gcc/testsuite/g++.dg/modules/mod-decl-3_a.C
M    gcc/testsuite/g++.dg/modules/proclaim-1.C
A  + gcc/testsuite/g++.dg/modules/mod-decl-3.C
D    gcc/testsuite/g++.dg/modules/mod-decl-3_b.C
D    gcc/testsuite/g++.dg/modules/mod-decl-4.C
M    gcc/testsuite/g++.dg/modules/mod-decl-5_a.C
M    gcc/testsuite/g++.dg/modules/mod-decl-5_b.C
M    gcc/cp/module.c

From-SVN: r245163
2017-02-03 19:05:25 +00:00
Nathan Sidwell
e7e77c41b4 Module names are identifiers.
gcc/cp/
	* config-lang.in (gtfiles): Add modules.c.
	* c-tree.h (module_name_t): Delete.
	(finish_module): Declare.
	* decl2.c (c_pare_final_cleanups): Call finish_module.
	* module.c: Change module_name_t to tree.
	(imported_module): Hash of module names.
	(import_add): New.
	(import_module, declare_module): Use it.
	(export_module): Import module.
	(finish_module): New.
	* parser.c (cp_parser_module_name): Build up identifier.  Adjust
	callers.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-0.C: Adjust.
	* g++.dg/modules/mod-decl-1.C: Adjust.
	* g++.dg/modules/mod-decl-2_b.C: Adjust.
	* g++.dg/modules/mod-decl-2_c.C: New.
	* g++.dg/modules/mod-decl-5_a.C: New.
	* g++.dg/modules/mod-decl-5_b.C: New.

From-SVN: r245150
2017-02-03 12:55:45 +00:00
Nathan Sidwell
d8f7cc0bd2 cp-tree.h: Adjust module interface fns.
[[interface]]
	gcc/cp
	* cp-tree.h: Adjust module interface fns.
	* modules.c (is_interface): New.
	(push_module_export, pop_module_export, module_exporting_level):
	Adjust.
	(module_proclaim): Delete.
	(module_interface_p): New.
	(declare_module): Use 'interface' attrib.
	(mport_module, export_module): Take attribs.
	* parser.c (check_module_outermost, cp_parser_module_declaration)
	cp_parser_module_export, cp_parser_module_proclamation): Adjust.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-2_a.C: Adjust.
	* g++.dg/modules/mod-decl-3_a.C: Adjust.
	* g++.dg/modules/proclaim-1.C: Adjust.
	* g++.dg/modules/mod-decl-4.C: New.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/testsuite/g++.dg/modules/mod-decl-2_a.C
M    gcc/testsuite/g++.dg/modules/mod-decl-3_a.C
M    gcc/testsuite/g++.dg/modules/proclaim-1.C
A    gcc/testsuite/g++.dg/modules/mod-decl-4.C
M    gcc/cp/cp-tree.h
M    gcc/cp/module.c
M    gcc/cp/parser.c

From-SVN: r245133
2017-02-02 17:42:11 +00:00
Nathan Sidwell
ce007f1016 Parse proclaimed ownership.
gcc/cp/
	* cp-tree.h (module_exporting_p, module_proclaim): Declare.
	* module.c (proclaimer): New.
	(module_exporting_p, module_proclaim): New.
	* parser.c (check_module_outermost): New.
	(cp_parser_module_declaration, cp_parser_module_export): Call it.
	(cp_parser_module_proclamation): New.
	(cp_parser_declaration): Add proclaimed-ownership.
	gcc/testsuite/
	* g++.dg/modules/proclaim-1.C: New.

From-SVN: r244994
2017-01-27 20:04:07 +00:00
Nathan Sidwell
87738c6872 Parse import & export. Test infra.
gcc/cp/
	* cp-tree.h (module_purview_p, push_module_export)
	pop_module_export, declare_module, import_module,
	export_module): Declare.
	* module.c (export_depth): New.
	(module_purview_p, push_module_export, pop_module_export): New
	(declare_module_name): Renme to ...
	(declare_module): ... here.
	(import_module, export_module): Stubs.
	* parser.c (cp_parser_module_declaration): Add IS_EXPORT
	parm. Deal with imports & exports.
	(cp_parser_module_export): New.
	(cp_parser_declaration): Allow module import, export.
	gcc/testsuite/
	* g++.dg/dg.exp: Prune module tests.
	* g++.dg/modules/modules.exp: New.
	* g++.dg/modules/mod-decl-2_[ab].C: New.
	* g++.dg/modules/mod-decl-3_[ab].C: New.
(--This line, and those below, will be ignored--

M    ChangeLog.modules
M    gcc/cp/cp-tree.h
M    gcc/cp/module.c
M    gcc/cp/parser.c
M    gcc/testsuite/g++.dg/dg.exp
A    gcc/testsuite/g++.dg/modules/modules.exp
A    gcc/testsuite/g++.dg/modules/mod-decl-2_a.C
A    gcc/testsuite/g++.dg/modules/mod-decl-2_b.C
A    gcc/testsuite/g++.dg/modules/mod-decl-3_a.C
A    gcc/testsuite/g++.dg/modules/mod-decl-3_b.C

From-SVN: r244992
2017-01-27 18:50:06 +00:00
Nathan Sidwell
02ac5dbe0f Parse module-declaration.
gcc/cp
	* cp-tree.h (module_name_t): Typedef.
	(declare_module_name): Declare.
	* parser.c (cp_parser_diagnose_invalid_type_name): Explain
	fmodules.
	(cp_parser_module_name, cp_parser_module_declaration): New.
	(cp_parser_declaration): Add module-declaration.
	* module.c (declared_module, module_location): New.
	(declare_module_name): Define.
	gcc/testsuite/
	* g++.dg/modules/mod-decl-0.C: New.
	* g++.dg/modules/mod-decl-1.C: New.

From-SVN: r244906
2017-01-25 17:51:53 +00:00
Nathan Sidwell
3ddaae627a New flag & keywords, etc
New flag & keywords, etc
	gcc/c-family/
	* c-common.c (c_common_reswords): Add 'module', 'import'.
	* c-common.h (enum rid): Add RID_MODULE, RID_IMPORT.
	(D_CXX_MODULES, D_CXX_MODULES_FLAGS) New.
	* c-cppbuiltins.c (c_cpp_builtins): Add _cpp_modules define.
	* c.opt: Add fmodules flag.
	gcc/cp/
	* Make-lang.in (CXX_AND_OBJCXX_OBJS): Add module.o.
	* module.c: New file.
	gcc/
	* doc/invoke.texi (-fmodules): Document it.

From-SVN: r244899
2017-01-25 14:39:49 +00:00
Nathan Sidwell
7d57a2193a Free up TREE_LANG_FLAG_3. DECL_CONSTRUCTION_VTABLE_P is useless.
gcc/cp/
	* cp-tree.h (DECL_CONSTRUCTION_VTABLE_P): Delete.
	(DECL_NON_TRIVIALLY_INITIALIZED_P): Move to TREE_LANG_FLAG_6.
	* class.c (build_ctor_vtbl_group): Don't set
	DECL_CONSTRUCTION_VTABLE_P.
	* decl2.c (determine_visibility_from_class): Don't check
	DECL_CONSTRUCTION_VTABLE_P anymore.

From-SVN: r244883
2017-01-24 19:37:45 +00:00
Nathan Sidwell
e913cbc601 Branch creation.
From-SVN: r244829
2017-01-23 19:35:58 +00:00
17803 changed files with 239652 additions and 161225 deletions

View File

@@ -1,3 +1,43 @@
2021-01-25 Martin Liska <mliska@suse.cz>
PR gcov-profile/98739
* Makefile.in: Enable -fprofile-reproducible=parallel-runs
for profiledbootstrap.
2021-01-22 Jonathan Wright <jonathan.wright@arm.com>
* MAINTAINERS (Write After Approval): Add myself.
2021-01-22 Maciej W. Rozycki <macro@orcam.me.uk>
* MAINTAINERS (Write After Approval): Update my e-mail address.
2021-01-12 Segher Boessenkool <segher@kernel.crashing.org>
* MAINTAINERS: Fix spacing.
2021-01-12 Qian Jianhua <qianjh@cn.fujitsu.com>
* MAINTAINERS (Write After Approval): Add myself
2021-01-06 Nick Alcock <nick.alcock@oracle.com>
* Makefile.def: Sync with binutils-gdb:
(dependencies): all-ld depends on all-libctf.
(host_modules): libctf is no longer no_install.
No longer no_check. Checking depends on all-ld.
* Makefile.in: Regenerated.
2021-01-05 Samuel Thibault <samuel.thibault@ens-lyon.org>
* libtool.m4: Match gnu* along other GNU systems.
* libgo/config/libtool.m4: Match gnu* along other GNU systems.
* libgo/configure: Re-generate.
2021-01-04 Philipp Tomsich <philipp.tomsich@vrull.eu>
* MAINTAINERS: Update my email address.
2020-12-17 Marius Hillenbrand <mhillen@linux.ibm.com>
* MAINTAINERS (Write After Approval): Add myself.

17852
ChangeLog.modules Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -415,7 +415,7 @@ Jiufu Guo <guojiufu@linux.ibm.com>
Xuepeng Guo <terry.xpguo@gmail.com>
Wei Guozhi <carrot@google.com>
Mostafa Hagog <hagog@gcc.gnu.org>
Andrew Haley <aph@redhat.com>
Andrew Haley <aph@redhat.com>
Frederik Harwath <frederik@codesourcery.com>
Stuart Hastings <stuart@apple.com>
Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
@@ -451,6 +451,7 @@ Daniel Jacobowitz <drow@false.org>
Andreas Jaeger <aj@suse.de>
Harsha Jagasia <harsha.jagasia@amd.com>
Fariborz Jahanian <fjahanian@apple.com>
Qian Jianhua <qianjh@cn.fujitsu.com>
Janis Johnson <janis.marie.johnson@gmail.com>
Teresa Johnson <tejohnson@google.com>
Kean Johnston <jkj@sco.com>
@@ -464,7 +465,7 @@ Andi Kleen <andi@firstfloor.org>
Jeff Knaggs <jknaggs@redhat.com>
Michael Koch <konqueror@gmx.de>
Nicolas Koenig <koenigni@student.ethz.ch>
Boris Kolpackov <boris@codesynthesis.com>
Boris Kolpackov <boris@codesynthesis.com>
Dave Korn <dave.korn.cygwin@gmail.com>
Julia Koval <julia.koval@intel.com>
Hongtao Liu <hongtao.liu@intel.com>
@@ -479,7 +480,7 @@ Razya Ladelsky <razya@gcc.gnu.org>
Thierry Lafage <thierry.lafage@inria.fr>
Aaron W. LaFramboise <aaronavay62@aaronwl.com>
Rask Ingemann Lambertsen <ccc94453@vip.cybercity.dk>
Jerome Lambourg <lambourg@adacore.com>
Jerome Lambourg <lambourg@adacore.com>
Asher Langton <langton2@llnl.gov>
Chris Lattner <sabre@nondot.org>
Terry Laurenzo <tlaurenzo@gmail.com>
@@ -580,7 +581,7 @@ Craig Rodrigues <rodrigc@gcc.gnu.org>
Erven Rohou <erven.rohou@inria.fr>
Ira Rosen <irar@il.ibm.com>
Yvan Roux <yvan.roux@linaro.org>
Maciej W. Rozycki <macro@linux-mips.org>
Maciej W. Rozycki <macro@orcam.me.uk>
Silvius Rus <rus@google.com>
Matthew Sachs <msachs@apple.com>
Hariharan Sandanagobalane <hariharan.gcc@gmail.com>
@@ -625,7 +626,7 @@ Dinar Temirbulatov <dtemirbulatov@gmail.com>
Kresten Krab Thorup <krab@gcc.gnu.org>
Kai Tietz <ktietz70@googlemail.com>
Ilya Tocar <tocarip@gmail.com>
Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Philipp Tomsich <philipp.tomsich@vrull.eu>
Daniel Towner <dant@picochip.com>
Konrad Trifunovic <konrad.trifunovic@inria.fr>
Markus Trippelsdorf <markus@trippelsdorf.de>
@@ -657,6 +658,7 @@ Kevin Williams <kevin.williams@inria.fr>
Przemyslaw Wirkus <przemyslaw.wirkus@arm.com>
Carlo Wood <carlo@alinoe.com>
Jackson Woodruff <jackson.woodruff@arm.com>
Jonathan Wright <jonathan.wright@arm.com>
Mingjie Xing <mingjie.xing@gmail.com>
Chenghua Xu <paul.hua.gm@gmail.com>
Canqun Yang <canqun@nudt.edu.cn>

View File

@@ -141,8 +141,7 @@ host_modules= { module= lto-plugin; bootstrap=true;
extra_make_flags='@extra_linker_plugin_flags@'; };
host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
host_modules= { module= gotools; };
host_modules= { module= libctf; no_install=true; no_check=true;
bootstrap=true; };
host_modules= { module= libctf; bootstrap=true; };
target_modules = { module= libstdc++-v3;
bootstrap=true;
@@ -463,6 +462,7 @@ dependencies = { module=all-binutils; on=all-build-bison; };
dependencies = { module=all-binutils; on=all-intl; };
dependencies = { module=all-binutils; on=all-gas; };
dependencies = { module=all-binutils; on=all-libctf; };
dependencies = { module=all-ld; on=all-libctf; };
// We put install-opcodes before install-binutils because the installed
// binutils might be on PATH, and they might need the shared opcodes
@@ -561,6 +561,7 @@ dependencies = { module=configure-libctf; on=all-bfd; };
dependencies = { module=configure-libctf; on=all-intl; };
dependencies = { module=configure-libctf; on=all-zlib; };
dependencies = { module=configure-libctf; on=all-libiconv; };
dependencies = { module=check-libctf; on=all-ld; };
// Warning, these are not well tested.
dependencies = { module=all-bison; on=all-intl; };

View File

@@ -565,7 +565,7 @@ STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
STAGEtrain_CFLAGS = $(filter-out -fchecking=1,$(STAGE3_CFLAGS))
STAGEtrain_TFLAGS = $(filter-out -fchecking=1,$(STAGE3_TFLAGS))
STAGEfeedback_CFLAGS = $(STAGE4_CFLAGS) -fprofile-use
STAGEfeedback_CFLAGS = $(STAGE4_CFLAGS) -fprofile-use -fprofile-reproducible=parallel-runs
STAGEfeedback_TFLAGS = $(STAGE4_TFLAGS)
STAGEautoprofile_CFLAGS = $(STAGE2_CFLAGS) -g
@@ -41747,6 +41747,12 @@ maybe-check-libctf:
maybe-check-libctf: check-libctf
check-libctf:
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) $(EXTRA_HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/libctf && \
$(MAKE) $(FLAGS_TO_PASS) $(EXTRA_BOOTSTRAP_FLAGS) check)
@endif libctf
@@ -41755,7 +41761,13 @@ maybe-install-libctf:
@if libctf
maybe-install-libctf: install-libctf
install-libctf:
install-libctf: installdirs
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/libctf && \
$(MAKE) $(FLAGS_TO_PASS) install)
@endif libctf
@@ -41764,7 +41776,13 @@ maybe-install-strip-libctf:
@if libctf
maybe-install-strip-libctf: install-strip-libctf
install-strip-libctf:
install-strip-libctf: installdirs
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(HOST_EXPORTS) \
(cd $(HOST_SUBDIR)/libctf && \
$(MAKE) $(FLAGS_TO_PASS) install-strip)
@endif libctf
@@ -61206,6 +61224,16 @@ all-stagetrain-binutils: maybe-all-stagetrain-libctf
all-stagefeedback-binutils: maybe-all-stagefeedback-libctf
all-stageautoprofile-binutils: maybe-all-stageautoprofile-libctf
all-stageautofeedback-binutils: maybe-all-stageautofeedback-libctf
all-ld: maybe-all-libctf
all-stage1-ld: maybe-all-stage1-libctf
all-stage2-ld: maybe-all-stage2-libctf
all-stage3-ld: maybe-all-stage3-libctf
all-stage4-ld: maybe-all-stage4-libctf
all-stageprofile-ld: maybe-all-stageprofile-libctf
all-stagetrain-ld: maybe-all-stagetrain-libctf
all-stagefeedback-ld: maybe-all-stagefeedback-libctf
all-stageautoprofile-ld: maybe-all-stageautoprofile-libctf
all-stageautofeedback-ld: maybe-all-stageautofeedback-libctf
install-binutils: maybe-install-opcodes
install-strip-binutils: maybe-install-strip-opcodes
install-opcodes: maybe-install-bfd
@@ -61566,6 +61594,16 @@ configure-stagetrain-libctf: maybe-all-stagetrain-libiconv
configure-stagefeedback-libctf: maybe-all-stagefeedback-libiconv
configure-stageautoprofile-libctf: maybe-all-stageautoprofile-libiconv
configure-stageautofeedback-libctf: maybe-all-stageautofeedback-libiconv
check-libctf: maybe-all-ld
check-stage1-libctf: maybe-all-stage1-ld
check-stage2-libctf: maybe-all-stage2-ld
check-stage3-libctf: maybe-all-stage3-ld
check-stage4-libctf: maybe-all-stage4-ld
check-stageprofile-libctf: maybe-all-stageprofile-ld
check-stagetrain-libctf: maybe-all-stagetrain-ld
check-stagefeedback-libctf: maybe-all-stagefeedback-ld
check-stageautoprofile-libctf: maybe-all-stageautoprofile-ld
check-stageautofeedback-libctf: maybe-all-stageautofeedback-ld
all-bison: maybe-all-build-texinfo
all-flex: maybe-all-build-bison
all-flex: maybe-all-m4

View File

@@ -1,3 +1,17 @@
2021-01-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR c++/98316
* configure.ac: Include ../config/ax_lib_socket_nsl.m4.
(NETLIBS): Determine using AX_LIB_SOCKET_NSL.
* configure: Regenerate.
* Makefile.in (NETLIBS): Define.
(g++-mapper-server$(exeext)): Add $(NETLIBS).
2021-01-04 Nathan Sidwell <nathan@acm.org>
* resolver.cc (module_resolver::cmi_response): Remove
std::move of temporary.
2020-12-23 Nathan Sidwell <nathan@acm.org>
PR bootstrap/98324
@@ -57,7 +71,7 @@
* server.cc: New.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -33,6 +33,7 @@ CXXOPTS := $(CXXFLAGS) $(PIEFLAG) -fno-exceptions -fno-rtti
LDFLAGS := @LDFLAGS@
exeext := @EXEEXT@
LIBIBERTY := ../libiberty/libiberty.a
NETLIBS := @NETLIBS@
VERSION.O := ../gcc/version.o
all::
@@ -90,7 +91,7 @@ MAPPER.O := server.o resolver.o
CODYLIB = ../libcody/libcody.a
CXXINC += -I$(srcdir)/../libcody -I$(srcdir)/../include -I$(srcdir)/../gcc -I.
g++-mapper-server$(exeext): $(MAPPER.O) $(CODYLIB)
+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(VERSION.O) $(LIBIBERTY)
+$(CXX) $(LDFLAGS) $(PIEFLAG) -o $@ $^ $(VERSION.O) $(LIBIBERTY) $(NETLIBS)
# copy to gcc dir so tests there can run
all::../gcc/g++-mapper-server$(exeext)

211
c++tools/configure vendored
View File

@@ -622,6 +622,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
NETLIBS
get_gcc_base_ver
EGREP
GREP
@@ -1703,6 +1704,52 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@@ -4242,6 +4289,170 @@ fi
# Solaris needs libsocket and libnsl for socket functions before 11.4.
# libcody uses those.
save_LIBS="$LIBS"
LIBS=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
$as_echo_n "checking for library containing gethostbyname... " >&6; }
if ${ac_cv_search_gethostbyname+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostbyname ();
int
main ()
{
return gethostbyname ();
;
return 0;
}
_ACEOF
for ac_lib in '' nsl; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_gethostbyname=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_gethostbyname+:} false; then :
break
fi
done
if ${ac_cv_search_gethostbyname+:} false; then :
else
ac_cv_search_gethostbyname=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5
$as_echo "$ac_cv_search_gethostbyname" >&6; }
ac_res=$ac_cv_search_gethostbyname
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
$as_echo_n "checking for library containing socket... " >&6; }
if ${ac_cv_search_socket+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char socket ();
int
main ()
{
return socket ();
;
return 0;
}
_ACEOF
for ac_lib in '' socket; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_socket=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_socket+:} false; then :
break
fi
done
if ${ac_cv_search_socket+:} false; then :
else
ac_cv_search_socket=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
$as_echo "$ac_cv_search_socket" >&6; }
ac_res=$ac_cv_search_socket
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
$as_echo_n "checking for socket in -lsocket... " >&6; }
if ${ac_cv_lib_socket_socket+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket -lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char socket ();
int
main ()
{
return socket ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_socket=yes
else
ac_cv_lib_socket_socket=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
$as_echo "$ac_cv_lib_socket_socket" >&6; }
if test "x$ac_cv_lib_socket_socket" = xyes; then :
LIBS="-lsocket -lnsl $LIBS"
fi
fi
NETLIBS="$LIBS"
LIBS="$save_LIBS"
ac_config_headers="$ac_config_headers config.h"
ac_config_files="$ac_config_files Makefile"

View File

@@ -22,6 +22,7 @@
# By default g++ uses an in-process mapper.
sinclude(../config/acx.m4)
sinclude(../config/ax_lib_socket_nsl.m4)
AC_INIT(c++tools)
@@ -218,6 +219,15 @@ fi
# Determine what GCC version number to use in filesystem paths.
GCC_BASE_VER
# Solaris needs libsocket and libnsl for socket functions before 11.4.
# libcody uses those.
save_LIBS="$LIBS"
LIBS=
AX_LIB_SOCKET_NSL
NETLIBS="$LIBS"
LIBS="$save_LIBS"
AC_SUBST(NETLIBS)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])

View File

@@ -226,9 +226,7 @@ module_resolver::cmi_response (Cody::Server *s, std::string &module)
auto iter = map.find (module);
if (iter == map.end ())
{
std::string file;
if (default_map)
file = std::move (GetCMIName (module));
std::string file = default_map ? GetCMIName (module) : std::string ();
auto res = map.emplace (module, file);
iter = res.first;
}

View File

@@ -1,3 +1,12 @@
2021-01-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR c++/98316
* ax_lib_socket_nsl.m4: Import from autoconf-archive.
2021-01-03 Mike Frysinger <vapier@gentoo.org>
* pkg.m4: New file from pkg-config-0.29.2.
2020-11-25 Matthew Malcomson <matthew.malcomson@arm.com>
* bootstrap-hwasan.mk: Disable random frame tags for stack-tagging

View File

@@ -0,0 +1,40 @@
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_lib_socket_nsl.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_LIB_SOCKET_NSL
#
# DESCRIPTION
#
# This macro figures out what libraries are required on this platform to
# link sockets programs.
#
# The common cases are not to need any extra libraries, or to need
# -lsocket and -lnsl. We need to avoid linking with libnsl unless we need
# it, though, since on some OSes where it isn't necessary it will totally
# break networking. Unisys also includes gethostbyname() in libsocket but
# needs libnsl for socket().
#
# LICENSE
#
# Copyright (c) 2008 Russ Allbery <rra@stanford.edu>
# Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
# Copyright (c) 2008 Warren Young <warren@etr-usa.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 7
AU_ALIAS([LIB_SOCKET_NSL], [AX_LIB_SOCKET_NSL])
AC_DEFUN([AX_LIB_SOCKET_NSL],
[
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket], [], [
AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
[], [-lnsl])])
])

275
config/pkg.m4 Normal file
View File

@@ -0,0 +1,275 @@
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
dnl General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
dnl 02111-1307, USA.
dnl
dnl As a special exception to the GNU General Public License, if you
dnl distribute this file as part of a program that contains a
dnl configuration script generated by Autoconf, you may include it under
dnl the same distribution terms that you use for the rest of that
dnl program.
dnl PKG_PREREQ(MIN-VERSION)
dnl -----------------------
dnl Since: 0.29
dnl
dnl Verify that the version of the pkg-config macros are at least
dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
dnl installed version of pkg-config, this checks the developer's version
dnl of pkg.m4 when generating configure.
dnl
dnl To ensure that this macro is defined, also add:
dnl m4_ifndef([PKG_PREREQ],
dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
dnl ----------------------------------
dnl Since: 0.16
dnl
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
dnl first found in the path. Checks that the version of pkg-config found
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
dnl used since that's the first version where most current features of
dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=m4_default([$1], [0.9.0])
AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi[]dnl
])dnl PKG_PROG_PKG_CONFIG
dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------------------------------
dnl Since: 0.18
dnl
dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you
dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
m4_default([$2], [:])
m4_ifvaln([$3], [else
$3])dnl
fi])
dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
dnl ---------------------------------------------
dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
[pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
pkg_failed=untried
fi[]dnl
])dnl _PKG_CONFIG
dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl ---------------------------
dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi[]dnl
])dnl _PKG_SHORT_ERRORS_SUPPORTED
dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl --------------------------------------------------------------
dnl Since: 0.4.0
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
_PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
fi[]dnl
])dnl PKG_CHECK_MODULES
dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
dnl [ACTION-IF-NOT-FOUND])
dnl ---------------------------------------------------------------------
dnl Since: 0.29
dnl
dnl Checks for existence of MODULES and gathers its build flags with
dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
dnl and VARIABLE-PREFIX_LIBS from --libs.
dnl
dnl Note that if there is a possibility the first call to
dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
dnl configure.ac.
AC_DEFUN([PKG_CHECK_MODULES_STATIC],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
_save_PKG_CONFIG=$PKG_CONFIG
PKG_CONFIG="$PKG_CONFIG --static"
PKG_CHECK_MODULES($@)
PKG_CONFIG=$_save_PKG_CONFIG[]dnl
])dnl PKG_CHECK_MODULES_STATIC
dnl PKG_INSTALLDIR([DIRECTORY])
dnl -------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable pkgconfigdir as the location where a module
dnl should install pkg-config .pc files. By default the directory is
dnl $libdir/pkgconfig, but the default can be changed by passing
dnl DIRECTORY. The user can override through the --with-pkgconfigdir
dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([pkgconfigdir],
[AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
[with_pkgconfigdir=]pkg_default)
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_INSTALLDIR
dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
dnl --------------------------------
dnl Since: 0.27
dnl
dnl Substitutes the variable noarch_pkgconfigdir as the location where a
dnl module should install arch-independent pkg-config .pc files. By
dnl default the directory is $datadir/pkgconfig, but the default can be
dnl changed by passing DIRECTORY. The user can override through the
dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
[pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
AC_ARG_WITH([noarch-pkgconfigdir],
[AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
[with_noarch_pkgconfigdir=]pkg_default)
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
])dnl PKG_NOARCH_INSTALLDIR
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl -------------------------------------------
dnl Since: 0.28
dnl
dnl Retrieves the value of the pkg-config variable for the given module.
AC_DEFUN([PKG_CHECK_VAR],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
])dnl PKG_CHECK_VAR

View File

@@ -1,3 +1,65 @@
2021-01-28 Eric Botcazou <ebotcazou@adacore.com>
PR lto/85574
* compare-lto: Deal with PE-COFF executables specifically.
2021-01-14 Martin Liska <mliska@suse.cz>
* mklog.py: Fix infinite loop for unsupported files.
2021-01-13 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_commit.py: Support wrapping of functions
in parentheses that can take multiple lines.
* gcc-changelog/test_email.py: Add tests for it.
* gcc-changelog/test_patches.txt: Add 2 patches.
2021-01-13 Martin Liska <mliska@suse.cz>
* mklog.py: Parse also define_insn_and_split and similar
directives in .md files.
* test_mklog.py: Test.
2021-01-13 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_commit.py: Allow modifications of older
ChangeLog (or specific) files without need to make a ChangeLog
entry.
* gcc-changelog/test_email.py: Test it.
* gcc-changelog/test_patches.txt: Add new patch.
2021-01-11 Martin Liska <mliska@suse.cz>
* update-copyright.py: Port to python3 by guessing encoding
(first utf8, then iso8859). Add 2 more ignores: .png and .pyc.
2021-01-06 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_commit.py: Add decode_path function.
* gcc-changelog/git_email.py: Use it in order to solve
utf8 encoding filename issues.
* gcc-changelog/git_repository.py: Likewise.
* gcc-changelog/test_email.py: Test it.
2021-01-04 Jakub Jelinek <jakub@redhat.com>
* update-copyright.py: Add AMD and Ulf Adams as external authors.
2021-01-04 Jakub Jelinek <jakub@redhat.com>
* update-copyright.py: Use 8 spaces instead of tab to indent.
2021-01-04 Martin Liska <mliska@suse.cz>
* mklog.py: Add --update-copyright option which adds:
"Update copyright years." to ChangeLog files belonging
to a modified file.
2021-01-04 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_commit.py: Skip Update copyright
years commits.
2020-12-21 Martin Liska <mliska@suse.cz>
* gcc-changelog/git_commit.py: Add new error for quoted

View File

@@ -32,7 +32,7 @@ case $1 in
esac
if test $# != 2; then
echo 'usage: compare-lto file1.o file2.o' >&2
echo 'usage: compare-lto file1 file2' >&2
exit 1
fi
@@ -101,6 +101,25 @@ else
else
status=1
fi
# PE-COFF executables are timestamped so skip leading bytes for them.
else
case "$1" in
*.exe)
if cmp -i 256 "$1" "$2"; then
status=0
else
status=1
fi
;;
*)
if test -f "$1.exe" && cmp -i 256 "$1.exe" "$2.exe"; then
status=0
else
status=1
fi
;;
esac
fi
fi

View File

@@ -174,6 +174,24 @@ REVIEW_PREFIXES = ('reviewed-by: ', 'reviewed-on: ', 'signed-off-by: ',
DATE_FORMAT = '%Y-%m-%d'
def decode_path(path):
# When core.quotepath is true (default value), utf8 chars are encoded like:
# "b/ko\304\215ka.txt"
#
# The upstream bug is fixed:
# https://github.com/gitpython-developers/GitPython/issues/1099
#
# but we still need a workaround for older versions of the library.
# Please take a look at the explanation of the transformation:
# https://stackoverflow.com/questions/990169/how-do-convert-unicode-escape-sequences-to-unicode-characters-in-a-python-string
if path.startswith('"') and path.endswith('"'):
return (path.strip('"').encode('utf8').decode('unicode-escape')
.encode('latin-1').decode('utf8'))
else:
return path
class Error:
def __init__(self, message, line=None):
self.message = message
@@ -196,6 +214,7 @@ class ChangeLogEntry:
self.lines = []
self.files = []
self.file_patterns = []
self.opened_parentheses = 0
def parse_file_names(self):
# Whether the content currently processed is between a star prefix the
@@ -205,8 +224,14 @@ class ChangeLogEntry:
for line in self.lines:
# If this line matches the star prefix, start the location
# processing on the information that follows the star.
# Note that we need to skip macro names that can be in form of:
#
# * config/i386/i386.md (*fix_trunc<mode>_i387_1,
# *add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0,
# *fist<mode>2_<rounding>_1, *<code><mode>3_1):
#
m = star_prefix_regex.match(line)
if m:
if m and len(m.group('spaces')) == 1:
in_location = True
line = m.group('content')
@@ -276,6 +301,10 @@ class GitCommit:
self.revert_commit = None
self.commit_to_info_hook = commit_to_info_hook
# Skip Update copyright years commits
if self.info.lines and self.info.lines[0] == 'Update copyright years.':
return
# Identify first if the commit is a Revert commit
for line in self.info.lines:
m = revert_regex.match(line)
@@ -286,7 +315,7 @@ class GitCommit:
self.info = self.commit_to_info_hook(self.revert_commit)
project_files = [f for f in self.info.modified_files
if self.is_changelog_filename(f[0])
if self.is_changelog_filename(f[0], allow_suffix=True)
or f[0] in misc_files]
ignored_files = [f for f in self.info.modified_files
if self.in_ignored_location(f[0])]
@@ -299,14 +328,6 @@ class GitCommit:
'separately from normal commits'))
return
# check for an encoded utf-8 filename
hint = 'git config --global core.quotepath false'
for modified, _ in self.info.modified_files:
if modified.startswith('"') or modified.endswith('"'):
self.errors.append(Error('Quoted UTF8 filename, please set: '
f'"{hint}"', modified))
return
all_are_ignored = (len(project_files) + len(ignored_files)
== len(self.info.modified_files))
self.parse_lines(all_are_ignored)
@@ -314,6 +335,7 @@ class GitCommit:
self.parse_changelog()
self.parse_file_names()
self.check_for_empty_description()
self.check_for_broken_parentheses()
self.deduce_changelog_locations()
self.check_file_patterns()
if not self.errors:
@@ -329,8 +351,14 @@ class GitCommit:
return [x[0] for x in self.info.modified_files if x[1] == 'A']
@classmethod
def is_changelog_filename(cls, path):
return path.endswith('/ChangeLog') or path == 'ChangeLog'
def is_changelog_filename(cls, path, allow_suffix=False):
basename = os.path.basename(path)
if basename == 'ChangeLog':
return True
elif allow_suffix and basename.startswith('ChangeLog'):
return True
else:
return False
@classmethod
def find_changelog_location(cls, name):
@@ -476,7 +504,8 @@ class GitCommit:
else:
m = star_prefix_regex.match(line)
if m:
if len(m.group('spaces')) != 1:
if (len(m.group('spaces')) != 1 and
last_entry.opened_parentheses == 0):
msg = 'one space should follow asterisk'
self.errors.append(Error(msg, line))
else:
@@ -488,6 +517,7 @@ class GitCommit:
msg = f'empty group "{needle}" found'
self.errors.append(Error(msg, line))
last_entry.lines.append(line)
self.process_parentheses(last_entry, line)
else:
if last_entry.is_empty:
msg = 'first line should start with a tab, ' \
@@ -495,6 +525,18 @@ class GitCommit:
self.errors.append(Error(msg, line))
else:
last_entry.lines.append(line)
self.process_parentheses(last_entry, line)
def process_parentheses(self, last_entry, line):
for c in line:
if c == '(':
last_entry.opened_parentheses += 1
elif c == ')':
if last_entry.opened_parentheses == 0:
msg = 'bad wrapping of parenthesis'
self.errors.append(Error(msg, line))
else:
last_entry.opened_parentheses -= 1
def parse_file_names(self):
for entry in self.changelog_entries:
@@ -518,6 +560,12 @@ class GitCommit:
msg = 'missing description of a change'
self.errors.append(Error(msg, line))
def check_for_broken_parentheses(self):
for entry in self.changelog_entries:
if entry.opened_parentheses != 0:
msg = 'bad parentheses wrapping'
self.errors.append(Error(msg, entry.lines[0]))
def get_file_changelog_location(self, changelog_file):
for file in self.info.modified_files:
if file[0] == changelog_file:

View File

@@ -22,7 +22,7 @@ from itertools import takewhile
from dateutil.parser import parse
from git_commit import GitCommit, GitInfo
from git_commit import GitCommit, GitInfo, decode_path
from unidiff import PatchSet, PatchedFile
@@ -52,8 +52,8 @@ class GitEmail(GitCommit):
modified_files = []
for f in diff:
# Strip "a/" and "b/" prefixes
source = f.source_file[2:]
target = f.target_file[2:]
source = decode_path(f.source_file)[2:]
target = decode_path(f.target_file)[2:]
if f.is_added_file:
t = 'A'

View File

@@ -26,7 +26,7 @@ except ImportError:
print(' Debian, Ubuntu: python3-git')
exit(1)
from git_commit import GitCommit, GitInfo
from git_commit import GitCommit, GitInfo, decode_path
def parse_git_revisions(repo_path, revisions, strict=True):
@@ -51,11 +51,11 @@ def parse_git_revisions(repo_path, revisions, strict=True):
# Consider that renamed files are two operations:
# the deletion of the original name
# and the addition of the new one.
modified_files.append((file.a_path, 'D'))
modified_files.append((decode_path(file.a_path), 'D'))
t = 'A'
else:
t = 'M'
modified_files.append((file.b_path, t))
modified_files.append((decode_path(file.b_path), t))
date = datetime.utcfromtimestamp(c.committed_date)
author = '%s <%s>' % (c.author.name, c.author.email)

View File

@@ -402,4 +402,17 @@ class TestGccChangelog(unittest.TestCase):
def test_bad_unicode_chars_in_filename(self):
email = self.from_patch_glob('0001-Add-horse2.patch')
assert email.errors[0].message.startswith('Quoted UTF8 filename')
assert not email.errors
assert email.changelog_entries[0].files == ['koníček.txt']
def test_modification_of_old_changelog(self):
email = self.from_patch_glob('0001-fix-old-ChangeLog.patch')
assert not email.errors
def test_multiline_parentheses(self):
email = self.from_patch_glob('0001-Add-macro.patch')
assert not email.errors
def test_multiline_bad_parentheses(self):
email = self.from_patch_glob('0002-Wrong-macro-changelog.patch')
assert email.errors[0].message == 'bad parentheses wrapping'

View File

@@ -3398,4 +3398,86 @@ index 00000000000..56c67f58752
--
2.29.2
=== 0001-fix-old-ChangeLog.patch ===
From fd498465b2801203089616be9a0e3c1f4fc065a0 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 13 Jan 2021 11:45:37 +0100
Subject: [PATCH] Fix a changelog.
---
gcc/ChangeLog-2020 | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/ChangeLog-2020 b/gcc/ChangeLog-2020
index 6553720acad..2c170ef014a 100644
--- a/gcc/ChangeLog-2020
+++ b/gcc/ChangeLog-2020
@@ -1 +1,2 @@
+
--
2.29.2
=== 0001-Add-macro.patch ===
From 9b7eedc932fe594547fb060b36dfd9e4178c4f9b Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 13 Jan 2021 16:26:45 +0100
Subject: [PATCH 1/2] Add macro.
gcc/ChangeLog:
* config/i386/i386.md (*fix_trunc<mode>_i387_1, *add<mode>3_eq,
*add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, *add<mode>3_eq,
*fist<mode>2_<rounding>_1, *<code><mode>3_1, *<code>di3_doubleword):
Use ix86_pre_reload_split instead of can_create_pseudo_p in condition.
* config/i386/sse.md
(*fix_trunc<mode>_i387_1, *add<mode>3_eq,
*add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, *add<mode>3_eq,
*fist<mode>2_<rounding>_1): This should also work.
---
gcc/config/i386/i386.md | 1 +
gcc/config/i386/sse.md | 1 +
2 files changed, 2 insertions(+)
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index b60784a2908..ac63591b33f 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -1 +1,2 @@
+
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 7f03fc491c3..0e17997db26 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -1 +1,2 @@
+
--
2.29.2
=== 0002-Wrong-macro-changelog.patch ===
From 3542802111d4c6752ac7233ef96655b7fb78aae4 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 13 Jan 2021 16:54:58 +0100
Subject: [PATCH 2/2] Wrong macro changelog
gcc/ChangeLog:
* config/i386/i386.md (*fix_trunc<mode>_i387_1,
(foo): Change it.
---
gcc/config/i386/i386.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index ac63591b33f..ff4d61764e7 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -1 +1,2 @@
+
--
2.29.2

View File

@@ -27,8 +27,10 @@
# Author: Martin Liska <mliska@suse.cz>
import argparse
import datetime
import os
import re
import subprocess
import sys
from itertools import takewhile
@@ -47,10 +49,11 @@ macro_regex = re.compile(r'#\s*(define|undef)\s+([a-zA-Z0-9_]+)')
super_macro_regex = re.compile(r'^DEF[A-Z0-9_]+\s*\(([a-zA-Z0-9_]+)')
fn_regex = re.compile(r'([a-zA-Z_][^()\s]*)\s*\([^*]')
template_and_param_regex = re.compile(r'<[^<>]*>')
md_def_regex = re.compile(r'\(define.*\s+"(.*)"')
bugzilla_url = 'https://gcc.gnu.org/bugzilla/rest.cgi/bug?id=%s&' \
'include_fields=summary'
function_extensions = {'.c', '.cpp', '.C', '.cc', '.h', '.inc', '.def'}
function_extensions = {'.c', '.cpp', '.C', '.cc', '.h', '.inc', '.def', '.md'}
help_message = """\
Generate ChangeLog template for PATCH.
@@ -130,6 +133,9 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
diff = PatchSet(data)
for file in diff:
# skip files that can't be parsed
if file.path == '/dev/null':
continue
changelog = find_changelog(file.path)
if changelog not in changelogs:
changelogs[changelog] = []
@@ -198,6 +204,15 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
for line in hunk:
m = identifier_regex.match(line.value)
if line.is_added or line.is_removed:
# special-case definition in .md files
m2 = md_def_regex.match(line.value)
if extension == '.md' and m2:
fn = m2.group(1)
if fn not in functions:
functions.append(fn)
last_fn = None
success = True
if not line.value.strip():
continue
modified_visited = True
@@ -227,6 +242,28 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
return out
def update_copyright(data):
current_timestamp = datetime.datetime.now().strftime('%Y-%m-%d')
username = subprocess.check_output('git config user.name', shell=True,
encoding='utf8').strip()
email = subprocess.check_output('git config user.email', shell=True,
encoding='utf8').strip()
changelogs = set()
diff = PatchSet(data)
for file in diff:
changelog = os.path.join(find_changelog(file.path), 'ChangeLog')
if changelog not in changelogs:
changelogs.add(changelog)
with open(changelog) as f:
content = f.read()
with open(changelog, 'w+') as f:
f.write(f'{current_timestamp} {username} <{email}>\n\n')
f.write('\tUpdate copyright years.\n\n')
f.write(content)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=help_message)
parser.add_argument('input', nargs='?',
@@ -238,28 +275,33 @@ if __name__ == '__main__':
parser.add_argument('-c', '--changelog',
help='Append the ChangeLog to a git commit message '
'file')
parser.add_argument('--update-copyright', action='store_true',
help='Update copyright in ChangeLog files')
args = parser.parse_args()
if args.input == '-':
args.input = None
data = open(args.input) if args.input else sys.stdin
output = generate_changelog(data, args.no_functions,
args.fill_up_bug_titles)
if args.changelog:
lines = open(args.changelog).read().split('\n')
start = list(takewhile(lambda l: not l.startswith('#'), lines))
end = lines[len(start):]
with open(args.changelog, 'w') as f:
if start:
# appent empty line
if start[-1] != '':
start.append('')
else:
# append 2 empty lines
start = 2 * ['']
f.write('\n'.join(start))
f.write('\n')
f.write(output)
f.write('\n'.join(end))
if args.update_copyright:
update_copyright(data)
else:
print(output, end='')
output = generate_changelog(data, args.no_functions,
args.fill_up_bug_titles)
if args.changelog:
lines = open(args.changelog).read().split('\n')
start = list(takewhile(lambda l: not l.startswith('#'), lines))
end = lines[len(start):]
with open(args.changelog, 'w') as f:
if start:
# appent empty line
if start[-1] != '':
start.append('')
else:
# append 2 empty lines
start = 2 * ['']
f.write('\n'.join(start))
f.write('\n')
f.write(output)
f.write('\n'.join(end))
else:
print(output, end='')

View File

@@ -399,6 +399,44 @@ gcc/ChangeLog:
'''
PATCH9 = '''\
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 2a260c1cfbd..7f03fc491c3 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -17611,6 +17611,23 @@ (define_insn "avx2_<code>v16qiv16hi2<mask_name>"
(set_attr "prefix" "maybe_evex")
(set_attr "mode" "OI")])
+(define_insn_and_split "*avx2_zero_extendv16qiv16hi2_1"
+ [(set (match_operand:V32QI 0 "register_operand" "=v")
+ (vec_select:V32QI
+ (vec_concat:V64QI
+ (match_operand:V32QI 1 "nonimmediate_operand" "vm")
+ (match_operand:V32QI 2 "const0_operand" "C"))
+ (match_parallel 3 "pmovzx_parallel"
+ [(match_operand 4 "const_int_operand" "n")])))]
+ "TARGET_AVX2"
+ "#"
+ "&& reload_completed"
+ [(set (match_dup 0) (zero_extend:V16HI (match_dup 1)))]
+{
+ operands[0] = lowpart_subreg (V16HImode, operands[0], V32QImode);
+ operands[1] = lowpart_subreg (V16QImode, operands[1], V32QImode);
+})
+
(define_expand "<insn>v16qiv16hi2"
[(set (match_operand:V16HI 0 "register_operand")
(any_extend:V16HI
'''
EXPECTED9 = '''\
gcc/ChangeLog:
* config/i386/sse.md (*avx2_zero_extendv16qiv16hi2_1):
'''
class TestMklog(unittest.TestCase):
def test_macro_definition(self):
changelog = generate_changelog(PATCH1)
@@ -437,3 +475,7 @@ class TestMklog(unittest.TestCase):
def test_renaming(self):
changelog = generate_changelog(PATCH8)
assert changelog == EXPECTED8
def test_define_macro_parsing(self):
changelog = generate_changelog(PATCH9)
assert changelog == EXPECTED9

View File

@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python3
#
# Copyright (C) 2013-2020 Free Software Foundation, Inc.
#
@@ -64,7 +64,10 @@ class GenericFilter:
def __init__ (self):
self.skip_files = set()
self.skip_dirs = set()
self.skip_extensions = set()
self.skip_extensions = set([
'.png',
'.pyc',
])
self.fossilised_files = set()
self.own_files = set()
@@ -307,7 +310,7 @@ class Copyright:
# If it looks like the copyright is incomplete, add the next line.
while not self.is_complete (match):
try:
next_line = file.next()
next_line = file.readline()
except StopIteration:
break
@@ -381,6 +384,15 @@ class Copyright:
return (line != orig_line, line, next_line)
def guess_encoding (self, pathname):
for encoding in ('utf8', 'iso8859'):
try:
open(pathname, 'r', encoding=encoding).read()
return encoding
except UnicodeDecodeError:
pass
return None
def process_file (self, dir, filename, filter):
pathname = os.path.join (dir, filename)
if filename.endswith ('.tmp'):
@@ -395,7 +407,8 @@ class Copyright:
changed = False
line_filter = filter.get_line_filter (dir, filename)
mode = None
with open (pathname, 'r') as file:
encoding = self.guess_encoding(pathname)
with open (pathname, 'r', encoding=encoding) as file:
prev = None
mode = os.fstat (file.fileno()).st_mode
for line in file:
@@ -421,7 +434,7 @@ class Copyright:
# If something changed, write the new file out.
if changed and self.errors.ok():
tmp_pathname = pathname + '.tmp'
with open (tmp_pathname, 'w') as file:
with open (tmp_pathname, 'w', encoding=encoding) as file:
for line in lines:
file.write (line)
os.fchmod (file.fileno(), mode)
@@ -432,7 +445,7 @@ class Copyright:
def process_tree (self, tree, filter):
for (dir, subdirs, filenames) in os.walk (tree):
# Don't recurse through directories that should be skipped.
for i in xrange (len (subdirs) - 1, -1, -1):
for i in range (len (subdirs) - 1, -1, -1):
if filter.skip_dir (dir, subdirs[i]):
del subdirs[i]
@@ -594,7 +607,7 @@ class TestsuiteFilter (GenericFilter):
if filename == 'README' and os.path.basename (dir) == 'params':
return True
if filename == 'pdt_5.f03' and os.path.basename (dir) == 'gfortran.dg':
return True
return True
return GenericFilter.skip_file (self, dir, filename)
class LibCppFilter (GenericFilter):
@@ -683,6 +696,7 @@ class GCCCopyright (Copyright):
self.add_external_author ('ARM')
self.add_external_author ('AdaCore')
self.add_external_author ('Advanced Micro Devices Inc.')
self.add_external_author ('Ami Tavory and Vladimir Dreizin, IBM-HRL.')
self.add_external_author ('Cavium Networks.')
self.add_external_author ('Faraday Technology Corp.')
@@ -710,6 +724,7 @@ class GCCCopyright (Copyright):
self.add_external_author ('The Go Authors. All rights reserved.')
self.add_external_author ('The Go Authors.')
self.add_external_author ('The Regents of the University of California.')
self.add_external_author ('Ulf Adams')
self.add_external_author ('Unicode, Inc.')
self.add_external_author ('University of Toronto.')
self.add_external_author ('Yoshinori Sato')

View File

@@ -49,7 +49,7 @@ configure GCC with --enable-maintainer-mode to get the master catalog
rebuilt.
Copyright (C) 1998-2020 Free Software Foundation, Inc.
Copyright (C) 1998-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

File diff suppressed because it is too large Load Diff

39860
gcc/ChangeLog-2020 Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
20201231
20210203

View File

@@ -57,7 +57,7 @@ Feb 1, 1998:
DEFTREECODE (CLASS_METHOD_DECL, "class_method_decl", 'd', 0)
Copyright (C) 1998-2020 Free Software Foundation, Inc.
Copyright (C) 1998-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -1,7 +1,7 @@
# Makefile for GNU Compiler Collection
# Run 'configure' to generate Makefile from Makefile.in
# Copyright (C) 1987-2020 Free Software Foundation, Inc.
# Copyright (C) 1987-2021 Free Software Foundation, Inc.
#This file is part of GCC.
@@ -415,6 +415,7 @@ CPPINC = -I$(srcdir)/../libcpp/include
CODYLIB = ../libcody/libcody.a
CODYINC = -I$(srcdir)/../libcody
NETLIBS = @NETLIBS@
# Where to find decNumber
enable_decimal_float = @enable_decimal_float@
@@ -449,6 +450,9 @@ USER_H = $(srcdir)/ginclude/float.h \
USER_H_INC_NEXT_PRE = @user_headers_inc_next_pre@
USER_H_INC_NEXT_POST = @user_headers_inc_next_post@
# Enable target overriding of this fragment, as in config/t-vxworks.
T_GLIMITS_H = $(srcdir)/glimits.h
# The GCC to use for compiling crt*.o.
# Usually the one we just built.
# Don't use this as a dependency--use $(GCC_PASSES).
@@ -1020,6 +1024,13 @@ PLUGIN_H = plugin.h $(GCC_PLUGIN_H)
PLUGIN_VERSION_H = plugin-version.h configargs.h
CONTEXT_H = context.h
GENSUPPORT_H = gensupport.h read-md.h optabs.def
RTL_SSA_H = $(PRETTY_PRINT_H) insn-config.h splay-tree-utils.h \
$(RECOG_H) $(REGS_H) function-abi.h obstack-utils.h \
mux-utils.h rtlanal.h memmodel.h $(EMIT_RTL_H) \
rtl-ssa/accesses.h rtl-ssa/insns.h rtl-ssa/blocks.h \
rtl-ssa/changes.h rtl-ssa/functions.h rtl-ssa/is-a.inl \
rtl-ssa/access-utils.h rtl-ssa/insn-utils.h rtl-ssa/movement.h \
rtl-ssa/change-utils.h rtl-ssa/member-fns.inl
#
# Now figure out from those variables how to compile and link.
@@ -1729,7 +1740,7 @@ endif
ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS)
BACKEND = libbackend.a main.o libcommon-target.a libcommon.a \
$(CPPLIB) $(CODYLIB) $(LIBDECNUMBER)
$(CPPLIB) $(LIBDECNUMBER)
# This is defined to "yes" if Tree checking is enabled, which roughly means
# front-end checking.
@@ -1789,7 +1800,7 @@ DO_LINK_SERIALIZATION = @DO_LINK_SERIALIZATION@
ifeq ($(DO_LINK_SERIALIZATION),)
LINK_PROGRESS = :
else
LINK_PROGRESS = msg="Linking |"; cnt=0; if test "$(2)" = start; then \
LINK_PROGRESS = msg="Linking $@ |"; cnt=0; if test "$(2)" = start; then \
idx=0; cnt2=$(DO_LINK_SERIALIZATION); \
while test $$cnt2 -le $(1); do msg="$${msg}=="; cnt2=`expr $$cnt2 + 1`; idx=`expr $$idx + 1`; done; \
cnt=$$idx; \
@@ -3075,7 +3086,7 @@ gcov-tool$(exeext): $(GCOV_TOOL_OBJS) $(LIBDEPS)
# be rebuilt.
# Build the include directories.
stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) fixinc_list
stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(USER_H) fixinc_list
# Copy in the headers provided with gcc.
#
# The sed command gets just the last file name component;
@@ -3129,9 +3140,9 @@ stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) fixinc_list
multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
fix_dir=include-fixed$${multi_dir}; \
if $(LIMITS_H_TEST) ; then \
cat $(srcdir)/limitx.h $(srcdir)/glimits.h $(srcdir)/limity.h > tmp-xlimits.h; \
cat $(srcdir)/limitx.h $(T_GLIMITS_H) $(srcdir)/limity.h > tmp-xlimits.h; \
else \
cat $(srcdir)/glimits.h > tmp-xlimits.h; \
cat $(T_GLIMITS_H) > tmp-xlimits.h; \
fi; \
$(mkinstalldirs) $${fix_dir}; \
chmod a+rx $${fix_dir} || true; \

View File

@@ -1,4 +1,4 @@
Copyright (C) 2000-2020 Free Software Foundation, Inc.
Copyright (C) 2000-2021 Free Software Foundation, Inc.
This file is intended to contain a few notes about writing C code
within GCC so that it compiles without error on the full range of

1
gcc/REVISION Normal file
View File

@@ -0,0 +1 @@
[c++-modules]

View File

@@ -1,4 +1,4 @@
dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
dnl Copyright (C) 2005-2021 Free Software Foundation, Inc.
dnl
dnl This file is part of GCC.
dnl

1
gcc/aclocal.m4 vendored
View File

@@ -18,6 +18,7 @@ m4_include([../ltsugar.m4])
m4_include([../ltversion.m4])
m4_include([../lt~obsolete.m4])
m4_include([../config/acx.m4])
m4_include([../config/ax_lib_socket_nsl.m4])
m4_include([../config/cet.m4])
m4_include([../config/codeset.m4])
m4_include([../config/depstand.m4])

File diff suppressed because it is too large Load Diff

13978
gcc/ada/ChangeLog-2020 Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2168,11 +2168,16 @@ ifeq ($(strip $(filter-out rtems%,$(target_os))),)
s-tpopsp.adb<libgnarl/s-tpopsp__tls.adb \
s-stchop.adb<libgnat/s-stchop__rtems.adb \
s-interr.adb<libgnarl/s-interr__hwint.adb
ifeq ($(strip $(filter-out arm%, $(target_cpu))),)
EH_MECHANISM=-arm
else
EH_MECHANISM=-gcc
endif
ifeq ($(strip $(filter-out riscv%,$(target_cpu))),)
LIBGNAT_TARGET_PAIRS += a-nallfl.ads<libgnat/a-nallfl__wraplf.ads
endif
endif
# PikeOS

View File

@@ -2197,14 +2197,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
}
else
{
/* We make the fields addressable for the sake of compatibility
with languages for which the regular fields are addressable. */
tem
= create_field_decl (get_identifier ("P_ARRAY"),
ptr_type_node, gnu_fat_type,
NULL_TREE, NULL_TREE, 0, 0);
NULL_TREE, NULL_TREE, 0, 1);
DECL_CHAIN (tem)
= create_field_decl (get_identifier ("P_BOUNDS"),
gnu_ptr_template, gnu_fat_type,
NULL_TREE, NULL_TREE, 0, 0);
NULL_TREE, NULL_TREE, 0, 1);
finish_fat_pointer_type (gnu_fat_type, tem);
SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_type);
}
@@ -2327,7 +2329,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
finish_record_type (gnu_template_type, gnu_template_fields, 0,
debug_info_p);
TYPE_CONTEXT (gnu_template_type) = current_function_decl;
TYPE_READONLY (gnu_template_type) = 1;
/* If Component_Size is not already specified, annotate it with the
size of the component. */
@@ -3054,15 +3055,24 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
|| type_annotate_only);
}
/* Make a node for the record. If we are not defining the record,
suppress expanding incomplete types. */
/* Make a node for the record type. */
gnu_type = make_node (tree_code_for_record_type (gnat_entity));
TYPE_NAME (gnu_type) = gnu_entity_name;
TYPE_PACKED (gnu_type) = (packed != 0) || has_align || has_rep;
TYPE_REVERSE_STORAGE_ORDER (gnu_type)
= Reverse_Storage_Order (gnat_entity);
/* If the record type has discriminants, pointers to it may also point
to constrained subtypes of it, so mark it as may_alias for LTO. */
if (has_discr)
prepend_one_attribute
(&attr_list, ATTR_MACHINE_ATTRIBUTE,
get_identifier ("may_alias"), NULL_TREE,
gnat_entity);
process_attributes (&gnu_type, &attr_list, true, gnat_entity);
/* If we are not defining it, suppress expanding incomplete types. */
if (!definition)
{
defer_incomplete_level++;
@@ -8320,12 +8330,12 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
if (p_gnu_rep_list && gnu_rep_list)
*p_gnu_rep_list = chainon (*p_gnu_rep_list, gnu_rep_list);
/* Deal with the annoying case of an extension of a record with variable size
and partial rep clause, for which the _Parent field is forced at offset 0
and has variable size, which we do not support below. Note that we cannot
do it if the field has fixed size because we rely on the presence of the
REP part built below to trigger the reordering of the fields in a derived
record type when all the fields have a fixed position. */
/* Deal with the case of an extension of a record type with variable size and
partial rep clause, for which the _Parent field is forced at offset 0 and
has variable size. Note that we cannot do it if the field has fixed size
because we rely on the presence of the REP part built below to trigger the
reordering of the fields in a derived record type when all the fields have
a fixed position. */
else if (gnu_rep_list
&& !DECL_CHAIN (gnu_rep_list)
&& TREE_CODE (DECL_SIZE (gnu_rep_list)) != INTEGER_CST
@@ -8343,33 +8353,52 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
record, before the others, if we also have fields without rep clause. */
else if (gnu_rep_list)
{
tree gnu_rep_type, gnu_rep_part;
int i, len = list_length (gnu_rep_list);
tree *gnu_arr = XALLOCAVEC (tree, len);
tree gnu_parent, gnu_rep_type;
/* If all the fields have a rep clause, we can do a flat layout. */
layout_with_rep = !gnu_field_list
&& (!gnu_variant_part || variants_have_rep);
/* Same as above but the extension itself has a rep clause, in which case
we need to set aside the _Parent field to lay out the REP part. */
if (TREE_CODE (DECL_SIZE (gnu_rep_list)) != INTEGER_CST
&& !layout_with_rep
&& !variants_have_rep
&& first_free_pos
&& integer_zerop (first_free_pos)
&& integer_zerop (bit_position (gnu_rep_list)))
{
gnu_parent = gnu_rep_list;
gnu_rep_list = DECL_CHAIN (gnu_rep_list);
}
else
gnu_parent = NULL_TREE;
gnu_rep_type
= layout_with_rep ? gnu_record_type : make_node (RECORD_TYPE);
for (gnu_field = gnu_rep_list, i = 0;
gnu_field;
gnu_field = DECL_CHAIN (gnu_field), i++)
gnu_arr[i] = gnu_field;
/* Sort the fields in order of increasing bit position. */
const int len = list_length (gnu_rep_list);
tree *gnu_arr = XALLOCAVEC (tree, len);
gnu_field = gnu_rep_list;
for (int i = 0; i < len; i++)
{
gnu_arr[i] = gnu_field;
gnu_field = DECL_CHAIN (gnu_field);
}
qsort (gnu_arr, len, sizeof (tree), compare_field_bitpos);
/* Put the fields in the list in order of increasing position, which
means we start from the end. */
gnu_rep_list = NULL_TREE;
for (i = len - 1; i >= 0; i--)
for (int i = len - 1; i >= 0; i--)
{
DECL_CHAIN (gnu_arr[i]) = gnu_rep_list;
gnu_rep_list = gnu_arr[i];
DECL_CONTEXT (gnu_arr[i]) = gnu_rep_type;
}
/* Do the layout of the REP part, if any. */
if (layout_with_rep)
gnu_field_list = gnu_rep_list;
else
@@ -8378,14 +8407,36 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
= create_concat_name (gnat_record_type, "REP");
TYPE_REVERSE_STORAGE_ORDER (gnu_rep_type)
= TYPE_REVERSE_STORAGE_ORDER (gnu_record_type);
finish_record_type (gnu_rep_type, gnu_rep_list, 1, debug_info);
finish_record_type (gnu_rep_type, gnu_rep_list, 1, false);
/* If FIRST_FREE_POS is nonzero, we need to ensure that the fields
without rep clause are laid out starting from this position.
Therefore, we force it as a minimal size on the REP part. */
gnu_rep_part
tree gnu_rep_part
= create_rep_part (gnu_rep_type, gnu_record_type, first_free_pos);
/* If this is an extension, put back the _Parent field as the first
field of the REP part at offset 0 and update its layout. */
if (gnu_parent)
{
const unsigned int align = DECL_ALIGN (gnu_parent);
DECL_CHAIN (gnu_parent) = TYPE_FIELDS (gnu_rep_type);
TYPE_FIELDS (gnu_rep_type) = gnu_parent;
DECL_CONTEXT (gnu_parent) = gnu_rep_type;
if (align > TYPE_ALIGN (gnu_rep_type))
{
SET_TYPE_ALIGN (gnu_rep_type, align);
TYPE_SIZE (gnu_rep_type)
= round_up (TYPE_SIZE (gnu_rep_type), align);
TYPE_SIZE_UNIT (gnu_rep_type)
= round_up (TYPE_SIZE_UNIT (gnu_rep_type), align);
SET_DECL_ALIGN (gnu_rep_part, align);
}
}
if (debug_info)
rest_of_record_type_compilation (gnu_rep_type);
/* Chain the REP part at the beginning of the field list. */
DECL_CHAIN (gnu_rep_part) = gnu_field_list;
gnu_field_list = gnu_rep_part;

View File

@@ -8479,15 +8479,16 @@ add_decl_expr (tree gnu_decl, Node_Id gnat_node)
MARK_VISITED (DECL_SIZE_UNIT (gnu_decl));
MARK_VISITED (DECL_INITIAL (gnu_decl));
}
/* In any case, we have to deal with our own TYPE_ADA_SIZE field. */
else if (TREE_CODE (gnu_decl) == TYPE_DECL
&& RECORD_OR_UNION_TYPE_P (type)
&& !TYPE_FAT_POINTER_P (type))
MARK_VISITED (TYPE_ADA_SIZE (type));
}
else
add_stmt_with_node (gnu_stmt, gnat_node);
/* Mark our TYPE_ADA_SIZE field now since it will not be gimplified. */
if (TREE_CODE (gnu_decl) == TYPE_DECL
&& RECORD_OR_UNION_TYPE_P (type)
&& !TYPE_FAT_POINTER_P (type))
MARK_VISITED (TYPE_ADA_SIZE (type));
/* If this is a variable and an initializer is attached to it, it must be
valid for the context. Similar to init_const in create_var_decl. */
if (TREE_CODE (gnu_decl) == VAR_DECL
@@ -10611,7 +10612,7 @@ make_alias_for_thunk (tree target)
return alias;
}
/* Create the covariant part of the {GNAT,GNU}_THUNK. */
/* Create the local covariant part of {GNAT,GNU}_THUNK. */
static tree
make_covariant_thunk (Entity_Id gnat_thunk, tree gnu_thunk)
@@ -10622,6 +10623,11 @@ make_covariant_thunk (Entity_Id gnat_thunk, tree gnu_thunk)
gnu_name, TREE_TYPE (gnu_thunk));
DECL_ARGUMENTS (gnu_cv_thunk) = copy_list (DECL_ARGUMENTS (gnu_thunk));
for (tree param_decl = DECL_ARGUMENTS (gnu_cv_thunk);
param_decl;
param_decl = DECL_CHAIN (param_decl))
DECL_CONTEXT (param_decl) = gnu_cv_thunk;
DECL_RESULT (gnu_cv_thunk) = copy_node (DECL_RESULT (gnu_thunk));
DECL_CONTEXT (DECL_RESULT (gnu_cv_thunk)) = gnu_cv_thunk;
@@ -10629,7 +10635,6 @@ make_covariant_thunk (Entity_Id gnat_thunk, tree gnu_thunk)
DECL_CONTEXT (gnu_cv_thunk) = DECL_CONTEXT (gnu_thunk);
TREE_READONLY (gnu_cv_thunk) = TREE_READONLY (gnu_thunk);
TREE_THIS_VOLATILE (gnu_cv_thunk) = TREE_THIS_VOLATILE (gnu_thunk);
TREE_PUBLIC (gnu_cv_thunk) = TREE_PUBLIC (gnu_thunk);
DECL_ARTIFICIAL (gnu_cv_thunk) = 1;
return gnu_cv_thunk;
@@ -10759,6 +10764,12 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk)
cgraph_node *target_node = cgraph_node::get_create (gnu_target);
/* We may also need to create an alias for the target in order to make
the call local, depending on the linkage of the target. */
tree gnu_alias = use_alias_for_thunk_p (gnu_target)
? make_alias_for_thunk (gnu_target)
: gnu_target;
/* If the return type of the target is a controlling type, then we need
both an usual this thunk and a covariant thunk in this order:
@@ -10771,17 +10782,11 @@ maybe_make_gnu_thunk (Entity_Id gnat_thunk, tree gnu_thunk)
tree gnu_cv_thunk = make_covariant_thunk (gnat_thunk, gnu_thunk);
target_node->create_thunk (gnu_cv_thunk, gnu_target, false,
- fixed_offset, 0, 0,
NULL_TREE, gnu_target);
NULL_TREE, gnu_alias);
gnu_target = gnu_cv_thunk;
gnu_alias = gnu_target = gnu_cv_thunk;
}
/* We may also need to create an alias for the target in order to make
the call local, depending on the linkage of the target. */
tree gnu_alias = use_alias_for_thunk_p (gnu_target)
? make_alias_for_thunk (gnu_target)
: gnu_target;
target_node->create_thunk (gnu_thunk, gnu_target, true,
fixed_offset, virtual_value, indirect_offset,
virtual_offset, gnu_alias);

View File

@@ -467,6 +467,11 @@ make_dummy_type (Entity_Id gnat_type)
= create_type_stub_decl (TYPE_NAME (gnu_type), gnu_type);
if (Is_By_Reference_Type (gnat_equiv))
TYPE_BY_REFERENCE_P (gnu_type) = 1;
if (Has_Discriminants (gnat_equiv))
decl_attributes (&gnu_type,
tree_cons (get_identifier ("may_alias"), NULL_TREE,
NULL_TREE),
ATTR_FLAG_TYPE_IN_PLACE);
SET_DUMMY_NODE (gnat_equiv, gnu_type);
@@ -516,10 +521,10 @@ build_dummy_unc_pointer_types (Entity_Id gnat_desig_type, tree gnu_desig_type)
= create_type_stub_decl (create_concat_name (gnat_desig_type, "XUP"),
gnu_fat_type);
fields = create_field_decl (get_identifier ("P_ARRAY"), gnu_ptr_array,
gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0);
gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1);
DECL_CHAIN (fields)
= create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template,
gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0);
gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1);
finish_fat_pointer_type (gnu_fat_type, fields);
SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_desig_type);
/* Suppress debug info until after the type is completed. */
@@ -1571,7 +1576,7 @@ maybe_pad_type (tree type, tree size, unsigned int align,
{
tree packable_type = make_packable_type (type, true, align);
if (TYPE_MODE (packable_type) != BLKmode
&& align >= TYPE_ALIGN (packable_type))
&& compare_tree_int (TYPE_SIZE (packable_type), align) <= 0)
type = packable_type;
}
@@ -2046,7 +2051,6 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
this_ada_size = this_size;
const bool variant_part = (TREE_CODE (type) == QUAL_UNION_TYPE);
const bool variant_part_at_zero = variant_part && integer_zerop (pos);
/* Clear DECL_BIT_FIELD for the cases layout_decl does not handle. */
if (DECL_BIT_FIELD (field)
@@ -2089,7 +2093,7 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
/* Clear DECL_BIT_FIELD_TYPE for a variant part at offset 0, it's simply
not supported by the DECL_BIT_FIELD_REPRESENTATIVE machinery because
the variant part is always the last field in the list. */
if (variant_part_at_zero)
if (variant_part && integer_zerop (pos))
DECL_BIT_FIELD_TYPE (field) = NULL_TREE;
/* If we still have DECL_BIT_FIELD set at this point, we know that the
@@ -2124,18 +2128,20 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
case RECORD_TYPE:
/* Since we know here that all fields are sorted in order of
increasing bit position, the size of the record is one
higher than the ending bit of the last field processed,
unless we have a variant part at offset 0, since in this
case we might have a field outside the variant part that
has a higher ending position; so use a MAX in this case.
Also, if this field is a QUAL_UNION_TYPE, we need to take
into account the previous size in the case of empty variants. */
higher than the ending bit of the last field processed
unless we have a rep clause, because we might be processing
the REP part of a record with a variant part for which the
variant part has a rep clause but not the fixed part, in
which case this REP part may contain overlapping fields
and thus needs to be treated like a union tyoe above, so
use a MAX in that case. Also, if this field is a variant
part, we need to take into account the previous size in
the case of empty variants. */
ada_size
= merge_sizes (ada_size, pos, this_ada_size, variant_part,
variant_part_at_zero);
= merge_sizes (ada_size, pos, this_ada_size, rep_level > 0,
variant_part);
size
= merge_sizes (size, pos, this_size, variant_part,
variant_part_at_zero);
= merge_sizes (size, pos, this_size, rep_level > 0, variant_part);
break;
default:
@@ -2427,14 +2433,14 @@ rest_of_record_type_compilation (tree record_type)
}
/* Utility function of above to merge LAST_SIZE, the previous size of a record
with FIRST_BIT and SIZE that describe a field. SPECIAL is true if this
represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and
replace a value of zero with the old size. If MAX is true, we take the
with FIRST_BIT and SIZE that describe a field. If MAX is true, we take the
MAX of the end position of this field with LAST_SIZE. In all other cases,
we use FIRST_BIT plus SIZE. Return an expression for the size. */
we use FIRST_BIT plus SIZE. SPECIAL is true if it's for a QUAL_UNION_TYPE,
in which case we must look for COND_EXPRs and replace a value of zero with
the old size. Return an expression for the size. */
static tree
merge_sizes (tree last_size, tree first_bit, tree size, bool special, bool max)
merge_sizes (tree last_size, tree first_bit, tree size, bool max, bool special)
{
tree type = TREE_TYPE (last_size);
tree new_size;
@@ -2451,11 +2457,11 @@ merge_sizes (tree last_size, tree first_bit, tree size, bool special, bool max)
integer_zerop (TREE_OPERAND (size, 1))
? last_size : merge_sizes (last_size, first_bit,
TREE_OPERAND (size, 1),
1, max),
max, special),
integer_zerop (TREE_OPERAND (size, 2))
? last_size : merge_sizes (last_size, first_bit,
TREE_OPERAND (size, 2),
1, max));
max, special));
/* We don't need any NON_VALUE_EXPRs and they can confuse us (especially
when fed through SUBSTITUTE_IN_EXPR) into thinking that a constant
@@ -3521,6 +3527,12 @@ create_subprog_decl (tree name, tree asm_name, tree type, tree param_decl_list,
void
finish_subprog_decl (tree decl, tree asm_name, tree type)
{
/* DECL_ARGUMENTS is set by the caller, but not its context. */
for (tree param_decl = DECL_ARGUMENTS (decl);
param_decl;
param_decl = DECL_CHAIN (param_decl))
DECL_CONTEXT (param_decl) = decl;
tree result_decl
= build_decl (DECL_SOURCE_LOCATION (decl), RESULT_DECL, NULL_TREE,
TREE_TYPE (type));
@@ -3566,8 +3578,6 @@ finish_subprog_decl (tree decl, tree asm_name, tree type)
void
begin_subprog_body (tree subprog_decl)
{
tree param_decl;
announce_function (subprog_decl);
/* This function is being defined. */
@@ -3583,10 +3593,6 @@ begin_subprog_body (tree subprog_decl)
/* Enter a new binding level and show that all the parameters belong to
this function. */
gnat_pushlevel ();
for (param_decl = DECL_ARGUMENTS (subprog_decl); param_decl;
param_decl = DECL_CHAIN (param_decl))
DECL_CONTEXT (param_decl) = subprog_decl;
}
/* Finish translating the current subprogram and set its BODY. */

View File

@@ -25,7 +25,7 @@ GNAT Reference Manual , Dec 11, 2020
AdaCore
Copyright @copyright{} 2008-2020, Free Software Foundation
Copyright @copyright{} 2008-2021, Free Software Foundation
@end quotation
@end copying

View File

@@ -25,7 +25,7 @@ GNAT User's Guide for Native Platforms , Dec 11, 2020
AdaCore
Copyright @copyright{} 2008-2020, Free Software Foundation
Copyright @copyright{} 2008-2021, Free Software Foundation
@end quotation
@end copying

View File

@@ -39,7 +39,7 @@ package Gnatvsn is
-- Note: Makefile.in uses the library version string to construct the
-- soname value.
Current_Year : constant String := "2020";
Current_Year : constant String := "2021";
-- Used in printing copyright messages
Verbose_Library_Version : constant String := "GNAT Lib v" & Library_Version;

View File

@@ -1,5 +1,5 @@
/* Inline functions to test validity of reg classes for addressing modes.
Copyright (C) 2006-2020 Free Software Foundation, Inc.
Copyright (C) 2006-2021 Free Software Foundation, Inc.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Adjust alignment for local variable.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by Kito Cheng <kito.cheng@sifive.com>
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Alias analysis for GNU C
Copyright (C) 1997-2020 Free Software Foundation, Inc.
Copyright (C) 1997-2021 Free Software Foundation, Inc.
Contributed by John Carr (jfc@mit.edu).
This file is part of GCC.
@@ -159,7 +159,8 @@ static tree decl_for_component_ref (tree);
static int write_dependence_p (const_rtx,
const_rtx, machine_mode, rtx,
bool, bool, bool);
static int compare_base_symbol_refs (const_rtx, const_rtx);
static int compare_base_symbol_refs (const_rtx, const_rtx,
HOST_WIDE_INT * = NULL);
static void memory_modified_1 (rtx, const_rtx, void *);
@@ -1837,7 +1838,11 @@ rtx_equal_for_memref_p (const_rtx x, const_rtx y)
return label_ref_label (x) == label_ref_label (y);
case SYMBOL_REF:
return compare_base_symbol_refs (x, y) == 1;
{
HOST_WIDE_INT distance = 0;
return (compare_base_symbol_refs (x, y, &distance) == 1
&& distance == 0);
}
case ENTRY_VALUE:
/* This is magic, don't go through canonicalization et al. */
@@ -2172,10 +2177,20 @@ compare_base_decls (tree base1, tree base2)
return ret;
}
/* Same as compare_base_decls but for SYMBOL_REF. */
/* Compare SYMBOL_REFs X_BASE and Y_BASE.
- Return 1 if Y_BASE - X_BASE is constant, adding that constant
to *DISTANCE if DISTANCE is nonnull.
- Return 0 if no accesses based on X_BASE can alias Y_BASE.
- Return -1 if one of the two results applies, but we can't tell
which at compile time. Update DISTANCE in the same way as
for a return value of 1, for the case in which that holds. */
static int
compare_base_symbol_refs (const_rtx x_base, const_rtx y_base)
compare_base_symbol_refs (const_rtx x_base, const_rtx y_base,
HOST_WIDE_INT *distance)
{
tree x_decl = SYMBOL_REF_DECL (x_base);
tree y_decl = SYMBOL_REF_DECL (y_base);
@@ -2192,8 +2207,8 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base)
std::swap (x_decl, y_decl);
std::swap (x_base, y_base);
}
/* We handle specially only section anchors and assume that other
labels may overlap with user variables in an arbitrary way. */
/* We handle specially only section anchors. Other symbols are
either equal (via aliasing) or refer to different objects. */
if (!SYMBOL_REF_HAS_BLOCK_INFO_P (y_base))
return -1;
/* Anchors contains static VAR_DECLs and CONST_DECLs. We are safe
@@ -2222,14 +2237,13 @@ compare_base_symbol_refs (const_rtx x_base, const_rtx y_base)
{
if (SYMBOL_REF_BLOCK (x_base) != SYMBOL_REF_BLOCK (y_base))
return 0;
if (SYMBOL_REF_BLOCK_OFFSET (x_base) == SYMBOL_REF_BLOCK_OFFSET (y_base))
return binds_def ? 1 : -1;
if (SYMBOL_REF_ANCHOR_P (x_base) != SYMBOL_REF_ANCHOR_P (y_base))
return -1;
return 0;
if (distance)
*distance += (SYMBOL_REF_BLOCK_OFFSET (y_base)
- SYMBOL_REF_BLOCK_OFFSET (x_base));
return binds_def ? 1 : -1;
}
/* In general we assume that memory locations pointed to by different labels
may overlap in undefined ways. */
/* Either the symbols are equal (via aliasing) or they refer to
different objects. */
return -1;
}
@@ -2513,11 +2527,12 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
if (GET_CODE (x) == SYMBOL_REF && GET_CODE (y) == SYMBOL_REF)
{
int cmp = compare_base_symbol_refs (x,y);
HOST_WIDE_INT distance = 0;
int cmp = compare_base_symbol_refs (x, y, &distance);
/* If both decls are the same, decide by offsets. */
if (cmp == 1)
return offset_overlap_p (c, xsize, ysize);
return offset_overlap_p (c + distance, xsize, ysize);
/* Assume a potential overlap for symbolic addresses that went
through alignment adjustments (i.e., that have negative
sizes), because we can't know how far they are from each
@@ -2526,7 +2541,7 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
return -1;
/* If decls are different or we know by offsets that there is no overlap,
we win. */
if (!cmp || !offset_overlap_p (c, xsize, ysize))
if (!cmp || !offset_overlap_p (c + distance, xsize, ysize))
return 0;
/* Decls may or may not be different and offsets overlap....*/
return -1;

View File

@@ -1,5 +1,5 @@
/* Exported functions from alias.c
Copyright (C) 2004-2020 Free Software Foundation, Inc.
Copyright (C) 2004-2021 Free Software Foundation, Inc.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Alignment-related classes.
Copyright (C) 2018-2020 Free Software Foundation, Inc.
Copyright (C) 2018-2021 Free Software Foundation, Inc.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Functions to support a pool of allocatable objects.
Copyright (C) 1987-2020 Free Software Foundation, Inc.
Copyright (C) 1987-2021 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dan@cgsoftware.com>
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Functions to support a pool of allocatable objects
Copyright (C) 1997-2020 Free Software Foundation, Inc.
Copyright (C) 1997-2021 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dan@cgsoftware.com>
This file is part of GCC.

View File

@@ -1,3 +1,211 @@
2021-02-02 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93355
PR analyzer/96374
* engine.cc (toplevel_function_p): Simplify so that
we only reject functions with a "__analyzer_" prefix.
(add_any_callbacks): Delete.
(exploded_graph::build_initial_worklist): Update for
dropped param of toplevel_function_p.
(exploded_graph::build_initial_worklist): Don't bother
looking for callbacks that are reachable from global
initializers.
2021-02-01 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98918
* region-model-manager.cc
(region_model_manager::get_or_create_initial_value):
Fold the initial value of *UNKNOWN_PTR to an UNKNOWN value.
(region_model_manager::get_field_region): Fold the value
of UNKNOWN_PTR->FIELD to *UNKNOWN_PTR_OF_&FIELD_TYPE.
2021-01-29 David Malcolm <dmalcolm@redhat.com>
* checker-path.cc (event_kind_to_string): Handle
EK_START_CONSOLIDATED_CFG_EDGES and
EK_END_CONSOLIDATED_CFG_EDGES.
(start_consolidated_cfg_edges_event::get_desc): New.
(checker_path::cfg_edge_pair_at_p): New.
* checker-path.h (enum event_kind): Add
EK_START_CONSOLIDATED_CFG_EDGES and
EK_END_CONSOLIDATED_CFG_EDGES.
(class start_consolidated_cfg_edges_event): New class.
(class end_consolidated_cfg_edges_event): New class.
(checker_path::delete_events): New.
(checker_path::replace_event): New.
(checker_path::cfg_edge_pair_at_p): New decl.
* diagnostic-manager.cc (diagnostic_manager::prune_path): Call
consolidate_conditions.
(same_line_as_p): New.
(diagnostic_manager::consolidate_conditions): New.
* diagnostic-manager.h
(diagnostic_manager::consolidate_conditions): New decl.
2021-01-18 David Malcolm <dmalcolm@redhat.com>
* analyzer.h (is_std_named_call_p): New decl.
* diagnostic-manager.cc (path_builder::get_sm): New.
(state_change_event_creator::state_change_event_creator): Add "pb"
param.
(state_change_event_creator::on_global_state_change): Don't consider
state changes affecting other state_machines.
(state_change_event_creator::on_state_change): Likewise.
(state_change_event_creator::m_pb): New field.
(diagnostic_manager::add_events_for_eedge): Pass pb to visitor
ctor.
* region-model-impl-calls.cc
(region_model::impl_deallocation_call): New.
* region-model.cc: Include "attribs.h".
(region_model::on_call_post): Handle fndecls referenced by
__attribute__((deallocated_by(FOO))).
* region-model.h (region_model::impl_deallocation_call): New decl.
* sm-malloc.cc: Include "stringpool.h" and "attribs.h". Add
leading comment.
(class api): Delete.
(enum resource_state): Update comment for change from api to
deallocator and deallocator_set.
(allocation_state::allocation_state): Drop api param. Add
"deallocators" and "deallocator".
(allocation_state::m_api): Drop field in favor of...
(allocation_state::m_deallocators): New field.
(allocation_state::m_deallocator): New field.
(enum wording): Add WORDING_DEALLOCATED.
(struct deallocator): New.
(struct standard_deallocator): New.
(struct custom_deallocator): New.
(struct deallocator_set): New.
(struct custom_deallocator_set): New.
(struct standard_deallocator_set): New.
(struct deallocator_set_map_traits): New.
(malloc_state_machine::m_malloc): Drop field
(malloc_state_machine::m_scalar_new): Likewise.
(malloc_state_machine::m_vector_new): Likewise.
(malloc_state_machine::m_free): New field
(malloc_state_machine::m_scalar_delete): Likewise.
(malloc_state_machine::m_vector_delete): Likewise.
(malloc_state_machine::deallocator_map_t): New typedef.
(malloc_state_machine::m_deallocator_map): New field.
(malloc_state_machine::deallocator_set_cache_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_cache): New field.
(malloc_state_machine::custom_deallocator_set_map_t): New typedef.
(malloc_state_machine::m_custom_deallocator_set_map): New field.
(malloc_state_machine::m_dynamic_sets): New field.
(malloc_state_machine::m_dynamic_deallocators): New field.
(api::api): Delete.
(deallocator::deallocator): New ctor.
(deallocator::hash): New.
(deallocator::dump_to_pp): New.
(deallocator::cmp): New.
(deallocator::cmp_ptr_ptr): New.
(standard_deallocator::standard_deallocator): New ctor.
(deallocator_set::deallocator_set): New ctor.
(deallocator_set::dump): New.
(custom_deallocator_set::custom_deallocator_set): New ctor.
(custom_deallocator_set::contains_p): New.
(custom_deallocator_set::maybe_get_single): New.
(custom_deallocator_set::dump_to_pp): New.
(standard_deallocator_set::standard_deallocator_set): New ctor.
(standard_deallocator_set::contains_p): New.
(standard_deallocator_set::maybe_get_single): New.
(standard_deallocator_set::dump_to_pp): New.
(start_p): New.
(class mismatching_deallocation): Update for conversion from api
to deallocator_set and deallocator.
(double_free::emit): Use %qs.
(class use_after_free): Update for conversion from api to
deallocator_set and deallocator.
(malloc_leak::describe_state_change): Only emit "allocated here" on
a start->nonnull transition, rather than on other transitions to
nonnull.
(allocation_state::dump_to_pp): Update for conversion from api to
deallocator_set.
(allocation_state::get_nonnull): Likewise.
(malloc_state_machine::malloc_state_machine): Likewise.
(malloc_state_machine::~malloc_state_machine): New.
(malloc_state_machine::add_state): Update for conversion from api
to deallocator_set.
(malloc_state_machine::get_or_create_custom_deallocator_set): New.
(malloc_state_machine::maybe_create_custom_deallocator_set): New.
(malloc_state_machine::get_or_create_deallocator): New.
(malloc_state_machine::on_stmt): Update for conversion from api
to deallocator_set. Handle "__attribute__((malloc(FOO)))", and
the special attribute set on FOO.
(malloc_state_machine::on_allocator_call): Update for conversion
from api to deallocator_set. Add "returns_nonnull" param and use
it to affect which state to transition to.
(malloc_state_machine::on_deallocator_call): Update for conversion
from api to deallocator_set.
2021-01-14 David Malcolm <dmalcolm@redhat.com>
* engine.cc (strongly_connected_components::to_json): New.
(worklist::to_json): New.
(exploded_graph::to_json): JSON-ify the worklist.
* exploded-graph.h (strongly_connected_components::to_json): New
decl.
(worklist::to_json): New decl.
* store.cc (store::to_json): Fix comment.
* supergraph.cc (supernode::to_json): Fix reference to
"returning_call" in comment. Add optional "fun" to JSON.
(edge_kind_to_string): New.
(superedge::to_json): Add "kind" to JSON.
2021-01-14 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98679
* analyzer.h (region_offset::operator==): Make const.
* pending-diagnostic.h (pending_diagnostic::equal_p): Likewise.
* store.h (binding_cluster::for_each_value): Likewise.
(binding_cluster::for_each_binding): Likewise.
2021-01-12 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98628
* store.cc (binding_cluster::make_unknown_relative_to): Don't mark
dereferenced unknown pointers as having escaped.
2021-01-07 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98580
* region.cc (decl_region::get_svalue_for_initializer): Gracefully
handle when LTO writes out DECL_INITIAL as error_mark_node.
2021-01-07 David Malcolm <dmalcolm@redhat.com>
PR analyzer/97074
* store.cc (binding_cluster::can_merge_p): Add "out_store" param
and pass to calls to binding_cluster::make_unknown_relative_to.
(binding_cluster::make_unknown_relative_to): Add "out_store"
param. Use it to mark base regions that are pointed to by
pointers that become unknown as having escaped.
(store::can_merge_p): Pass out_store to
binding_cluster::can_merge_p.
* store.h (binding_cluster::can_merge_p): Add "out_store" param.
(binding_cluster::make_unknown_relative_to): Likewise.
* svalue.cc (region_svalue::implicitly_live_p): New vfunc.
* svalue.h (region_svalue::implicitly_live_p): New vfunc decl.
2021-01-07 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98564
* engine.cc (exploded_path::feasible_p): Add missing call to
bitmap_clear.
2021-01-06 David Malcolm <dmalcolm@redhat.com>
PR analyzer/97072
* region-model-reachability.cc (reachable_regions::init_cluster):
Convert symbolic region handling to a switch statement. Add cases
to handle SK_UNKNOWN and SK_CONJURED.
2021-01-05 David Malcolm <dmalcolm@redhat.com>
PR analyzer/98293
* store.cc (binding_map::apply_ctor_to_region): When "index" is
NULL, iterate through the fields for RECORD_TYPEs, rather than
creating an INTEGER_CST index.
2020-11-30 David Malcolm <dmalcolm@redhat.com>
* analyzer-pass.cc: Include "analyzer/analyzer.h" for the
@@ -3892,7 +4100,7 @@
* Initial creation
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright

View File

@@ -1,5 +1,5 @@
/* A class to encapsulate decisions about how the analysis should happen.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* A class to encapsulate decisions about how the analysis should happen.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Hierarchical log messages for the analyzer.
Copyright (C) 2014-2020 Free Software Foundation, Inc.
Copyright (C) 2014-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Hierarchical log messages for the analyzer.
Copyright (C) 2014-2020 Free Software Foundation, Inc.
Copyright (C) 2014-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Integration of the analyzer with GCC's pass manager.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Selftest support for the analyzer.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Selftests for the analyzer.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Utility functions for the analyzer.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Utility functions for the analyzer.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -169,7 +169,7 @@ public:
return m_offset;
}
bool operator== (const region_offset &other)
bool operator== (const region_offset &other) const
{
return (m_base_region == other.m_base_region
&& m_offset == other.m_offset
@@ -205,6 +205,7 @@ extern bool is_special_named_call_p (const gcall *call, const char *funcname,
extern bool is_named_call_p (tree fndecl, const char *funcname);
extern bool is_named_call_p (tree fndecl, const char *funcname,
const gcall *call, unsigned int num_args);
extern bool is_std_named_call_p (tree fndecl, const char *funcname);
extern bool is_std_named_call_p (tree fndecl, const char *funcname,
const gcall *call, unsigned int num_args);
extern bool is_setjmp_call_p (const gcall *call);

View File

@@ -1,6 +1,6 @@
; analyzer.opt -- Options for the analyzer.
; Copyright (C) 2019-2020 Free Software Foundation, Inc.
; Copyright (C) 2019-2021 Free Software Foundation, Inc.
;
; This file is part of GCC.
;

View File

@@ -1,5 +1,5 @@
/* Support for plotting bar charts in dumps.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Support for plotting bar charts in dumps.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Call stacks at program points.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Call stacks at program points.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Subclasses of diagnostic_path and diagnostic_event for analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -93,6 +93,10 @@ event_kind_to_string (enum event_kind ek)
return "EK_CALL_EDGE";
case EK_RETURN_EDGE:
return "EK_RETURN_EDGE";
case EK_START_CONSOLIDATED_CFG_EDGES:
return "EK_START_CONSOLIDATED_CFG_EDGES";
case EK_END_CONSOLIDATED_CFG_EDGES:
return "EK_END_CONSOLIDATED_CFG_EDGES";
case EK_SETJMP:
return "EK_SETJMP";
case EK_REWIND_FROM_LONGJMP:
@@ -709,6 +713,16 @@ return_event::is_return_p () const
return true;
}
/* class start_consolidated_cfg_edges_event : public checker_event. */
label_text
start_consolidated_cfg_edges_event::get_desc (bool can_colorize) const
{
return make_label_text (can_colorize,
"following %qs branch...",
m_edge_sense ? "true" : "false");
}
/* class setjmp_event : public checker_event. */
/* Implementation of diagnostic_event::get_desc vfunc for
@@ -991,6 +1005,18 @@ checker_path::fixup_locations (pending_diagnostic *pd)
e->set_location (pd->fixup_location (e->get_location ()));
}
/* Return true if there is a (start_cfg_edge_event, end_cfg_edge_event) pair
at (IDX, IDX + 1). */
bool
checker_path::cfg_edge_pair_at_p (unsigned idx) const
{
if (m_events.length () < idx + 1)
return false;
return (m_events[idx]->m_kind == EK_START_CFG_EDGE
&& m_events[idx + 1]->m_kind == EK_END_CFG_EDGE);
}
} // namespace ana
#endif /* #if ENABLE_ANALYZER */

View File

@@ -1,5 +1,5 @@
/* Subclasses of diagnostic_path and diagnostic_event for analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -37,6 +37,8 @@ enum event_kind
EK_END_CFG_EDGE,
EK_CALL_EDGE,
EK_RETURN_EDGE,
EK_START_CONSOLIDATED_CFG_EDGES,
EK_END_CONSOLIDATED_CFG_EDGES,
EK_SETJMP,
EK_REWIND_FROM_LONGJMP,
EK_REWIND_TO_SETJMP,
@@ -63,6 +65,8 @@ extern const char *event_kind_to_string (enum event_kind ek);
end_cfg_edge_event (EK_END_CFG_EDGE)
call_event (EK_CALL_EDGE)
return_edge (EK_RETURN_EDGE)
start_consolidated_cfg_edges_event (EK_START_CONSOLIDATED_CFG_EDGES)
end_consolidated_cfg_edges_event (EK_END_CONSOLIDATED_CFG_EDGES)
setjmp_event (EK_SETJMP)
rewind_event
rewind_from_longjmp_event (EK_REWIND_FROM_LONGJMP)
@@ -337,6 +341,42 @@ public:
bool is_return_p () const FINAL OVERRIDE;
};
/* A concrete event subclass for the start of a consolidated run of CFG
edges all either TRUE or FALSE e.g. "following 'false' branch...'. */
class start_consolidated_cfg_edges_event : public checker_event
{
public:
start_consolidated_cfg_edges_event (location_t loc, tree fndecl, int depth,
bool edge_sense)
: checker_event (EK_START_CONSOLIDATED_CFG_EDGES, loc, fndecl, depth),
m_edge_sense (edge_sense)
{
}
label_text get_desc (bool can_colorize) const FINAL OVERRIDE;
private:
bool m_edge_sense;
};
/* A concrete event subclass for the end of a consolidated run of
CFG edges e.g. "...to here'. */
class end_consolidated_cfg_edges_event : public checker_event
{
public:
end_consolidated_cfg_edges_event (location_t loc, tree fndecl, int depth)
: checker_event (EK_END_CONSOLIDATED_CFG_EDGES, loc, fndecl, depth)
{
}
label_text get_desc (bool /*can_colorize*/) const FINAL OVERRIDE
{
return label_text::borrow ("...to here");
}
};
/* A concrete event subclass for a setjmp or sigsetjmp call. */
class setjmp_event : public checker_event
@@ -490,6 +530,19 @@ public:
delete event;
}
void delete_events (unsigned start_idx, unsigned len)
{
for (unsigned i = start_idx; i < start_idx + len; i++)
delete m_events[i];
m_events.block_remove (start_idx, len);
}
void replace_event (unsigned idx, checker_event *new_event)
{
delete m_events[idx];
m_events[idx] = new_event;
}
void add_final_event (const state_machine *sm,
const exploded_node *enode, const gimple *stmt,
tree var, state_machine::state_t state);
@@ -525,6 +578,8 @@ public:
return false;
}
bool cfg_edge_pair_at_p (unsigned idx) const;
private:
DISABLE_COPY_AND_ASSIGN(checker_path);

View File

@@ -1,5 +1,5 @@
/* Measuring the complexity of svalues/regions.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Measuring the complexity of svalues/regions.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Tracking equivalence classes and constraints at a point on an execution path.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Tracking equivalence classes and constraints at a point on an execution path.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for saving, deduplicating, and emitting analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -189,6 +189,8 @@ public:
return m_feasibility_problem;
}
const state_machine *get_sm () const { return m_sd.m_sm; }
private:
typedef reachability<eg_traits> enode_reachability;
@@ -709,9 +711,11 @@ diagnostic_manager::build_emission_path (const path_builder &pb,
class state_change_event_creator : public state_change_visitor
{
public:
state_change_event_creator (const exploded_edge &eedge,
state_change_event_creator (const path_builder &pb,
const exploded_edge &eedge,
checker_path *emission_path)
: m_eedge (eedge),
: m_pb (pb),
m_eedge (eedge),
m_emission_path (emission_path)
{}
@@ -720,6 +724,8 @@ public:
state_machine::state_t dst_sm_val)
FINAL OVERRIDE
{
if (&sm != m_pb.get_sm ())
return false;
const exploded_node *src_node = m_eedge.m_src;
const program_point &src_point = src_node->get_point ();
const int src_stack_depth = src_point.get_stack_depth ();
@@ -748,6 +754,8 @@ public:
const svalue *sval,
const svalue *dst_origin_sval) FINAL OVERRIDE
{
if (&sm != m_pb.get_sm ())
return false;
const exploded_node *src_node = m_eedge.m_src;
const program_point &src_point = src_node->get_point ();
const int src_stack_depth = src_point.get_stack_depth ();
@@ -783,6 +791,7 @@ public:
return false;
}
const path_builder &m_pb;
const exploded_edge &m_eedge;
checker_path *m_emission_path;
};
@@ -1002,7 +1011,7 @@ diagnostic_manager::add_events_for_eedge (const path_builder &pb,
| ~~~~~~~~~~~~~^~~~~
| |
| (3) ...to here (end_cfg_edge_event). */
state_change_event_creator visitor (eedge, emission_path);
state_change_event_creator visitor (pb, eedge, emission_path);
for_each_state_change (src_state, dst_state, pb.get_ext_state (),
&visitor);
@@ -1292,6 +1301,7 @@ diagnostic_manager::prune_path (checker_path *path,
path->maybe_log (get_logger (), "path");
prune_for_sm_diagnostic (path, sm, sval, state);
prune_interproc_events (path);
consolidate_conditions (path);
finish_pruning (path);
path->maybe_log (get_logger (), "pruned");
}
@@ -1647,6 +1657,151 @@ diagnostic_manager::prune_interproc_events (checker_path *path) const
while (changed);
}
/* Return true iff event IDX within PATH is on the same line as REF_EXP_LOC. */
static bool
same_line_as_p (const expanded_location &ref_exp_loc,
checker_path *path, unsigned idx)
{
const checker_event *ev = path->get_checker_event (idx);
expanded_location idx_exp_loc = expand_location (ev->get_location ());
gcc_assert (ref_exp_loc.file);
if (idx_exp_loc.file == NULL)
return false;
if (strcmp (ref_exp_loc.file, idx_exp_loc.file))
return false;
return ref_exp_loc.line == idx_exp_loc.line;
}
/* This path-readability optimization reduces the verbosity of compound
conditional statements (without needing to reconstruct the AST, which
has already been lost).
For example, it converts:
| 61 | if (cp[0] != '\0' && cp[0] != '#')
| | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | | | |
| | | | (6) ...to here
| | | (7) following true branch...
| | (5) following true branch...
| 62 | {
| 63 | alias = cp++;
| | ~~~~
| | |
| | (8) ...to here
into:
| 61 | if (cp[0] != '\0' && cp[0] != '#')
| | ~
| | |
| | (5) following true branch...
| 62 | {
| 63 | alias = cp++;
| | ~~~~
| | |
| | (6) ...to here
by combining events 5-8 into new events 5-6.
Find runs of consecutive (start_cfg_edge_event, end_cfg_edge_event) pairs
in which all events apart from the final end_cfg_edge_event are on the same
line, and for which either all the CFG edges are TRUE edges, or all are
FALSE edges.
Consolidate each such run into a
(start_consolidated_cfg_edges_event, end_consolidated_cfg_edges_event)
pair. */
void
diagnostic_manager::consolidate_conditions (checker_path *path) const
{
/* Don't simplify edges if we're debugging them. */
if (flag_analyzer_verbose_edges)
return;
for (unsigned start_idx = 0; start_idx < path->num_events () - 1; start_idx++)
{
if (path->cfg_edge_pair_at_p (start_idx))
{
const checker_event *old_start_ev
= path->get_checker_event (start_idx);
expanded_location start_exp_loc
= expand_location (old_start_ev->get_location ());
if (start_exp_loc.file == NULL)
continue;
if (!same_line_as_p (start_exp_loc, path, start_idx + 1))
continue;
/* Are we looking for a run of all TRUE edges, or all FALSE edges? */
gcc_assert (old_start_ev->m_kind == EK_START_CFG_EDGE);
const start_cfg_edge_event *old_start_cfg_ev
= (const start_cfg_edge_event *)old_start_ev;
const cfg_superedge& first_cfg_sedge
= old_start_cfg_ev->get_cfg_superedge ();
bool edge_sense;
if (first_cfg_sedge.true_value_p ())
edge_sense = true;
else if (first_cfg_sedge.false_value_p ())
edge_sense = false;
else
continue;
/* Find a run of CFG start/end event pairs from
[start_idx, next_idx)
where all apart from the final event are on the same line,
and all are either TRUE or FALSE edges, matching the initial. */
unsigned next_idx = start_idx + 2;
while (path->cfg_edge_pair_at_p (next_idx)
&& same_line_as_p (start_exp_loc, path, next_idx))
{
const checker_event *iter_ev
= path->get_checker_event (next_idx);
gcc_assert (iter_ev->m_kind == EK_START_CFG_EDGE);
const start_cfg_edge_event *iter_cfg_ev
= (const start_cfg_edge_event *)iter_ev;
const cfg_superedge& iter_cfg_sedge
= iter_cfg_ev->get_cfg_superedge ();
if (edge_sense)
{
if (!iter_cfg_sedge.true_value_p ())
break;
}
else
{
if (!iter_cfg_sedge.false_value_p ())
break;
}
next_idx += 2;
}
/* If we have more than one pair in the run, consolidate. */
if (next_idx > start_idx + 2)
{
const checker_event *old_end_ev
= path->get_checker_event (next_idx - 1);
log ("consolidating CFG edge events %i-%i into %i-%i",
start_idx, next_idx - 1, start_idx, start_idx +1);
start_consolidated_cfg_edges_event *new_start_ev
= new start_consolidated_cfg_edges_event
(old_start_ev->get_location (),
old_start_ev->get_fndecl (),
old_start_ev->get_stack_depth (),
edge_sense);
checker_event *new_end_ev
= new end_consolidated_cfg_edges_event
(old_end_ev->get_location (),
old_end_ev->get_fndecl (),
old_end_ev->get_stack_depth ());
path->replace_event (start_idx, new_start_ev);
path->replace_event (start_idx + 1, new_end_ev);
path->delete_events (start_idx + 2, next_idx - (start_idx + 2));
}
}
}
}
/* Final pass of diagnostic_manager::prune_path.
If all we're left with is in one function, then filter function entry

View File

@@ -1,5 +1,5 @@
/* Classes for saving, deduplicating, and emitting analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -175,6 +175,7 @@ private:
state_machine::state_t state) const;
void update_for_unsuitable_sm_exprs (tree *expr) const;
void prune_interproc_events (checker_path *path) const;
void consolidate_conditions (checker_path *path) const;
void finish_pruning (checker_path *path) const;
engine *m_eng;

View File

@@ -1,5 +1,5 @@
/* The analysis "engine".
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -1772,6 +1772,17 @@ strongly_connected_components::dump () const
}
}
/* Return a new json::array of per-snode SCC ids. */
json::array *
strongly_connected_components::to_json () const
{
json::array *scc_arr = new json::array ();
for (int i = 0; i < m_sg.num_nodes (); i++)
scc_arr->append (new json::integer_number (get_scc_id (i)));
return scc_arr;
}
/* Subroutine of strongly_connected_components's ctor, part of Tarjan's
SCC algorithm. */
@@ -1968,6 +1979,22 @@ worklist::key_t::cmp (const worklist::key_t &ka, const worklist::key_t &kb)
return ka.m_enode->m_index - kb.m_enode->m_index;
}
/* Return a new json::object of the form
{"scc" : [per-snode-IDs]}, */
json::object *
worklist::to_json () const
{
json::object *worklist_obj = new json::object ();
worklist_obj->set ("scc", m_scc.to_json ());
/* The following field isn't yet being JSONified:
queue_t m_queue; */
return worklist_obj;
}
/* exploded_graph's ctor. */
exploded_graph::exploded_graph (const supergraph &sg, logger *logger,
@@ -2321,38 +2348,27 @@ exploded_graph::get_per_function_data (function *fun) const
return NULL;
}
/* Return true if NODE and FUN should be traversed directly, rather than
/* Return true if FUN should be traversed directly, rather than only as
called via other functions. */
static bool
toplevel_function_p (cgraph_node *node, function *fun, logger *logger)
toplevel_function_p (function *fun, logger *logger)
{
/* TODO: better logic here
e.g. only if more than one caller, and significantly complicated.
Perhaps some whole-callgraph analysis to decide if it's worth summarizing
an edge, and if so, we need summaries. */
if (flag_analyzer_call_summaries)
{
int num_call_sites = 0;
for (cgraph_edge *edge = node->callers; edge; edge = edge->next_caller)
++num_call_sites;
/* For now, if there's more than one in-edge, and we want call
summaries, do it at the top level so that there's a chance
we'll have a summary when we need one. */
if (num_call_sites > 1)
{
if (logger)
logger->log ("traversing %qE (%i call sites)",
fun->decl, num_call_sites);
return true;
}
}
if (!TREE_PUBLIC (fun->decl))
/* Don't directly traverse into functions that have an "__analyzer_"
prefix. Doing so is useful for the analyzer test suite, allowing
us to have functions that are called in traversals, but not directly
explored, thus testing how the analyzer handles calls and returns.
With this, we can have DejaGnu directives that cover just the case
of where a function is called by another function, without generating
excess messages from the case of the first function being traversed
directly. */
#define ANALYZER_PREFIX "__analyzer_"
if (!strncmp (IDENTIFIER_POINTER (DECL_NAME (fun->decl)), ANALYZER_PREFIX,
strlen (ANALYZER_PREFIX)))
{
if (logger)
logger->log ("not traversing %qE (static)", fun->decl);
logger->log ("not traversing %qE (starts with %qs)",
fun->decl, ANALYZER_PREFIX);
return false;
}
@@ -2362,18 +2378,6 @@ toplevel_function_p (cgraph_node *node, function *fun, logger *logger)
return true;
}
/* Callback for walk_tree for finding callbacks within initializers;
ensure they are treated as possible entrypoints to the analysis. */
static tree
add_any_callbacks (tree *tp, int *, void *data)
{
exploded_graph *eg = (exploded_graph *)data;
if (TREE_CODE (*tp) == FUNCTION_DECL)
eg->on_escaped_function (*tp);
return NULL_TREE;
}
/* Add initial nodes to EG, with entrypoints for externally-callable
functions. */
@@ -2387,7 +2391,7 @@ exploded_graph::build_initial_worklist ()
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
{
function *fun = node->get_fun ();
if (!toplevel_function_p (node, fun, logger))
if (!toplevel_function_p (fun, logger))
continue;
exploded_node *enode = add_function_entry (fun);
if (logger)
@@ -2399,19 +2403,6 @@ exploded_graph::build_initial_worklist ()
logger->log ("did not create enode for %qE entrypoint", fun->decl);
}
}
/* Find callbacks that are reachable from global initializers. */
varpool_node *vpnode;
FOR_EACH_VARIABLE (vpnode)
{
tree decl = vpnode->decl;
if (!TREE_PUBLIC (decl))
continue;
tree init = DECL_INITIAL (decl);
if (!init)
continue;
walk_tree (&init, add_any_callbacks, this, NULL);
}
}
/* The main loop of the analysis.
@@ -3315,10 +3306,10 @@ exploded_graph::to_json () const
/* m_sg is JSONified at the top-level. */
egraph_obj->set ("ext_state", m_ext_state.to_json ());
egraph_obj->set ("worklist", m_worklist.to_json ());
egraph_obj->set ("diagnostic_manager", m_diagnostic_manager.to_json ());
/* The following fields aren't yet being JSONified:
worklist m_worklist;
const state_purge_map *const m_purge_map;
const analysis_plan &m_plan;
stats m_global_stats;
@@ -3374,6 +3365,7 @@ exploded_path::feasible_p (logger *logger, feasibility_problem **out,
LOG_SCOPE (logger);
auto_sbitmap snodes_visited (eg->get_supergraph ().m_nodes.length ());
bitmap_clear (snodes_visited);
/* Traverse the path, updating this model. */
region_model model (eng->get_model_manager ());

View File

@@ -1,5 +1,5 @@
/* The analysis "engine".
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for managing a directed graph of <point, state> pairs.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -622,6 +622,8 @@ public:
void dump () const;
json::array *to_json () const;
private:
struct per_node_data
{
@@ -664,6 +666,8 @@ public:
return m_scc.get_scc_id (snode.m_index);
}
json::object *to_json () const;
private:
class key_t
{

View File

@@ -1,5 +1,5 @@
/* Sets of function names.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Sets of function names.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for analyzer diagnostics.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -157,7 +157,7 @@ class pending_diagnostic
/* Compare for equality with OTHER, which might be of a different
subclass. */
bool equal_p (const pending_diagnostic &other)
bool equal_p (const pending_diagnostic &other) const
{
/* Check for pointer equality on the IDs from get_kind. */
if (get_kind () != other.get_kind ())

View File

@@ -1,5 +1,5 @@
/* Classes for representing locations within the program.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for representing locations within the program.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for representing the state of interest at a given path of analysis.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for representing the state of interest at a given path of analysis.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Digraph reachability.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Handling for the known behavior of various specific functions.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -436,6 +436,15 @@ region_model::impl_call_strlen (const call_details &cd)
return true;
}
/* Handle calls to functions referenced by
__attribute__((malloc(FOO))). */
void
region_model::impl_deallocation_call (const call_details &cd)
{
impl_call_free (cd);
}
} // namespace ana
#endif /* #if ENABLE_ANALYZER */

View File

@@ -1,5 +1,5 @@
/* Consolidation of svalues and regions.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -249,6 +249,10 @@ region_model_manager::get_or_create_initial_value (const region *reg)
get_or_create_initial_value (original_reg));
}
/* INIT_VAL (*UNKNOWN_PTR) -> UNKNOWN_VAL. */
if (reg->symbolic_for_unknown_ptr_p ())
return get_or_create_unknown_svalue (reg->get_type ());
if (initial_svalue **slot = m_initial_values_map.get (reg))
return *slot;
initial_svalue *initial_sval = new initial_svalue (reg->get_type (), reg);
@@ -815,6 +819,15 @@ region_model_manager::get_field_region (const region *parent, tree field)
{
gcc_assert (TREE_CODE (field) == FIELD_DECL);
/* (*UNKNOWN_PTR).field is (*UNKNOWN_PTR_OF_&FIELD_TYPE). */
if (parent->symbolic_for_unknown_ptr_p ())
{
tree ptr_to_field_type = build_pointer_type (TREE_TYPE (field));
const svalue *unknown_ptr_to_field
= get_or_create_unknown_svalue (ptr_to_field_type);
return get_symbolic_region (unknown_ptr_to_field);
}
field_region::key_t key (parent, field);
if (field_region *reg = m_field_regions.get (key))
return reg;

View File

@@ -1,5 +1,5 @@
/* Finding reachable regions and values.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -88,20 +88,38 @@ reachable_regions::init_cluster (const region *base_reg)
if (m_store->escaped_p (base_reg))
add (base_reg, true);
/* If BASE_REG is *INIT_VAL(REG) for some other REG, see if REG is
unbound and untouched. If so, then add BASE_REG as a root. */
if (const symbolic_region *sym_reg = base_reg->dyn_cast_symbolic_region ())
{
const svalue *ptr = sym_reg->get_pointer ();
if (const initial_svalue *init_sval = ptr->dyn_cast_initial_svalue ())
switch (ptr->get_kind ())
{
const region *init_sval_reg = init_sval->get_region ();
const region *other_base_reg = init_sval_reg->get_base_region ();
const binding_cluster *other_cluster
= m_store->get_cluster (other_base_reg);
if (other_cluster == NULL
|| !other_cluster->touched_p ())
default:
break;
case SK_INITIAL:
{
/* If BASE_REG is *INIT_VAL(REG) for some other REG, see if REG is
unbound and untouched. If so, then add BASE_REG as a root. */
const initial_svalue *init_sval
= as_a <const initial_svalue *> (ptr);
const region *init_sval_reg = init_sval->get_region ();
const region *other_base_reg = init_sval_reg->get_base_region ();
const binding_cluster *other_cluster
= m_store->get_cluster (other_base_reg);
if (other_cluster == NULL
|| !other_cluster->touched_p ())
add (base_reg, true);
}
break;
case SK_UNKNOWN:
case SK_CONJURED:
{
/* If this cluster is due to dereferencing an unknown/conjured
pointer, any values written through the pointer could still
be live. */
add (base_reg, true);
}
break;
}
}
}

View File

@@ -1,5 +1,5 @@
/* Finding reachable regions and values.
Copyright (C) 2020 Free Software Foundation, Inc.
Copyright (C) 2020-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Classes for modeling the state of memory.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3. If not see
#include "analyzer/region-model-reachability.h"
#include "analyzer/analyzer-selftests.h"
#include "stor-layout.h"
#include "attribs.h"
#if ENABLE_ANALYZER
@@ -917,6 +918,14 @@ region_model::on_call_post (const gcall *call,
impl_call_operator_delete (cd);
return;
}
/* Was this fndecl referenced by
__attribute__((malloc(FOO)))? */
if (lookup_attribute ("*dealloc", DECL_ATTRIBUTES (callee_fndecl)))
{
call_details cd (call, this, ctxt);
impl_deallocation_call (cd);
return;
}
}
if (unknown_side_effects)

View File

@@ -1,5 +1,5 @@
/* Classes for modeling the state of memory.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -463,6 +463,7 @@ class region_model
bool impl_call_strlen (const call_details &cd);
bool impl_call_operator_new (const call_details &cd);
bool impl_call_operator_delete (const call_details &cd);
void impl_deallocation_call (const call_details &cd);
void handle_unrecognized_call (const gcall *call,
region_model_context *ctxt);

View File

@@ -1,5 +1,5 @@
/* Regions of memory.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.
@@ -969,6 +969,11 @@ decl_region::get_svalue_for_initializer (region_model_manager *mgr) const
c.get_map ());
}
/* LTO can write out error_mark_node as the DECL_INITIAL for simple scalar
values (to avoid writing out an extra section). */
if (init == error_mark_node)
return NULL;
if (TREE_CODE (init) == CONSTRUCTOR)
return get_svalue_for_constructor (init, mgr);

View File

@@ -1,5 +1,5 @@
/* Regions of memory.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* A state machine for detecting misuses of <stdio.h>'s FILE * API.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* An overview of the state machine from sm-malloc.cc.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,7 +1,7 @@
/* A state machine for use in DejaGnu tests, to check that
pattern-matching works as expected.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,6 +1,6 @@
/* An experimental state machine, for tracking exposure of sensitive
data (e.g. through logging).
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,7 +1,7 @@
/* An experimental state machine, for tracking bad calls from within
signal handlers.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,7 +1,7 @@
/* An experimental state machine, for tracking "taint": unsanitized uses
of data potentially under an attacker's control.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

View File

@@ -1,5 +1,5 @@
/* Modeling API uses and misuses via state machines.
Copyright (C) 2019-2020 Free Software Foundation, Inc.
Copyright (C) 2019-2021 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
This file is part of GCC.

Some files were not shown because too many files have changed in this diff Show More