Commit Graph

2450 Commits

Author SHA1 Message Date
Jason Merrill b4e93c5826 PR c++/81843 - ICE with variadic member template.
PR c++/72801
	* pt.c (unify_pack_expansion): Don't try to deduce enclosing
	template args.

From-SVN: r256808
2018-01-17 13:08:05 -05:00
Jason Merrill 99547487e1 PR c++/82331 - ICE with variadic partial specialization of auto
* pt.c (unify) [TEMPLATE_PARM_INDEX]: Set processing_template_decl
	around call to tsubst.

From-SVN: r256807
2018-01-17 13:07:53 -05:00
Jakub Jelinek c3fce73ee9 backport: re PR c++/81197 (ICE with structured binding and lifetime-extended temporaries)
Backported from mainline
	2017-12-15  Jakub Jelinek  <jakub@redhat.com>

	PR c++/81197
	* cp-tree.h (cp_maybe_mangle_decomp): Declare.
	* decl.c (cp_maybe_mangle_decomp): New function.
	(cp_finish_decomp): Don't SET_DECL_ASSEMBLER_NAME here.
	* parser.c (cp_convert_range_for,
	cp_parser_decomposition_declaration): Call cp_maybe_mangle_decomp.
	* pt.c (tsubst_expr): Likewise.
	* mangle.c (find_decomp_unqualified_name): New function.
	(write_unqualified_name): Handle DECL_DECOMPOSITION_P
	where DECL_ASSEMBLER_NAME is already set.

	* g++.dg/cpp1z/decomp34.C: New test.

From-SVN: r255735
2017-12-16 01:40:14 +01:00
Jakub Jelinek a31d2f7b36 backport: re PR c++/79650 (ICE on invalid c++ code with label arithmetic in convert_nontype_argument (pt.c:6515))
Backported from mainline
	2017-12-14  Jakub Jelinek  <jakub@redhat.com>

	PR c++/79650
	* pt.c (convert_nontype_argument): Diagnose
	reduced_constant_expression_p expressions that aren't INTEGER_CST.

	* g++.dg/template/pr79650.C: New test.

From-SVN: r255727
2017-12-15 23:13:37 +01:00
Paolo Carlini 4fb0491161 re PR c++/82085 (ICE: Template variable reference used in nested template alias)
/cp
2017-10-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/82085
	* pt.c (tsubst_copy_and_build, [INDIRECT_REF]): For a REFERENCE_REF_P,
	unconditionally call convert_from_reference.

/testsuite
2017-10-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/82085
	* g++.dg/cpp1y/var-templ56.C: New.

From-SVN: r254240
2017-10-30 19:17:40 +00:00
Jason Merrill 3d2be6b44d PR c++/81525 - broken handling of auto in generic lambda.
* pt.c (tsubst_decl) [VAR_DECL]: Use strip_innermost_template_args.

From-SVN: r253415
2017-10-04 11:38:24 -04:00
Jason Merrill 3ef1cd3d1e PR c++/81671 - nullptr_t template parameter
* pt.c (convert_nontype_argument): Fix nullptr_t check.

From-SVN: r252942
2017-09-18 14:36:53 -04:00
Jason Merrill 3f2b67a9bb PR c++/81525 - wrong constant value with generic lambda
* pt.c (tsubst_decl) [VAR_DECL]: Avoid clobbering auto.
	(tsubst_copy) [VAR_DECL]: Handle auto.

From-SVN: r252941
2017-09-18 14:36:47 -04:00
Jason Merrill 5b6f97c9a7 Revert "PR c++/81525 - wrong constant value with generic lambda"
From-SVN: r251002
2017-08-09 16:18:59 -04:00
Jason Merrill c02c8b11e1 PR c++/81525 - wrong constant value with generic lambda
* pt.c (tsubst_decl) [VAR_DECL]: Avoid clobbering auto.
	(tsubst_copy) [VAR_DECL]: Handle auto.

