blob: ec05c379bea82597f21dbbd32ccb9b74f366acc3 [file] [log] [blame]
2019-12-30 Marek Polacek <>
* decl.c (reshape_init_r): Remove assert.
2019-12-30 Paolo Carlini <>
* decl2.c (delete_sanity): Add location_t parameter and use
it throughout.
* init.c (build_vec_delete_1): Likewise.
(build_delete): Likewise.
(build_vec_delete): Likewise.
(perform_target_ctor): Adjust call.
(perform_member_init): Likewise.
(build_vec_init): Likewise.
* decl.c (cxx_maybe_build_cleanup): Likewise.
* pt.c (tsubst_copy_and_build): Likewise.
* parser.c (cp_parser_delete_expression): Likewise, pass the
* cp-tree.h: Update declarations.
2019-12-29 Marek Polacek <>
PR c++/88337 - Implement P1327R1: Allow dynamic_cast in constexpr.
* constexpr.c (cxx_dynamic_cast_fn_p): New function.
(extract_obj_from_addr_offset): New function.
(get_component_with_type): New function.
(cxx_eval_dynamic_cast_fn): New function.
(cxx_eval_call_expression): Call cxx_eval_dynamic_cast_fn for a call
to __dynamic_cast.
(potential_constant_expression_1): Don't give up on
* rtti.c (build_dynamic_cast_1): When creating a call to
__dynamic_cast, use the location of the original expression.
2019-12-26 Jakub Jelinek <>
PR c++/92438
* parser.c (cp_parser_constructor_declarator_p): If open paren
is followed by RID_ATTRIBUTE, skip over the attribute tokens and
try to parse type specifier.
2019-12-23 Richard Sandiford <>
PR c++/92789
* typeck.c (structural_comptypes): Make sure that two vector types
agree on gnu_vector_type_p.
2019-12-23 Richard Sandiford <>
* cvt.c (ocp_convert): Apply rvalue to the source of vector
* typeck.c (build_reinterpret_cast_1): Likewise.
2019-12-19 Marek Polacek <>
PR c++/92745 - bogus error when initializing array of vectors.
* decl.c (reshape_init_r): For a nested compound literal, do
call reshape_init_{class,array,vector}.
PR c++/92974 - bogus location for enum and non-enum in ?: warning.
* tree.c (build_min_non_dep): Use the location of NON_DEP when
building the expression.
2019-12-20 Jakub Jelinek <>
PR c++/92965
* pt.c (invalid_nontype_parm_type_p): Call structural_type_p with
explain=true only if emitting error.
PR c++/92966
* method.c (early_check_defaulted_comparison): Don't set
DECL_MAYBE_DELETED when returning false.
PR c++/92973
* method.c (early_check_defaulted_comparison): For C++17 and earlier
diagnose defaulted comparison operators.
PR c++/92666
* call.c (convert_arg_to_ellipsis): For floating point or
decltype(nullptr) arguments call mark_rvalue_use.
PR c++/92992
* call.c (convert_arg_to_ellipsis): For decltype(nullptr) arguments
that have side-effects use cp_build_compound_expr.
2019-12-20 Eric Botcazou <>
* decl2.c (c_parse_final_cleanups): Always call collect_source_ref on
the main input filename.
2019-12-19 Julian Brown <>
Cesar Philippidis <>
* parser.c (cp_parser_omp_clause_name): Support attach and detach
(cp_parser_omp_var_list_no_open): Add ALLOW_DEREF optional parameter.
Parse deref if true.
(cp_parser_omp_var_list): Add ALLOW_DEREF optional parameter. Pass to
(cp_parser_oacc_data_clause): Support attach and detach clauses.
Update call to cp_parser_omp_var_list_no_open.
(cp_parser_oacc_all_clauses): Support attach and detach.
* semantics.c (handle_omp_array_sections_1): Reject subarrays for
attach and detach.
(handle_omp_array_sections): Use GOMP_MAP_ATTACH_DETACH instead of
(cp_oacc_check_attachments): New function.
(finish_omp_clauses): Use above function. Allow structure fields and
class members to appear in OpenACC data clauses. Support
2019-12-19 Jason Merrill <>
PR c++/52320 - EH cleanups for partially constructed arrays.
* typeck2.c (split_nonconstant_init_1): Add nested parm.
Add cleanup for whole array if true.
PR c++/66139 - EH cleanups for partially constructed aggregates.
PR c++/57510
* cp-gimplify.c (cp_gimplify_init_expr): Use split_nonconstant_init.
* typeck2.c (split_nonconstant_init): Handle non-variable dest.
(split_nonconstant_init_1): Clear TREE_SIDE_EFFECTS.
* tree.c (is_local_temp): New.
2019-12-18 Jason Merrill <>
PR c++/91165 follow-on tweak
* constexpr.c (cxx_eval_call_expression): Use
2019-12-19 Julian Brown <>
Maciej W. Rozycki <>
Tobias Burnus <>
Thomas Schwinge <>
* parser.c (cp_parser_omp_clause_name): Support no_create.
(cp_parser_oacc_data_clause): Likewise.
(cp_parser_oacc_all_clauses): Likewise.
* semantics.c (handle_omp_array_sections): Support no_create.
2019-12-18 Paolo Carlini <>
* typeck.c (cxx_sizeof_or_alignof_type): Add location_t parameter
and use it throughout.
(cxx_sizeof_expr): Likewise.
(cxx_alignof_expr): Likewise.
(cxx_sizeof_or_alignof_expr): Likewise.
(cxx_alignas_expr): Update call.
* decl.c (fold_sizeof_expr): Likewise.
* pt.c (tsubst_copy): Likewise.
(tsubst_copy_and_build): Likewise.
* except.c (build_throw): Add location_t parameter and use it.
(expand_end_catch_block): Update call.
* parser.c (cp_parser_unary_expression): Update
cxx_sizeof_or_alignof_type and cxx_sizeof_or_alignof_expr calls,
pass the compound location.
(cp_parser_throw_expression): Likewise pass the combined location
to build_throw.
* cp-tree.h: Update declarations.
* semantics.c (finish_handler_parms): Use DECL_SOURCE_LOCATION.
* decl2.c (check_classfn): Likewise.
* except.c (is_admissible_throw_operand_or_catch_parameter):
Exploit cp_expr_loc_or_input_loc in one place.
* except.c (create_try_catch_expr): Remove, unused.
2019-12-17 Jason Merrill <>
PR c++/12333 - X::~X() with implicit this->.
* parser.c (cp_parser_lookup_name): Use lookup_destructor.
* typeck.c (lookup_destructor): No longer static.
2019-12-17 Martin Sebor <>
PR c++/61339
* parser.c (cp_parser_maybe_warn_enum_key): New function.
(class_decl_loc_t): New class.
(cp_parser_elaborated_type_specifier): Call
(cp_parser_class_head): Call cp_parser_check_class_key.
(cp_parser_check_class_key): Add arguments. Call class_decl_loc_t::add.
(c_parse_file): Call class_decl_loc_t::diag_mismatched_tags.
2019-12-17 Jason Merrill <>
PR c++/79592 - missing explanation of invalid constexpr.
* constexpr.c (register_constexpr_fundef): Do store the body of a
template instantiation that is not potentially constant.
(explain_invalid_constexpr_fn): Look it up.
(cxx_eval_call_expression): Check fundef->result.
2019-12-17 Jason Merrill <>
PR c++/92576 - redeclaration of variable template.
* decl.c (redeclaration_error_message): Recurse for variable
2019-12-17 Jason Merrill <>
* name-lookup.c (get_std_name_hint): Add std::byte.
2019-12-17 Jakub Jelinek <>
PR c++/59655
* pt.c (push_tinst_level_loc): If limit_bad_template_recursion,
set TREE_NO_WARNING on tldcl.
* decl2.c (no_linkage_error): Treat templates with TREE_NO_WARNING
as defined during error recovery.
2019-12-13 Jason Merrill <>
PR c++/91165 - verify_gimple ICE with cached constexpr.
* constexpr.c (cxx_bind_parameters_in_call): Don't unshare.
(cxx_eval_call_expression): Unshare all args if we're caching.
2019-12-12 Jason Merrill <>
PR c++/92496 - ICE with <=> and no #include <compare>.
* typeck.c (cp_build_binary_op): Handle error from spaceship_type.
2019-12-11 David Malcolm <>
* cxx-pretty-print.c (cxx_pretty_printer::clone): New vfunc
* cxx-pretty-print.h (cxx_pretty_printer::clone): New vfunc decl.
* error.c (cxx_format_postprocessor::clone): New vfunc.
2019-12-11 Jakub Jelinek <>
PR c++/92869
* class.c (finish_struct): For C++17 and earlier, check
type_has_user_provided_or_explicit_constructor rather than
2019-12-11 Marek Polacek <>
PR c++/92878 - Parenthesized init of aggregates in new-expression.
* init.c (build_new_1): Handle parenthesized initialization of
aggregates in new-expression.
2019-12-11 Jason Merrill <>
PR c++/92105 - decltype(decltype) error cascade.
* parser.c (cp_parser_decltype_expr): Don't tentative_firewall here.
(cp_parser_decltype): Do it here. Remember a non-tentative error.
PR c++/57082 - new X{} and private destructor.
* init.c (build_new_1): Also pass tf_no_cleanup to
PR c++/92774 - ICE with implicitly deleted operator<=>.
* method.c (comp_info::~comp_info): Factor out of...
(build_comparison_op): Here. Handle error return from build_new_op.
PR c++/92859 - ADL and bit-field.
* name-lookup.c: Use unlowered_expr_type.
PR c++/92446 - deduction of class NTTP.
* pt.c (deducible_expression): Look through VIEW_CONVERT_EXPR.
2019-12-10 Jason Merrill <>
PR c++/92847 - C++20 comparison ambiguity with class template.
* call.c (cand_parms_match): Handle all templated functions.
Fix C++20 structural type vs. private base.
* class.c (build_base_field_1): Take access parameter.
(build_base_field): Likewise.
(build_base_fields, layout_virtual_bases): Pass it.
* tree.c (structural_type_p): Improve private base diagnostic.
PR c++/92560 - ICE with decltype and rewritten operator.
* call.c (build_new_op_1): Clear tf_decltype on inner call.
2019-12-09 David Malcolm <>
* error.c (range_label_for_type_mismatch::get_text): Replace
label_text ctor calls with label_text::borrow.
2019-12-09 Paolo Carlini <>
* typeck.c (check_for_casting_away_constness): Add location_t
parameter and use it.
(maybe_warn_about_useless_cast): Likewise.
(maybe_warn_about_cast_ignoring_quals): Likewise.
(build_static_cast_1): Likewise.
(build_static_cast): Likewise; sets the location of the returned tree.
(build_reinterpret_cast_1): Likewise.
(build_reinterpret_cast): Likewise; sets the location of the returned
(build_const_cast_1): Likewise.
(build_const_cast): Likewise; sets the location of the returned tree.
(cp_build_c_cast): Likewise.
(build_c_cast): Adjust.
(build_ptrmemfunc): Adjust calls.
(cp_build_unary_op): Pass the location to invert_truthvalue_loc.
* rtti.c (build_dynamic_cast_1): Add location_t parameter and
use it.
(build_dynamic_cast): Likewise.
* cp-tree.h: Adjust declarations.
* parser.c (cp_parser_postfix_expression): Pass cp_cast_loc to
the various build_*_cast functions.
(get_cast_suggestion): Adjust calls.
(cp_parser_builtin_offsetof): Likewise.
* decl.c (reshape_init): Adjust call.
* method.c (forward_parm): Likewise.
(build_comparison_op): Likewise.
* pt.c (tsubst_copy_and_build): Likewise.
* semantics.c (finish_omp_reduction_clause): Likewise.
(cp_omp_finish_iterators): Likewise.
* tree.c (cp_stabilize_reference): Likewise.
(move): Likewise.
* typeck2.c (build_functional_cast): Likewise.
* typeck2.c (build_functional_cast_1): New.
(build_functional_cast_1): Calls the latter and sets the location
of the returned tree.
2019-12-08 Jakub Jelinek <>
* cvt.c (maybe_warn_nodiscard): Add workaround for GCC 3.4-4.4 - cast
msg to (const char *) in conditional expressions. Formatting fixes.
2019-12-07 Jason Merrill <>
Jakub Jelinek <>
PR c++/92831
* call.c (build_conditional_expr_1): For ?: with omitted middle
operand use cp_stabilize_reference if arg1 is glvalue_p rather than
just if it is lvalue_p.
2019-12-06 Jakub Jelinek <>
* parser.c (cp_parser_diagnose_invalid_type_name): Mention
that concept is also available with -std=c++2a.
PR c++/92831 - CWG 1299, not extending temporary lifetime for ?:
* cp-tree.h (extend_ref_init_temps): Add a new argument with NULL
default arg.
* call.c (set_up_extended_ref_temp): Add COND_GUARD argument, pass it
down to extend_ref_init_temps. Before pushing cleanup, if COND_GUARD
is non-NULL, create a bool temporary if needed, initialize to false
and guard the cleanup with the temporary being true.
(extend_ref_init_temps_1): Add COND_GUARD argument, pass it down
to recursive calls and set_up_extended_ref_temp. Handle COND_EXPR.
(extend_ref_init_temps): Add COND_GUARD argument, pass it down to
recursive calls and to extend_ref_init_temps_1.
2019-12-06 Richard Sandiford <>
* decl.c (start_decl_1): Use verify_type_context to check whether
the target allows variables of a particular type to have static
or thread-local storage duration.
(check_array_initializer): Use verify_type_context to check whether
the target allows a particular type to be used as an array element.
(create_array_type_for_decl): Likewise.
(cp_finish_decl): Use verify_type_context to check whether
the target allows static member variables of a particular type.
(grokdeclarator): Likewise. Also use verify_type_context to check
whether the target allows non-static member variables of a particular
* except.c: Include target.h.
(is_admissible_throw_operand_or_catch_parameter): Use
verify_type_context to check whether the target allows particular
types to be thrown and caught.
* typeck2.c (add_exception_specifier): Likewise.
* init.c (build_new_1): Use verify_type_context to check whether
the target allows particular types to be dynamically allocated.
(build_vec_delete_1, build_delete): Use verify_type_context to check
whether the target allows particular types to be deleted.
* lambda.c (add_capture): Use verify_type_context to check
whether the target allows particular types to be captured by copy.
* pt.c: Include target.h.
(instantiate_class_template_1): Use verify_type_context to check
whether the target allows non-static member variables of a particular
* typeck.c (cxx_alignof_expr): Use verify_type_context to check
whether the target allows the alignment of a particular type
to be measured.
(pointer_diff, cp_build_unary_op): Use verify_type_context to check
whether the target allows arithmetic involving pointers to particular
2019-12-05 Marek Polacek <>
Jakub Jelinek <>
PR c++/91353 - P1331R2: Allow trivial default init in constexpr contexts.
* class.c (trivial_default_constructor_is_constexpr): Return true in
* constexpr.c (cx_check_missing_mem_inits): Allow missing field
initializers in C++20.
(cxx_eval_call_expression): Don't clear CONSTRUCTOR_NO_CLEARING for
constexpr constructors in C++20.
(reduced_constant_expression_p): Don't set FIELD for union and array
types. Skip empty class fields without initializers.
* decl.c (check_for_uninitialized_const_var): Permit trivial default
initialization in constexpr.
(next_initializable_field): Don't skip vptr fields.
* method.c (walk_field_subobs): Still consider a constructor that
doesn't initialize all the members constexpr.
2019-12-05 Marek Polacek <>
PR c++/92271 - make __is_same alias for __is_same_as.
* cxx-pretty-print.c (pp_cxx_trait_expression) <case CPTK_IS_SAME_AS>:
Print "__is_same".
2019-12-05 David Edelsohn <>
* cp-gimplify.c: Include memmodel.h.
2019-12-05 Paolo Carlini <>
* typeck2.c (build_functional_cast): Add location_t parameter
and use it.
* cp-tree.h: Update declaration.
* parser.c (cp_parser_functional_cast): Adjust call.
* call.c (build_op_delete_call): Likewise.
(build_new_method_call_1): Likewise.
* decl.c (check_initializer): Likewise.
* pt.c (tsubst_copy_and_build): Likewise.
* semantics.c (finish_compound_literal): Likewise.
2019-12-04 David Edelsohn <>
* cp-gimplify.c: Include tm_p.h.
2019-12-04 Marek Polacek <>
* parser.c (enum primary_constraint_error): Remove stray comma.
2019-12-04 Richard Sandiford <>
* cp-tree.h (CP_AGGREGATE_TYPE_P): Check for gnu_vector_type_p
instead of VECTOR_TYPE.
* call.c (build_conditional_expr_1): Restrict vector handling
to vectors that satisfy gnu_vector_type_p.
* cvt.c (ocp_convert): Only allow vectors to be converted
to bool if they satisfy gnu_vector_type_p.
(build_expr_type_conversion): Only allow conversions from
vectors if they satisfy gnu_vector_type_p.
* typeck.c (cp_build_binary_op): Only allow binary operators to be
applied to vectors if they satisfy gnu_vector_type_p.
(cp_build_unary_op): Likewise unary operators.
2019-12-03 Jakub Jelinek <>
* cp-tree.h (enum cp_tree_index): Add CPTI_SOURCE_LOCATION_IMPL.
(source_location_impl): Define.
(enum cp_built_in_function): Add CP_BUILT_IN_SOURCE_LOCATION.
(fold_builtin_source_location): Declare.
* cp-gimplify.c: Include output.h, file-prefix-map.h and cgraph.h.
(cp_gimplify_expr, cp_fold): Handle CP_BUILT_IN_SOURCE_LOCATION.
Formatting fix.
(get_source_location_impl_type): New function.
(struct source_location_table_entry,
struct source_location_table_entry_hash): New types.
(source_location_table, source_location_id): New variables.
(fold_builtin_source_location): New function.
* constexpr.c (cxx_eval_builtin_function_call): Handle
* tree.c (builtin_valid_in_constant_expr_p): Likewise. Formatting
* decl.c (cxx_init_decl_processing): Register
* name-lookup.c (get_std_name_hint): Add source_location entry.
2019-12-03 Paolo Carlini <>
* typeck.c (cp_build_addr_expr_1): Use the cp_expr_loc_or_input_loc
location in a few additional diagnostics; tidy.
(check_return_expr): Likewise.
* typeck.c (cp_build_addr_expr_1): Use tree_strip_any_location_wrapper
for the address of main pedwarn.
2019-12-03 Jakub Jelinek <>
PR c++/91369
* constexpr.c (struct constexpr_global_ctx): Add cleanups member,
initialize it in the ctor.
(cxx_eval_constant_expression) <case TARGET_EXPR>: If TARGET_EXPR_SLOT
is already in the values hash_map, don't evaluate it again. Put
TARGET_EXPR_SLOT into hash_map even if not lval, and push it into
save_exprs too. If there is TARGET_EXPR_CLEANUP and not
CLEANUP_EH_ONLY, push the cleanup to cleanups vector.
<case CLEANUP_POINT_EXPR>: Save outer cleanups, set cleanups to
local auto_vec, after evaluating the body evaluate cleanups and
restore previous cleanups.
<case TRY_CATCH_EXPR>: Don't crash if the first operand is NULL_TREE.
(cxx_eval_outermost_constant_expr): Set cleanups to local auto_vec,
after evaluating the expression evaluate cleanups.
2019-12-03 Marek Polacek <>
PR c++/91363 - P0960R3: Parenthesized initialization of aggregates.
* call.c (build_new_method_call_1): Handle parenthesized initialization
of aggregates by building up a CONSTRUCTOR.
(extend_ref_init_temps): Do nothing for CONSTRUCTOR_IS_PAREN_INIT.
* decl.c (grok_reference_init): Handle aggregate initialization from
a parenthesized list of values.
(reshape_init): Do nothing for CONSTRUCTOR_IS_PAREN_INIT.
(check_initializer): Handle initialization of an array from a
parenthesized list of values. Use NULL_TREE instead of NULL.
* tree.c (build_cplus_new): Handle BRACE_ENCLOSED_INITIALIZER_P.
* typeck2.c (digest_init_r): Set LOOKUP_AGGREGATE_PAREN_INIT if it
(massage_init_elt): Don't lose LOOKUP_AGGREGATE_PAREN_INIT when passing
flags to digest_init_r.
2019-12-03 Jakub Jelinek <>
PR c++/92732
* typeck2.c (digest_nsdmi_init): For bitfields, use
2019-12-03 Jason Merrill <>
Jakub Jelinek <>
PR c++/92705
* call.c (strip_standard_conversion): New function.
(build_new_op_1): Use it for user_conv_p.
(compare_ics): Likewise.
(source_type): Likewise.
2019-12-03 Jakub Jelinek <>
PR c++/92695
* constexpr.c (cxx_bind_parameters_in_call): For virtual calls,
adjust the first argument to point to the derived object rather
than its base.
2019-12-02 Jakub Jelinek <>
PR c++/92695
* constexpr.c (cxx_eval_constant_expression) <case OBJ_TYPE_REF>: Use
STRIP_NOPS before checking for ADDR_EXPR.
2019-11-29 Jakub Jelinek <>
PR c++/60228
* parser.c (cp_parser_omp_declare_reduction_exprs): If
processing_template_decl, wrap the combiner or initializer
* decl.c (start_preparsed_function): Don't start a lambda scope
(finish_function): Don't finish a lambda scope for
DECL_OMP_DECLARE_REDUCTION_P functions, nor cp_fold_function
them nor cp_genericize them.
* mangle.c (decl_mangling_context): Look through
* semantics.c (expand_or_defer_fn_1): For DECL_OMP_DECLARE_REDUCTION_P
functions, use tentative linkage, don't keep their bodies with
-fkeep-inline-functions and return false at the end.
2019-11-28 Jakub Jelinek <>
PR c++/92695
* decl2.c (mark_used): Don't call note_vague_linkage_fn for pure
virtual functions, even if they are declared inline.
2019-11-16 Jason Merrill <>
Implement P1814R0, CTAD for alias templates.
* pt.c (rewrite_tparm_list): Factor out of build_deduction_guide.
(maybe_aggr_guide): Check for copy-init here.
(alias_ctad_tweaks, deduction_guides_for): New.
(ctor_deduction_guides_for): Factor out of do_class_deduction.
(ctad_template_p): New.
* parser.c (cp_parser_simple_type_specifier): Use it.
* (append_constraint): New.
2019-11-16 Jason Merrill <>
* cxx-pretty-print.c (pp_cxx_unqualified_id): Handle alias
* pt.c (complex_alias_template_p): True if constraints.
(get_underlying_template, tsubst): Check alias constraints.
(push_template_decl_real): Set alias constraints here.
* parser.c (cp_parser_alias_declaration): Not here.
* (get_constraints): Take const_tree.
2019-11-12 Jason Merrill <>
PR c++/92206 - ICE with typedef to dependent alias.
* pt.c (dependent_alias_template_spec_p)
(alias_template_specialization_p): Add transparent_typedefs
(iterative_hash_template_arg, any_template_parm_r)
(primary_template_specialization_p, tsubst, dependent_type_p_r):
* decl.c (check_elaborated_type_specifier): Adjust.
* error.c (dump_template_bindings, dump_aggr_type): Adjust.
2019-11-27 Andrew Sutton <>
PR c++/92236
Defer evaluation of concept checks so that static assertions can
emit more detailed diagnostics.
* constexpr.c (cxx_eval_call_expression): Handle concept checks.
(cxx_eval_constant_expression): Diagnose misuse of function concepts
as template-id expressions. Follow the usual return path for results.
(cxx_eval_outermost_constant_expr): Avoid calling
cp_get_callee_fndecl_nofold for function concepts.
* (build_function_check): Fully type the concept check
so that we don't ICE in conversions.
* cp-gimplify.c (cp_genericize_r) [CALL_EXPR]: Handle concept checks.
* cvt.c (convert_to_void): Always evaluate concept checks so we don't
accidentally ignore them. Substitution during satisfaction can make
a program ill-formed (example in g++.dg/cpp2a/concepts6.C).
* pt.c (tsubst_copy_and_build): [CALL_EXPR]: Don't evaluate concepts.
* semantics.c (finish_call_expr): Don't evaluate concepts.
(finish_id_expression_1): Likewise.
(finish_static_assert): Preserve the original condition so we can
diagnose concept errors when a check returns false.
2019-11-27 Andrew Sutton <>
PR c++/92439
Improve quality of diagnostics for subexpressions that need parens.
* parser.c (cp_parser_requires_clause_opt): Add a flag to indicate
when parsing a requires-clause before lambda parameters, and...
(cp_parser_lambda_declarator_opt): ... use that here ...
(cp_parser_type_parameter): ... and here ...
(cp_parser_late_return_type_opt): ... and here ...
(cp_parser_explicit_template_declaration): ... and here.
(cp_parser_diagnose_ungrouped_constraint_plain): Adjust the message
because this can apply to subexpressions that are not immediately
after a requires-clause.
(cp_parser_diagnose_ungrouped_constraint_rich): Likewise.
(primary_constraint_error): New.
(cp_parser_constraint_requires_parens): New.
(cp_parser_unary_constraint_requires_parens): New.
(cp_parser_constraint_primary_expression): Check for unary expressions
before parsing the primary expression. Also check for binary and
postfix operators after a successful parse of the primary expression.
Force a re-parse if the result would form a lower-precedence string.
(cp_parser_constraint_logical_and_expression): Propagate lambda flag;
move checks for ill-formed constraints into the constraint primary
(cp_parser_constraint_logical_or_expression): Likewise.
(cp_parser_requires_clause_expression): Propagate lambda flag.
2019-11-27 Andrew Sutton <>
PR c++/88395
* (satisfy_declaration_constraints): Push tinst levels
around satisfaction.
2019-11-27 Andrew Sutton <>
Diagnose certain constraint errors as hard errors, but otherwise treat
them the same as normal SFINAE-type errors. Also, generally clean up
the satisfaction functions.
* constexpr.c (cxx_eval_constant_expression): Use
* (normalize_concept_definition): Accept a diagnostic
flag and only cache when not diagnosing errors.
(decl_satisfied_cache): Map to trees instead of bools.
(satisfy_atom): Guarantee a location for the errors, propagate complain
flags to force_rvalue, and emit errors for non-boolean constraints.
(get_normalized_constraints_and_args): New overloads. Factored out of
satisfy_constraint_expression and satisfy_declaration_constraints.
(satisfy_constraint_expression): Propagate diagnostic info to
(satisfy_declaration_constraints): New. Factored out of
(constraint_satisfaction_value): New. Calls
satisfy_constraint_expression or satisfy_declaration_constraints.
(constraints_satisfied_p): Call constraint_satisfaction_value.
(evaluate_concept_check): Don't take tsubst_falgs_t. Replay
satisfaction if an error is encountered.
(current_failed_constraint): Moved from pt.c.
(diagnose_constraints): Call constraint_satisfaction_value.
* cp-tree.h: Update declarations.
* pt.c (current_failed_constraint): Moved to
* semantics.c (finish_id_expression_1): Remove a duplicate case.
2019-11-27 Jakub Jelinek <>
PR c++/92524
* tree.c (replace_placeholders_r): Don't walk constructor elts with
RANGE_EXPR indexes.
2019-11-26 Jason Merrill <>
* pt.c (tsubst_copy_and_build) [TEMPLATE_ID_EXPR]: Remember the
location of a variable template-id.
* constexpr.c (cxx_eval_constant_expression): Get expr location
before stripping location wrappers.
(non_const_var_error): Take location argument.
2019-11-26 Paolo Carlini <>
* typeck.c (cp_build_unary_op): Consistently use the accurate
location in seven additional diagnostic messages.
(cp_build_compound_expr): Use cp_expr_loc_or_input_loc in one place.
2019-11-26 Jakub Jelinek <>
PR c++/92648
* parser.c (cp_parser_std_attribute): For unknown attributes,
skip balanced token seq instead of trying to parse
attribute-argument-clause as expression list. Formatting fix.
PR c++/61414
* class.c (enum_to_min_precision): New hash_map.
(enum_min_precision): New function.
(check_bitfield_decl): Use it.
2019-11-25 Paolo Carlini <>
* typeck.c (cp_build_indirect_ref_1): Add location_t parameter
and use it in error messages.
(build_x_indirect_ref): Adjust call.
(build_indirect_ref): Likewise.
(cp_build_fold_indirect_ref): Likewise.
(cp_build_array_ref): Likewise.
* call.c (build_new_op_1): Likewise.
* semantics.c (finish_omp_clauses): Likewise.
(finish_omp_depobj): Likewise.
* typeck2.c (build_x_arrow): Likewise.
* cp-tree.h (cp_build_indirect_ref): Update declaration.
* call.c (build_new_op_1): Use location argument in warning_at.
* typeck.c (cp_build_modify_expr): Consistently use the
location_t argument.
2019-11-23 Bernd Edlinger <>
PR c++/92365
* name-lookup.c (check_local_shadow): Use can_convert_arg
instead of can_convert.
2019-11-22 Marek Polacek <>
PR c++/88337 - P1327R1: Allow polymorphic typeid in constexpr.
* constexpr.c (potential_constant_expression_1): Allow a typeid
expression whose operand is of polymorphic type in constexpr in
* rtti.c (build_typeid): Remove obsolete FIXME comment.
2019-11-22 Jakub Jelinek <>
PR c/90677
* cp-objcp-common.c (identifier_global_tag): Define.
PR c++/92458
* init.c (nsdmi_inst): Change type to
decl_tree_cache_map * from tree_cache_map *.
* (decl_constraints): Likewise.
* decl.c (get_tuple_decomp_init): Likewise.
* pt.c (defarg_inst, explicit_specifier_map): Likewise.
(tsubst_default_argument, store_explicit_specifier): Use
decl_tree_cache_map::create_ggc rather than
* cp-objcp-common.c (debug_type_map): Change type to
type_tree_cache_map * from tree_cache_map *.
2019-11-21 Marek Polacek <>
PR c++/92450 - ICE with invalid nested name specifier.
* parser.c (cp_parser_member_declaration): Don't attempt to print
erroneous bit-field diagnostic if grokdeclarator returns
2019-11-21 Jakub Jelinek <>
Jason Merrill <>
PR c++/90842
* parser.c (cp_parser_decl_specifier_seq): For concept or typedef
2019-11-20 Paolo Carlini <>
* typeck2.c (build_x_arrow): Early return if decay_conversion
returns error_mark_node.
2019-11-20 Jakub Jelinek <>
PR c++/90767
* call.c (complain_about_no_candidates_for_method_call): If
conv->from is not a type, pass to complain_about_bad_argument
lvalue_type of conv->from.
2019-11-20 Paolo Carlini <>
* cvt.c (ocp_convert): Use additional warning sentinel.
2019-11-19 Jakub Jelinek <>
PR c++/92414
* constexpr.c (cxx_eval_outermost_constant_expr): If DECL_INITIAL
on object is erroneous, return t without trying to evaluate
a constexpr dtor.
2019-11-12 Jason Merrill <>
* call.c (same_fn_or_template): Change to cand_parms_match.
(joust): Adjust.
(print_z_candidate): Mark rewritten/reversed candidates.
(build_new_op_1): Warn about recursive call with reversed arguments.
2019-11-15 Andrew Sutton <>
PR c++/89913
* pt.c (get_underlying_template): Exit loop if the original type
of the alias is null.
2019-11-19 Andrew Sutton <>
PR c++/92078
* pt.c (maybe_new_partial_specialization): Apply access to newly
created partial specializations. Update comment style.
2019-11-19 Andrew Sutton <>
PR c++/92078
* pt.c (maybe_new_partial_specialization): Apply access to newly
created partial specializations. Update comment style.
2019-11-19 Andrew Sutton <>
PR c++/92403
Suppress diagnostics substituting into a requires-expression.
* pt.c (tsubst_copy_and_build): Perform the first substitution without
diagnostics and a second only if tsubst_requries_expr returns an error.
2019-11-19 Jakub Jelinek <>
PR c++/92504
* semantics.c (handle_omp_for_class_iterator): Don't call
cp_fully_fold on cond.
2019-11-18 Paolo Carlini <>
* typeck.c (cp_build_addr_expr_1): Use cp_expr_loc_or_input_loc
in three places.
(cxx_sizeof_expr): Use it in one additional place.
(cxx_alignof_expr): Likewise.
(lvalue_or_else): Likewise.
2019-11-18 Marek Polacek <>
PR c++/91962 - ICE with reference binding and qualification conversion.
* call.c (convert_like_real) <case ck_ref_bind>: Check need_temporary_p.
2019-11-17 Jakub Jelinek <>
* method.c (lookup_comparison_result): Use %qD instead of %<%T::%D%>
to print the decl.
(lookup_comparison_category): Use %qD instead of %<std::%D%> to print
the decl.
2019-11-15 Paolo Carlini <>
* typeck.c (cp_truthvalue_conversion): Add tsubst_flags_t parameter
and use it in calls; also pass the location_t of the expression to
cp_build_binary_op and c_common_truthvalue_conversion.
* rtti.c (build_dynamic_cast_1): Adjust call.
* cvt.c (ocp_convert): Likewise.
* cp-gimplify.c (cp_fold): Likewise.
* cp-tree.h (cp_truthvalue_conversion): Update declaration.
2019-11-14 Jason Merrill <>
Implement P1816R0, class template argument deduction for aggregates.
* pt.c (maybe_aggr_guide, collect_ctor_idx_types): New.
(is_spec_or_derived): Split out from do_class_deduction.
(build_deduction_guide): Handle aggregate guide.
* class.c (finish_struct): Set CLASSTYPE_NON_AGGREGATE in a
* cp-tree.h (CP_AGGREGATE_TYPE_P): An incomplete class is not an
2019-11-14 Richard Sandiford <>
* call.c (build_conditional_expr_1): Use truth_type_for instead
of build_same_sized_truth_vector_type.
* typeck.c (build_vec_cmp): Likewise.
2019-11-14 Jakub Jelinek <>
* parser.c (cp_parser_omp_context_selector): Don't require score
argument to fit into shwi, just to be INTEGER_CST. Diagnose
negative score.
* pt.c (tsubst_attribute): Likewise.
* parser.c (cp_parser_omp_context_selector): Rename
Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single
identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers
and string literals.
* pt.c (tsubst_attribute): Fix up STRING_CST handling if allow_string.
2019-11-13 Marek Polacek <>
PR c++/89070 - bogus [[nodiscard]] warning in SFINAE.
* cvt.c (convert_to_void): Guard maybe_warn_nodiscard calls with
2019-11-13 Richard Sandiford <>
PR c++/92206
* cp-tree.h (STF_STRIP_DEPENDENT): New constant.
* tree.c (strip_typedefs): Add STF_STRIP_DEPENDENT to the flags
when calling strip_typedefs recursively on a DECL_ORIGINAL_TYPE.
Don't apply the fix for DR1558 in that case; allow aliases with
dependent template parameters to be stripped instead.
2019-11-12 Nathan Sidwell <>
* name-lookup.c (lookup_using_decl): New function, merged from ...
(do_class_using_decl): ... here. Call it. And ...
(finish_nonmember_using_decl): ... here. Call it.
2019-11-12 Martin Liska <>
* name-lookup.c: Do not include params.h.
* typeck.c: Likewise.
2019-11-12 Martin Liska <>
* name-lookup.c (namespace_hints::namespace_hints): Replace old
parameter syntax with the new one, include opts.h if needed. Use
* typeck.c (comptypes): Likewise.
2019-11-12 Maciej W. Rozycki <>
Frederik Harwath <>
* constexpr.c (potential_constant_expression_1): Handle
* parser.c (OACC_SERIAL_CLAUSE_MASK): New macro.
(cp_parser_oacc_kernels_parallel): Rename function to...
(cp_parser_oacc_compute): ... this. Handle PRAGMA_OACC_SERIAL.
(cp_parser_omp_construct): Update accordingly.
(cp_parser_pragma): Handle PRAGMA_OACC_SERIAL. Fix alphabetic
* pt.c (tsubst_expr): Handle OACC_SERIAL.
2019-11-11 Jason Merrill <>
Implement P1946R0, Allow defaulting comparisons by value.
* method.c (early_check_defaulted_comparison): Accept by-value,
reject mixed by-value and by-reference parms.
* decl.c (grokdeclarator): Set funcdef_flag for defaulted friend.
* decl2.c (grokfield): Don't SET_DECL_FRIEND_CONTEXT.
* typeck.c (cp_build_binary_op): Sorry about <=> on VECTOR_TYPE.
2019-11-11 Jakub Jelinek <>
PR c++/92447
* decl.c (finish_function): Move ctype initialization before
* semantics.c (finish_translation_unit): Diagnose declare target
without corresponding end declare target.
2019-11-10 Jason Merrill <>
Implement D1957R0, T* to bool should be considered narrowing.
* typeck2.c (check_narrowing): Treat pointer->bool as a narrowing
conversion with -std=c++2a.
2019-11-08 Marek Polacek <>
PR c++/92215 - flawed diagnostic for bit-field with non-integral type.
* parser.c (cp_parser_member_declaration): Add a diagnostic for
bit-fields with non-integral types.
2019-11-08 Jakub Jelinek <>
* init.c (build_vec_delete_1): Fix a comment typo - mist -> must.
2019-11-07 Jason Merrill <>
Implement D1959R0, remove weak_equality and strong_equality.
* method.c (enum comp_cat_tag, comp_cat_info): Remove *_equality.
(genericize_spaceship, common_comparison_type): Likewise.
* typeck.c (cp_build_binary_op): Move SPACESHIP_EXPR to be with the
relational operators, exclude other types no longer supported.
2019-11-06 Jason Merrill <>
Implement D1907R1 "structural type".
* tree.c (structural_type_p): New.
* pt.c (invalid_nontype_parm_type_p): Use it.
* class.c (build_base_field_1): Take binfo. Copy TREE_PRIVATE.
(build_base_field): Pass binfo.
PR c++/92150 - partial specialization with class NTTP.
* pt.c (unify): Handle VIEW_CONVERT_EXPR.
* pt.c (use_pack_expansion_extra_args_p): Still do substitution if
all packs are simple pack expansions.
(add_extra_args): Check that the extra args aren't dependent.
2019-11-06 Andrew Sutton <>
Use satisfaction with nested requirements.
* (build_parameter_mapping): Use
current_template_parms when the declaration is not available.
(norm_info::norm_info) Make explicit.
(normalize_constraint_expression): Factor into a separate overload
that takes arguments, and use that in the original function.
(tsubst_nested_requirement): Use satisfy_constraint instead of
trying to evaluate this as a constant expression.
(finish_nested_requirement): Keep the normalized constraint and the
original normalization arguments with the requirement.
(diagnose_nested_requirement): Use satisfy_constraint. Tentatively
implement more comprehensive diagnostics, but do not enable.
* parser.c (cp_parser_requires_expression): Relax requirement that
requires-expressions can live only inside templates.
* pt.c (any_template_parm_r): Look into type of PARM_DECL.
2019-11-06 Jason Merrill <>
C++20 NB CA378 - Remove constrained non-template functions.
* decl.c (grokfndecl): Reject constraints on non-templated function.
2019-11-06 Matthias Kretz <>
* parser.c (cp_parser_operator): Parse operator?: as an
attempt to overload the conditional operator.
2019-11-05 Jason Merrill <>
Implement C++20 operator<=>.
* cp-tree.h (struct lang_decl_fn): Add maybe_deleted bitfield.
(enum special_function_kind): Add sfk_comparison.
* call.c (struct z_candidate): Add rewritten and reversed methods.
(add_builtin_candidate): Handle SPACESHIP_EXPR.
(add_builtin_candidates): Likewise.
(add_candidates): Don't add a reversed candidate if the parms are
the same.
(add_operator_candidates): Split out from build_new_op_1. Handle
rewritten and reversed candidates.
(add_candidate): Swap conversions of reversed candidate.
(build_new_op_1): Swap them back. Build a second operation for
rewritten candidates.
(extract_call_expr): Handle rewritten calls.
(same_fn_or_template): New.
(joust): Handle rewritten and reversed candidates.
* class.c (add_implicitly_declared_members): Add implicit op==.
(classtype_has_op, classtype_has_defaulted_op): New.
* constexpr.c (cxx_eval_binary_expression): Handle SPACESHIP_EXPR.
(cxx_eval_constant_expression, potential_constant_expression_1):
* cp-gimplify.c (genericize_spaceship): New.
(cp_genericize_r): Use it.
* cp-objcp-common.c (cp_common_init_ts): Handle SPACESHIP_EXPR.
* decl.c (finish_function): Handle deleted function.
* decl2.c (grokfield): SET_DECL_FRIEND_CONTEXT on defaulted friend.
(mark_used): Check DECL_MAYBE_DELETED. Remove assumption that
defaulted functions are non-static members.
* error.c (dump_expr): Handle SPACESHIP_EXPR.
* method.c (type_has_trivial_fn): False for sfk_comparison.
(enum comp_cat_tag, struct comp_cat_info_t): New types.
(comp_cat_cache): New array variable.
(lookup_comparison_result, lookup_comparison_category)
(is_cat, cat_tag_for, spaceship_comp_cat)
(spaceship_type, genericize_spaceship)
(common_comparison_type, early_check_defaulted_comparison)
(comp_info, build_comparison_op): New.
(synthesize_method): Handle sfk_comparison. Handle deleted.
(get_defaulted_eh_spec, maybe_explain_implicit_delete)
(explain_implicit_non_constexpr, implicitly_declare_fn)
(defaulted_late_check, defaultable_fn_check): Handle sfk_comparison.
* name-lookup.c (get_std_name_hint): Add comparison categories.
* tree.c (special_function_p): Add sfk_comparison.
* typeck.c (cp_build_binary_op): Handle SPACESHIP_EXPR.
2019-11-05 Tim van Deurzen <>
Add new tree code for the spaceship operator.
* cp-tree.def: Add new tree code.
* operators.def: New binary operator.
* parser.c: Add new token and tree code.
2019-09-15 Jason Merrill <>
* call.c (build_new_op_1): Don't apply any standard conversions to
the operands of a built-in operator. Don't suppress conversions in
* typeck.c (cp_build_unary_op): Do integral promotions for enums.
2019-11-04 Jason Merrill <>
Use vec instead of raw array for built-in candidates.
* call.c (build_builtin_candidate): Take args in a vec.
(add_builtin_candidate, add_builtin_candidates): Likewise.
(build_conditional_expr_1, build_new_op_1): Adjust.
2019-11-04 Jason Merrill <>
* constexpr.c (explain_invalid_constexpr_fn): Show location of fn.
* pt.c (maybe_instantiate_noexcept): Only update clones if we
* typeck.c (contextual_conv_bool): New.
* name-lookup.c (lookup_qualified_name): Add wrapper overload taking
C string rather than identifier.
* parser.c (cp_parser_userdef_numeric_literal): Use it.
* rtti.c (emit_support_tinfos): Use it.
* cp-tree.h (ovl_op_identifier): Change to inline functions.
(build_x_binary_op): Add wrapper with fewer parms.
2019-11-05 Jason Merrill <>
* decl2.c (mark_used): Diagnose use of a function with unsatisfied
constraints here.
* typeck.c (cp_build_function_call_vec): Not here.
2019-11-05 Nathan Sidwell <>
PR c++/92370
* parser.c (cp_parser_error_1): Check EOF and UNKNOWN_LOCATION
when skipping over version control marker.
2019-11-05 Jakub Jelinek <>
PR c++/92343
* constexpr.c (potential_constant_expression_1): Return true rather
than false for PREDICT_EXPR.
* decl.c (omp_declare_variant_finalize_one): Call
declare_simd_adjust_this not just on the context, but also on the
variant-id expression for methods. Don't call
cp_get_callee_fndecl_nofold, call cp_get_callee and only if it is
safe cp_get_fndecl_from_callee. Don't try to print as %qD
NULL in diagnostics.
* pt.c (tsubst_attribute): Handle "omp declare variant base"
(tsubst_function_decl): Call omp_declare_variant_finalize
if there are any "omp declare variant base" attributes left.
2019-11-04 Kamlesh Kumar <>
PR c++/91979 - mangling nullptr expression
* mangle.c (write_template_arg_literal): Handle nullptr
2019-11-04 Jason Merrill <>
* typeck.c (check_return_expr): Avoid redundant error.
2019-11-02 Paolo Carlini <>
* typeck.c (composite_pointer_type): Add a const op_location_t&
parameter and use it in diagnostics.
(composite_pointer_error): Likewise.
(composite_pointer_type_r): Add a const op_location_t&
parameter and forward it.
(cp_build_binary_op): Adjust calls.
(common_pointer_type): Likewise.
* call.c (add_builtin_candidate): Likewise.
(build_conditional_expr_1): Likewise.
* cp-tree.h (composite_pointer_type): Update declaration.
* typeck.c (cxx_sizeof_expr): Use cp_expr_loc_or_input_loc
in permerror.
(cxx_alignof_expr): Likewise.
(lvalue_or_else): Likewise.
2019-11-02 Jakub Jelinek <>
* decl.c (omp_declare_variant_finalize_one): Use
omp_get_context_selector instead of c_omp_get_context_selector.
PR c++/89640
* parser.c (cp_parser_decl_specifier_seq): Don't parse attributes
PR c++/88335 - Implement P1073R3: Immediate functions
* cp-tree.h (struct lang_decl_fn): Add immediate_fn_p bit.
(enum cp_decl_spec): Add ds_consteval.
(fold_non_dependent_expr): Add another tree argument defaulted to
* name-lookup.h (struct cp_binding_level): Add immediate_fn_ctx_p
* parser.c (cp_keyword_starts_decl_specifier_p): Adjust comments
for C++11 and C++20 specifiers. Handle RID_CONSTEVAL.
(cp_parser_skip_balanced_tokens): New forward declaration.
(cp_parser_lambda_declarator_opt): Handle ds_consteval. Set
current_binding_level->immediate_fn_ctx_p before parsing parameter
list if decl-specifier-seq contains consteval specifier.
(cp_parser_decl_specifier_seq): Handle RID_CONSTEVAL.
(cp_parser_explicit_instantiation): Diagnose explicit instantiation
with consteval specifier.
(cp_parser_init_declarator): For consteval or into flags
(cp_parser_direct_declarator): If CP_PARSER_FLAGS_CONSTEVAL, set
current_binding_level->immediate_fn_ctx_p in the sk_function_parms
(set_and_check_decl_spec_loc): Add consteval entry, formatting fix.
* call.c (build_addr_func): For direct calls to immediate functions
use build_address rather than decay_conversion.
(build_over_call): Evaluate immediate function invocations.
* error.c (dump_function_decl): Handle DECL_IMMEDIATE_FUNCTION_P.
* semantics.c (expand_or_defer_fn_1): Use tentative linkage and don't
call mark_needed for immediate functions.
* typeck.c (cxx_sizeof_or_alignof_expr): Likewise. Formatting fix.
(cp_build_addr_expr_1): Reject taking address of immediate function
outside of immediate function.
* decl.c (validate_constexpr_redeclaration): Diagnose consteval
vs. non-consteval or vice versa redeclaration. Use
SET_DECL_IMMEDIATE_FUNCTION_P if new_decl is immediate function.
(check_tag_decl): Use %qs with keyword string to simplify translation.
Handle ds_consteval.
(start_decl): Adjust diagnostics for static or thread_local variables
in immediate functions.
(grokfndecl): Call sorry_at on virtual consteval. Use %qs with keyword
to string to simplify translation. Diagnose consteval main. Use
(grokdeclarator): Handle consteval. Use %qs with keyword strings to
simplify translation. Use separate ifs instead of chained else if
for invalid specifiers. For constinit clear constinit_p rather than
* constexpr.c (find_immediate_fndecl): New function.
(cxx_eval_outermost_constant_expr): Allow consteval calls returning
void. Diagnose returning address of immediate function from consteval
(fold_non_dependent_expr_template): Add OBJECT argument, pass it
through to cxx_eval_outermost_constant_expr.
(fold_non_dependent_expr): Add OBJECT argument, pass it through to
(fold_non_dependent_init): Adjust fold_non_dependent_expr_template
* method.c (defaulted_late_check): Adjust diagnostics for consteval.
* lambda.c (maybe_add_lambda_conv_op): Copy over
callop to both artificial functions.
* init.c (build_value_init): Don't do further processing if
build_special_member_call returned a TREE_CONSTANT. Formatting fix.
PR c++/91369 - Implement P0784R7: constexpr new
* cp-tree.h (CALL_FROM_NEW_OR_DELETE_P): Define.
* init.c (build_new_1, build_vec_delete_1, build_delete): Set
CALL_FROM_NEW_OR_DELETE_P on the CALL_EXPR to allocator functions.
* constexpr.c (is_std_allocator_allocate): Only allow
global replaceable allocator functions if CALL_FROM_NEW_OR_DELETE_P
or in std::allocate<T>::{,de}allocate.
(potential_constant_expression_1): Likewise.
2019-11-01 Nathan Sidwell <>
* class.c (check_field_decls): Refactor.
2019-10-31 Jakub Jelinek <>
PR c++/90947
* cp-tree.h (type_initializer_zero_p): Declare.
* decl.c (reshape_init_array_1): Formatting fix.
* tree.c (type_initializer_zero_p): New function. Moved from
../tree.c, use next_initializable_field, formatting fix. Return
2019-10-30 Jason Merrill <>
PR c++/92268 - hard error satisfying return-type-requirement
* (type_deducible_p): Check for substitution failure.
(diagnose_compound_requirement): Adjust diagnostic.
* pt.c (do_auto_deduction): Don't pass cargs to
2019-10-30 Jakub Jelinek <>
PR c++/91369 - Implement P0784R7: constexpr new
* constexpr.c (cxx_replaceable_global_alloc_fn): Don't return true
for placement new.
(cxx_placement_new_fn, is_std_construct_at): New functions.
(cxx_eval_call_expression): Allow placement new in std::construct_at.
(potential_constant_expression_1): Likewise.
* typeck.c (decl_in_std_namespace_p): Return true also for decls
in inline namespaces inside of std namespace.
2019-10-30 Bernd Edlinger <>
PR c++/92024
* name-lookup.c (check_local_shadow): Shadowing TYPE_DECLs
is always a -Wshadow=compatible-local warning, unless
-Wshadow is used.
2019-10-30 Jason Merrill <>
* cxx-pretty-print.c (get_fold_operator): Use OVL_OP_INFO.
2019-10-30 Marek Polacek <>
PR c++/92134 - constinit malfunction in static data member.
* decl2.c (grokfield): Set LOOKUP_CONSTINIT.
2019-10-30 Jakub Jelinek <>
* cp-tree.h (omp_declare_variant_finalize, build_local_temp): Declare.
* decl.c: Include omp-general.h.
(declare_simd_adjust_this): Add forward declaration.
(omp_declare_variant_finalize_one, omp_declare_variant_finalize): New
(cp_finish_decl, finish_function): Call omp_declare_variant_finalize.
* parser.c (cp_finish_omp_declare_variant): Adjust parsing of the
variant id-expression and propagate enough information to
omp_declare_variant_finalize_one in the attribute so that it can
finalize it.
* class.c (finish_struct): Call omp_declare_variant_finalize.
* tree.c (build_local_temp): No longer static, remove forward
2019-10-30 Paolo Carlini <>
* typeck.c (cp_build_modify_expr): Prefer error + inform to
error + error in one place.
(get_delta_difference_1): Likewise.
(get_delta_difference): Likewise, in two places.
2019-10-29 Paolo Carlini <>
* typeck.c (build_x_unary_op): Use the location_t argument in
three error_at.
2019-10-29 Marek Polacek <>
PR c++/90998 - ICE with copy elision in init by ctor and -Wconversion.
* call.c (joust): Don't attempt to warn if ->second_conv is null.
2019-10-29 Jakub Jelinek <>
PR c++/92201
* cp-gimplify.c (cp_gimplify_expr): If gimplify_to_rvalue changes the
function pointer type, re-add cast to the original one.
2019-10-29 Marek Polacek <>
PR c++/91548 - fix detecting modifying const objects for ARRAY_REF.
* constexpr.c (cxx_eval_store_expression): Don't call
modifying_const_object_p for ARRAY_REF.
2019-10-29 Richard Sandiford <>
* cp-objcp-common.h (cxx_simulate_enum_decl): Declare.
(LANG_HOOKS_SIMULATE_ENUM_DECL): Define to the above.
* decl.c (cxx_simulate_enum_decl): New function.
2019-10-29 Richard Sandiford <>
* cp-tree.h (cxx_simulate_builtin_function_decl): Declare.
* decl.c (cxx_simulate_builtin_function_decl): New function.
Define to the above.
2019-10-28 Martin Sebor <>
PR c/66970
* cp-objcp-common.c (names_builtin_p): Define new function.
2019-10-28 Nathan Sidwell <>
* parser.h (struct cp_token): Drop {ENUM,BOOL}_BITFIELD C-ism.
Add tree_check_p flag, use as nested union discriminator.
(struct cp_lexer): Add saved_type & saved_keyword fields.
* parser.c (eof_token): Delete.
(cp_lexer_new_main): Always init last_token to last token of
(cp_lexer_new_from_tokens): Overlay EOF token at end of range.
(cp_lexer_destroy): Restore token under the EOF.
(cp_lexer_previous_token_position): No check for eof_token here.
(cp_lexer_get_preprocessor_token): Clear tree_check_p.
(cp_lexer_peek_nth_token): Check CPP_EOF not eof_token.
(cp_lexer_consume_token): Assert not CPP_EOF, no check for
(cp_lexer_purge_token): Likewise.
(cp_lexer_purge_tokens_after): No check for EOF token.
(cp_parser_nested_name_specifier, cp_parser_decltype)
(cp_parser_template_id): Set tree_check_p.
2019-10-24 Jakub Jelinek <>
* decl2.c (cplus_decl_attributes): Add "omp declare target block"
attribute in between declare target and end declare target
* call.c (convert_arg_to_ellipsis): Add missing space in string
2019-10-24 Marek Polacek <>
* decl.c (reshape_init_r): Add missing space.
2019-10-24 Nathan Sidwell <>
* pt.c (reduce_template_parm_level): Attach the new TPI to the new
(convert_generic_types_to_packs): Pass the copied type to
2019-10-23 Nathan Sidwell <>
* cp-tree.c (CPTI_STD_IDENTIFIER): Delete.
(std_identifier): Delete.
(DECL_NAME_SPACE_STD_P): Compare against std_node.
* decl.c (initialize_predefined_identifiers): 'std' is not needed.
(cxx_init_decl_processing): Adjust creation of ::std. Use
(cxx_builtin_function): Use {push,pop}_nested_namespace.
* except.c (init_exception_processing): Likewise.
* rtti.c (init_rtti_processing): Likewise.
2019-10-23 Jason Merrill <>
Implement P1286R2, Contra CWG1778
* method.c (defaulted_late_check): Don't check explicit
exception-specification on defaulted function.
(after_nsdmi_defaulted_late_checks): Remove.
* parser.h (struct cp_unparsed_functions_entry): Remove classes.
* parser.c (unparsed_classes): Remove.
(push_unparsed_function_queues, cp_parser_class_specifier_1):
2019-10-23 Jakub Jelinek <>
* constexpr.c (cxx_eval_constant_expression) <case CLEANUP_STMT>:
Temporarily change input_location to CLEANUP_STMT location.
2019-10-22 Jakub Jelinek <>
PR tree-optimization/85887
* decl.c (expand_static_init): Drop ECF_LEAF from __cxa_guard_acquire
and __cxa_guard_release.
2019-10-22 Marc Glisse <>
PR c++/85746
* constexpr.c (cxx_eval_builtin_function_call): Only set
force_folding_builtin_constant_p if manifestly_const_eval.
2019-10-22 Richard Sandiford <>
* cp-tree.h (STF_USER_VISIBLE): New constant.
(strip_typedefs, strip_typedefs_expr): Take a flags argument.
* tree.c (strip_typedefs, strip_typedefs_expr): Likewise,
updating mutual calls accordingly. When STF_USER_VISIBLE is true,
only look through typedefs if user_facing_original_type_p.
* error.c (dump_template_bindings, type_to_string): Pass
STF_USER_VISIBLE to strip_typedefs.
(dump_type): Likewise, unless pp_c_flag_gnu_v3 is set.
2019-10-21 Kamlesh Kumar <>
Jason Merrill <>
PR c++/83534 - typeinfo of noexcept function
* rtti.c (get_tinfo_decl_dynamic): Do not call
TYPE_MAIN_VARIANT for function.
(get_typeid): Likewise.
2019-10-21 Paolo Carlini <>
* parser.c (cp_parser_class_head): Improve error recovery upon
extra qualification error.
2019-10-21 Jakub Jelinek <>
PR c++/92015
* constexpr.c (cxx_eval_component_reference, cxx_eval_bit_field_ref):
2019-10-21 Marek Polacek <>
PR c++/92062 - ODR-use ignored for static member of class template.
* pt.c (has_value_dependent_address): Strip location wrappers.
2019-10-21 Marek Polacek <>
PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr.
* typeck.c (maybe_warn_about_returning_address_of_local): Avoid
recursing on null initializer and return false instead.
2019-10-17 JeanHeyd Meneide <>
Implement p1301 [[nodiscard("should have a reason")]] + p1771 DR
* tree.c (handle_nodiscard_attribute): Handle C++2a nodiscard
string message.
(std_attribute_table) Increase nodiscard argument handling
max_length from 0 to 1.
* parser.c (cp_parser_check_std_attribute): Add requirement
that nodiscard only be seen once in attribute-list.
(cp_parser_std_attribute): Check that empty parenthesis lists are
not specified for attributes that have max_length > 0 (e.g.
* cvt.c (maybe_warn_nodiscard): Add nodiscard message to
output, if applicable.
(convert_to_void): Allow constructors to be nodiscard-able (P1771).
2019-10-18 Nathan Sidwell <>
* cp-tree.h (struct lang_type): Remove was_anonymous.
(TYPE_WAS_UNNAMED): Implement by checking TYPE_DECL &
* decl.c (name_unnamed_type): Don't set TYPE_WAS_UNNAMED.
2019-10-17 Paolo Carlini <>
* decl.c (grokfndecl): Remove redundant use of in_system_header_at.
(compute_array_index_type_loc): Likewise.
(grokdeclarator): Likewise.
* error.c (cp_printer): Likewise.
* lambda.c (add_default_capture): Likewise.
* parser.c (cp_parser_primary_expression): Likewise.
(cp_parser_selection_statement): Likewise.
(cp_parser_toplevel_declaration): Likewise.
(cp_parser_enumerator_list): Likewise.
(cp_parser_using_declaration): Likewise.
(cp_parser_member_declaration): Likewise.
(cp_parser_exception_specification_opt): Likewise.
(cp_parser_std_attribute_spec): Likewise.
* pt.c (do_decl_instantiation): Likewise.
(do_type_instantiation): Likewise.
* typeck.c (cp_build_unary_op): Likewise.
* decl.c (check_tag_decl): Pass to in_system_header_at the same
location used for the permerror.
(grokdeclarator): Likewise.
* decl.c (check_tag_decl): Use locations[ds_typedef] in error_at.
2019-10-17 Jason Merrill <>
* cp-gimplify.c (cp_gimplify_expr): Use get_initialized_tmp_var.
(gimplify_to_rvalue): Remove default NULL argument.
2019-10-17 Nathan Sidwell <>
* decl.c (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
2019-10-16 Luis Machado <>
* cp-gimplify.c: Fix reference to non-existing tree-gimple.c file.
2019-10-16 Jakub Jelinek <>
* decl.c (cxx_maybe_build_cleanup): When clearing location of cleanup,
if cleanup is a nop, clear location of its operand too.
2019-10-15 Andrew Sutton <>
Finish moving constraint and logic functionality of out pt.c.
Reimplement and re-enable subsumption caching.
* (gtfiles): Add
* (atomic_constraints_identical_p): Add assertions.
(hash_atomic_constraint): Likewise.
(constraints_equivalent_p): New.
(inchash::add_constraint): New.
(iterative_hash_constraint): New.
(decl_constraints): Moved from pt.c.
(get_constraints): Likewise.
(set_constraints): Likewise.
(remove_constraints): Likewise.
* cp-tree.h (CONSTR_P): New.
(init_constraint_processing): Remove.
(constraints_equivalent_p, iterative_hash_constraint): Declare.
* decl.c (cxx_init_decl_processing): Don't initialize constraints.
* (subsumption_entry): Moved from pt.c.
(subsumption_hasher): Likewise.
(subsumption_cache): Likewise.
(lookup_subsumption): Likewise.
(save_subsumption): Likewise.
(subsumes_constraints_nonnull): Use subsumption cache.
* pt.c: Move aforementioned declarations out of this file.
(init_constraint_processing): Remove.
2019-10-15 Andrew Sutton <>
* parser.c (cp_parser_constructor_declarator_p): Pass an empty
decl-specifier-seq to make sure we parse type constraints as part
of a type-specifier.
2019-10-15 Nathan Sidwell <>
* class.c (build_clones): Break out of clone_function_decl. Just
build the clones.
(clone_function_decl): Call build_clones, then maybe add them to
the method vector.
* class.c (build_clone): Refactor to clarify recursiveness.
2019-10-14 Jason Merrill <>
PR c++/91930 - ICE with constrained inherited default ctor.
* name-lookup.c (do_class_using_decl): Set TYPE_HAS_USER_CONSTRUCTOR
for inherited constructor.
2019-10-14 Paolo Carlini <>
* decl.c (check_tag_decl): Use DECL_SOURCE_LOCATION.
2019-10-14 Jakub Jelinek <>
PR c++/92084
* semantics.c (handle_omp_array_sections_1): Temporarily disable
-fstrong-eval-order also for in_reduction and task_reduction clauses.
* parser.c (cp_parser_omp_all_clauses): Change bool NESTED_P argument
into int NESTED, if it is 2, diagnose missing commas in between
(cp_parser_omp_context_selector): Pass 2 as last argument to
2019-10-12 Jakub Jelinek <>
* parser.c (cp_parser_omp_context_selector): Improve error recovery.
For simd properties, put them directly into TREE_VALUE.
(cp_finish_omp_declare_variant): Add "omp declare variant base"
attribute rather than "omp declare variant".
2019-10-11 Marek Polacek <>
PR c++/92049 - extra error with -fchecking=2.
* pt.c (build_non_dependent_expr): Call fold_non_dependent_expr
with tf_none.
2019-10-11 Paolo Carlini <>
* typeck.c (cp_build_binary_op): Do not handle RROTATE_EXPR and
* constexpr.c (cxx_eval_constant_expression): Likewise.
(potential_constant_expression_1): Likewise.
* pt.c (tsubst_copy): Likewise.
2019-10-11 Jason Merrill <>
* decl2.c (mark_used): Don't clobber DECL_SOURCE_LOCATION on
explicitly defaulted functions.
* method.c (synthesize_method): Likewise.
2019-10-11 Jakub Jelinek <>
PR c++/91987
* decl2.c (grok_array_decl): For -fstrong-eval-order, when array ref
operands have been swapped and at least one operand has side-effects,
revert the swapping before calling build_array_ref.
* typeck.c (cp_build_array_ref): For non-ARRAY_TYPE array ref with
side-effects on the index operand, if -fstrong-eval-order use
save_expr around the array operand.
(cp_build_binary_op): For shifts with side-effects in the second
operand, wrap first operand into SAVE_EXPR and evaluate it before
the shift.
* semantics.c (handle_omp_array_sections_1): Temporarily disable
flag_strong_eval_order during OMP_CLAUSE_REDUCTION array section
* cp-gimplify.c (gimplify_to_rvalue): New function.
(cp_gimplify_expr): Use it.
2019-10-10 Marek Polacek <>
* typeck.c (comp_ptr_ttypes_real): Change the return type to bool.
Use false instead of 0.
2019-10-10 Jakub Jelinek <>
* parser.h (struct cp_omp_declare_simd_data): Add variant_p member.
* parser.c (cp_ensure_no_omp_declare_simd): Handle both declare simd
and declare variant.
(cp_parser_oacc_all_clauses): Formatting fix.
(cp_parser_omp_all_clauses): Add NESTED_P argument, if true, terminate
processing on closing paren and don't skip to end of pragma line.
(cp_parser_omp_declare_simd): Add VARIANT_P argument. Handle also
declare variant.
(omp_construct_selectors, omp_device_selectors,
omp_implementation_selectors, omp_user_selectors): New variables.
cp_finish_omp_declare_variant): New functions.
(cp_parser_late_parsing_omp_declare_simd): Handle also declare variant.
(cp_parser_omp_declare): Handle declare variant.
2019-10-09 Jason Merrill <>
* cp-tree.h (template_info_decl_check): Check ENABLE_TREE_CHECKING.
2019-10-09 Marek Polacek <>
PR c++/91364 - P0388R4: Permit conversions to arrays of unknown bound.
PR c++/69531 - DR 1307: Differently bounded array parameters.
PR c++/88128 - DR 330: Qual convs and pointers to arrays of pointers.
* call.c (build_array_conv): Build ck_identity at the beginning
of the conversion.
(standard_conversion): Pass bounds_none to comp_ptr_ttypes_const.
(maybe_warn_array_conv): New.
(convert_like_real): Call it. Add an error message about converting
from arrays of unknown bounds.
(conv_get_original_expr): New.
(nelts_initialized_by_list_init): New.
(conv_binds_to_array_of_unknown_bound): New.
(compare_ics): Implement list-initialization ranking based on
array sizes, as specified in DR 1307 and P0388R.
* cp-tree.h (comp_ptr_ttypes_const): Adjust declaration.
(compare_bounds_t): New enum.
* typeck.c (comp_array_types): New bool and compare_bounds_t
parameters. Use them.
(structural_comptypes): Adjust the call to comp_array_types.
(similar_type_p): Handle ARRAY_TYPE.
(build_const_cast_1): Pass bounds_none to comp_ptr_ttypes_const.
(comp_ptr_ttypes_real): Don't check cv-quals of ARRAY_TYPEs. Use
comp_array_types to compare array types. Look through arrays as per
DR 330.
(comp_ptr_ttypes_const): Use comp_array_types to compare array types.
Look through arrays as per DR 330.
2019-10-09 Marek Polacek <>
PR c++/92032 - DR 1601: Promotion of enum with fixed underlying type.
* call.c (standard_conversion): When converting an enumeration with
a fixed underlying type to the underlying type, give it the cr_promotion
(compare_ics): Implement a tiebreaker as per CWG 1601.
2019-10-08 Andrew Sutton <>
Jason Merrill <>
Update the concepts implementation to conform to the C++20
specification, improve compile times, and generally clean up
the implementation.
* call.c (build_new_function_call): Don't evaluate concepts here.
(constraint_failure): Don't record the template.
(print_z_candidate): Don't extract the template.
* class.c (add_method): When overloading, hide ineligible special
member fns.
(check_methods): Set TYPE_HAS_COMPLEX_* here.
* constexpr.c (cxx_eval_constant_expression): Evaluate concepts.
(maybe_initialize_fundef_copies_table): Remove.
(get_fundef_copy): Use hash_map_safe_get_or_insert.
(clear_cv_and_fold_caches): Clear the satisfaction cache.
* (known_non_bool_p): New.
(parsing_constraint_expression_sentinel): Renamed from
(check_constraint_operands): New.
(check_constraint_atom): New.
(finish_constraint_binary_op): New.
(finish_constraint_or_expr): Likewise.
(finish_constraint_and_expr): Likewise.
(finish_constraint_primary_expr): Likewise.
(combine_constraint_expressions): New.
(finish_requires_expr): Add location parm.
(get_concept_definition): Return the initializer of concept definitions.
(get_template_head_requirements): New.
(get_trailing_function_requirements): New.
(deduce_constrained_parameter): Check if the identifier or template-id
is a concept definition.
(resolve_concept_definition_check): Removed.
(resolve_variable_concept_check): Removed.
(resolve_concept_check): New.
(resolve_constraint_check): Handle concept definitions.
converting arguments.
(function_concept_check_p): Removed.
(variable_concept_check_p): Removed.
(unpack_concept_check): New.
(get_concept_check_template): New.
(build_call_check): Moved and renamed to build_function_check.
(build_concept_check_arguments): make static.
(build_function_check): Always do overload resolution
in order to force conversion of template arguments (i.e., actually
check that the use of a concept is valid).
(build_standard_check): Renamed from build_real_concept_check.
(build_real_concept_check): Build checks for C++2a concepts by
(build_wildcard_concept_check): New.
(build_concept_check): Use build_real_concept_check. New overload.
(build_constraints): Save expressions, not normalized constraints.
(build_concept_id): New. Pass tf_warning_or_error.
(build_type_constraint): New.
(finish_type_constraints): New.
(associate_classtype_constraints): Also add constraints to union
types. Note the original declaration in errors. Don't return
error_mark_node in order to avoid an assertion later.
(push_down_pack_expansion): Remove.
(finish_shorthand_constraint): Make fold expressions, not naked
parameter packs. Always apply the constraint to each template argument.
(check_introduction_list): New. Fail if not enough
names are introduced.
(finish_template_introduction): Don't normalize constraints. Pass
tsubst flags. Check for insufficient introductions.
(placeholder_extract_concept_and_args): Handle the template-id case.
Unpack function concept checks correctly.
(tsubst_simple_requirement): Return errors if they occur. Don't
process as a template.
(tsubst_type_requirement): Likewise.
(type_deducible_p): New. Wrap the input expression in parens for the
purpose of deduction.
(expression_convertible_t): New.
(tsubst_compound_requirement): Use new deduction, conversion predicates.
(tsubst_nested_requirement): Return errors if they occur. Don't
process as a template. Instantiate and evaluate the nested requirement.
(tsubst_valid_expression_requirement): New.
(tsubst_simple_requirement): Use tsubst_valid_expression_requirement.
(tsubst_compound_requirement): Use tsubst_valid_expression_requirement.
(check_constaint_variables): New.
(tsubst_constraint_variables): Check that type substitutions are valid.
(tsubst_requires_expr): Likewise. Produce new requires-exprs during
template substitution. Copy the previous local specialization stack,
so references to non-local parameters can be found. Use cp_unevaluated.
(tsubst_constraint): New. Don't evaluate concept checks.
(subst_info): New.
(norm_info): New. Used to build a normalization tree for concept check
(debug_parameter_mapping): New.
(debug_argument_list): New.
(expand_concept): Removed.
(normalize_logical_operation): Pass subst_info through call.
(normalize_pack_expansion): Remove.
(normalize_simple_requirement): Removed
(normalize_type_requirement): Removed
(normalize_compound_requirement): Removed
(normalize_nested_requirement): Removed
(normalize_requirement): Removed
(normalize_requirements): Removed
(normalize_requires_expression): Removed
(normalize_variable_concept_check): Removed.
(normalize_function_concept_check): Removed.
(normalize_concept_check): Merged all normalize_*_check here.
Substitute through written template arguments before normalizing the
definition. Only substitute the innermost template arguments.
(check_for_logical_overloads): Delete.
(map_arguments): New. Associate template parameters with arguments.
(build_parameter_mapping): New. Extract used parameters.
(normalize_expression): Rewrite.
(normalize_conjunction): Removed
(normalize_disjunction): Removed
(normalize_predicate_constraint): Removed
(normalize_parameterized_constraint): Removed
(normalized_map): New variable.
(get_normalized_constraints): New entry point for normalization.
Establishes a timer.
(get_normalized_constraints_from_info): New.
(get_normalized_constraints_from_decl): New. Turn on template processing
prior to normalization. Handle inheriting ctors. Build the
normalization arguments from the full set of template parameters of the
most general template. This guarantees that we have no concrete arguments
in the parameter mapping (e.g., from template members of class
templates). Cache normalizations.
(normalize_concept_definition): New. Cache normalizations.
(normalize_template_requirements): New.
(normalize_nontemplate_requirements): New.
(normalize_constraint_expression): New.
(tsubst_parameter_mapping): New.
(get_mapped_args): New.
(parameter_mapping_equivalent_p): New. Use template_args_equal.
(atomic_constraints_identical_p): New.
(hash_atomic_constraint): New.
(satisfying_constraint_p): New. Guard against recursive evaluation of
constraints during satisfaction.
(satisfy_conjunction): New.
(satisfy_disjunction): New.
(sat_entry): New class for hashing satisfaction results.
(sat_hasher): New hash traits.
(sat_cache): New.
(get_satisfaction): New. Returns cached satisfaction result.
(save_satisfaction): New. Caches a satisfaction result.
(clear_satisfaction_cache): New.
(satisfaction_cache): New. Helps manage satisfaction cache requests.
(decl_satisfied_cache): New.
(satisfy_atom): New.
(satisfy_constraint_r): New.
(satisfy_constraint): Use new satisfaction algorithm.
(evaluate_concept_check): New.
(evaluate_concept): Removed.
(evaluate_function_concept): Removed.
(evaluate_variable_concept): Removed.
(satisfy_constraint_expression): New.
(constraint_expression_satisfied_p): New.
(constraints_satisfied_p): Use strip_inheriting_ctors. Use
(more_constrained): Normalize before calling out to subsumption. Allow
classes as arguments.
(strictly_subsumes): Allow non-templates as arguments. Accept a new
template argument.
(weakly_subsumes): New.
(at_least_as_constrained): Removed.
(diagnose_other_expression): Removed.
(diagnose_predicate_constraint): Removed.
(diagnose_pack_expansion): Removed.
(diagnose_check_constraint): Removed.
(diagnose_logical_constraint): Removed.
(diagnose_expression_constraint): Removed.
(diagnose_type_constraint): Removed.
(diagnose_implicit_conversion_constraint): Removed.
(diagnose_argument_deduction_constraint): Removed.
(diagnose_exception_constraint): Removed.
(diagnose_parameterized_constraint): Removed.
(diagnose_argument_deduction_constraint): Removed.
(diagnose_argument_deduction_constraint): Removed.
(diagnose_argument_deduction_constraint): Removed.
(diagnose_trait_expr): New.
(diagnose_requires_expr): New.
(diagnose_atomic_constraint): New.
(diagnose_valid_expression) Stop wrongly diagnosing valid expressions.
Don't substitute as if in template decls. This causes substitution
to generate expressions that aren't suitable for use with the noexcept
(diagnose_valid_type) Likewise.
(diagnose_compound_requirement) Actually emit diagnostics for
the causes of errors.Call force_paren_expr_uneval.
(diagnose_declaration_constraints): Turn on template processing to
suppress certain analyses.
* cp-objcp-common.c (cp_common_init_ts): Make concepts typed.
(cp_get_debug_type): Use hash_map_safe_*.
* cp-tree.h: New function declarations for semantic actions, other
facilities. Remove declaration no longer used or needed. Remove
unused _CONSTR macros.
(template_info_decl_check): Factor macro check into an inline function.
(DECL_TEMPLATE_INFO): Use new check facility.
(finish_concept_definition): New. Don't invalid concept declarations
with invalid initializers.
(find_template_parameters): New.
(concept_definition_p): New.
(concept_check_p): New.
(variable_concept_check_p): New.
(force_paren_expr_uneval): New.
(ovl_iterator::using_p): A USING_DECL by itself was also
introduced by a using-declaration.
(struct tree_template_info): Use tree_base instead of
tree_common. Add tmpl and args fields.
(struct tree_trait_expr): Add locus field.
(enum tsubst_flags): Add tf_norm as a hint to generate normalization
context when diagnosing constraint failure.
* cp-tree.def: Remove unused _CONSTR nodes and rename PRED_CONSTR
* cxx-pretty-print.c: Remove constraint printing code.
(pp_cxx_concept_definition): New.
(pp_cxx_template_declaration): Print concept definitions.
(pp_cxx_check_constraint): Update printing for concept definitions.
(pp_cxx_nested_name_specifier): Fix a weird
case where we're printing '::::' for concepts.
(simple_type_specifier): Print requirements for placeholder types.
(pp_cxx_constrained_type_spec): Print the associated requirements of
a placeholder type.
(pp_cxx_compound_requirement): Add space before the '->'.
(pp_cxx_parameter_mapping): Print the parameter mapping.
(pp_cxx_atomic_constraint): Use the function above.
* decl.c (redeclaration_error_message): New error for concepts.
(grokdeclarator): Check for and disallow decltype(auto) in parameter
(grokfndecl): Don't normalize constraints. Add check for constraints
on declaration.
(grokvardecl): Don't normalize constraints.
(grok_special_member_properties): Don't set TYPE_HAS_COMPLEX_*.
(function_requirements_equivalent_p): New. Compare trailing
requires clauses. Compare combined constraints in pre-C++20 mode.
(decls_match): Compare trailing requires clauses. Compare template
heads for function templates. Remove old constraint comparison.
Simplify comparison of functions, function templates.
(duplicate_function_template_decls): New. Refactor a nasty if
condition into a single predicate.
(require_deduced_type): Don't complain if we already complained about
deduction failure.
(finish_function): Perform auto deduction to ensure that constraints
are checked even when functions contain no return statements. Only do
auto deduction if we haven't previously seen any return statements.
This prevents multiple diagnostics of the same error.
(store_decomp_type): Remove.
(cp_finish_decomp): Use hash_map_safe_put.
* error.c: Remove constraint printing code.
(dump_decl): Dump concept definitions. Handle wildcard declarations.
(dump_template_decl): Likewise.
(dump_type): Print associated requirements for placeholder
(rebuild_concept_check): New.
(maybe_print_single_constraint_context): New.
(maybe_print_constraint_context): Recursively print nested contexts.
* init.c (get_nsdmi): Use hash_map_safe_*.
* lambda.c (maybe_add_lambda_conv_op): Bail if deduction failed.
(add_capture): Copy parameter packs from init.
(lambda_capture_field_type): Always use auto for init-capture.
* Completely rewrite.
(constraint_hash): New.
(clause/ctor): Save atoms in the hash table.
(replace): Save atoms during replacement.
(insert): Save atoms during insertion.
(contains): Only search the hash table for containment.
(clause): Keep a hash of atomic constraints.
(clause::clause): Explicitly copy the hash table when copying.
(disjunction_p, conjunction_p, atomic_p, dnf_size, cnf_size): New.
(diagnose_constraint_size): New.
(subsumes_constraints_nonnull): Compare the sizes of normalized formula
to determine the cheapest decomposition.
* name-lookup.c (diagnose_name_conflict): Diagnose name issues with
(matching_fn_p): Check constraints.
(push_class_level_binding_1): Move overloaded functions case down,
accept FUNCTION_DECL as target_decl.
* parser.c (enum required_token): New required token for auto.
(make_location): Add overload taking lexer as last parm.
(cp_parser_required_error): Diagnose missing auto.
(cp_parser_diagnose_ungrouped_constraint_plain): New.
(cp_parser_diagnose_ungrouped_constraint_plain): New.
(cp_parser_constraint_primary_expression): New. Tentatively parse the
primary expression. If that fails tentatively parse a lower
precedence expression in order to diagnose the error.
(cp_parser_check_non_logical_constraint): New. Performs a trial
parse of the right-hand-side of non-logical operators in order to
generate good diagnostics.
(cp_parser_constraint_logical_and_expression): New.
(cp_parser_constraint_logical_or_expression): New.
(cp_parser_requires_clause_expression): New.
(cp_parser_requires_clause): Renamed to cp_parser_constraint_expression.
(cp_parser_requires_clause_opt): Parse the requires-clause differently
in -fconcepts and -std=c++2a modes.
(cp_parser_requirement_list): Rename to cp_parser_requirement_seq.
Rewrite so that semicolons are parsed
along with requirements, not the sequence.
(cp_parser_simple_requirement): Expect a semicolon at end.
(cp_parser_compound_requirement): Expect a semicolon at end. Only
allow trailing-return-type with -fconcepts-ts.
(cp_parser_nested_requirement): Expect a semicolon at end. Parse
(cp_parser_concept_definition): New. Don't fail parsing the concept
definition if the initializer is ill-formed. Don't declare the concept
before parsing the initializer.
(cp_parser_constraint_expression): Declare earlier.
(cp_parser_type_requirement): Current scope is not valid.
(cp_parser_requires_expression): Commit to the tentative parse.
(cp_parser_decl_specifier_seq): Warn when concept appears to be used
as a decl-specifier.
(cp_parser_template_declaration_after_parameters): Parse concept
(cp_parser_template_id): Don't try to resolve a concept template-id yet.
(cp_parser_template_id_expr): Resolve it as a concept check.
(cp_parser_decl_specifier_seq): Warn on 'concept bool'.
(cp_parser_type_parameter): Combine expressions not
(cp_parser_explicit_template_declaration): Combine expressions not
(cp_parser_maybe_concept_name): Removed.
(cp_parser_simple_type_specifier): Handle an error condition of
a bad constrained type specifier. Expect auto or decltype after
a concept name. Also handle the case where we have a template-id
as a concept check.
(cp_parser_template_introduction): Diagnose errors on invalid
introductions. Give up if it doesn't start with a concept name.
Pedwarn if not -fconcepts-ts.
(synthesize_implicit_template_parm): Don't do consistent binding.
Use a new flag for constrained parameters. Combine expressions,
not constraints. Fail if we get a placeholder in block scope.
Placeholders that do not constrain types are not allowed in parameter
declarations, so don't handle them.
(cp_parser_placeholder_type_specifier): New. Implement parsing of
placeholder type specifiers following a concept name or partial
concept check. Disallow decltype(auto) parameters.
(cp_parser_nested_name_specifier_opt): If the token is already
(cp_parser_id_expression, cp_parser_unqualified_id): Call
(cp_parser_placeholder_type_specifier): Add tentative parm. Don't
(cp_parser_trait_expr): Pass trait_loc down.
(cp_parser_postfix_expression): Do set location of dependent member
* pt.c (finish_concept_definition): New.
(push_template_decl_real): Handle concept definitions.
(start_concept_definition): Let push_template_decl_real handle the
creation of the template.
(get_constraints): Return null if the table hasn't been initialized.
(tsubst_copy_and_build): Build template-id expressions for concept
[TRAIT_EXPR]: Pass trait_loc down.
(lookup_template_class_1): Add the template name to the constraint
failure diagnostic.
(lookup_and_finish_template_variable): Build concept checks
with the correct arguments.
(tsubst_function_decl): Don't substitute through constraints.
Always associate constraints with functions.
(template_parm_level_and_index): Make non-static.
(for_each_template_parm_r): Handle requires expressions.
(keep_template_parm): New.
(find_template_parameters): New.
(more_specialized_fn): Change how winners and losers are chosen.
(make_constrained_auto): Don't normalize constraints.
(template_parameters_equivalent_p): New. Compare template
parameters. Add a comparison for implicitly vs. explicitly declared
(template_parameter_lists_equivalent_p): New. Compare template
parameter lists.
(template_requirements_equivalent_p): New.
(template_heads_equivalent_p): New. Compare template heads.
(template_parameter_constraints_equivalent_p): New.
(is_compatible_template_arg): Use weakly_subsumes.
(maybe_new_partial_specialization): Use new constraint comparison
for finding specializations.
(process_partial_specialization): Pass main template as argument.
(more_specialized_partial_spec): Don't immediately return when
detecting a winner.
(make_constrained_auto): Handle concept definitions.
(do_auto_deduction): Update auto deduction for new concept model.
Extract the function concept correctly; rename constr to check to
reflect the kind of node.
(tsubst): Adjust wildcard argument during substitution.
[DECLTYPE_TYPE]: Remove init-capture handling.
(tsubst_copy_and_build): Build concept checks, not template ids.
Defer checks of function concepts. Handle concepts before variable
templates. Handle calls to function concepts explicitly.
(coerce_template_parms): Use concept_definition_p. Handle a deduction
error where a potentially empty pack can be supplied after the last
parameter of a concept.
(finish_template_variable): Don't process concepts here.
(instantiation_dependent_r): Use concept_check_p.
(tsubst_template_args): Make non-static.
(make_constrained_placeholder_type): New. Refactored from
(make_constrained_auto) Use make_constrained_placeholder_type.
(make_constrained_decltype_auto) New.
(tsubst_function_parms): New.
(value_dependent_expression_p) [TEMPLATE_ID_EXPR]: Use
(push_access_scope, pop_access_scope): No longer static.
(tsubst_template_parm): Substitute TEMPLATE_PARM_CONSTRAINTS.
(tsubst_friend_function): Use tsubst_constraint. Use generic_targs_for.
(get_underlying_template) Use generic_targs_for.
(uses_parameter_packs): Return tree.
(gen_elem_of_pack_expansion_instantiation): Don't push
(prepend_one_capture): New.
(tsubst_lambda_expr): Use prepend_one_capture. Don't touch
(template_parms_level_to_args): No longer static.
(add_outermost_template_args): Likewise.
(find_template_parameter_info): New. Provide context for finding
template parameters.
(keep_template_parm): Don't keep parameters declared at depth levels
greater than those of the template parameters of the source declaration.
Don't propagate cv-qualified types. Return 0, so we find all template
parameters, not the just first.
(any_template_parm_r): New. Handle cases that are mishandled by
(generic_targs_for): Factor out of coerce_template_args_for_ttp.
(tsubst_argument_pack): Factor out of tsubst_template_args.
(constraint_sat_entry): Removed.
(constraint_sat_hasher): Removed.
(concept_spec_entry): Removed.
(concept_spec_hasher): Removed.
(constraint_memos): Removed.
(concept_memos): Removed.
(lookup_constraint_satisfaction): Removed.
(memoize_constraint_satisfaction): Removed.
(lookup_concept_satisfaction): Removed.
(memoize_concept_satisfaction): Removed.
(concept_expansions): Removed.
(get_concept_expansion): Removed.
(save_concept_expansion): Removed.
(init_constraint_processing): Remove initialization of non-existing
(find_template_requirement): New. Search for the sub-requirement
within the associated constraints.
(convert_generic_types_to_packs): Also transform the associated
constraint and update the current template requirements.
(store_defaulted_ttp, lookup_defaulted_ttp): Remove.
(add_defaults_to_ttp): Use hash_map_safe_*.
* semantics.c (finish_call_expr): Diagnose calls to concepts.
Handle concept checks explicitly.
(finish_id_expression): Evaluate variable concepts as part of
id-expression processing. Don't treat variable concepts as variables,
and don't process function concepts as plain id-expressions.
(force_paren_expr): Add even_uneval parm.
(finish_trait_expr): Add location parm.
* tree.c (special_memfn_p): New.
(cp_expr_location): Handle TRAIT_EXPR.
* typeck.c (check_return_expr): Actually use the diagnostic kind
when performing return-type deduction.
* typeck2.c (build_functional_cast): Don't rely on the location of
2019-10-09 Paolo Carlini <>
* decl.c (grok_ctor_properties): Use DECL_SOURCE_LOCATION.
* typeck.c (cp_build_binary_op): Use the op_location_t argument
in many error messages.
2019-10-08 Martin Sebor <>
PR c++/92001
* call.c (maybe_warn_class_memaccess): Handle arrays.
2019-10-07 Paolo Carlini <>
* call.c (resolve_args): Use cp_expr_loc_or_input_loc in one place.
* decl.c (grokdeclarator): Use id_loc in one place.
* decl2.c (build_anon_union_vars): Use DECL_SOURCE_LOCATION.
* parser.c (cp_parser_delete_expression): Fix the location of the
returned expression.
(cp_parser_throw_expression): Likewise.
* pt.c (determine_specialization): Use DECL_SOURCE_LOCATION.
2019-10-05 Jakub Jelinek <>
PR c++/91369 - Implement P0784R7: constexpr new
* cp-tree.h (enum cp_tree_index): Add CPTI_HEAP_UNINIT_IDENTIFIER,
(heap_uninit_identifier, heap_identifier, heap_deleted_identifier):
(type_has_constexpr_destructor, build_new_constexpr_heap_type,
cxx_constant_dtor): Declare.
* class.c (type_maybe_constexpr_default_constructor): Make static.
(type_maybe_constexpr_destructor, type_has_constexpr_destructor): New
(finalize_literal_type_property): For c++2a, don't clear
CLASSTYPE_LITERAL_P for types without trivial destructors unless they
have non-constexpr destructors.
(explain_non_literal_class): For c++2a, complain about non-constexpr
destructors rather than about non-trivial destructors.
* constexpr.c: Include stor-layout.h.
(struct constexpr_global_ctx): New type.
(struct constexpr_ctx): Add global field, remove values and
(cxx_replaceable_global_alloc_fn): New inline function.
(cxx_eval_call_expression): For c++2a allow calls to replaceable
global allocation functions, for new return address of a heap uninit
var, for delete record its deletion. Change ctx->values->{get,put} to
(non_const_var_error): Add auto_diagnostic_group sentinel. Emit
special diagnostics for heap variables.
(cxx_eval_store_expression): Change ctx->values->{get,put} to
(cxx_eval_loop_expr): Initialize jump_target if NULL. Change
new_ctx.values->remove to ctx->global->values.remove.
(cxx_eval_constant_expression): Change *ctx->constexpr_ops_count
to ctx->global->constexpr_ops_count. Change ctx->values->{get,put} to
<case NOP_EXPR>: Formatting fix. On cast of replaceable global
allocation function to some pointer type, adjust the type of
the heap variable and change name from heap_uninit_identifier
to heap_identifier.
(find_heap_var_refs): New function.
(cxx_eval_outermost_constant_expr): Add constexpr_dtor argument,
handle evaluation of constexpr dtors and add tracking of heap
variables. Use tf_no_cleanup for get_target_expr_with_sfinae.
(cxx_constant_value): Adjust cxx_eval_outermost_constant_expr caller.
(cxx_constant_dtor): New function.
(maybe_constant_value, fold_non_dependent_expr_template,
maybe_constant_init_1): Adjust cxx_eval_outermost_constant_expr
(potential_constant_expression_1): Ignore clobbers. Allow
* decl.c (initialize_predefined_identifiers): Add heap identifiers.
(decl_maybe_constant_destruction): New function.
(cp_finish_decl): Don't clear TREE_READONLY for constexpr variables
with non-trivial, but constexpr destructors.
(register_dtor_fn): For constexpr variables with constexpr non-trivial
destructors call cxx_maybe_build_cleanup instead of adding destructor
calls at runtime.
(expand_static_init): For constexpr variables with constexpr
non-trivial destructors call cxx_maybe_build_cleanup.
(grokdeclarator): Allow constexpr destructors for c++2a. Formatting
(cxx_maybe_build_cleanup): For constexpr variables with constexpr
non-trivial destructors call cxx_constant_dtor instead of adding
destructor calls at runtime.
* init.c: Include stor-layout.h.
(build_new_constexpr_heap_type, maybe_wrap_new_for_constexpr): New
(build_new_1): For c++2a and new[], add cast around the alloc call
to help constexpr evaluation figure out the type of the heap storage.
(build_vec_delete_1): Set DECL_INITIAL of tbase and emit a DECL_EXPR
for it instead of initializing an uninitialized variable.
* method.c: Include intl.h.
definitions earlier.
(process_subob_fn): Add sfk argument, adjust non-constexpr call
diagnostics based on it.
(walk_field_subobs): Formatting fixes. Adjust process_subob_fn caller.
(synthesized_method_base_walk): Likewise.
(synthesized_method_walk): Set *constexpr_p to true for dtors in c++2a.
Fix up DR number in comment.
(implicitly_declare_fn): Formatting fix.
* typeck2.c (store_init_value): Don't call cp_fully_fold_init on
initializers of automatic non-constexpr variables in constexpr
2019-10-04 Jakub Jelinek <>
PR c++/71504
* constexpr.c (cxx_fold_indirect_ref_1): New function.
(cxx_fold_indirect_ref): Use it.
PR c++/91974
* cp-gimplify.c (cp_gimplify_expr) <case CALL_EXPR>: For
-fstrong-eval-order ensure CALL_EXPR_FN side-effects are evaluated
before any arguments. Additionally, ensure CALL_EXPR_FN that isn't
invariant nor OBJ_TYPE_REF nor SSA_NAME is forced into a temporary.
2019-10-03 Paolo Carlini <>
* init.c (build_new): Use cp_expr_loc_or_input_loc in two places.
* name-lookup.c (do_pushdecl): Use DECL_SOURCE_LOCATION.
(push_class_level_binding_1): Likewise.
(set_decl_namespace): Likewise.
2019-10-03 Jakub Jelinek <>
* constexpr.c (cxx_eval_constant_expression) <case CLEANUP_STMT>: If
not skipping upon entry to body, run cleanup with the same *jump_target
as it started to run the cleanup even if the body returns, breaks or
(potential_constant_expression_1): Allow CLEANUP_STMT.
* constexpr.c (cxx_eval_store_expression): Formatting fix. Handle
const_object_being_modified with array type.
2019-10-02 Jason Merrill <>
* typeck2.c (store_init_value): Only clear_cv_and_fold_caches if the
value is constant.
2019-09-30 Jason Merrill <>
Use hash_map_safe_* functions.
* constexpr.c (maybe_initialize_fundef_copies_table): Remove.
(get_fundef_copy): Use hash_map_safe_get_or_insert.
* cp-objcp-common.c (cp_get_debug_type): Use hash_map_safe_*.
* decl.c (store_decomp_type): Remove.
(cp_finish_decomp): Use hash_map_safe_put.
* init.c (get_nsdmi): Use hash_map_safe_*.
* pt.c (store_defaulted_ttp, lookup_defaulted_ttp): Remove.
(add_defaults_to_ttp): Use hash_map_safe_*.
2019-10-02 Richard Biener <>
PR c++/91606
* decl.c (build_ptrmemfunc_type): Mark pointer-to-member
fat pointer structure members as DECL_NONADDRESSABLE_P.
2019-09-28 Marek Polacek <>
PR c++/91889 - follow-up fix for DR 2352.
* call.c (involves_qualification_conversion_p): New function.
(direct_reference_binding): Build a ck_qual if the conversion
would involve a qualification conversion.
(convert_like_real): Strip the conversion created by the ck_qual
in direct_reference_binding.
PR c++/91921 - stray warning with -Woverloaded-virtual.
* class.c (warn_hidden): Only emit the second part of
-Woverloaded-virtual if the first part was issued. Use inform instead
PR c++/91923 - failure-to-SFINAE with class type NTTP in C++17.
* pt.c (invalid_nontype_parm_type_p): Only emit errors when
2019-09-27 Jakub Jelinek <>
PR c++/88203
* parser.c (cp_parser_omp_var_list_no_open): Parse predefined
* semantics.c (finish_omp_clauses): Allow predefined variables in
shared and firstprivate clauses, even when they are predetermined
* cp-gimplify.c (cxx_omp_predetermined_sharing_1): Return
OMP_CLAUSE_DEFAULT_SHARED for predefined variables.
2019-09-27 Jason Merrill <>
* constexpr.c (cxx_fold_indirect_ref): Use similar_type_p.
(cxx_eval_indirect_ref): Likewise. Improve error location.
* cp-tree.h (class iloc_sentinel): New.
* decl.c (grokdeclarator, finish_enum_value_list): Use it.
* mangle.c (mangle_decl_string): Use it.
* pt.c (perform_typedefs_access_check): Use it.
2019-09-27 Richard Sandiford <>
* cp-tree.h (build_cxx_call): Take the original function decl
as an optional final parameter.
(cp_build_function_call_vec): Likewise.
* call.c (build_cxx_call): Likewise. Pass all built-in calls to
* typeck.c (build_function_call_vec): Take the original function
decl as an optional final parameter and pass it to
(cp_build_function_call_vec): Take the original function
decl as an optional final parameter and pass it to build_cxx_call.
2019-09-25 Marek Polacek <>
PR c++/91877 - ICE with converting member of packed struct.
* call.c (convert_like_real): Use similar_type_p in an assert.
2019-09-25 Paolo Carlini <>
* name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION.
(check_local_shadow): Use it in three additional places.
2019-09-24 Jason Merrill <>
* parser.c (cp_parser_postfix_expression): Do set location of
dependent member call.
2019-09-24 Marek Polacek <>
PR c++/91868 - improve -Wshadow location.
* name-lookup.c (check_local_shadow): Use DECL_SOURCE_LOCATION
instead of input_location.
PR c++/91845 - ICE with invalid pointer-to-member.
* expr.c (mark_use): Use error_operand_p.
* typeck2.c (build_m_component_ref): Check error_operand_p after
calling mark_[lr]value_use.
2019-09-23 Paolo Carlini <>
* pt.c (check_explicit_specialization): Use cp_expr_loc_or_input_loc.
(process_partial_specialization): Likewise.
(convert_nontype_argument_function): Likewise.
(invalid_tparm_referent_p): Likewise.
(convert_template_argument): Likewise.
(check_valid_ptrmem_cst_expr): Tidy.
2019-09-23 Jason Merrill <>
PR c++/91809 - bit-field and ellipsis.
* call.c (convert_arg_to_ellipsis): Don't call decay_conversion for
arithmetic arguments.
2019-09-23 Marek Polacek <>
PR c++/91844 - Implement CWG 2352, Similar types and reference binding.
* call.c (reference_related_p): Use similar_type_p instead of
(reference_compatible_p): Update implementation to match CWG 2352.
* cp-tree.h (similar_type_p): Declare.
* typeck.c (similar_type_p): New.
2019-09-22 Marek Polacek <>
PR c++/91819 - ICE with operator++ and enum.
* call.c (build_new_op_1): Set arg2_type.
2019-09-17 Jason Merrill <>
* parser.c (cp_parser_statement): Handle [[likely]] on
2019-09-19 Jason Merrill <>
* call.c (build_new_op_1): Don't apply any standard conversions to
the operands of a built-in operator. Don't suppress conversions in
* typeck.c (cp_build_unary_op): Do integral promotions for enums.
2019-09-16 Paolo Carlini <>
* decl.c (grokdeclarator): Use declspecs->locations and
declarator->id_loc in a few error messages.
* pt.c (finish_member_template_decl): Use DECL_SOURCE_LOCATION.
(push_template_decl_real): Likewise.
2019-09-15 Jason Merrill <>
PR c++/30277 - int-width bit-field promotion.
PR c++/33819 - long bit-field promotion.
* typeck.c (cp_perform_integral_promotions): Handle large bit-fields
properly. Handle 32-bit non-int bit-fields properly.
(is_bitfield_expr_with_lowered_type): Don't look through NOP_EXPR.
PR c++/82165 - enum bitfields and operator overloading.
* call.c (build_new_op_1): Use unlowered_expr_type.
* call.c (build_new_op_1): Don't apply any standard conversions to
the operands of a built-in operator. Don't suppress conversions in
* typeck.c (cp_build_unary_op): Do integral promotions for enums.
2019-09-15 Marek Polacek <>
PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
* pt.c (build_non_dependent_expr): Call build_non_dependent_expr for
the first operand.
2019-09-15 Nathan Sidwell <>
* cp-tree.h (DECL_CLONED_FUNCTION_P): Reimplement using
IDENTIFIER_CDTOR_P, correct documentation.
(DECL_CLONED_FUNCTION): Directly access field.
(decl_cloned_function_p): Delete.
* class.c (decl_cloned_function_p): Delete.
* pt.c (instantiate_template_1): Check DECL_CHAIN is a decl.
2019-09-11 Nathan Sidwell <>
* c-objcp-common.c (cp-objcp-common.c): Alphababetize and
correctly mark all C++ nodes.
* decl.c (cp_tree_node_structure): Alphabetize.
2019-09-10 Marek Polacek <>
PR c++/91673 - ICE with noexcept in alias-declaration.
* parser.c (CP_PARSER_FLAGS_DELAY_NOEXCEPT): New parser flag.
(cp_parser_lambda_declarator_opt): Pass CP_PARSER_FLAGS_NONE to
(cp_parser_direct_declarator): Adjust a call to
(cp_parser_member_declaration): Pass CP_PARSER_FLAGS_DELAY_NOEXCEPT
to cp_parser_declarator if not processing a friend or typedef
(cp_parser_late_noexcept_specifier): Adjust a call to
(cp_parser_noexcept_specification_opt): New parameter for parser flags,
drop the FRIEND_P parameter. Use the new parameter.
(cp_parser_exception_specification_opt): Likewise.
(cp_parser_transaction): Adjust a call to
(cp_parser_transaction_expression): Likewise.
2019-09-10 Marek Polacek <>
PR c++/91705 - constexpr evaluation rejects ++/-- on floats.
* constexpr.c (cxx_eval_increment_expression): Call fold_simple on
the offset.
2019-09-10 Paolo Carlini <>
* decl.c (has_designator_problem): Use cp_expr_loc_or_input_loc
in error_at.
(build_enumerator): Likewise.
(cp_finish_decl): Use DECL_SOURCE_LOCATION.
(grokdeclarator): Use id_loc in two error_at; change errror
message about constinit together constexpr to use two ranges.
2019-09-09 Marek Polacek <>
PR c++/84374 - diagnose invalid uses of decltype(auto).
* decl.c (grokdeclarator): Diagnose wrong usage of decltype(auto) in
a function declaration.
2019-09-06 Nathan Sidwell <>
PR c++/91125
(struct lang_decl_base): Remove repo_available_p.
* decl.c (duplicate_decls): Don't copy DECL_REPO_AVAILABLE_P.
(Reserve TREE_LANG_FLAG_3 for modules.
* cp-tree.h (DECL_CONSTRUCTION_VTABLE_P): Delete.
* class.c (build_ctor_vtbl_group): Don't set
* decl2.c (determine_visibility_from_class): Don't check
2019-09-06 Martin Liska <>
PR c++/91125
* Remove repo.o.
* Likewise.
* cp-tree.h (init_repo): Remove declarations
of repo-related functions.
(repo_emit_p): Likewise.
(repo_export_class_p): Likewise.
(finish_repo): Likewise.
* decl2.c (import_export_class): Always
set -1 value/
(mark_needed): Remove -frepo from comment.
(import_export_decl): Similarly here.
(c_parse_final_cleanups): Remove call of finish_repo.
* lex.c (cxx_init): Remove call to init_repo.
* optimize.c (can_alias_cdtor): Remove dead condition.
* pt.c (push_template_decl_real): Update comment.
(instantiate_decl): Remove dead code used for -frepo.
* repo.c: Remove.
2019-09-05 Marek Polacek <>
PR c++/91644 - ICE with constinit in function template.
* decl.c (start_decl): Call retrofit_lang_decl for constinit variables.
* pt.c (tsubst_expr): Pass LOOKUP_CONSTINIT down to cp_finish_decl for
constinit variables.
2019-09-05 Nathan Sidwell <>
* cp-tree.h (DECL_VTABLE_OR_VTT_P): Forward to DECL_VIRTUAL_P.
2019-09-04 Marek Polacek <>
* call.c (build_over_call): Remove -fdeduce-init-list implementation.
* pt.c (unify): Likewise.
2019-09-01 Marek Polacek <>
PR c++/91129 - wrong error with binary op in template argument.
* typeck.c (warn_for_null_address): Use fold_for_warn instead of
(cp_build_binary_op): Likewise.
2019-08-30 Jason Merrill <>
Add source location to TRAIT_EXPR.
* cp-tree.h (TRAIT_EXPR_LOCATION): New.
(struct tree_trait_expr): Add locus field.
* parser.c (cp_parser_trait_expr): Pass trait_loc down.
* pt.c (tsubst_copy_and_build) [TRAIT_EXPR]: Likewise.
* semantics.c (finish_trait_expr): Add location parm.
* tree.c (cp_expr_location): Handle TRAIT_EXPR.
2019-08-29 Paolo Carlini <>
* decl.c (check_var_type): Add location_t parameter and use it.
(grokdeclarator): Adjust call.
* pt.c (tsubst_decl): Likewise.
* cp-tree.h: Adjust declaration.
2019-08-28 Marek Polacek <>
Implement P1152R4: Deprecating some uses of volatile.
PR c++/91361
* cp-gimplify.c (cp_fold): Set TREE_THIS_VOLATILE.
* decl.c (grokdeclarator): Warn about a volatile-qualified structured
binding and return type.
(grokparms): Warn about a volatile-qualified function parameter.
* expr.c (mark_use) <case MODIFY_EXPR>: Emit a -Wvolatile warning.
* typeck.c (cp_build_unary_op): Emit a -Wvolatile warning for pre and
post ++/-- on a volatile operand.
(genericize_compound_lvalue): Use a better location. Don't lose
(cp_build_modify_expr): Emit a -Wvolatile warning for a compound
assignment whose LHS is volatile-qualified. Build the assignment with
a more precise location.
2019-08-28 Marek Polacek <>
PR c++/91360 - Implement C++20 P1143R2: constinit.
(enum cp_decl_spec): Add ds_constinit.
* decl.c (check_tag_decl): Give an error for constinit in type
(check_initializer): Also check LOOKUP_CONSTINIT.
(cp_finish_decl): Add checking for a constinit declaration. Set
(grokdeclarator): Add checking for a declaration with the constinit
* lex.c (init_reswords): Handle D_CXX20.
* parser.c (cp_lexer_get_preprocessor_token): Pass a better location
to warning_at. Warn about C++20 keywords.
(cp_keyword_starts_decl_specifier_p): Handle RID_CONSTINIT.
(cp_parser_diagnose_invalid_type_name): Add an inform about constinit.
(cp_parser_decomposition_declaration): Maybe pass LOOKUP_CONSTINIT to
(cp_parser_decl_specifier_seq): Handle RID_CONSTINIT.
(cp_parser_init_declarator): Maybe pass LOOKUP_CONSTINIT to
(set_and_check_decl_spec_loc): Add "constinit".
* pt.c (tsubst_decl): Set TINFO_VAR_DECLARED_CONSTINIT.
(instantiate_decl): Maybe pass LOOKUP_CONSTINIT to cp_finish_decl.
* typeck2.c (store_init_value): If a constinit variable wasn't
initialized using a constant initializer, give an error.
2019-08-28 Nathan Sidwell <>
PR c++/90613
* name-lookup.c (cp_emit_debug_info): Check for builtins during
overload iteration.
2019-08-27 Marek Polacek <>
PR c++/81676 - bogus -Wunused warnings in constexpr if.
* semantics.c (maybe_mark_exp_read_r): New function.
(finish_if_stmt): Call it on THEN_CLAUSE and ELSE_CLAUSE.
PR c++/91428 - warn about std::is_constant_evaluated in if constexpr.
* cp-tree.h (decl_in_std_namespace_p): Declare.
* semantics.c (is_std_constant_evaluated_p): New.
(finish_if_stmt_cond): Warn about "std::is_constant_evaluated ()" in
an if-constexpr.
* typeck.c (decl_in_std_namespace_p): No longer static.
2019-08-26 Jason Merrill <>
* decl.c (duplicate_decls): Always merge DECL_DECLARED_CONSTEXPR_P.
2019-08-26 Marek Polacek <>
PR c++/91545 - ICE in constexpr store evaluation.
* constexpr.c (cxx_eval_store_expression): Check FIELD_DECL instead
of DECL_P.
2019-08-24 Nathan Sidwell <>
* class.c (check_for_overrides): Conversion operators need
checking too.
2019-08-24 Paolo Carlini <>
* semantics.c (finish_switch_cond): Improve error message location.
2019-08-23 Jason Merrill <>
* decl2.c (decl_dependent_p): New.
(mark_used): Check it instead of just processing_template_decl.
2019-08-23 Jason Merrill <>
* parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant
2019-08-23 Marek Polacek <>
PR c++/91521 - wrong error with operator->.
* decl.c (grokdeclarator): Return error_mark_node for an invalid
trailing return type.
PR c++/79817 - attribute deprecated on namespace.
* cp-tree.h (cp_warn_deprecated_use_scopes): Declare.
* decl.c (grokdeclarator): Call cp_warn_deprecated_use_scopes.
(type_is_deprecated): Likewise.
* decl2.c (cp_warn_deprecated_use_scopes): New function.
* name-lookup.c (handle_namespace_attrs): Handle attribute deprecated.
* parser.c (cp_parser_namespace_alias_definition): Call
(cp_parser_using_declaration): Likewise.
(cp_parser_using_directive): Likewise.
* semantics.c (finish_id_expression_1): Likewise.
2019-08-23 Nathan Sidwell <>
* class.c (check_for_override): Checking IDENTIFIER_VIRTUAL_P is
sufficient, reorder DECL_OVERRIDE_P check.
2019-08-23 Iain Sandoe <>
PR pch/61250
* parser.c (cp_parser_initial_pragma): Call c_common_no_more_pch ()
after determining that the first token is not
2019-08-22 Marek Polacek <>
PR c++/91304 - prefix attributes ignored in condition.
* parser.c (cp_parser_condition): Handle prefix attributes.
2019-08-21 Richard Sandiford <>
PR c++/91505
* decl.c (duplicate_decls): Call copy_attributes_to_builtin inside
the BUILT_IN_NORMAL block rather than afterward.
2019-08-19 Marek Polacek <>
PR c++/91264 - detect modifying const objects in constexpr.
* constexpr.c (modifying_const_object_error): New function.
(cxx_eval_call_expression): Set TREE_READONLY on a CONSTRUCTOR of
a const-qualified object after it's been fully constructed.
(modifying_const_object_p): New function.
(cxx_eval_store_expression): Detect modifying a const object
during constant expression evaluation.
(cxx_eval_increment_expression): Use a better location when building
up the store.
(cxx_eval_constant_expression) <case DECL_EXPR>: Mark a constant
object's constructor TREE_READONLY.
2019-08-15 Jason Merrill <>
PR c++/90393 - ICE with thow in ?:
PR c++/64372, DR 1560 - Gratuitous lvalue-to-rvalue conversion in ?:
* tree.c (lvalue_kind): Handle throw in one arm.
* typeck.c (rationalize_conditional_expr): Likewise.
(cp_build_modify_expr): Likewise.
2019-08-14 Jason Merrill <>
Implement P0848R3, Conditionally Trivial Special Member Functions.
* tree.c (special_memfn_p): New.
* class.c (add_method): When overloading, hide ineligible special
member fns.
(check_methods): Set TYPE_HAS_COMPLEX_* here.
* decl.c (grok_special_member_properties): Not here.
* name-lookup.c (push_class_level_binding_1): Move overloaded
functions case down, accept FUNCTION_DECL as target_decl.
2019-08-14 Jonathan Wakely <>
PR c++/91436
* name-lookup.c (get_std_name_hint): Fix min_dialect field for
complex_literals and make_unique entries.
2019-08-14 Jakub Jelinek <>
Marek Polacek <>
PR c++/91391 - bogus -Wcomma-subscript warning.
* parser.c (cp_parser_postfix_open_square_expression): Don't warn about
a deprecated comma here. Pass warn_comma_subscript down to
(cp_parser_expression): New bool parameter. Warn about uses of a comma
operator within a subscripting expression.
(cp_parser_skip_to_closing_square_bracket): Revert to pre-r274121 state.
(cp_parser_skip_to_closing_square_bracket_1): Remove.
2019-08-14 Jonathan Wakely <>
* name-lookup.c (get_std_name_hint): Add more entries.
2019-08-14 Paolo Carlini <>
* decl2.c (grok_array_decl): Use the location of the open square
bracket in error message about invalid types.
2019-08-14 Paolo Carlini <>
* decl.c (grokdeclarator): Check here for typedef a function
definition or a member function definition.
(start_function): Adjust.
(grokmethod): Likewise.
2019-08-13 Richard Sandiford <>
PR middle-end/91421
* decl.c (duplicate_decls): Use copy_decl_built_in_function.
* pt.c (declare_integer_pack): Use set_decl_built_in_function.
2019-08-13 Marek Polacek <>
PR c++/90473 - wrong code with nullptr in default argument.
* call.c (null_ptr_cst_p): Update quote from the standard.
* decl.c (check_default_argument): Don't return nullptr when the arg
has side-effects.
2019-08-13 Marek Polacek <>
2019-08-10 Jakub Jelinek <>
* parser.c (cp_parser_omp_clause_name): Parse device_type.
(cp_parser_omp_clause_device_type): New function.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DEVICE_TYPE.
(cp_parser_omp_declare_target): Handle device_type clauses. Remove
diagnostics for declare target with clauses nested in clause-less
declare target declaration-definition-seq.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DEVICE_TYPE.
2019-08-09 Jakub Jelinek <>
* parser.c (check_no_duplicate_clause): Simplify using
(cp_parser_omp_clause_if): Fix up printing of target {enter,exit} data
directive name modifiers.
PR c/91401
* parser.c (cp_parser_omp_clause_dist_schedule): Comment out the
check_no_duplicate_clause call, instead emit a warning for duplicate
dist_schedule clauses.
2019-08-08 Paolo Carlini <>
* decl.c (grokdeclarator): Use id_loc and EXPR_LOCATION in
a few error messages.
2019-08-08 Marek Polacek <>
PR c++/87519 - bogus warning with -Wsign-conversion.
* typeck.c (cp_build_binary_op): Use same_type_p instead of comparing
the types directly.
* constexpr.c (inline_asm_in_constexpr_error): New.
(cxx_eval_constant_expression) <case ASM_EXPR>: Call it.
(potential_constant_expression_1) <case ASM_EXPR>: Likewise.
2019-08-08 Jakub Jelinek <>
* semantics.c (finish_omp_clauses): For C_ORT_OMP
OMP_CLAUSE_USE_DEVICE_* clauses use oacc_reduction_head bitmap
instead of generic_head to track duplicates.
2019-08-07 Marek Polacek <>
PR c++/81429 - wrong parsing of constructor with C++11 attribute.
* parser.c (cp_parser_constructor_declarator_p): Handle the scenario
when a parameter declaration begins with [[attribute]].
2019-08-07 Marek Polacek <>
PR c++/91346 - Implement P1668R1, allow unevaluated asm in constexpr.
* constexpr.c (cxx_eval_constant_expression): Handle ASM_EXPR.
(potential_constant_expression_1) <case ASM_EXPR>: Allow.
* cp-tree.h (finish_asm_stmt): Adjust.
* parser.c (cp_parser_asm_definition): Grab the locaion of "asm" and
use it. Change an error to a pedwarn. Allow asm in C++2a, warn
* pt.c (tsubst_expr): Pass a location down to finish_asm_stmt.
* semantics.c (finish_asm_stmt): New location_t parameter. Use it.
2019-08-07 Jakub Jelinek <>
* parser.c (cp_parser_omp_clause_name): Parse use_device_addr clause.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR.
(cp_parser_omp_target_data): Handle PRAGMA_OMP_CLAUSE_USE_DEVICE_ADDR
like PRAGMA_OMP_CLAUSE_USE_DEVICE_PTR, adjust diagnostics about no
map or use_device_* clauses.
* semantics.c (finish_omp_clauses): For OMP_CLAUSE_USE_DEVICE_PTR
in OpenMP, require pointer or reference to pointer type rather than
pointer or array or reference to pointer or array type. Handle
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_USE_DEVICE_ADDR.
2019-08-06 Jason Merrill <>
PR c++/91378 - ICE with noexcept and auto return type.
* pt.c (maybe_instantiate_noexcept): push_to_top_level.
2019-08-06 Paolo Carlini <>
* decl.c (check_array_designated_initializer): Use
cp_expr_loc_or_input_loc in one place.
2019-08-06 Jakub Jelinek <>
* parser.c (cp_parser_omp_for_loop): For OMP_LOOP, ignore parallel
clauses and predetermine iterator as lastprivate.
* semantics.c (handle_omp_for_class_iterator): Use
OMP_CLAUSE_LASTPRIVATE_TASKLOOP_IV, set it for lastprivate also
on OMP_LOOP construct. If a clause is missing for class iterator
on OMP_LOOP, add firstprivate clause, and if there is private
clause, turn it into firstprivate too.
(finish_omp_for): Formatting fix. For OMP_LOOP, adjust
uses copy ctor instead of default ctor.
* cp-gimplify.c (cp_gimplify_expr): Handle OMP_LOOP like
(cp_fold_r): Likewise.
(cp_genericize_r): Likewise.
(cxx_omp_finish_clause): Also finish lastprivate clause with
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_BIND.
(tsubst_omp_for_iterator): For OMP_LOOP, ignore parallel
clauses and predetermine iterator as lastprivate.
* constexpr.c (potential_constant_expression_1): Handle OMP_LOOP
2019-08-05 Marek Polacek <>
DR 2413 - typename in conversion-function-ids.
* parser.c (cp_parser_conversion_type_id): Call
cp_parser_type_specifier_seq with CP_PARSER_FLAGS_TYPENAME_OPTIONAL
2019-08-05 Paolo Carlini <>
* cp-tree.h (cp_expr_loc_or_input_loc): New.
(cxx_incomplete_type_diagnostic): Use it.
* call.c (build_converted_constant_expr_internal, convert_like_real,
convert_arg_to_ellipsis, convert_for_arg_passing, build_over_call,
build_cxx_call, perform_implicit_conversion_flags,
initialize_reference): Likewise.
* constexpr.c (cxx_eval_internal_function, cxx_eval_call_expression,
eval_and_check_array_index, cxx_eval_store_expression,
cxx_eval_statement_list, cxx_eval_loop_expr,
cxx_eval_constant_expression, potential_constant_expression_1):
* (check_for_logical_overloads,
satisfy_predicate_constraint): Likewise.
* cp-gimplify.c (cp_gimplify_expr): Likewise.
* cvt.c (cp_convert_to_pointer, convert_to_reference,
cp_convert_and_check, ocp_convert, maybe_warn_nodiscard): Likewise.
* decl.c (pop_switch): Likewise.
* decl2.c (delete_sanity): Likewise.
* error.c (location_of): Likewise.
* init.c (maybe_warn_list_ctor, build_aggr_init,
warn_placement_new_too_small, build_new_1, build_vec_init): Likewise.
* lex.c (unqualified_name_lookup_error): Likewise.
* parser.c (cp_parser_initializer_list, cp_parser_omp_for_cond):
* pt.c (check_for_bare_parameter_packs, check_valid_ptrmem_cst_expr,
unify_arg_conversion, convert_nontype_argument,
tsubst_copy_and_build, resolve_typename_type): Likewise.
* semantics.c (maybe_convert_cond, finish_call_expr,
cp_build_vec_convert): Likewise.
* typeck.c (decay_conversion, rationalize_conditional_expr,
cp_build_unary_op, build_x_compound_expr_from_list,
maybe_warn_pessimizing_move): Likewise.
* typeck2.c (check_narrowing, digest_init_r,
process_init_constructor_array): Likewise.
2019-08-05 Tom Honermann <>
* parser.c (cp_parser_template_declaration_after_parameters): Enable
class template argument deduction for non-type template parameters
in literal operator templates.
2019-08-05 Marek Polacek <>
PR c++/91338 - Implement P1161R3: Deprecate a[b,c].
* parser.c (cp_parser_postfix_open_square_expression): Warn about uses
of a comma operator within a subscripting expression.
(cp_parser_skip_to_closing_square_bracket_1): New function, made out
(cp_parser_skip_to_closing_square_bracket): ...this.
2019-08-05 Jason Merrill <>
* semantics.c (force_paren_expr): Preserve location.
2019-08-02 Marek Polacek <>
PR c++/91230 - wrong error with __PRETTY_FUNCTION__ and generic lambda.
* pt.c (value_dependent_expression_p): Consider __PRETTY_FUNCTION__
inside a template function value-dependent.
2019-08-02 Paolo Carlini <>
* tree.c (handle_nodiscard_attribute): Do not warn about nodiscard
applied to a constructor.
2019-08-02 Martin Liska <>
* decl.c (grok_op_properties):
Mark DECL_SET_IS_OPERATOR_DELETE for user-provided delete operators.
2019-08-01 Martin Sebor <>
PR c++/90947
* decl.c (reshape_init_array_1): Avoid truncating initializer
lists containing string literals.
2019-08-01 Marek Polacek <>
PR c++/90805 - detect narrowing in case values.
* decl.c (case_conversion): Detect narrowing in case values.
2019-07-31 Paolo Carlini <>
* decl2.c (delete_sanity): Improve diagnostic locations, use
cp_expr_loc_or_loc in four places.
2019-07-31 Jason Merrill <>
PR c++/90538 - multiple expansions of capture packs
* cp-tree.h (DECLTYPE_FOR_INIT_CAPTURE): Remove.
* lambda.c (add_capture): Copy parameter packs from init.
(lambda_capture_field_type): Always use auto for init-capture.
* pt.c (uses_parameter_packs): Return tree.
(tsubst) [DECLTYPE_TYPE]: Remove init-capture handling.
(gen_elem_of_pack_expansion_instantiation): Don't push
(prepend_one_capture): New.
(tsubst_lambda_expr): Use it. Don't touch local_specializations.
(do_auto_deduction): Avoid redundant error.
Fix copy_node of TEMPLATE_INFO.
* cp-tree.h (struct tree_template_info): Use tree_base instead of
tree_common. Add tmpl and args fields.
2019-07-30 Martin Liska <>
PR tree-optimization/91270
* tree-ssa-dce.c (propagate_necessity): Mark 2nd argument
of delete operator as needed.
2019-07-25 Martin Liska <>
Dominik Infuhr <>
PR c++/23383
* decl.c (cxx_init_decl_processing): Mark delete operators
2019-07-25 Martin Liska <>
* decl.c (duplicate_decls): Use new macros
(cxx_init_decl_processing): Likewise.
(grok_op_properties): Likewise.
* parser.c (cp_parser_lambda_declarator_opt): Likewise.
2019-07-24 Martin Sebor <>
PR driver/80545
* decl.c (finish_function): Use lang_mask.
2019-07-20 Jason Merrill <>
* cp-tree.h (ovl_iterator::using_p): A USING_DECL by itself was also
introduced by a using-declaration.
2019-07-20 Jason Merrill <>
Reduce memory consumption for push/pop_access_scope.
* name-lookup.c (leave_scope): Do add class levels other than
previous_class_level to free_binding_level.
(invalidate_class_lookup_cache): Move from class.c, add to
* pt.c (saved_access_scope): Change from list to vec.
2019-07-20 Jakub Jelinek <>
instead of OMP_LOOP_CHECK.
* parser.c (cp_parser_omp_clause_name): Handle bind clause.
(cp_parser_omp_clause_bind): New function.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_BIND.
(cp_parser_omp_loop): New function.
(cp_parser_omp_parallel, cp_parser_omp_teams): Handle parsing of
loop combined with parallel or teams.
(cp_parser_omp_construct): Handle PRAGMA_OMP_LOOP.
(cp_parser_pragma): Likewise.
* pt.c (tsubst_expr): Handle OMP_LOOP.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_BIND.
2019-07-19 Jason Merrill <>
PR c++/90101 - dependent class non-type parameter.
* pt.c (invalid_nontype_parm_type_p): Check for dependent class type.
2019-07-18 Jason Merrill <>
PR c++/90098 - partial specialization and class non-type parms.
PR c++/90099
PR c++/90101
* call.c (build_converted_constant_expr_internal): Don't copy.
* pt.c (process_partial_specialization): Allow VIEW_CONVERT_EXPR
around class non-type parameter.
(unify) [TEMPLATE_PARM_INDEX]: Ignore cv-quals.
2019-07-16 Jason Merrill <>
* parser.c (make_location): Add overload taking cp_lexer* as last
* parser.c (cp_parser_simple_type_specifier): Separate tentative
parses for optional type-spec and CTAD.
* parser.c (cp_parser_nested_name_specifier_opt): If the token is
already CPP_NESTED_NAME_SPECIFIER, leave it alone.
2019-07-12 Jakub Jelinek <>
* parser.c (cp_parser_omp_clause_name): Handle order clause.
(cp_parser_omp_clause_order): New function.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_ORDER.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_ORDER.
* pt.c (tsubst_omp_clauses): Likewise.
2019-07-10 Paolo Carlini <>
* decl.c (get_type_quals,
smallest_type_location (const cp_decl_specifier_seq*)): New.
(check_tag_decl): Use smallest_type_location in error_at about
multiple types in one declaration.
(grokdeclarator): Use locations[ds_complex] in error_at about
complex invalid; use locations[ds_storage_class] in error_at
about static cdtor; use id_loc in error_at about flexible
array member in union; use get_type_quals.
2019-07-09 Martin Sebor <>
PR c++/61339
* cp-tree.h: Change class-key of PODs to struct and others to class.
* search.c: Same.
* semantics.c (finalize_nrv_r): Same.
2019-07-09 Martin Sebor <>
PR c++/61339
* constexpr.c (cxx_eval_call_expression): Change class-key from class
to struct and vice versa to match convention and avoid -Wclass-is-pod
and -Wstruct-no-pod.
* (get_concept_definition): Same.
* cp-tree.h: Same.
* cxx-pretty-print.h: Same.
* error.c: Same.
* (term_list::replace): Same.
* name-lookup.c (find_local_binding): Same.
* pt.c (tsubst_binary_right_fold): Same.
* search.c (field_accessor_p): Same.
* semantics.c (expand_or_defer_fn): Same.
2019-07-08 Jakub Jelinek <>
PR c++/91110
* decl2.c (cp_omp_mappable_type_1): Don't emit any note for
error_mark_node type.
2019-07-05 Jakub Jelinek <>
PR c++/67184
PR c++/69445
* call.c (build_new_method_call_1): Remove set but not used variable
2019-07-05 Paolo Carlini <>
PR c++/67184 (again)
PR c++/69445
* call.c (build_over_call): Devirtualize user-defined operators
coming from a base too.
(build_new_method_call_1): Do not devirtualize here.
2019-07-04 Marek Polacek <>
DR 1813
PR c++/83374 - __is_standard_layout wrong for a class with repeated
* class.c (check_bases): Set CLASSTYPE_NON_STD_LAYOUT for a class if
2019-07-04 Andrew Stubbs <>
* cp-tree.h (cp_omp_emit_unmappable_type_notes): New prototype.
* decl.c (cp_finish_decl): Call cp_omp_emit_unmappable_type_notes.
* decl2.c (cp_omp_mappable_type): Move contents to ...
(cp_omp_mappable_type_1): ... here and add note output.
(cp_omp_emit_unmappable_type_notes): New function.
* semantics.c (finish_omp_clauses): Call
cp_omp_emit_unmappable_type_notes in four places.
2019-07-03 Martin Liska <>
* call.c (build_new_op_1): Remove dead assignemts.
* typeck.c (cp_build_binary_op): Likewise.
2019-06-27 Jason Merrill <>
PR c++/55442 - memory-hog with highly recursive constexpr.
* constexpr.c (push_cx_call_context): Return depth.
(cxx_eval_call_expression): Don't cache past constexpr_cache_depth.
2019-06-27 Jan Hubicka <>
* class.c (layout_class_type): Set TYPE_CXX_ODR_P for as-base
type copy.
2019-06-27 Martin Liska <>
* class.c (adjust_clone_args): Remove obviously
dead assignments.
(dump_class_hierarchy_r): Likewise.
* decl.c (check_initializer): Likewise.
* parser.c (cp_parser_lambda_expression): Likewise.
* pt.c (unify_bound_ttp_args): Likewise.
(convert_template_argument): Likewise.
* rtti.c (build_headof): Likewise.
* typeck.c (convert_for_initialization): Likewise.
2019-06-25 Jason Merrill <>
PR c++/70462 - unnecessary base ctor variant with final.
* optimize.c (populate_clone_array): Skip base variant if
(maybe_clone_body): We don't need an alias if we are only defining
one clone.
* class.c (resolves_to_fixed_type_p): Check CLASSTYPE_FINAL.
2019-06-25 Jakub Jelinek <>
PR c++/90969
* constexpr.c (cxx_eval_array_reference): Don't look through VCE from
vector type if lval.
2019-06-25 Jozef Lawrynowicz <>
* lex.c (init_reswords): Create keyword for "__intN__" type.
* cp-tree.h (cp_decl_specifier_seq): New bitfield "int_n_alt".
* decl.c (grokdeclarator): Don't pedwarn about "__intN" ISO
C incompatibility if alternate "__intN__" form is used.
* parser.c (cp_parser_simple_type_specifier): Set
decl_specs->int_n_alt if "__intN__" form is used.
2019-06-24 Jan Hubicka <>
* lex.c (cxx_make_type): Set TYPE_CXX_ODR_P.
2019-06-24 Jason Merrill <>
* class.c (layout_class_type): Don't use a separate
CLASSTYPE_AS_BASE if it's the same size.
2019-06-23 Marek Polacek <>
* call.c (convert_default_arg): Use DEFERRED_PARSE instead of
* cp-objcp-common.c (cp_tree_size): Likewise. Use tree_deferred_parse
instead of tree_default_arg.
* cp-tree.def: Rename DEFAULT_ARG to DEFERRED_PARSE.
* cp-tree.h: Rename DEFARG_TOKENS to DEFPARSE_TOKENS. Rename
tree_default_arg to tree_deferred_parse.
(cp_tree_node_structure_enum): Rename TS_CP_DEFAULT_ARG to
(lang_tree_node): Rename tree_default_arg to tree_deferred_parse.
Rename default_arg to deferred_parse. Use TS_CP_DEFERRED_PARSE instead
(defarg_location): Remove declaration.
(defparse_location): Add declaration.
* decl.c (grokfndecl): Use DEFERRED_PARSE instead of DEFAULT_ARG.
Call defparse_location instead of defarg_location.
(check_default_argument): Use DEFERRED_PARSE instead of DEFAULT_ARG.
(cp_tree_node_structure): Likewise. Use TS_CP_DEFERRED_PARSE instead
* decl2.c (grokfield): Use DEFERRED_PARSE instead of DEFAULT_ARG.
* error.c (dump_expr): Likewise.
(location_of): Likewise.
* init.c (get_nsdmi): Likewise.
* parser.c (cp_parser_save_noexcept): Likewise. Use DEFPARSE_TOKENS
instead of DEFARG_TOKENS.
(cp_parser_late_noexcept_specifier): Likewise.
(cp_parser_late_parse_one_default_arg): Use DEFPARSE_TOKENS instead
(cp_parser_late_parsing_default_args): Use DEFERRED_PARSE instead of
(cp_parser_cache_defarg): Use DEFERRED_PARSE instead of DEFAULT_ARG.
(defparse_location): Renamed from defarg_location.
* pt.c (tsubst_default_argument): Use DEFERRED_PARSE instead of
(tsubst_arg_types): Likewise.
(dependent_type_p_r): Likewise.
* tree.c (cp_tree_equal): Likewise.
(cp_walk_subtrees): Likewise.
* typeck.c (convert_arguments): Likewise.
2019-06-22 Marek Polacek <>
PR c++/86476 - noexcept-specifier is a complete-class context.
PR c++/52869
* cp-tree.def (DEFAULT_ARG): Update commentary.
* cp-tree.h (UNPARSED_NOEXCEPT_SPEC_P): New macro.
(tree_default_arg): Use tree_base instead of tree_common.
(do_push_parm_decls, maybe_check_overriding_exception_spec): Declare.
* decl.c (do_push_parm_decls): New function, broken out of...
(store_parm_decls): Call it.
* except.c (nothrow_spec_p): Accept DEFAULT_ARG in the assert.
* parser.c (cp_parser_noexcept_specification_opt,
cp_parser_late_noexcept_specifier, noexcept_override_late_checks):
(unparsed_noexcepts): New macro.
(push_unparsed_function_queues): Update initializer.
(cp_parser_direct_declarator): Pass FRIEND_P to
(inject_parm_decls): New.
(pop_injected_parms): New.
(cp_parser_class_specifier_1): Implement delayed parsing of
(cp_parser_save_noexcept): New.
(cp_parser_late_noexcept_specifier): New.
(noexcept_override_late_checks): New.
(cp_parser_noexcept_specification_opt): Add FRIEND_P parameter. Call
cp_parser_save_noexcept instead of the normal processing if needed.
(cp_parser_exception_specification_opt): Add FRIEND_P parameter and
pass it to cp_parser_noexcept_specification_opt.
(cp_parser_save_member_function_body): Fix comment.
(cp_parser_save_default_args): Maybe save the noexcept-specifier to
post process.
(cp_parser_transaction): Update call to
(cp_parser_transaction_expression): Likewise.
* parser.h (cp_unparsed_functions_entry): Add new field to carry
a noexcept-specifier.
* pt.c (dependent_type_p_r): Handle unparsed noexcept expression.
* search.c (maybe_check_overriding_exception_spec): New function, broken
out of...
(check_final_overrider): Call
* tree.c (canonical_eh_spec): Handle UNPARSED_NOEXCEPT_SPEC_P.
(cp_tree_equal): Handle DEFAULT_ARG.
PR c++/90881 - bogus -Wunused-value in unevaluated context.
* cvt.c (convert_to_void): Don't emit unused warnings in
an unevaluated context.
2019-06-22 Paolo Carlini <>
* decl.c (grokdeclarator): Use id_loc, typespec_loc, and
locations[ds_storage_class] in a few additional places.
2019-06-21 Paolo Carlini <>
PR c++/90909
2019-05-21 Paolo Carlini <>
PR c++/67184
PR c++/69445
* call.c (build_over_call): Devirtualize when the final overrider
comes from the base.
2019-06-21 Marek Polacek <>
PR c++/61490 - qualified-id in friend function definition.
* decl.c (grokdeclarator): Diagnose qualified-id in friend function
definition. Improve location for diagnostics of friend functions.
PR c++/60223 - ICE with T{} in non-deduced context.
* pt.c (unify): Allow COMPOUND_LITERAL_P in a non-deduced context.
PR c++/64235 - missing syntax error with invalid alignas.
* parser.c (cp_parser_std_attribute_spec): Commit to tentative parse
if there's a missing close paren.
PR c++/90490 - fix decltype issues in noexcept-specifier.
* except.c (build_noexcept_spec): Call
instantiate_non_dependent_expr_sfinae before
build_converted_constant_expr instead of calling
instantiate_non_dependent_expr after it. Add
2019-06-21 Jakub Jelinek <>
PR c++/90950
* semantics.c (finish_omp_clauses): Don't reject references to
incomplete types if processing_template_decl.
2019-06-19 Marek Polacek <>
PR c++/60364 - noreturn after first decl not diagnosed.
* decl.c (duplicate_decls): Give an error when a function is
declared [[noreturn]] after its first declaration.
* parser.c (cp_parser_std_attribute): Don't treat C++11 noreturn
attribute as equivalent to GNU's.
* tree.c (std_attribute_table): Add noreturn.
2019-06-19 Jakub Jelinek <>
* cp-gimplify.c (cp_genericize_r): Handle OMP_CLAUSE_{IN,EX}CLUSIVE
2019-06-18 Jason Merrill <>
* constexpr.c (cxx_eval_store_expression): Delay target evaluation.
2019-06-18 Jason Merrill <>
* constexpr.c (eval_and_check_array_index): Split out from...
(cxx_eval_store_expression): Use it here, too.
(diag_array_subscript): Take location. Strip location wrapper.
2019-06-18 Jason Merrill <>
* constexpr.c (cxx_eval_constant_expression): Handle conversion from
and then to the same type.
2019-06-18 Jason Merrill <>
* constexpr.c (unshare_constructor): Add MEM_STAT_DECL.
2019-06-17 Jakub Jelinek <>
* semantics.c (finish_omp_clauses): For OMP_CLAUSE_REDUCTION_INSCAN
set need_copy_assignment.
2019-06-17 Marek Polacek <>
PR c++/83820 - excessive attribute arguments not detected.
* parser.c (cp_parser_std_attribute): Detect excessive arguments.
2019-06-17 Nathan Sidwell <>
PR c++/90754
* name-lookup.c (lookup_type_scope_1): Calll qualify_lookup before
checking context.
2019-06-14 Marek Polacek <>
PR c++/90884 - stray note with -Wctor-dtor-privacy.
* class.c (maybe_warn_about_overly_private_class): Guard the call to
2019-06-12 Jason Merrill <>
PR c++/85552 - wrong instantiation of dtor for DMI.
* typeck2.c (digest_nsdmi_init): Set tf_no_cleanup for direct-init.
2019-06-13 Paolo Carlini <>
* decl.c (grokdeclarator): Use id_loc in five additional places
in the last part of the function.
2019-06-13 Paolo Carlini <>
* decl.c (grokdeclarator): Move further up the declaration of
id_loc, use it immediately, update its value after the loop
over declarator, use it again in the final part of function;
improve locations of error messages about multiple data types
and conflicting specifiers.
2019-06-13 Richard Biener <>
PR c++/90801
* typeck2.c (split_nonconstant_init_1): Properly count
num_split_elts, optimize single constructor elt removal.
2019-06-12 Marek Polacek <>
PR c++/66999 - 'this' captured by reference.
* parser.c (cp_parser_lambda_introducer): Reject `&this'. Use
cp_lexer_nth_token_is instead of cp_lexer_peek_nth_token.
PR c++/90825 - endless recursion when evaluating sizeof.
PR c++/90832 - endless recursion when evaluating sizeof.
* constexpr.c (cxx_eval_constant_expression): Don't recurse on the
result of fold_sizeof_expr if is returns a SIZEOF_EXPR.
* typeck.c (cxx_sizeof_expr): Only return a SIZEOF_EXPR if the operand
is instantiation-dependent.
PR c++/90736 - bogus error with alignof.
* constexpr.c (adjust_temp_type): Use cv_unqualified type.
2019-06-11 Matthew Beliveau <>
PR c++/90449 - add -Winaccessible-base option.
* class.c (warn_about_ambiguous_bases): Changed name to:
(maybe_warn_about_inaccessible_bases): Implemented new
Winaccessible-base warning option for both direct and virtual
base warnings.
(layout_class_type): Call to warn_about_ambiguous_bases changed to fit
new name.
2019-06-11 Richard Biener <>
PR c++/90801
* typeck2.c (split_nonconstant_init_1): Avoid ordered remove
from CONSTRUCTOR by marking to remove elements and doing all
of them in a O(n) scan.
2019-06-11 Jakub Jelinek <>
PR c++/90810
* init.c (constant_value_1): Handle VECTOR_CST DECL_INITIAL for
2019-06-11 Martin Liska <>
PR c++/87847
* pt.c (init_template_processing): Disable hash table
sanitization for decl_specializations and type_specializations.
2019-06-10 Jason Merrill <>
* constexpr.c (free_constructor): New.
(cxx_eval_call_expression): Free parameter value CONSTRUCTORs.
* constexpr.c (unshare_constructor): Only unshare if T is itself a
(cxx_eval_call_expression): Don't call it on the result here.
Reduce constexpr_call memory consumption.
* constexpr.c (cxx_bind_parameters_in_call): Use TREE_VEC rather
(constexpr_call_hasher::equal, cxx_bind_parameters_in_call)
(cxx_eval_call_expression): Adjust.
2019-06-10 Jakub Jelinek <>
* parser.c (cp_parser_omp_clause_reduction): Don't sorry_at on inscan
(cp_parser_omp_scan_loop_body): New function.
(cp_parser_omp_for_loop): Call cp_parser_omp_scan_loop_body if there
are inscan reduction clauses.
(cp_parser_pragma): Reject PRAGMA_OMP_SCAN.
* semantics.c (finish_omp_clauses): Reject mixing inscan with
non-inscan reductions on the same construct, or inscan reductions with
ordered or schedule clauses, or inscan array reductions.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_{IN,EX}CLUSIVE.
(tsubst_expr): Handle OMP_SCAN.
2019-06-07 Jason Merrill <>
* constexpr.c (cxx_eval_constant_expression): Call
[CONVERT_EXPR]: Don't build anything for conversion to void.
[ADDR_EXPR]: ggc_free unused ADDR_EXPR.
2019-06-05 Martin Sebor <>
PR c/90737
* typeck.c (maybe_warn_about_returning_address_of_local): Only
consider functions returning pointers as candidates for
2019-06-05 Paolo Carlini <>
* decl.c (smallest_type_location): New.
(check_special_function_return_type): Use it.
(grokdeclarator): Lkewise.
2019-06-05 Paolo Carlini <>
* decl.c (grokdeclarator): Use locations[ds_friend]
in one place.
2019-06-05 Martin Sebor <>
* call.c (build_conditional_expr_1): Adjust quoting and hyphenation.
(convert_like_real): Same.
(convert_arg_to_ellipsis): Same.
* constexpr.c (diag_array_subscript): Same.
* (diagnose_trait_expression): Same.
* cvt.c (ocp_convert): Same.
* decl.c (start_decl): Same.
(check_for_uninitialized_const_var): Same.
(grokfndecl): Same.
(check_special_function_return_type): Same.
(finish_enum_value_list): Same.
(start_preparsed_function): Same.
* parser.c (cp_parser_decl_specifier_seq): Same.
* typeck.c (cp_build_binary_op): Same.
(build_static_cast_1): Same.
2019-06-04 Nina Dinka Ranns <>
PR c++/63149 - Wrong auto deduction from braced-init-list.
* pt.c (listify_autos): use non cv qualified auto_node in
2019-06-04 Paolo Carlini <>
* decl.c (grokdeclarator): Use declarator->id_loc in two
additional places.
2019-06-04 Nathan Sidwell <>
* name-lookup.c (lookup_type_scope_1): Reimplement, handle local
and namespace scopes separately.
2019-06-04 Harald van Dijk <>
PR c++/60531 - Wrong error about unresolved overloaded function
* typeck.c (cp_build_binary_op): See if overload can be resolved.
(cp_build_unary_op): Ditto.
2019-06-04 Jason Merrill <>
Reduce accumulated garbage in constexpr evaluation.
* constexpr.c (cxx_eval_call_expression): ggc_free any bindings we
don't save.
(cxx_eval_increment_expression): ggc_free the MODIFY_EXPR after
evaluating it.
2019-06-04 Jakub Jelinek <>
* cp-tree.h (CP_OMP_CLAUSE_INFO): Allow for any clauses up to _condvar_
instead of only up to linear.
2019-06-03 Paolo Carlini <>
* parser.c (cp_parser_unqualified_id): Use build_min_nt_loc in
five places.
2019-06-01 Ville Voutilainen <>
PR c++/85254
* class.c (fixup_type_variants): Handle CLASSTYPE_FINAL.
2019-05-31 Nathan Sidwell <>
* cp-tree.h (IDENTIFIER_LAMBDA_P): New.
(make_lambda_name): Don't declare.
* error.c (dump_aggr_type): Check for lambdas before other
anonymous names.
* lambda.c (begin_lambda_type): Use make_anon_name.
* cp-lang.c (cxx_dwarf_name): Lambda names smell anonymous.
* mangle.c (write_local_name): Likewise.
* name-lookup.c (lambda_cnt, make_lambda_name): Delete.
2019-05-30 Marek Polacek <>
* cp-tree.h (TYPE_HAS_NONTRIVIAL_DESTRUCTOR): Fix a typo.
2019-05-31 Paolo Carlini <>
* decl.c (grokdeclarator): Use declarator->id_loc in five
error_at calls.
2019-05-29 Jakub Jelinek <>
PR c++/90598
* tree.c (lvalue_kind): Return clk_none for expressions with
2019-05-29 Paolo Carlini <>
PR c++/89875
* parser.c (cp_parser_sizeof_operand): When the type-id production
did not work out commit to the tentative parse.
2019-05-29 Jakub Jelinek <>
P1091R3 - Extending structured bindings to be more like var decls
P1381R1 - Reference capture of structured bindings
* decl.c (cp_maybe_mangle_decomp): Handle TREE_STATIC decls even at
function scope.
(cp_finish_decomp): Copy over various decl properties from decl to
v[i] in the tuple case.
(grokdeclarator): Allow static, thread_local and __thread for C++2a
and use pedwarn instead of error for older standard revisions.
Make other structured binding diagnostic messages more i18n friendly.
2019-05-28 Nathan Sidwell <>
* decl.c (duplicate_decls): Assert a template newdecl has no
2019-05-28 Marek Polacek <>
PR c++/90548 - ICE with generic lambda and empty pack.
* pt.c (tsubst_copy_and_build): Handle pack expansion properly.
2019-05-28 Nathan Sidwell <>
* cp-tree.h (make_anon_name): Drop declaration.
* cp-lang.c (cxx_dwarf_name): Likewise.
* class.c (find_flexarrays): Likewise.
* decl.c (name_unnamed_type, xref_tag_1): Likewise.
* error.c (dump_aggr_type): Likewise.
* pt.c (push_template_decl_real): Likewise.
* name-lookup.c (consider_binding_level): Likewise.
(anon_cnt, make_anon_name): Delete.
2019-05-25 Marek Polacek <>
PR c++/90572 - wrong disambiguation in friend declaration.
* parser.c (cp_parser_constructor_declarator_p): Don't allow missing
typename for friend declarations.
2019-05-23 Jonathan Wakely <>
* cp-tree.h (CP_AGGREGATE_TYPE_P): Fix whitespace.
* init.c (std_placement_new_fn_p): Remove outdated TODO comment that
was resolved by r254694.
2019-05-22 Jason Merrill <>
PR c++/20408 - unnecessary code for empty struct.
* call.c (build_call_a): Use simple_empty_class_p.
PR c++/86485 - -Wmaybe-unused with empty class ?:
* cp-gimplify.c (simple_empty_class_p): Also true for MODIFY_EXPR.
2019-05-21 Paolo Carlini <>
* parser.c (cp_parser_template_declaration_after_parameters): Use
DECL_SOURCE_LOCATION in literal operator template errors.
2019-05-21 Paolo Carlini <>
PR c++/67184
PR c++/69445
* call.c (build_over_call): Devirtualize when the final overrider
comes from the base.
2019-05-21 Nathan Sidwell <>
* name-lookup.c (do_nonmember_using_decl): Drop INSERT_P
parameter. Document.
(finish_nonmember_using_decl): Adjust do_nonmember_using_decl
calls. Remove stray FIXME comment.
* name-lookup.h (struct cp_binding_level): Drop usings field.
(finish_namespace_using_decl, finish_local_using_decl): Replace with ...
(finish_nonmember_using_decl): ... this.
* name-lookup.c (push_using_decl_1, push_using_decl):
(do_nonmember_using_decl): ... here. Add INSERT_P arg. Reimplement.
(validate_nonmember_using_decl, finish_namespace_using_decl)
(finish_local_using_decl): Replace with ...
(finish_nonmember_using_decl): ... this. Drop DECL parm.
* parser.c (cp_parser_using_declaration): Don't do lookup here.
* pt.c (tsubst_expr): Do not do using decl lookup here.
2019-05-21 Eric Botcazou <>
* decl2.c (cpp_check) <IS_ASSIGNMENT_OPERATOR>: New case.
2019-05-20 Marek Polacek <>
CWG 2094 - volatile scalars are trivially copyable.
PR c++/85679
* tree.c (trivially_copyable_p): Don't check CP_TYPE_VOLATILE_P for
scalar types.
2019-05-20 Marek Polacek <>
* pt.c (convert_template_argument): Add a diagnostic for the
[temp.arg]/2 ambiguity case.
* name-lookup.c (finish_using_directive): Don't issue inform() if the
warning didn't trigger. Add quoting. Tweak the inform message.
2019-05-20 Paolo Carlini <>
* cp-tree.h: Remove remnants of CONV_NONCONVERTING.
2019-05-20 Nathan Sidwell <>
* name-lookup.c (finish_namespace_using_directive)
(finish_local_using_directive): Merge to ...
(finish_using_directive): ... here. Handle both contexts.
* name-lookup.h (finish_namespace_using_directive)
(finish_local_using_directive): Replace with ...
(finish_using_directive): ... this.
* parser.c (cp_parser_using_directive): Adjust.
* pt.c (tsubst_expr): Likewise.
* cp-tree.h (struct lang_decl_ns): Remove usings field.
* name-lookup.c (name_lookup::search_usings): Use namespace's
binding scope.
(name_lookup::queue_namespae): Likewise.
(finish_namespace_using_directive, push_namespace): Likewise.
(has_using_namespace_std_directive): Just search the entire
binding stack.
2019-05-20 Jonathan Wakely <>
PR c++/90532 Ensure __is_constructible(T[]) is false
* method.c (is_xible_helper): Return error_mark_node for construction
of an array of unknown bound.
2019-05-17 Thomas Schwinge <>
PR c++/89433
* parser.c (cp_finalize_oacc_routine): Rework checking if already
marked with an OpenACC 'routine' directive.
PR c++/89433
* parser.c (cp_parser_oacc_routine)
(cp_parser_late_parsing_oacc_routine): Normalize order of clauses.
(cp_finalize_oacc_routine): Call oacc_verify_routine_clauses.
PR c++/89433
* parser.c (cp_finalize_oacc_routine): Refer to OpenACC 'routine'
clauses from "omp declare target" attribute.
2019-05-16 Martin Sebor <>
* call.c (print_z_candidate): Wrap diagnostic text in a gettext
macro. Adjust.
(print_z_candidates): Same.
(build_conditional_expr_1): Quote keywords, operators, and types
in diagnostics.
(build_op_delete_call): Same.
(maybe_print_user_conv_context): Wrap diagnostic text in a gettext
(convert_like_real): Same.
(convert_arg_to_ellipsis): Quote keywords, operators, and types
in diagnostics.
(build_over_call): Same.
(joust): Break up an overlong line. Wrap diagnostic text in a gettext
* constexpr.c (cxx_eval_check_shift_p): Spell out >= in English.
(cxx_eval_constant_expression): Quote keywords, operators, and types
in diagnostics.
(potential_constant_expression_1): Same.
* cp-gimplify.c (cp_genericize_r): Same.
* cvt.c (maybe_warn_nodiscard): Quote keywords, operators, and types
in diagnostics.
(type_promotes_to): Same.
* decl.c (check_previous_goto_1): Same.
(check_goto): Same.
(start_decl): Same.
(cp_finish_decl): Avoid parenthesizing a sentence for consistency.
(grok_op_properties): Quote keywords, operators, and types
in diagnostics.
* decl2.c (grokfield): Same.
(coerce_delete_type): Same.
* except.c (is_admissible_throw_operand_or_catch_parameter): Same.
* friend.c (do_friend): Quote C++ tokens.
* init.c (build_new_1): Quote keywords, operators, and types
in diagnostics.
(build_vec_delete_1): Same.
(build_delete): Same.
* lex.c (parse_strconst_pragma): Same.
(handle_pragma_implementation): Same.
(unqualified_fn_lookup_error): Same.
* mangle.c (write_type): Same.
* method.c (defaulted_late_check): Avoid two consecutive punctuators.
* name-lookup.c (cp_binding_level_debug): Remove a trailing newline.
(pop_everything): Same.
* parser.c (cp_lexer_start_debugging): Quote a macro name.
in a diagnostic
(cp_lexer_stop_debugging): Same.
(cp_parser_userdef_numeric_literal): Quote a C++ header name
in a diagnostic.
(cp_parser_nested_name_specifier_opt): Quote keywords, operators,
and types in diagnostics.
(cp_parser_question_colon_clause): Same.
(cp_parser_asm_definition): Same.
(cp_parser_init_declarator): Same.
(cp_parser_template_declaration_after_parameters): Avoid capitalizing
a sentence in a diagnostic.
(cp_parser_omp_declare_reduction): Quote keywords, operators, and types
in diagnostics.
(cp_parser_transaction): Same.
* pt.c (maybe_process_partial_specialization): Replace second call
to permerror with inform for consistency with other uses.
(expand_integer_pack): Quote keywords, operators, and types
in diagnostics.
* rtti.c (get_typeid): Quote keywords, operators, and types
in diagnostics.
(build_dynamic_cast_1): Same.
* semantics.c (finish_asm_stmt): Same.
(finish_label_decl): Same.
(finish_bases): Same.
(finish_offsetof): Same.
(cp_check_omp_declare_reduction): Same.
(finish_decltype_type): Same.
* tree.c (handle_init_priority_attribute): Same. Add detail
to diagnostics.
(maybe_warn_zero_as_null_pointer_constant): Same.
* typeck.c (cp_build_binary_op): Quote keywords, operators, and types
in diagnostics.
(cp_build_unary_op): Same.
(check_for_casting_away_constness): Same.
(build_static_cast): Same.
(build_const_cast_1): Same.
(maybe_warn_about_returning_address_of_local): Same.
(check_return_expr): Same.
* typeck2.c (abstract_virtuals_error_sfinae): Same.
(digest_init_r): Replace a tab with spaces in a diagnostic.
(build_functional_cast): Quote keywords, operators, and types
in diagnostics.
2019-05-15 Jakub Jelinek <>
PR debug/90197
* cp-gimplify.c (genericize_cp_loop): Emit a DEBUG_BEGIN_STMT
before the condition (or if missing or constant non-zero at the end
of the loop. Emit a DEBUG_BEGIN_STMT before the increment expression
if any. Don't call protected_set_expr_location on incr if it already
has a location.
2019-05-15 Marek Polacek <>
CWG 2096 - constraints on literal unions.
* class.c (check_field_decls): Initialize booleans directly. A union
is literal if at least one of its non-static data members is of
non-volatile literal type.
2019-05-15 Paolo Carlini <>
* cp-tree.h (REFERENCE_VLA_OK): Remove.
* lambda.c (build_capture_proxy): Remove use of the above.
2019-05-15 Paolo Carlini <>
* call.c (perform_overload_resolution, build_new_method_call_1):
Use OVL_P; remove redundant TEMPLATE_DECL checks.
* decl.c (grokfndecl): Likewise.
* mangle.c (write_expression): Likewise.
* parser.c (cp_parser_template_id): Likewise.
* pt.c (resolve_overloaded_unification, type_dependent_expression_p):
* search.c (build_baselink): Likewise.
* tree.c (is_overloaded_fn, dependent_name, maybe_get_fns): Likewise.
2019-05-14 Paolo Carlini <>
PR preprocessor/90382
* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
2019-05-13 Jason Merrill <>
Use releasing_vec more broadly.
* cp-tree.h (struct releasing_vec): Replace get_ref method with
(vec_safe_push, vec_safe_reserve, vec_safe_length, vec_safe_splice):
Forwarding functions for releasing_vec.
(release_tree_vector): Declare but don't define.
* call.c (build_op_delete_call, build_temp, call_copy_ctor)
(perform_direct_initialization_if_possible): Use releasing_vec.
* constexpr.c (cxx_eval_vec_init_1, cxx_eval_store_expression):
* cp-gimplify.c (cp_fold): Likewise.
* cvt.c (force_rvalue, ocp_convert): Likewise.
* decl.c (get_tuple_decomp_init): Likewise.
* except.c (build_throw): Likewise.
* init.c (perform_member_init, expand_default_init): Likewise.
* method.c (do_build_copy_assign, locate_fn_flags): Likewise.
* parser.c (cp_parser_userdef_char_literal)
(cp_parser_range_for_member_function, cp_parser_omp_for_loop)
(cp_parser_omp_for_loop_init): Likewise.
* pt.c (tsubst_copy_and_build, do_class_deduction): Likewise.
* semantics.c (calculate_direct_bases, calculate_bases)
(finish_omp_barrier, finish_omp_flush, finish_omp_taskwait)
(finish_omp_taskyield, finish_omp_cancel)
(finish_omp_cancellation_point): Likewise.
* tree.c (build_vec_init_elt, strip_typedefs, strip_typedefs_expr)
(build_min_non_dep_op_overload): Likewise.
* typeck.c (build_function_call_vec, cp_build_function_call_nary)
(cp_build_modify_expr): Likewise.
* typeck2.c (build_functional_cast): Likewise.
2019-05-11 Paolo Carlini <>
* typeck.c (cp_build_function_call_vec): When mark_used fails
unconditionally return error_mark_node.
2019-05-10 Paolo Carlini <>
* decl.c (grokvardecl): Use an accurate location in error message
about main as a global variable.
2019-05-10 Paolo Carlini <>
* call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P.
* cp-gimplify.c (cp_fold): Likewise.
* cp-objcp-common.c (cp_type_dwarf_attribute): Likewise.
* cp-tree.h (TYPE_OBJ_P, TYPE_PTROBV_P): Likewise.
* cvt.c (perform_qualification_conversions): Likewise.
* decl.c (grokdeclarator): Likewise.
* decl2.c (build_memfn_type): Likewise.
* mangle.c (canonicalize_for_substitution, write_type): Likewise.
* parser.c (cp_parser_omp_declare_reduction): Likewise.
* pt.c (check_explicit_specialization, uses_deducible_template_parms,
check_cv_quals_for_unify, dependent_type_p_r): Likewise.
* rtti.c (ptr_initializer): Likewise.
* semantics.c (finish_asm_stmt, finish_offsetof,
cp_check_omp_declare_reduction): Likewise.
* tree.c (cp_build_qualified_type_real,
cp_build_type_attribute_variant, cxx_type_hash_eq,
cxx_copy_lang_qualifiers, cp_free_lang_data): Likewise.
* typeck.c (structural_comptypes, convert_arguments,
cp_build_addr_expr_1, unary_complex_lvalue, cp_build_c_cast,
cp_build_modify_expr, comp_ptr_ttypes_real, type_memfn_rqual):
2019-05-10 Marek Polacek <>
PR c++/78010 - bogus -Wsuggest-override warning on final function.
* class.c (check_for_override): Don't warn for final functions.
2019-05-10 Jakub Jelinek <>
PR pch/90326
* (gtfiles): Remove c-family/c-lex.c, add
2019-05-09 Paolo Carlini <>
PR c++/90382
2018-04-26 Paolo Carlini <>
* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
2019-05-08 Nathan Sidwell <>
* cp-tree.h (language_function): Remove x_auto_return_pattern.
(current_function_auto_return_pattern): Delete.
(lang_decl_fn): Replace saved_language_function with
saved_auto_return type.
(FNDECL_USED_AUTO): Correct documentation.
* decl.c (duplicate_decls): Adjust AUTO return handling.
(start_preparsed_function): Replace
current_function_auto_return_pattern with
(finish_function): Likewise.
(save_function_data): Delete.
(fndecl_declared_return_type): Reimplement.
* mangle.c (write_unqualified_name): Use DECL_SAVED_AUTO_RETURN_TYPE.
* method.c (make_thunk, make_alias_for): Likewise.
* parser.c (cp_parser_jump_statement): Likewise.
* pt.c (do_auto_deduction): Likewise.
* typeck.c (check_return_expr): Likewise.
2019-05-06 Jason Merrill <>
PR c++/90171 - reorganize usual_deallocation_fn_p
* call.c (struct dealloc_info): New.
(usual_deallocation_fn_p): Take a dealloc_info*.
(aligned_deallocation_fn_p, sized_deallocation_fn_p): Remove.
(build_op_delete_call): Adjust.
2019-05-07 Jason Merrill <>
PR c++/86485 - -Wmaybe-unused with empty class ?:
* typeck.c (build_static_cast_1): Use cp_build_addr_expr.
* pt.c (type_dependent_expression_p): A non-type template parm with
a placeholder type is type-dependent.
2019-05-06 Marek Polacek <>
PR c++/90265 - ICE with generic lambda.
* pt.c (tsubst_copy_and_build): Use a dedicated variable for the last
element in the vector.
2019-05-03 Martin Liska <>
* call.c (build_aggr_conv): Use is_empty instead of
elements () == 0 (and similar usages).
* parser.c (cp_parser_lambda_introducer): Likewise.
2019-05-02 Nathan Sidwell <>
* semantics.c (finish_id_expression_1): Remove unreachable code.
2019-05-01 Nathan Sidwell <>
* name-lookup.h (get_class_binding_direct): Change final arg to
(get_class_binding): Likewise.
* name-lookup.c (get_class_binding_direct): Replace TYPE_OR_FNS
arg with WANT_TYPE bool. Simplify.
(get_class_binding): Adjust final arg.
* decl.c (reshape_init_class): Adjust get_class_binding calls.
2019-04-30 Nathan Sidwell <>
* cp-objcp-common.c (cp_common_init_ts): Use MARK_TS_EXP for _EXPR
nodes. Call c_common_init_ts.
2019-04-29 Nathan Sidwell <>
* decl.c (duplicate_decls): Add whitespace, move comments into
conditional blocks.
* method.c (explain_implicit_non_constexpr): Refactor.
* pt.c (check_explicit_specialization): Fix indentation.
* semantics.c (process_outer_var_ref): Reformat.
(finish_id_expression_1): Use STRIP_TEMPLATE.
2019-04-26 Jonathan Wakely <>
PR c++/90243 - orphaned note in uninstantiated constexpr function
* decl.c (check_for_uninitialized_const_var): Suppress notes if no
error was shown.
2019-04-26 Paolo Carlini <>
PR c++/90173
* decl.c (grokdeclarator): Set type to error_mark_node
upon error about template placeholder type non followed
by a simple declarator-id.
2019-04-26 Paolo Carlini <>
* decl.c (grokdeclarator): Fix value assigned to typespec_loc, use
2019-04-24 Jason Merrill <>
PR c++/90227 - error with template parameter packs.
* pt.c (coerce_template_parms): Do add empty pack when
2019-04-24 Richard Biener <>
* call.c (null_ptr_cst_p): Order checks according to expensiveness.
(conversion_null_warnings): Likewise.
* typeck.c (same_type_ignoring_top_level_qualifiers_p): Return
early if type1 == type2.
2019-04-22 Jason Merrill <>
PR c++/87366 - wrong error with alias template.
* typeck.c (structural_comptypes): When comparing_specializations,
aliases are unequal.
(comptypes): When comparing_specializations, do structural
2019-04-19 Jason Merrill <>
PR c++/90190 - CTAD with list-constructor.
* pt.c (do_class_deduction): Don't try the single element deduction
if the single element is also a braced list.