Age | Commit message (Collapse) | Author | Files | Lines |
|
The awaiter.await_ready() should be converted per [expr.await]/3
(3.6) await-ready is the expression e.await_ready(), contextually
converted to bool.
gcc/cp/ChangeLog:
PR c++/99047
* coroutines.cc (expand_one_await_expression): If the
await_ready() expression is not a boolean then convert it
as required.
gcc/testsuite/ChangeLog:
PR c++/99047
* g++.dg/coroutines/pr99047.C: New test.
|
|
Although there is still some discussion in CWG 2451 on this, the
implementors are agreed on the intent.
When promise.unhandled_exception () is entered, the coroutine is
considered to be still running - returning from the method will
cause the final await expression to be evaluated.
If the method throws, that action is considered to make the
coroutine suspend (since, otherwise, it would be impossible to
reclaim its resources, since one cannot destroy a running coro).
The wording issue is to do with how to represent the place at
which the coroutine should be considered suspended.
For the implementation here, that place is immediately before the
promise life-time ends. A handler for the rethrown exception, can
thus call xxxx.destroy() which will run DTORs for the promise and
any parameter copies [as needed] then the coroutine frame will be
deallocated.
At present, we also set "done=true" in this case (for compatibility
with other current implementations). One might consider 'done()'
to be misleading in the case of an abnormal termination - that is
also part of the CWG 2451 discussion.
gcc/cp/ChangeLog:
PR c++/98704
* coroutines.cc (build_actor_fn): Make destroy index 1
correspond to the abnormal unhandled_exception() exit.
Substitute the proxy for the resume index.
(coro_rewrite_function_body): Arrange to reset the resume
index and make done = true for a rethrown exception from
unhandled_exception ().
(morph_fn_to_coro): Adjust calls to build_actor_fn and
coro_rewrite_function_body.
gcc/testsuite/ChangeLog:
PR c++/98704
* g++.dg/coroutines/torture/pr98704.C: New test.
|
|
The handling of await expressions in the init, condition and iteration
expressions of for loops had been omitted. Fixed thus.
gcc/cp/ChangeLog:
PR c++/98480
* coroutines.cc (replace_continue): Rewrite continue into
'goto label'.
(await_statement_walker): Handle await expressions in the
initializer, condition and iteration expressions of for
loops.
gcc/testsuite/ChangeLog:
PR c++/98480
* g++.dg/coroutines/pr98480.C: New test.
* g++.dg/coroutines/torture/co-await-24-for-init.C: New test.
* g++.dg/coroutines/torture/co-await-25-for-condition.C: New test.
* g++.dg/coroutines/torture/co-await-26-for-iteration-expr.C: New test.
|
|
In the compiler-only idiom:
" a = (target expr creats temp, op uses temp) "
the target expression variable needs to be promoted to a frame one
(if the expression has a suspend point). However, the only uses of
the var are in the second part of the compound expression - and we
were creating an empty statement corresponding to the (now unused)
first arm. This then produces the spurious warnings noted.
Fixed by avoiding generation of a separate variable nest for
isolated target expressions (or similarly isolated co_awaits used
in a function call).
gcc/cp/ChangeLog:
PR c++/96749
* coroutines.cc (flatten_await_stmt): Allow for the case
where a target expression variable only has uses in the
second part of a compound expression.
(maybe_promote_temps): Avoid emiting empty statements.
gcc/testsuite/ChangeLog:
PR c++/96749
* g++.dg/coroutines/pr96749-1.C: New test.
* g++.dg/coroutines/pr96749-2.C: New test.
|
|
For variables with 'declare target' attribute,
varpool_node::get_create marks variables as offload; however,
if the node already exists, it is not updated. C/C++ may tag
decl with 'declare target implicit', which may only be after
varpool creation turned into 'declare target' or 'declare target link';
in this case, the tagging has to happen in the FE.
gcc/c/ChangeLog:
PR c++/99509
* c-decl.c (finish_decl): For 'omp declare target implicit' vars,
ensure that the varpool node is marked as offloadable.
gcc/cp/ChangeLog:
PR c++/99509
* decl.c (cp_finish_decl): For 'omp declare target implicit' vars,
ensure that the varpool node is marked as offloadable.
libgomp/ChangeLog:
PR c++/99509
* testsuite/libgomp.c-c++-common/declare_target-1.c: New test.
|
|
|
|
This ICE was caused by a stray TREE_VISITED marker. The lookup
machinery was leaving it there due to the way I'd arranged for it to
be cleared. That was presuming the name_lookup::value field didn't
change, and that wasn't always true in the using-decl processing. I
took the opportunity to break out a helper, and then call it
immediately after lookups, rather than wait until destructor time.
Added some asserts the module machinery to catch further cases of
this.
PR c++/99238
gcc/cp/
* module.cc (depset::hash::add_binding_entity): Assert not
visited.
(depset::add::add_specializations): Likewise.
* name-lookup.c (name_lookup::dedup): New.
(name_lookup::~name_lookup): Assert not deduping.
(name_lookup::restore_state): Likewise.
(name_lookup::add_overload): Replace outlined code with dedup
call.
(name_lookup::add_value): Likewise.
(name_lookup::search_namespace_only): Likewise.
(name_lookup::adl_namespace_fns): Likewise.
(name_lookup::adl_class_fns): Likewise.
(name_lookup::search_adl): Likewise. Add clearing dedup call.
(name_lookup::search_qualified): Likewise.
(name_lookup::search_unqualified): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99238.h: New.
* g++.dg/modules/pr99238_a.H: New.
* g++.dg/modules/pr99238_b.H: New.
|
|
build_cxx_call calls convert_from_reference at the end, so if an immediate
function returns a reference, we were constant evaluating not just that
call, but that call wrapped in an INDIRECT_REF. That unfortunately means
it can constant evaluate to something non-addressable, so if code later
needs to take its address it will fail.
The following patch fixes that by undoing the convert_from_reference
wrapping for the cxx_constant_value evaluation and readdding it ad the end.
2021-03-12 Jakub Jelinek <jakub@redhat.com>
PR c++/99507
* call.c (build_over_call): For immediate evaluation of functions
that return references, undo convert_from_reference effects before
calling cxx_constant_value and call convert_from_reference
afterwards.
* g++.dg/cpp2a/consteval19.C: New test.
|
|
|
|
This was a simple thinko about which object held the reference to the
binding vector. I also noticed stale code in the tree dumper, as I
recently removed the flags from a lazy number.
PR c++/99248
gcc/cp/
* name-lookup.c (lookup_elaborated_type_1): Access slot not bind
when there's a binding vector.
* ptree.c (cxx_print_xnode): Lazy flags are no longer a thing.
gcc/testsuite/
* g++.dg/modules/pr99248.h: New.
* g++.dg/modules/pr99248_a.H: New.
* g++.dg/modules/pr99248_b.H: New.
|
|
This turned out to be an existing problem, which had been hidden by
other bugs. Templated members of templated classes can end up
instantiating the template itself, and we were not handling the
mergeableness of that correctly.
PR c++/99528
gcc/cp/
* module.cc (enum merge_kind): Delete MK_type_tmpl_spec,
MK_decl_tmpl_spec.
(trees_in::decl_value): Adjust add_mergeable_specialization call.
(trees_out::get_merge_kind): Adjust detecting a partial template
instantiation.
(trees_out::key_mergeable): Adjust handling same.
(trees_in::key_mergeabvle): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99528.h: New.
* g++.dg/modules/pr99528_a.H: New.
* g++.dg/modules/pr99528_b.H: New.
* g++.dg/modules/pr99528_c.C: New.
|
|
|
|
My reworking of pending-entity loading introduced a GC problem. The
post-load processing needs to inhibit GCs (that would otherwise occur
in clone_decl). That wasn't happening on one code path, leading to
dangling pointers in the active call frames.
PR c++/99423
gcc/cp/
* module.cc (post_load_processing): Assert not gcable.
(laxy_load_pendings): Extend no-gc region around
post_load_processing.
gcc/testsuite/
* g++.dg/modules/pr99423_a.H: New.
* g++.dg/modules/pr99423_b.H: New.
|
|
This is another place where our one-true-decl representation breaks
down. The fix here propagates the assembly name to the ns-scope
alias. that fixes the reported problem but changes the behaviour when
the user has explicitly declared the entity in its namespace.
However, we didn't handle that case 'correctly' anyway before.
Previously we'd also ignore the explicitly specified assembler name,
now we propagate it. It's not clear to me what the desired semantics
would be in decorating just one of the local extern declarations this
way. I don't think we can really do better without propagating this
aliasing property into the middle end (which is also needed for some
constexpr handling, see PR97306). I tried that before and it turned
into a rat-hole.
PR c++/99508
gcc/cp/
* decl.c (make_rtl_for_nonlocal_decl): Propagate local-extern's
assembler name to the ns alias.
gcc/testsuite/
* g++.dg/ext/pr99508.C: New.
|
|
|
|
The r11-7528 build_co_await changes broke coroutines on arm*-linux-gnuabi,
2780 ^FAIL.*coroutines/ in total.
The problem is that arm is targetm.cxx.cdtor_return_this target where
both ctors and dtors in the ABI return this pointer rather than
void, and build_new_method_call_1 does:
else if (call != error_mark_node
&& DECL_DESTRUCTOR_P (cand->fn)
&& !VOID_TYPE_P (TREE_TYPE (call)))
/* An explicit call of the form "x->~X()" has type
"void". However, on platforms where destructors
return "this" (i.e., those where
targetm.cxx.cdtor_returns_this is true), such calls
will appear to have a return value of pointer type
to the low-level call machinery. We do not want to
change the low-level machinery, since we want to be
able to optimize "delete f()" on such platforms as
"operator delete(~X(f()))" (rather than generating
"t = f(), ~X(t), operator delete (t)"). */
call = build_nop (void_type_node, call);
The new code in build_co_await relies on build_special_member_call
returned expression being a CALL_EXPR, but due to the build_nop
in there it is a NOP_EXPR around the CALL_EXPR. It can't be stripped
with STRIP_NOPS because void has different mode from the pointer mode.
2021-03-09 Jakub Jelinek <jakub@redhat.com>
PR c++/99459
* coroutines.cc (build_co_await): Look through NOP_EXPRs in
build_special_member_call return value to find the CALL_EXPR.
Simplify.
|
|
This clarifies that c++2[03] intentionally does not enable
c++20 modules.
PR c++/99472
gcc/cp/
* parser.c (cp_parser_diagnose_invalid_type_name): Clarify
that C++20 does not yet imply modules.
|
|
|
|
This adds support for c++23 mode to modules, and enables such testing.
PR c++/99436
gcc/cp/
* name-lookup.c (get_cxx_dialect_name): Add cxx23.
gcc/testsuite/
* g++.dg/modules/modules.exp (MOD_STD_LIST): Add 2b.
|
|
We didn't specifically check for a module-decl inside a header unit.
That leads to a confusing diagostic. Fixed thusly.
gcc/cp/
* lex.c (module_token_filter::resume): Ignore module-decls inside
header-unit.
* parser.c (cp_parser_module_declaration): Reject in header-unit.
gcc/testsuite/
* g++.dg/modules/pr99468.H: New.
|
|
Class template partial specializations need to be in the
specialization hash, but not all of them. This defers adding
streamed-in entities to the hash table, in the same way I deferred
adding the instantiation and specialization lists for 99170.
PR c++/99285
gcc/cp/
* cp-tree.h (match_mergeable_specialization)
(add_mergeable_specialization): Adjust parms.
* module.cc (trees_in::decl_value): Adjust
add_mergeable_specialization calls.
(trees_out::key_mergeable): Adjust match_mergeable_specialization
calls.
(specialization_add): Likewise.
* pt.c (match_mergeable_specialization): Do not insert.
(add_mergeable_specialization): Add to hash table here.
gcc/testsuite/
* g++.dg/modules/pr99285_a.H: New.
* g++.dg/modules/pr99285_b.H: New.
|
|
|
|
Here, during cxx_eval_increment_expression (with lval=false) of
++__first where __first is &"mystr"[0], we correctly update __first
to &"mystr"[1] but we end up returning &"mystr"[0] + 1 instead of
&"mystr"[1]. This unreduced return value inhibits other pointer
arithmetic folding during later constexpr evaluation, which ultimately
causes the constexpr evaluation to fail.
It turns out the simplification of &"mystr"[0] + 1 to &"mystr"[1]
is performed by cxx_fold_pointer_plus_expression, not by fold_build2.
So we perform this simplification during constexpr evaluation of
the temporary MODIFY_EXPR (during which we assign to __first the
simplified value), but then we return 'mod' which has only been folded
via fold_build2 and hasn't gone through cxx_fold_pointer_plus_expression.
This patch fixes this by updating 'mod' with the result of the
MODIFY_EXPR evaluation appropriately, so that it captures any additional
folding of the expression when !lval. We now need to be wary of this
evaluation failing and returning e.g. the MODIFY_EXPR or NULL_TREE; it
seems checking *non_constant_p should cover our bases here and is
generally prudent.
gcc/cp/ChangeLog:
PR c++/99287
* constexpr.c (cxx_eval_increment_expression): Pass lval when
evaluating the MODIFY_EXPR, and update 'mod' with the result of
this evaluation. Check *non_constant_p afterwards. For prefix
ops, just return 'mod'.
gcc/testsuite/ChangeLog:
PR c++/99287
* g++.dg/cpp2a/constexpr-99287.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
|
|
This makes tsubst_copy appropriately handle a variable template-id, which
in turn fixes tsubsting a COMPONENT_REF whose member operand is known at
parse time to be a variable template-id, as in the initialization of 'x'
in the first testcase. Previously, we rejected this testcase with the
error "foo_t::bar<T> is not a function template", issued from
lookup_template_fuction.
We were already properly handling the analagous case where the object
operand of the COMPONENT_REF is dependent (and so the member operand is
a dependent template name), but there doesn't seems to be existing test
coverage for this, hence the second testcase below.
gcc/cp/ChangeLog:
PR c++/96330
* pt.c (tsubst_copy) <case TEMPLATE_ID_EXPR>: Rename local
variable 'fn' to 'tmpl'. Handle a variable template-id by
calling lookup_template_variable.
gcc/testsuite/ChangeLog:
PR c++/96330
* g++.dg/cpp1y/var-templ68.C: New test.
* g++.dg/cpp1y/var-templ68a.C: New test.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
|
|
My recent r11-7454 changed the way do_auto_deduction handles constrained
placeholders during template argument deduction (context == adc_unify)
when processing_template_decl != 0. Before the patch, we would just
ignore the constraints on the placeholder, and return the deduced type.
After the patch, we now punt and return the original placeholder type
While this change fixed instances where we'd prematurely resolve a
constrained placeholder return or variable type with non-dependent
initializer at template parse time (such as PR96444), it broke the
adc_unify callers that rely on the previous behavior.
This patch restores the previous behavior during adc_unify deduction
while retaining the new behavior only during adc_variable_type or
adc_return_type deduction.
We additionally now need to pass the outer template arguments to
do_auto_deduction during unify, for sake of constraint checking.
But we want to avoid substituting these outer arguments into type
when the caller has already done so, so this patch adds a
TEMPLATE_TYPE_LEVEL check to do_auto_deduction to that effect.
This above is enough to fix partial specialization of non-nested
templates with constrained 'auto' template parameters, but it doesn't
fix the nested template case, ultimately because
most_specialized_partial_spec passes only the innermost template
arguments to get_partial_spec_bindings, and so outer_targs during
do_auto_deduction (called from unify) contains only the innermost
template arguments, and this breaks satisfaction. Fixing this properly
is perhaps too risky at this stage, so this patch adds a hack to
do_auto_deduction to compensate for callers that don't supply all outer
template arguments. The goal of this hack is to ensure placeholder type
constraint checking continues to work whenever it worked before
r11-7454, namely whenever the constraint is non-dependent.
Finally, this patch allows do_auto_deduction to resolve a constrained
placeholder type ahead of time (at template parse time), as long as the
constraint is non-dependent.
gcc/cp/ChangeLog:
PR c++/99365
* pt.c (unify) <case TEMPLATE_TYPE_PARM>: Pass targs as
outer_targs to do_auto_deduction.
(placeholder_type_constraint_dependent_p): Define.
(do_auto_deduction): When processing_template_decl != 0
and context is adc_unify and we have constraints, pretend the
constraints are satisfied instead of punting. Otherwise don't
punt unless placeholder_type_constraint_dependent_p holds.
Add some clarifying sanity checks. Add a hack to add missing
outermost template levels to outer_args before checking
satisfaction. Don't substitute outer_targs into type if it's
already been done.
gcc/testsuite/ChangeLog:
PR c++/99365
* g++.dg/cpp2a/concepts-partial-spec9.C: New test.
* g++.dg/cpp2a/concepts-placeholder4.C: New test.
|
|
|
|
The issue in this PR is that we wrongly reject converting pointers to
member function of incomplete types, one of which has noexcept. Recall
that pointers (including pointers to member functions) to non-throwing
functions can be implicitly converted to potentially-throwing functions
(but not vice versa).
We reject the conversion when called from can_convert_arg_bad because
standard_conversion can't create such a conversion. It comes down to
the DERIVED_FROM_P check in the TYPE_PTRMEMFUNC_P block. It considers
every class derived from itself, but not when the class is incomplete.
But surely we want to reach fnptr_conv_p when tbase is fbase (one of
them could be an alias to the other so use same_type_p instead of ==).
Another approach would be to not perform DERIVED_FROM_P at all when
either tbase or fbase are incomplete (so perhaps something like at the
end of ptr_reasonably_similar).
gcc/cp/ChangeLog:
PR c++/99374
* call.c (standard_conversion): When converting pointers to
member, don't return NULL when the bases are equivalent but
incomplete.
gcc/testsuite/ChangeLog:
PR c++/99374
* g++.dg/cpp1z/noexcept-type23.C: New test.
|
|
We crash here, because in a template, an enumerator doesn't have
a type until we've called finish_enum_value_list. But our -Wshadow
implementation, check_local_shadow, is called when we pushdecl in
build_enumerator, which takes place before finish_enum_value_list.
gcc/cp/ChangeLog:
PR c++/99120
* name-lookup.c (check_local_shadow): Check if the type of decl
is non-null before checking TYPE_PTR*.
gcc/testsuite/ChangeLog:
PR c++/99120
* g++.dg/warn/Wshadow-17.C: New test.
|
|
Header units can declare the same entity, and this can lead to one of
them containing a (non-using) binding to an import. If one gets the
cluster ordering just right, an assert will trigger. Relax that assert.
PR c++/99245
gcc/cp/
* module.cc (module_state::write_cluster): Relax binding assert.
gcc/testsuite/
* g++.dg/modules/pr99245_a.H: New.
* g++.dg/modules/pr99245_b.H: New.
|
|
This turned out to be the function version of the previous fix. We
can import an implicit specialization declaration that we need to
instantiate. We must mark the instantiation so we remember to stream
it.
PR c++/99377
gcc/cp/
* pt.c (instantiate_decl): Call set_instantiating_module.
gcc/testsuite/
* g++.dg/modules/pr99377_a.H: New.
* g++.dg/modules/pr99377_b.C: New.
* g++.dg/modules/pr99377_c.C: New.
|
|
PR98118 shows that TYPE_NEEDS_CONSTRUCTING is necessary but not
sufficient. Use type_build_ctor_call() instead.
gcc/cp/ChangeLog:
PR c++/98118
* coroutines.cc (build_co_await): Use type_build_ctor_call()
to determine cases when a CTOR needs to be built.
(flatten_await_stmt): Likewise.
(morph_fn_to_coro): Likewise.
gcc/testsuite/ChangeLog:
PR c++/98118
* g++.dg/coroutines/pr98118.C: New test.
|
|
From the PR:
The wording of [dcl.fct.def.coroutine]/15 states:
* The expression co_await promise.final_suspend() shall not be
potentially-throwing ([except.spec]).
See http://eel.is/c++draft/dcl.fct.def.coroutine#15
and http://eel.is/c++draft/except.spec#6
ie. all of the following must be declared noexcept (if they form part of the await-expression):
- promise_type::final_suspend()
- finalSuspendObj.operator co_await()
- finalSuspendAwaiter.await_ready()
- finalSuspendAwaiter.await_suspend()
- finalSuspendAwaiter.await_resume()
- finalSuspedObj destructor
- finalSuspendAwaiter destructor
This implements the checks for these cases and rejects such code with
a diagnostic if exceptions are enabled.
gcc/cp/ChangeLog:
PR c++/95616
* coroutines.cc (coro_diagnose_throwing_fn): New helper.
(coro_diagnose_throwing_final_aw_expr): New helper.
(build_co_await): Diagnose throwing final await expression
components.
(build_init_or_final_await): Diagnose a throwing promise
final_suspend() call.
gcc/testsuite/ChangeLog:
PR c++/95616
* g++.dg/coroutines/pr95616-0-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-0.C: New test.
* g++.dg/coroutines/pr95616-1-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-1.C: New test.
* g++.dg/coroutines/pr95616-2.C: New test.
* g++.dg/coroutines/pr95616-3-no-exceptions.C: New test.
* g++.dg/coroutines/pr95616-3.C: New test.
* g++.dg/coroutines/pr95616-4.C: New test.
* g++.dg/coroutines/pr95616-5.C: New test.
* g++.dg/coroutines/pr95616-6.C: New test.
|
|
The coroutine body is wrapped in a try-catch block which is responsible for
handling any exceptions thrown by the original function body. Originally, the
initial suspend expression was outside this, but an amendement to the standard
places the await_resume call inside and eveything else outside.
This means that any exception thrown prior to the initial suspend expression
await_resume() will propagate to the ramp function. However, some portion of
the coroutine state will exist at that point (how much depends on where the
exception is thrown from). For example, we might have some frame parameter
copies, or the promise object or the return object any of which might have a
non-trivial DTOR. Also the frame itself needs to be deallocated. This patch
fixes the handling of these cases.
gcc/cp/ChangeLog:
PR c++/95615
* coroutines.cc (struct param_info): Track parameter copies that need
a DTOR.
(coro_get_frame_dtor): New helper function factored from build_actor().
(build_actor_fn): Use coro_get_frame_dtor().
(morph_fn_to_coro): Track parameters that need DTORs on exception,
likewise the frame promise and the return object. On exception, run the
DTORs for these, destroy the frame and then rethrow the exception.
gcc/testsuite/ChangeLog:
PR c++/95615
* g++.dg/coroutines/torture/pr95615-01.C: New test.
* g++.dg/coroutines/torture/pr95615-02.C: New test.
* g++.dg/coroutines/torture/pr95615-03.C: New test.
* g++.dg/coroutines/torture/pr95615-04.C: New test.
* g++.dg/coroutines/torture/pr95615-05.C: New test.
|
|
When an incomplete class specialization is imported, and is completed
by instantiation, we were failing to mark the instantiation, and thus
didn't stream it out. Leading to errors in importing as we had
members of an incomplete type.
PR c++/99389
gcc/cp/
* pt.c (instantiate_class_template_1): Set instantiating module
here.
gcc/testsuite/
* g++.dg/modules/pr99389_a.H: New.
* g++.dg/modules/pr99389_b.C: New.
* g++.dg/modules/pr99389_c.C: New.
|
|
gcc/c/ChangeLog:
PR c/99137
* c-parser.c (c_parser_oacc_clause_async): Reject comma expressions.
gcc/cp/ChangeLog:
PR c/99137
* parser.c (cp_parser_oacc_clause_async): Reject comma expressions.
gcc/testsuite/ChangeLog:
PR c/99137
* c-c++-common/goacc/asyncwait-1.c: Update dg-error; add
additional test.
|
|
|
|
[PR99362]
In the P1771R1 changes JeanHeyd reverted part of Alex' PR88146 fix,
but that seems to be incorrect to me.
Where P1771R1 suggests warnings for [[nodiscard]] on constructors is
handled in a different place - in particular the TARGET_EXPR handling
of convert_to_void. When we have CALL_EXPR of a ctor, on most arches
that call has void return type and so returns early, and on arm where
the ctor returns the this pointer it is undesirable to warn as it warns
about all ctor calls, not just the ones where it should warn.
The P1771R1 changes added a test for this, but as it was given *.c
extension rather than *.C, the test was never run and so this didn't get
spotted immediately. The test also had a bug, (?n) can't be used
in dg-warning/dg-error because those are implemented by prepending
some regexp before the user provided one and (?n) must come at the start
of the regexp. Furthermore, while -ftrack-macro-expansion=0 is useful
in one nodiscard test which uses macros, I don't see how it would be
relevant to all the other cpp2a/nodiscard* tests which don't use any
macros.
2021-03-04 Jakub Jelinek <jakub@redhat.com>
PR c++/88146
PR c++/99362
gcc/cp/
* cvt.c (convert_to_void): Revert 2019-10-17 changes. Clarify
comment.
gcc/testsuite/
* g++.dg/cpp2a/nodiscard-constructor.c: Renamed to ...
* g++.dg/cpp2a/nodiscard-constructor1.C: ... this. Remove
-ftrack-macro-expansion=0 from dg-options. Don't use (?n) in
dg-warning regexps, instead replace .* with \[^\n\r]*.
* g++.dg/cpp2a/nodiscard-constructor2.C: New test.
* g++.dg/cpp2a/nodiscard-reason-only-one.C: Remove
-ftrack-macro-expansion=0 from dg-options.
* g++.dg/cpp2a/nodiscard-reason-nonstring.C: Likewise.
* g++.dg/cpp2a/nodiscard-once.C: Likewise.
|
|
With pending entities reimplemented, the remaining use of uintset can just
use a regular hash map -- I only used a uintset because it was there.
So one adhoc hash-table/vector structure goes away.
PR c++/99170
gcc/cp/
* module.cc (class uintset): Delete.
(typedef attached_map_t): A hash map.
(attached_table): Use attached_map_t. Adjust uses ...
(trees_out::decl_value, trees_in::decl_value): ... here ...
(trees_out::key_mergeable): ... here ...
(trees_in::key_mergeable): ... here ...
(maybe_attach_decl): ... here ...
(direct_import): ... and here.
|
|
This patch addresses 99170. with modules (and in particular header
units), one module can provide a (maybe nested) class or template and
another module can provide a definition or (maybe partial)
specialization of said entity, or member thereof. when both are
imported into a 3rd TU, and that TU instantiates or uses the class, it
needs to stream in those entities (in general). But how does it key
those entities to the original? It can't /just/ use the entity index,
because, when header-units and/or partitions are in play, the entity
index /is not unique/. I had two complicated schemes that tried to
unify that, but it failed. Here's a simpler scheme. Such pending
entities are keyed to the namespace and identifier of the
namespace-scope entity that contains them. Thus the final TU needs to
find that entity and look in a hash table for lists of sections that
need loading just before instantiating a template or looking inside a
class.
I would like to make this more efficient, but given the complex scheme
failed, I'm shooting for correctness right now. There will be a
follow up patch to complete the cleanup this enables.
PR c++/99170
gcc/cp/
* cp-tree.h
* lex.c (cxx_dup_lang_specific_decl): Adjust for module_attached_p
rename.
* module.cc (class pending_key): New.
(default_hash_traits<pending_key>): New specialization.
(pending_map_t): New typedef.
(pending_table): Replace old table.
(trees_out::lang_decl_bools): Adjust.
(trees_in::lang_decl_bools): Adjust.
(trees_in::install_entity): Drop pending member and specialization
handling.
(find_pending_key): New.
(depset::hash::fiund_dependencies): Use it.
(pendset_lazy_load): Delete.
(module_state::write_cluster): Don't count pendings here. Bye
Duff's device-like thing.
(module_state::write_pendings): Reimplement.
(module_state::read_pendings): Reimplement.
(lazy_specializations_p): Delete.
(module_state::write): Adjust write_pendings call.
(lazy_load_pendings): New.
(lazy_load_specializations): Delete.
(lazy_load_members): Delete.
(init_modules): Adjust.
* name-lookup.c (maybe_lazily_declare): Call lazy_load_pendings
not lazy_load_members.
(note_pending_specializations): Delete.
(load_pending_specializations): Delete.
* name-lookup.h (BINDING_VECTR_PENDING_SPECIALIZATIONS_P): Delete.
(BINDING_VECTOR_PENDING_MEMBERS_P): Delete.
(BINDING_VECTR_PENDING_MEMBERS_P): Delete.
(note_pending_specializations): Delete.
(load_pending_specializations): Delete.
* pt.c (lookup_template_class_1): Call lazy_load_pendings not
lazy_load_specializations.
(instantiate_template_class_1): Likewise.
(instantiate_decl): Call lazy_load_pendings.
* typeck.c (complete_type): Likewise.
gcc/testsuite/
* g++.dg/modules/pr99170-1_a.H: New.
* g++.dg/modules/pr99170-1_b.C: New.
* g++.dg/modules/pr99170-2.h: New.
* g++.dg/modules/pr99170-2_a.C: New.
* g++.dg/modules/pr99170-2_b.C: New.
* g++.dg/modules/pr99170-3_a.H: New.
* g++.dg/modules/pr99170-3_b.C: New.
* g++.dg/modules/inst-2_b.C: Adjust scan.
* g++.dg/modules/inst-4_a.C: Adjust scan.
* g++.dg/modules/inst-4_b.C: Adjust scan.
* g++.dg/modules/member-def-1_b.C: Adjust scan.
* g++.dg/modules/member-def-1_c.C: Adjust scan.
* g++.dg/modules/tpl-spec-1_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-1_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_c.C: Adjust scan.
* g++.dg/modules/tpl-spec-2_d.C: Adjust scan.
* g++.dg/modules/tpl-spec-3_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-3_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-4_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-4_b.C: Adjust scan.
* g++.dg/modules/tpl-spec-5_a.C: Adjust scan.
* g++.dg/modules/tpl-spec-5_b.C: Adjust scan.
|
|
|
|
It turns out that cloning can cause use to load things. Specifically when
checking paramter shadows (this is avoidable), and also the delete
operator of a deleting dtor (not avoidable). Doing that in the middle of
loading is a bad thing. This defers it to a post-load worklist. If it
causes more loading at that point there is no problem, as we've completed
the first set of loads, bar this bit of cleanup.
Again, this doesn't fix 99170, but is a step towards a solution.
PR c++/99170
gcc/cp/
* module.cc (post_load_decls): New.
(lazy_snum, recursive_lazy): Move earlier.
(module_state::read_cluster): Push cloning onto post_load_decls.
(post_load_processing): New. Do the cloning here.
(module_state::read_inits): Call post_load_processing.
(module_state::read_language): Likewise.
(lazy_load_binding, lazy_load_specializations): Likewise
(lazy_load_members): Likewise
|
|
This defers inserting specializations into the specialization table,
until we have completed their streaming. When streaming a cluster we
ensure that all imports are populated before any of the cluster, so
they need no visibility of other specializations. Further within the
same import, we've already partitioned the graph, so no earlier
cluster can be refering to a specialization in a later cluster.
Inserting them early causes problems when other specializations of the
same template are inserted. (This doesn't fix 99170, but is a
necessary change for that PR).
Earlier on, I had less deferred processing, but it has become clearer
that deferred worklists are the right way of handling a few things.
This patch highlights a fixme, in that we're streaming a key twice,
and need not do that, but I wanted to get correctness first. Besides
the second streaming will end up being a back reference, which is of
course much cheaper than a by-value stream.
PR c++/99170
gcc/cp/
* module.cc (trees_out::decl_value): Stream specialization keys
after decl.
(trees_in::decl_value): Stream them back and insert after
completing the decl.
(trees_out::key_mergeable): Drop some streaming here ...
(trees_in::key_mergeable): ... and here. Don't insert into
specialization tables.
|
|
This folds the diagnose_requires_expr routines into the corresponding
tsubst_requires_expr ones. This is achieved by making the latter
routines take a sat_info instead of a subst_info, and assigning the
appropriate meanings to the flags sat_info::noisy and
sat_info::diagnose_unsatisfaction_p during tsubst_requires_expr:
info.noisy() controls whether to diagnose invalid types and expressions
inside the requirements, and info.diagnose_unsatisfaction_p() controls
whether to additionally diagnose why the requires-expression evaluates
to false.
gcc/cp/ChangeLog:
* constraint.cc (struct sat_info): Document the different
meanings of noisy() and diagnose_unsatisfaction_p() during
satisfaction and requires-expression evaluation.
(tsubst_valid_expression_requirement): Take a sat_info instead
of a subst_info. Perform the substitution quietly first. Fold
in error-replaying code from diagnose_valid_expression.
(tsubst_simple_requirement): Take a sat_info instead of a
subst_info.
(tsubst_type_requirement_1): New. Fold in error-replaying code
from diagnose_valid_type.
(tsubst_type_requirement): Use the above. Take a sat_info
instead of a subst_info.
(tsubst_compound_requirement): Likewise. Fold in
error-replaying code from diagnose_compound_requirement.
(tsubst_nested_requirement): Take a sat_info instead of a
subst_info. Fold in error-replaying code from
diagnose_nested_requirement.
(tsubst_requirement): Take a sat_info instead of a subst_info.
(tsubst_requires_expr): Split into two versions, one that takes
a sat_info argument and another that takes a complain and
in_decl argument. Remove outdated documentation. Document the
effects of the sat_info argument. Don't short-circuit
processing of requirements when diagnosing unsatisfaction,
mirroring diagnose_requires_expr.
(satisfy_nondeclaration_constraint) <case REQUIRES_EXPR>: Remove
assert, and se the three-parameter version of tsubst_requires_expr.
(diagnose_trait_expr): Make static. Take a template argument
vector instead of a parameter mapping.
(diagnose_valid_expression): Remove.
(diagnose_valid_type): Remove.
(diagnose_simple_requirement): Remove.
(diagnose_compound_requirement): Remove.
(diagnose_type_requirement): Remove.
(diagnose_nested_requirement): Remove.
(diagnose_requirement): Remove.
(diagnose_requires_expr): Remove.
(diagnose_atomic_constraint): Take a sat_info instead of a
subst_info. Adjust call to diagnose_trait_expr. Call
tsubst_requires_expr instead of diagnose_requires_expr.
(diagnose_constraints): Remove special casing of REQUIRES_EXPR
and just always call constraint_satisfaction_value.
|
|
This patch mostly performs some straightforward refactoring:
- Renamed satisfy_constraint to satisfy_normalized_constraints
- Renamed the three-parameter version of satisfy_constraint_expression
to satisfy_nondeclaration_constraints
- Removed normalize_(non)?template_requirements
- Removed satisfy_associated_constraints (and made its callers
check for dependent template args sooner, before normalization)
- Removed the tsubst_flags_t parameter of evaluate_concept_check
- Combined the two versions of constraint_satisfaction_value
- Combined the two versions of constraint_satisfied_p
Additionally, this patch removes the handling of general
constraint-expressions from satisfy_nondeclaration_constraints, and
hence constraints_satisfied_p and constraint_satisfaction_value now take
only things that carry their own template information needed for
normalization, and, as a special case, REQUIRES_EXPRs. But the latter
now get evaluated directly via tsubst_requires_expr rather than going
through satisfaction.
(That we used to evaluate REQUIRES_EXPR via satisfaction might even be a
correctness issue: since we cache satisfaction in special ways that don't
apply to regular evaluation, going through satisfaction could in theory
cause us to reuse a cached value for a REQUIRES_EXPR when we shouldn't
have.)
gcc/cp/ChangeLog:
* constexpr.c (cxx_eval_call_expression): Adjust call to
evaluate_concept_check.
(cxx_eval_constant_expression) <case REQUIRES_EXPR>: Use
evaluate_requires_expression instead of
satisfy_constraint_expression.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* constraint.cc (struct sat_info): Adjust comment about which
satisfaction entrypoints use noisy-unsat.
(normalize_template_requirements): Remove (and adjust callers
appropriately).
(normalize_nontemplate_requirements): Likewise.
(tsubst_nested_requirement): Use constraint_satisfaction_value
instead of satisfy_constraint_expression, which'll do the
noisy replaying of ill-formed quiet satisfaction for us.
(decl_satisfied_cache): Adjust comment.
(satisfy_constraint): Rename to ...
(satisfy_normalized_constraints): ... this.
(satisfy_associated_constraints): Remove (and make its
callers check for dependent arguments).
(satisfy_constraint_expression): Rename to ...
(satisfy_nondeclaration_constraints): ... this. Assert that
'args' is empty when 't' is a concept-id. Removing handling
bare constraint-expressions, and handle REQUIRES_EXPRs
specially. Adjust comment accordingly.
(satisfy_declaration_constraints): Assert in the two-parameter
version that 't' is not a TEMPLATE_DECL. Adjust following
removal of normalize_(non)?template_requirements and
satisfy_asociated_constraints.
(constraint_satisfaction_value): Combine the two- and
three-parameter versions in the natural way.
(constraints_satisfied_p): Combine the one- and two-parameter
versions in the natural way. Improve documentation.
(evaluate_requires_expr): Define.
(evaluate_concept_check): Remove 'complain' parameter. Use
constraint_satisfaction_value instead of
satisfy_constraint_expression.
(diagnose_nested_requirement): Adjust following renaming of
satisfy_constraint_expression.
(diagnose_constraints): Handle REQUIRES_EXPR by going through
diagnose_requires_expr directly instead of treating it as a
constraint-expression. Improve documentation.
* cp-gimplify.c (cp_genericize_r) <case CALL_EXPR>: Adjust call
to evaluate_concept_check.
<case REQUIRES_EXPR>: Use evaluate_requires_expr instead of
constraints_satisfied_p.
<case TEMPLATE_ID_EXPR>: Adjust call to evaluate_concept_check.
* cp-tree.h (evaluate_requires_expr): Declare.
(evaluate_concept_check): Remove tsubst_flag_t parameter.
(satisfy_constraint_expression): Remove declaration.
(constraints_satisfied_p): Remove one-parameter declaration.
Add a default argument to the two-parameter declaration.
* cvt.c (convert_to_void): Adjust call to
evaluate_concept_check.
|
|
P0145R3 added
"However, the operands are sequenced in the order prescribed for the built-in
operator" rule for overloaded operator calls when using the operator syntax.
op_is_ordered follows that, but added just the overloaded operators
added in that paper. &&, || and comma operators had rules that
lhs is sequenced before rhs already in C++98.
The following patch adds those cases to op_is_ordered.
2021-03-03 Jakub Jelinek <jakub@redhat.com>
PR c++/82959
* call.c (op_is_ordered): Handle TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR
and COMPOUND_EXPR.
* g++.dg/cpp1z/eval-order10.C: New test.
|
|
We represent deduction guides with FUNCTION_DECLs, but they are built
without DECL_CONTEXT, leading to an ICE in type_dependent_expression_p
on the assert that the type of a function template with no dependent
(innermost!) template arguments must be non-dependent. Consider the
attached class-deduction79.C: we create a deduction guide:
template<class T> G(T)-> E<Z>::G<T>
we deduce T and create a partial instantiation:
G(T) -> E<Z>::G<T> [with T = int]
And then do_class_deduction wants to create a CALL_EXPR from the above
using build_new_function_call -> build_over_call which calls mark_used
-> maybe_instantiate_noexcept -> type_dependent_expression_p.
There, the innermost template arguments are non-dependent (<int>), but
the fntype is dependent -- the return type is a TYPENAME_TYPE, and
since we have no DECL_CONTEXT, this check holds:
/* Otherwise, if the function decl isn't from a dependent scope, it can't be
type-dependent. Checking this is important for functions with auto return
type, which looks like a dependent type. */
if (TREE_CODE (expression) == FUNCTION_DECL
&& !(DECL_CLASS_SCOPE_P (expression)
&& dependent_type_p (DECL_CONTEXT (expression)))
whereupon we ICE.
This patch fixes it by deferring the class deduction until the
enclosing scope is non-dependent. build_deduction_guide and maybe_aggr_guide
needed a little tweaking to make the deduction work in a member
template.
Co-Authored-By: Jason Merrill <jason@redhat.com>
gcc/cp/ChangeLog:
PR c++/97034
PR c++/99009
* pt.c (build_deduction_guide): Use INNERMOST_TEMPLATE_ARGS.
(maybe_aggr_guide): Use the original template type where needed. In
a class member template, partially instantiate the result of
collect_ctor_idx_types.
(do_class_deduction): Defer the deduction until the enclosing
scope is non-dependent.
gcc/testsuite/ChangeLog:
PR c++/97034
PR c++/99009
* g++.dg/cpp1z/class-deduction81.C: New test.
* g++.dg/cpp1z/class-deduction82.C: New test.
* g++.dg/cpp2a/class-deduction-aggr8.C: New test.
* g++.dg/cpp2a/class-deduction-aggr9.C: New test.
* g++.dg/cpp2a/class-deduction-aggr10.C: New test.
|
|
A call that is the immediate operand of decltype has special semantics: no
temporary is produced, so it's OK for the return type to be e.g. incomplete.
But we were treating (e | f) the same way, which confused overload
resolution when we then tried to evaluate ... | g.
Fixed by making build_temp do what its name says, and force the C++17
temporary materialization conversion.
gcc/cp/ChangeLog:
PR c++/95675
* call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
if it didn't get one before.
gcc/testsuite/ChangeLog:
PR c++/95675
* g++.dg/cpp0x/decltype-call5.C: New test.
* g++.dg/cpp0x/decltype-call6.C: New test.
|
|
This reworks namespace serializing to avoid some issues I ran into
when working on 99170. In modules, (non-anonymous) namespaces are
strange beasts, that always have external linkage, but may have
module-specific visibility. I still don't get the latter 100%
correct, but this is in the right direction.
PR c++/99344
gcc/cp/
* module.cc (trees_out::decl_node): Small refactor.
(depset::hash::add_binding_entity): Return true on meeting an
import. Set namespace's import here.
(module_state:write_namespaces): Inform of purview too.
(module_state:read_namespaces): Adjust.
* name-lookup.c (implicitly_export_namespace): Delete.
(do_pushdecl): Don't call it.
(push_namespace): Likewise, set purview.
(add_imported_namespace): Reorder parms.
* name-lookup.h (add_imported_namespace): Alter param ordering.
gcc/testsuite/
* g++.dg/modules/namespace-2_a.C
* g++.dg/modules/pr99344_a.C
* g++.dg/modules/pr99344_b.C
|
|
|
|
gcc/cp/ChangeLog:
PR c++/99251
* class.c (build_base_path): Call build_if_nonnull.
* cp-tree.h (build_if_nonnull): Declare.
* rtti.c (ifnonnull): Rename...
(build_if_nonnull): ...to this. Set no-warning bit on COND_EXPR.
(build_dynamic_cast_1): Adjust to name change.
gcc/testsuite/ChangeLog:
PR c++/99251
* g++.dg/warn/Wnonnull9.C: Expect no warnings.
* g++.dg/warn/Wnonnull12.C: New test.
|