From-SVN: r251001
2017-08-09 16:17:55 -04:00
Jason Merrill 7c9092dba9 PR c++/81180 - ICE with C++17 deduction of member class template.
* pt.c (build_deduction_guide): Correct member template handling.

From-SVN: r249817
2017-06-29 17:32:20 -04:00
Jason Merrill 35813cb651 PR c++/61022 - error with variadic template template parm
* pt.c (convert_template_argument): Keep the TYPE_PACK_EXPANSION.

From-SVN: r249763
2017-06-28 17:08:58 -04:00
Jason Merrill ae2daf1922 PR c++/72801 - ICE with variadic partial specialization
* pt.c (unify_pack_expansion): Use PACK_EXPANSION_EXTRA_ARGS.

From-SVN: r249762
2017-06-28 17:08:50 -04:00
Jason Merrill aa2978007a re PR c++/81215 (deduction failure with variadic template template parameter)
PR c++/81215

	* pt.c (unify_bound_ttp_args): Restore old logic for C++14 and down.

From-SVN: r249665
2017-06-26 14:49:25 -04:00
Jason Merrill 6eb22297df PR c++/79056 - C++17 ICE with invalid template syntax.
* parser.c (cp_parser_simple_type_specifier): Don't assume that type
	is a TYPE_DECL.
	(cp_parser_check_for_invalid_template_id): Handle TYPE_DECL.
	* pt.c (template_placeholder_p): New.
	* cp-tree.h: Declare it.

From-SVN: r249615
2017-06-23 19:30:01 -04:00
Jason Merrill 05b1510406 PR c++/81045 - Wrong type-dependence with auto return type.
* pt.c (type_dependent_expression_p): An undeduced auto outside the
	template isn't dependent.
	* call.c (build_over_call): Instantiate undeduced auto even in a
	template.

From-SVN: r249333
2017-06-16 22:34:15 -04:00
Jason Merrill 2fa1a2d996 PR c++/81102 - Wrong error with partial specialization.
* pt.c (unify) [TEMPLATE_PARM_INDEX]: Strip reference when comparing
	types.  Do type deduction later.

From-SVN: r249332
2017-06-16 22:34:08 -04:00
Jason Merrill 9773d53aa3 PR c++/80174 - ICE with partial specialization of member template.
PR c++/71747
	* pt.c (get_partial_spec_bindings): Only coerce innermost args.

From-SVN: r249331
2017-06-16 22:34:01 -04:00
Jason Merrill a053c1f4ee PR c++/80384 - ICE with dependent noexcept-specifier
* pt.c (dependent_type_p_r) [FUNCTION_TYPE]: Check for dependent
	noexcept-specifier.

From-SVN: r249326
2017-06-16 22:33:10 -04:00
Jason Merrill 154c2e3781 Fix array decay handling in constant expressions.
* parser.c (cp_parser_constant_expression): Check
	potential_rvalue_constant_expression after decay_conversion.
	* pt.c (convert_nontype_argument): Don't require linkage in C++17.

From-SVN: r249325
2017-06-16 22:33:01 -04:00
Jason Merrill 222a78553a PR c++/80840 - ICE with constexpr and reference
* pt.c (convert_nontype_argument): Don't test whether a decl is
	value-dependent when binding to a reference.

From-SVN: r248755
2017-05-31 13:53:20 -04:00
Jason Merrill 6864d84921 * pt.c (tsubst_init): Set TARGET_EXPR_DIRECT_INIT_P.
From-SVN: r246953
2017-04-17 15:24:31 -04:00
Jakub Jelinek 347e1f7769 re PR c++/80370 (ICE when using structured bindings and nested generic lambdas (tsubst_decomp_names))
PR c++/80370
	* decl.c (cp_finish_decomp): If processing_template_decl on
	non-dependent decl, only set TREE_TYPE on the v[i] decls, but don't
	change their DECL_VALUE_EXPR nor cp_finish_decl them.  Instead make
	sure DECL_VALUE_EXPR is the canonical NULL type ARRAY_REF for tsubst
	processing.
	* pt.c (value_dependent_expression_p) <case VAR_DECL>: For variables
	with DECL_VALUE_EXPR, return true if DECL_VALUE_EXPR is type
	dependent.

	* g++.dg/cpp1z/decomp28.C: New test.

From-SVN: r246857
2017-04-11 22:51:16 +02:00
Jason Merrill 3f4334cb95 PR c++/80356 - ICE with reference to function template argument.
PR c++/79294
	* pt.c (convert_nontype_argument_function): Adjust type even with a
	value-dependent argument.

From-SVN: r246794
2017-04-09 01:38:40 -04:00
Jason Merrill c60faeee9e PR c++/80267 - ICE with nested capture of reference
PR c++/60992
	* pt.c (tsubst_copy): Handle lookup finding a capture proxy.

From-SVN: r246793
2017-04-09 01:06:08 -04:00
Jakub Jelinek 98568e0337 re PR c++/80309 (ICE: canonical types differ for identical types _Args2 and _Args2)
PR c++/80309
	* pt.c (canonical_type_parameter): Use vec_safe_grow_cleared instead
	of a loop doing vec_safe_push of NULL.  Formatting fixes.
	(rewrite_template_parm): Copy TEMPLATE_PARM_PARAMETER_PACK from oldidx
	to newidx before calling canonical_type_parameter on newtype.

From-SVN: r246717
2017-04-05 21:10:17 +02:00
Jonathan Wakely 5764ee3c84 Fix numerous typos in comments
gcc:

	* alias.c (base_alias_check): Fix typo in comment.
	* cgraph.h (class ipa_polymorphic_call_context): Likewise.
	* cgraphunit.c (symbol_table::compile): Likewise.
	* collect2.c (maybe_run_lto_and_relink): Likewise.
	* config/arm/arm.c (arm_thumb1_mi_thunk): Likewise.
	* config/avr/avr-arch.h (avr_arch_info_t): Likewise.
	* config/avr/avr.c (avr_map_op_t): Likewise.
	* config/cr16/cr16.h (DATA_ALIGNMENT): Likewise.
	* config/epiphany/epiphany.c (TARGET_ARG_PARTIAL_BYTES): Likewise.
	* config/epiphany/epiphany.md (movcc): Likewise.
	* config/i386/i386.c (legitimize_pe_coff_extern_decl): Likewise.
	* config/m68k/m68k.c (struct _sched_ib, m68k_sched_variable_issue):
	Likewise.
	* config/mips/mips.c (mips_save_restore_reg): Likewise.
	* config/rx/rx.c (rx_is_restricted_memory_address): Likewise.
	* config/s390/s390.c (Z10_EARLYLOAD_DISTANCE): Likewise.
	* config/sh/sh.c (sh_rtx_costs): Likewise.
	* fold-const.c (fold_truth_andor): Likewise.
	* genautomata.c (collapse_flag): Likewise.
	* gengtype.h (struct type::u::s): Likewise.
	* gensupport.c (has_subst_attribute, add_mnemonic_string): Likewise.
	* input.c (FORMAT_AMOUNT): Likewise.
	* ipa-cp.c (class ipcp_lattice, agg_replacements_to_vector)
	(known_aggs_to_agg_replacement_list): Likewise.
	* ipa-inline-analysis.c: Likewise.
	* ipa-inline.h (estimate_edge_time, estimate_edge_hints): Likewise.
	* ipa-polymorphic-call.c
	(ipa_polymorphic_call_context::restrict_to_inner_class): Likewise.
	* loop-unroll.c (analyze_insn_to_expand_var): Likewise.
	* lra.c (lra_optional_reload_pseudos, lra_subreg_reload_pseudos):
	Likewise.
	* modulo-sched.c (apply_reg_moves): Likewise.
	* omp-expand.c (build_omp_regions_1): Likewise.
	* trans-mem.c (struct tm_wrapper_hasher): Likewise.
	* tree-ssa-loop-ivopts.c (may_eliminate_iv): Likewise.
	* tree-ssa-loop-niter.c (maybe_lower_iteration_bound): Likewise.
	* tree-vect-data-refs.c (vect_enhance_data_refs_alignment): Likewise.
	* value-prof.c: Likewise.
	* var-tracking.c (val_reset): Likewise.

gcc/ada:

	* doc/gnat_ugn/gnat_and_program_execution.rst: Fix typo.
	* g-socket.adb (To_Host_Entry): Fix typo in comment.
	* gnat_ugn.texi: Fix typo.
	* raise.c (_gnat_builtin_longjmp): Fix capitalization in comment.
	* s-stposu.adb (Allocate_Any_Controlled): Fix typo in comment.
	* sem_ch3.adb (Build_Derived_Record_Type): Likewise.
	* sem_util.adb (Mark_Coextensions): Likewise.
	* sem_util.ads (Available_Full_View_Of_Component): Likewise.

gcc/c:

	* c-array-notation.c: Fix typo in comment.

gcc/c-family:

	* c-warn.c (do_warn_double_promotion): Fix typo in comment.

gcc/cp:

        * class.c (update_vtable_entry_for_fn): Fix typo in comment.
	* decl2.c (one_static_initialization_or_destruction): Likewise.
	* name-lookup.c (store_bindings): Likewise.
	* parser.c (make_call_declarator): Likewise.
	* pt.c (check_explicit_specialization): Likewise.

gcc/testsuite:

	* g++.old-deja/g++.benjamin/scope02.C: Fix typo in comment.
	* gcc.dg/20031012-1.c: Likewise.
	* gcc.dg/ipa/ipcp-1.c: Likewise.
	* gcc.dg/torture/matrix-3.c: Likewise.
	* gcc.target/powerpc/ppc-spe.c: Likewise.
	* gcc.target/rx/zero-width-bitfield.c: Likewise.

libcpp:

	* include/line-map.h (LINEMAPS_MACRO_MAPS): Fix typo in comment.
	* lex.c (search_line_fast): Likewise.
	* pch.h (cpp_valid_state): Likewise.

libdecnumber:

	* decCommon.c (decFloatFromPackedChecked): Fix typo in comment.
	* decNumber.c (decNumberPower, decMultiplyOp): Likewise.

libgcc:

	* config/c6x/pr-support.c (__gnu_unwind_execute): Fix typo in comment.

libitm:

	* libitm_i.h (sutrct gtm_thread): Fix typo in comment.

From-SVN: r246664
2017-04-03 23:30:56 +01:00
Jason Merrill 90471a3d83 PR c++/77339 - ICE with invalid use of alias template.
* pt.c (lookup_template_class_1): Don't try to enter the scope of an
	alias template.

From-SVN: r246462
2017-03-24 10:40:13 -04:00
Jason Merrill 842562b4e1 PR c++/80150 - ICE with overloaded variadic deduction.
* pt.c (try_one_overload): Remove asserts.

From-SVN: r246422
2017-03-23 14:23:25 -04:00
Jason Merrill 55b11c6090 PR c++/80096 - ICE with C++17 non-type auto.
* pt.c (tsubst): Delay tsubst of type of template non-type
	parameter.

From-SVN: r246292
2017-03-20 16:36:54 -04:00
Jason Merrill 8afd9c45b6 PR c++/79640 - infinite recursion with generic lambda.
* pt.c (tsubst_copy) [VAR_DECL]: Register the dummy instantiation
	before substituting its initializer.

From-SVN: r246289
2017-03-20 14:49:10 -04:00
Jason Merrill 0c942f3eda PR c++/79960 - alias templates and partial ordering
* pt.c (comp_template_args): Add partial_order parm.
	(template_args_equal): Likewise.
	(comp_template_args_porder): New.
	(get_partial_spec_bindings): Use it.

From-SVN: r246042
2017-03-10 12:35:54 -05:00
Jason Merrill 90d9a8e6ef Revert "Allow deduction guides to look into primary template."
* cp-tree.h, parser.c, pt.c, search.c: Revert.

From-SVN: r245924
2017-03-06 09:44:44 -05:00
Jason Merrill fb5ce60890 Update overload resolution with deduction guides.
* pt.c (do_class_deduction): Always build the copy guide.
	(copy_guide_p, template_guide_p): New.
	(build_deduction_guide): Remember the original constructor.
	* call.c (joust): Prefer the copy guide and non-template guides.

From-SVN: r245859
2017-03-03 02:31:54 -05:00
Jason Merrill de35db4271 Allow deduction guides to look into primary template.
* cp-tree.h (struct saved_scope): Add deduction_guide_type.
	(struct cp_decl_specifier_seq): Add constructor_p.
	* parser.c (cp_parser_decl_specifier_seq): Set constructor_p.
	(cp_parser_init_declarator): Check it.  Set ctor_dtor_or_conv_p.
	Clear deduction_guide_type.  Don't handle deduction guide names.
	(cp_parser_declarator): Don't clear ctor_dtor_or_conv_p.
	(cp_parser_direct_declarator): Likewise.  Handle deduction guides.
	(cp_parser_member_declaration, cp_parser_cache_defarg)
	(cp_parser_objc_class_ivars): Set ctor_dtor_or_conv_p.
	* pt.c (tsubst_copy, tsubst_copy_and_build): Revert last change.
	(build_deduction_guide): Set deduction_guide_type.
	(dependent_scope_p): Check deduction_guide_type.
	* search.c (lookup_member): Likewise.

From-SVN: r245858
2017-03-02 20:26:47 -05:00
Jason Merrill 9a642ccae4 Class template argument deduction in new-expression
Class template argument deduction in new-expression
	* init.c (build_new): Handle deduction from no initializer.
	* parser.c (cp_parser_new_expression): Don't require a single
	expression for class template deduction.
	* typeck2.c (cxx_incomplete_type_diagnostic): Fix diagnostic for
	class template placeholder.
	* pt.c (tsubst_copy) [TEMPLATE_DECL]: Handle dependent context.
	(tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Handle SCOPE_REF.
	(redeclare_class_template): Set TEMPLATE_TYPE_PARM_FOR_CLASS.

From-SVN: r245826
2017-03-01 20:58:30 -05:00
Jason Merrill 853ef4e563 Class template argument deduction refinements
* call.c (joust): Move deduction guide tiebreaker down.
	* decl.c (start_decl_1, cp_finish_decl, grokdeclarator): Allow class
	deduction with no initializer.
	* pt.c (build_deduction_guide): Handle implicit default/copy ctor.
	(do_class_deduction): Use that rather than special case.
	(do_auto_deduction): Handle null initializer.

From-SVN: r245796
2017-02-28 18:57:09 -05:00
Volker Reichelt 24f1282383 init.c: Include intl.h.
2017-02-27  Volker Reichelt  <v.reichelt@netcologne.de>

       * init.c: Include intl.h.
       (build_new_1): Move message strings into pedwarn to make them
       -Wformat-security friendly. Mark string for translation.
       * pt.c (tsubst_copy_and_build): Mark string for translation.
       Make the pointer const.
       * semantics.c (finish_id_expression): Mark strings for
       * translation.

From-SVN: r245757
2017-02-27 13:29:35 +00:00
Paolo Carlini e3beb191c5 re PR c++/79361 (ICE redefining a template function as defaulted or deleted)
/cp
2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/79361
	* pt.c (register_specialization): Check duplicate_decls return value
	for error_mark_node and pass it back.

/testsuite
2017-02-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/79361
	* g++.dg/cpp0x/pr79361-1.C: New.
	* g++.dg/cpp0x/pr79361-2.C: Likewise.

From-SVN: r245692
2017-02-23 23:20:58 +00:00
Jason Merrill 349c635163 * pt.c (do_class_deduction): Handle 0 argument case.
From-SVN: r245665
2017-02-22 17:55:26 -05:00
Marek Polacek 78af14ae0e re PR c++/79653 (ICE on invalid c++ code in cp_check_const_attributes in cp/decl2.c:1423)
PR c++/79653
	* parser.c (cp_parser_std_attribute_spec): Don't build the attribute
	if the alignas expression is erroneous.
	* pt.c (tsubst_attribute): If tsubst_pack_expansion fails, return
	error_mark_node.

	* g++.dg/cpp0x/alignas10.C: New test.
	* g++.dg/cpp0x/alignas9.C: New test.

From-SVN: r245657
2017-02-22 19:31:49 +00:00
Jason Merrill 46b48ef565 PR c++/41727 - ICE with partial spec of partial instantiation
* pt.c (process_partial_specialization): For now, don't check more
	specialized if there is more than one level of args.

From-SVN: r245642
2017-02-21 15:50:57 -05:00
Jakub Jelinek b7280ac270 re PR c++/79654 (ICE on invalid c++ code in register_dtor_fn in cp/decl.c:7877)
PR c++/79654
	* decl.c (cp_finish_decomp): Don't set decl's type to error_mark_node
	on error.
	* pt.c (tsubst_decomp_names): Return error_mark_node if the first
	decl after the decomposition artificial decl has error_mark_node.
	* decl2.c (prune_vars_needing_no_initialization): Use error_operand_p
	instead of just == error_mark_node comparison.

	* g++.dg/cpp1z/decomp26.C: New test.

Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>

From-SVN: r245639
2017-02-21 19:00:35 +01:00
Jason Merrill 8f712b7690 PR c++/78282 - auto template and pack expansion
* pt.c (find_parameter_packs_r): Don't walk into the type of
	templates other than template template-parameters.

From-SVN: r245594
2017-02-20 01:06:39 -05:00
Jason Merrill 4cd159317c PR c++/79470 - partial ordering with reference parameters
* pt.c (unify) [INDIRECT_REF]: Handle pack expansions.

From-SVN: r245589
2017-02-20 01:05:38 -05:00
Jason Merrill cfb825648d PR c++/79500 - ICE with non-template deduction guide
* pt.c (do_class_deduction): Use STRIP_TEMPLATE rather than
	DECL_TEMPLATE_RESULT.

From-SVN: r245588
2017-02-20 01:05:31 -05:00
Jason Merrill 7c5867495b PR c++/78690 - ICE with using and global type with same name
* pt.c (type_dependent_object_expression_p): True for
	IDENTIFIER_NODE.

From-SVN: r245549
2017-02-17 15:28:38 -05:00
Jason Merrill edf1849aa6 PR c++/79549 - C++17 ICE with non-type auto template parameter pack
* pt.c (convert_template_argument): Just return an auto arg pack.
	(tsubst_template_args): Don't tsubst an auto pack type.

From-SVN: r245544
2017-02-17 13:42:43 -05:00
Jason Merrill b10c7cd74a PR c++/79556 - C++17 ICE with non-type auto
* pt.c (do_auto_deduction): Don't try to deduce from null type.

From-SVN: r245543
2017-02-17 13:42:37 -05:00
Jakub Jelinek 790ecf8532 PR c++/79502 - lost nodiscard attribute
* pt.c (apply_late_template_attributes): Do apply non-dependent
	attributes to types.

Co-Authored-By: Jason Merrill <jason@redhat.com>

From-SVN: r245516
2017-02-16 14:49:19 -05:00