Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
We want to move to having different representations of the contract
semantic for C++26, since that wants values outside the range that
can be accommodated using the cxx2a mechanisms. First part, abstract
the interfaces to constexpr, so that they do not see the underlying
source of data.
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_constant_expression): Use revised
interfaces to determine if contracts are ignored and, if not,
whether they are evaluated.
* contracts.h (contract_ignored_p, contract_evaluated_p): New.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
|
|
currently autoprofiled bootstrap produces auto-profiles for cc1 and cc1plus
binaries. Those are used to build respective frontend files. For backend
cc1plus.fda is used. This does not work well with LTO bootstrap where cc1plus
backend is untrained since it is used only for parsing and ealry opts. As a
result all binaries gets most of the backend optimized for size rather then
speed.
This patch adds lto1.fda and then combines all of cc1, cc1plus and lto1 into
all.fda that is used compiling common modules. This is more or less equivalent
to what -fprofile-use effectively uses modulo that with -fprofile-use we know
number of runs of evety object file and scale accordingly at LTO time.
gcc/ChangeLog:
* Makefile.in (ALL_FDAS): New variable.
(ALL_HOST_BACKEND_OBJ): Use all.fda instead of cc1plus.fda
(all.fda): New target
gcc/c/ChangeLog:
* Make-lang.in: Add c_FDAS
(create_fdas_for_cc1): Be sure that build fails if create_gcov fails.
gcc/cp/ChangeLog:
* Make-lang.in: Add c++_FDAS
(create_fdas_for_cc1plus): Be sure that build fails if create_gcov fails.
gcc/lto/ChangeLog:
* Make-lang.in: Add lto_FDAS; enable FDA collection
(create_fdas_for_lto1): Be sure that build fails if create_gcov fails.
|
|
|
|
One case missed in my fix for this PR: Here we were omitting the
IMPLICIT_CONV_EXPR that expresses the conversion from int to char because
the target type was non-dependent and the argument was not type-dependent.
But we still need it if the argument is value-dependent.
PR c++/112632
gcc/cp/ChangeLog:
* pt.cc (convert_template_argument): Also force IMPLICIT_CONV_EXPR
if the argument is value-dependent.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-conv4.C: New test.
|
|
Here template substitution was replacing a reference to the 'this' of X::f
with the implicit closure parameter of the operator(), which is wrong. The
closure parameter is never a suitable replacement for a 'this' parameter.
PR c++/122048
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr): Don't use a lambda current_class_ptr.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-this6.C: New test.
|
|
|
|
This assertion, despite what I said in r16-4070, is not valid: we can
reach here when deduping a VAR_DECL that didn't get a LANG_SPECIFIC in
the current TU. It's still correct to always use lang_cplusplus however
as for anything else the decl would have been created with an
appropriate LANG_SPECIFIC to start with.
PR c++/122015
PR c++/122019
gcc/cp/ChangeLog:
* module.cc (trees_in::install_entity): Remove incorrect
assertion.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
|
|
|
|
The ICE in the linked PR is caused because when current_lang_name is
lang_name_c, set_decl_linkage calls decl_linkage on the retrofitted
declaration. This is problematic because at this point we haven't
finished streaming the declaration, and so we crash when attempting to
access these missing bits (such as the type).
The only declarations we can reach here will be things like types that
don't get a language linkage anyway, so it seems reasonable to just
hardcode a C++ language linkage here to work around the issue.
An alternative fix would be to override current_lang_name in
lazy_load_binding instead, but this is potentially confusing if we ever
deliberately implement `extern "C" import "header_unit.hpp";` to
override the language linkage of imported declarations, so I went with
this approach instead. (Though it seems we never will do this.)
While testing this I found that we don't currently complain about
mismatching language linkages for variables, and module_may_redeclare
doesn't cope well with implementation units, so this patch also fixes
those issues.
PR c++/122019
gcc/cp/ChangeLog:
* module.cc (trees_in::install_entity): Don't be affected by
global language linkage state.
(trees_in::is_matching_decl): Check mismatching language linkage
for variables too.
(module_may_redeclare): Report the correct module name for
partitions and implementation units.
gcc/testsuite/ChangeLog:
* g++.dg/modules/lang-4_a.C: New test.
* g++.dg/modules/lang-4_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
|
|
This change refactors FMV handling in the frontend to allows greater
reasoning about versions in shared code.
This is needed for allowing target_clones and target_versions to be used
together in a function set, as there is then two distinct concerns when
encountering two declarations that previously were conflated:
1. Are these two declarations completely disjoint FMV declarations
(ie. the sets of versions they define have no overlap). If so, they don't
conflict so there is no need to merge and both can be pushed.
2. For two declarations that aren't completely disjoint, are they matching
and therefore mergeable. (ie. two target_clone decls that define the same set
of versions, or an un-annotated declaration, and a target_clones definition
containing the default version). If so, continue to the existing merging logic
to try to merge these and diagnose if it's not possible.
If not, then diagnose the conflicting declarations.
To do this the common_function_versions function has been renamed
disjoint_function_versions (meaning, are the version sets defined by these
two decl's completely distinct from each other).
A new hook called same_function_version is introduces taking two
string_slice's (each representing a single version) and determining if they
define the same version.
A new function, called diagnose_versioned_decls is added, which checks
if two decls (with overlapping version sets) can be merged and diagnose when
they cannot be (only in terms of the attributes, the existing logic is used to
detect other mergeability conflicts like redefinition).
This only effects targets with TARGET_HAS_FMV_TARGET_ATTRIBUTE set to false.
(ie. aarch64 and riscv), the existing logic for i86 and ppc is unchanged.
This also means the same function version hook is only used for aarch64 and
riscv.
gcc/ChangeLog:
* attribs.h (common_function_versions): Removed.
* attribs.cc (common_function_versions): Removed.
* config/aarch64/aarch64.cc (aarch64_common_function_versions): Removed.
(aarch64_same_function_versions): New function to check if two version
strings imply the same version.
(TARGET_OPTION_FUNCTION_VERSIONS): Removed.
(TARGET_OPTION_SAME_FUNCTION_VERSIONS): New macro.
* config/i386/i386.cc (TARGET_OPTION_FUNCTION_VERSIONS): Removed.
* config/rs6000/rs6000.cc (TARGET_OPTION_FUNCTION_VERSIONS): Removed.
* config/riscv/riscv.cc (riscv_same_function_versions): New function
to check if two version strings imply the same version.
(riscv_common_function_versions): Removed.
(TARGET_OPTION_FUNCTION_VERSIONS): Removed.
(TARGET_OPTION_SAME_FUNCTION_VERSIONS): New macro.
* doc/tm.texi: Regenerated.
* target.def: Remove common_version hook and add same_function_version
hook.
* doc/tm.texi.in: Ditto.
* tree.cc (distinct_version_decls): New function.
(mergeable_version_decls): Ditto.
* tree.h (distinct_version_decls): New function.
(mergeable_version_decls): Ditto.
* hooks.h (hook_stringslice_stringslice_unreachable): New function.
* hooks.cc (hook_stringslice_stringslice_unreachable): New function.
gcc/cp/ChangeLog:
* class.cc (resolve_address_of_overloaded_function): Updated to use
dijoint_versions_decls instead of common_function_version hook.
* decl.cc (decls_match): Refacture to use disjoint_version_decls and
to pass through conflicting_version argument.
(maybe_version_functions): Updated to use
disjoint_version_decls instead of common_function_version hook.
(duplicate_decls): Add logic to handle conflicting unmergable decls
and improve diagnostics for conflicting versions.
* decl2.cc (check_classfn): Updated to use
disjoint_version_decls instead of common_function_version hook.
|
|
Adds the target_version and target_clones attributes to diagnostic messages
for target_version semantics.
This is because the target_version/target_clones attributes affect the identity
of the decls, so need to be represented in diagnostics for them.
This also requires making maybe_print_whitespace available to c++ code so
we can control if whitespace is needed cosistantly between c and c++
diagnostics.
After this change diagnostics look like:
c:
```
test.c:6:8: error: redefinition of ‘foo [[target_version("sve")]]’
6 | float foo () {return 1;}
| ^~~
test.c:3:8: note: previous definition of ‘foo [[target_version("sve")]]’ with type ‘float(void)’
3 | float foo () {return 2;}
| ^~~
test.c:12:8: error: redefinition of ‘bar [[target_clones("sve")]]’
12 | float bar () {return 1;}
| ^~~
test.c:9:8: note: previous definition of ‘bar [[target_clones("sve")]]’ with type ‘float(void)’
9 | float bar () {return 2;}
| ^~~
```
c++:
```
test.cpp:6:8: error: redefinition of ‘float foo [[target_version("sve")]] ()’
6 | float foo () {return 1;}
| ^~~
test.cpp:3:8: note: ‘float foo [[target_version("sve")]] ()’ previously defined here
3 | float foo () {return 2;}
| ^~~
test.cpp:12:8: error: redefinition of ‘float bar [[target_clones("sve")]] ()’
12 | float bar () {return 1;}
| ^~~
test.cpp:9:8: note: ‘float bar [[target_clones("sve")]] ()’ previously defined here
9 | float bar () {return 2;}
| ^~~
```
This only affects targets which use target_version (aarch64 and riscv).
gcc/c-family/ChangeLog:
* c-pretty-print.cc (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
(pp_c_maybe_whitespace): Move to c-pretty-print.h.
* c-pretty-print.h (pp_c_function_target_version): New function.
(pp_c_function_target_clones): New function.
(pp_c_maybe_whitespace): Moved here from c-pretty-print.cc.
gcc/c/ChangeLog:
* c-objc-common.cc (c_tree_printer): Add printing of target_clone and
target_version in decl diagnostics.
gcc/cp/ChangeLog:
* cxx-pretty-print.h (pp_cxx_function_target_version): New macro.
(pp_cxx_function_target_clones): Ditto.
(pp_cxx_maybe_whitespace): Ditto.
* error.cc (dump_function_decl): Add printing of target_clone and
target_version in decl diagnostics.
|
|
This patch changes the semantics of target_version and target_clones attributes
to match the behavior described in the Arm C Language extension.
The changes to behavior are:
- The scope and signature of an FMV function set is now that of the default
version.
- The FMV resolver is now created at the locations of the default version
implementation. Previously this was at the first call to an FMV function.
- When a TU has a single annotated function version, it gets mangled.
- This includes a lone annotated default version.
This only affects targets with TARRGET_HAS_FMV_TARGET_ATTRIBUTE set to false.
Currently that is aarch64 and riscv.
This is achieved by:
- Skipping the existing FMV dispatching code at C++ gimplification and instead
making use of the target_clones dispatching code in multiple_targets.cc.
(This fixes PR target/118313 for aarch64 and riscv).
- Splitting target_clones pass in two, an early and late pass, where the early
pass handles cases where multiple declarations are used to define a version,
and the late pass handling target semantics targets, and cases where a FMV
set is defined by a single target_clones decl.
- Changing the logic in add_candidates and resolve_address of overloaded
function to prevent resolution of any version except a default version.
(thus making the default version determine scope and signature of the
versioned function set).
- Adding logic for dispatching a lone annotated default version in
multiple_targets.cc
- As as annotated default version gets mangled an alias is created from the
dispatched symbol to the default version as no ifunc resolution is required
in this case. (ie. an alias from `_Z3foov` to `_Z3foov.default`)
- Adding logic to `symbol_table::remove_unreachable_nodes` and analyze_functions
that a reference to the default function version also implies a possible
reference to the other versions (so they shouldnt be deleted and do need to
be analyzed).
gcc/ChangeLog:
PR target/118313
* cgraph.cc (delete_function_version): Made public static member of
cgraph_node.
* cgraph.h (delete_function_version): Ditto.
* cgraphunit.cc (analyze_functions): Add logic for target version
dependencies.
* ipa.cc (symbol_table::remove_unreachable_nodes): Ditto.
* multiple_target.cc (create_dispatcher_calls): Change to support
target version semantics.
(ipa_target_clone): Change to dispatch all function sets in
target_version semantics, and to have early and late pass.
(expand_target_clones): Add logic for cases of target_clones with no
defaults.
(is_simple_target_clones_case): New function.
(class pass_target_clone): New parameter for early or late pass.
* config/aarch64/aarch64.cc: (aarch64_get_function_versions_dispatcher):
Refactor with the assumption that the DECL node will be default.
* config/riscv/riscv.cc: (riscv_get_function_versions_dispatcher):
Refactor with the assumption that the DECL node will be default.
* passes.def: Split target_clones pass into early and late version.
gcc/cp/ChangeLog:
PR target/118313
* call.cc (add_candidates): Change to not resolve non-default versions
in target_version semantics.
* class.cc (resolve_address_of_overloaded_function): Ditto.
* cp-gimplify.cc (cp_genericize_r): Change logic to not apply for
target_version semantics.
* decl.cc (maybe_mark_function_versioned): Remove static.
* cp-tree.h (maybe_mark_function_versioned): New function.
* decl2.cc (cplus_decl_attributes ): Change to mark and therefore
mangle all target_version decls in target_version semantics.
* typeck.cc (cp_build_function_call_vec): Add error for calling
unresolvable non-default node in target_version semantics.
gcc/testsuite/ChangeLog:
* g++.target/aarch64/mv-1.C: Change for target_version semantics.
* g++.target/aarch64/mv-symbols2.C: Ditto.
* g++.target/aarch64/mv-symbols3.C: Ditto.
* g++.target/aarch64/mv-symbols4.C: Ditto.
* g++.target/aarch64/mv-symbols5.C: Ditto.
* g++.target/aarch64/mvc-symbols3.C: Ditto.
* g++.target/riscv/mv-symbols2.C: Ditto.
* g++.target/riscv/mv-symbols3.C: Ditto.
* g++.target/riscv/mv-symbols4.C: Ditto.
* g++.target/riscv/mv-symbols5.C: Ditto.
* g++.target/riscv/mvc-symbols3.C: Ditto.
* g++.target/aarch64/mv-symbols10.C: New test.
* g++.target/aarch64/mv-symbols11.C: New test.
* g++.target/aarch64/mv-symbols12.C: New test.
* g++.target/aarch64/mv-symbols13.C: New test.
* g++.target/aarch64/mv-symbols6.C: New test.
* g++.target/aarch64/mv-symbols7.C: New test.
* g++.target/aarch64/mv-symbols8.C: New test.
* g++.target/aarch64/mv-symbols9.C: New test.
|
|
This patch is an overhaul of how FMV name mangling works. Previously
mangling logic was duplicated in several places across both target
specific and independent code. This patch changes this such that all
mangling is done in targetm.mangle_decl_assembler_name (including for the
dispatched symbol and dispatcher resolver).
Adds the assembler_name member to cgraph_function_version_info to store
the base assembler name of the function set, before FMV mangling.
This allows for the removing of previous hacks, such as where the default
mangled decl's assembler name was unmangled to then remangle all versions
and the resolver and dispatched symbol.
This introduces a change (shown in test changes) for the assembler name of the
dispatched symbol for a x86 versioned function set. Previously it used the
function name mangled twice. This was hard to reproduce without hacks I
wasn't comfortable with. Therefore, the mangling is changed to instead append
".ifunc" which matches clang's behavior.
This change also refactors expand_target_clone using
targetm.mangle_decl_assembler_name for mangling and get_clone_versions.
It is modified such that if the target_clone is in a FMV structure
the ordering is preserved once expanded. This is used later for ACLE semantics
and target_clone/target_version mixing.
gcc/ChangeLog:
* attribs.cc (make_dispatcher_decl): Move duplicated cgraph logic into
this function and change to use targetm.mangle_decl_assembler_name for
mangling.
* cgraph.cc (cgraph_node::insert_new_function_version): Record
assembler_name.
* cgraph.h (struct cgraph_function_version_info): Add assembler_name.
(struct cgraph_node): Add dispatcher_resolver_function and
is_target_clone.
* config/aarch64/aarch64.cc (aarch64_parse_fmv_features): Change to
support string_slice.
(aarch64_process_target_version_attr): Ditto.
(get_feature_mask_for_version): Ditto.
(aarch64_mangle_decl_assembler_name): Add logic for mangling dispatched
symbol and resolver.
(get_suffixed_assembler_name): Removed.
(make_resolver_func): Refactor to use
aarch64_mangle_decl_assembler_name for mangling.
(aarch64_generate_version_dispatcher_body): Remove remangling.
(aarch64_get_function_versions_dispatcher): Refactor to remove
duplicated cgraph logic.
* config/i386/i386-features.cc
(ix86_mangle_function_version_assembler_name): Refactor to use
clone_identifier and to mangle default.
(ix86_mangle_decl_assembler_name): Add logic for mangling dispatched
symbol and resolver.
(ix86_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
(make_resolver_func): Refactor to use ix86_mangle_decl_assembler_name
for mangling.
* config/riscv/riscv.cc (riscv_mangle_decl_assembler_name): Add logic
for FMV mangling.
(get_suffixed_assembler_name): Removed.
(make_resolver_func): Refactor to use riscv_mangle_decl_assembler_name
for mangling.
(riscv_generate_version_dispatcher_body): Remove unnecessary remangling.
(riscv_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
* config/rs6000/rs6000.cc (rs6000_mangle_decl_assembler_name): New
function.
(rs6000_get_function_versions_dispatcher): Remove duplicated cgraph
logic.
(make_resolver_func): Refactor to use rs6000_mangle_decl_assembler_name
for mangling.
(rs6000_mangle_function_version_assembler_name): New function.
* multiple_target.cc (create_dispatcher_calls): Remove mangling code.
(get_attr_str): Removed.
(separate_attrs): Ditto.
(is_valid_asm_symbol): Removed.
(create_new_asm_name): Ditto.
(expand_target_clones): Refactor to use
targetm.mangle_decl_assembler_name for mangling and be more general.
* tree.cc (get_target_clone_attr_len): Removed.
* tree.h (get_target_clone_attr_len): Removed.
gcc/cp/ChangeLog:
* decl.cc (maybe_mark_function_versioned): Change to insert function version
and therefore record assembler name.
gcc/testsuite/ChangeLog:
* g++.target/i386/mv-symbols1.C: Update x86 FMV mangling.
* g++.target/i386/mv-symbols3.C: Ditto.
* g++.target/i386/mv-symbols4.C: Ditto.
* g++.target/i386/mv-symbols5.C: Ditto.
|
|
|
|
comp_template_parms_position uses whether a TEMPLATE_TYPE_PARM is a pack
to determine equivalency. This in turn affects whether
canonical_type_parameter finds a pre-existing auto type as equivalent.
When generating the 'auto...' type for a lambda pack capture, we only
mark it as a pack after generating the node (and calculating its
canonical); this means that later when comparing a version streamed in
from a module we think that two equivalent types have different
TYPE_CANONICAL, because the latter already had
TEMPLATE_PARM_PARAMETER_PACK set before calculating its canonical.
This patch fixes this by using a new 'make_auto_pack' function to ensure
that packness is set before the canonical is looked up.
PR c++/122015
gcc/cp/ChangeLog:
* cp-tree.h (make_auto_pack): Declare.
* lambda.cc (lambda_capture_field_type): Use make_auto_pack to
ensure TYPE_CANONICAL is set correctly.
* pt.cc (make_auto_pack): New function.
gcc/testsuite/ChangeLog:
* g++.dg/modules/lambda-11.h: New test.
* g++.dg/modules/lambda-11_a.H: New test.
* g++.dg/modules/lambda-11_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
|
|
|
|
Here the normal form of the two immediately-declared D<<placeholder>, V>
constraints is the same, so we rightfully share the normal form between
them. We first compute the normal form from the context of auto deduction
for W in which case the placeholder has level 2 where the set of
in-scope template parameters has depth 2 (a dummy level is added from
normalize_placeholder_type_constraints).
Naturally the atomic constraint only depends on the template parameter
V of depth 1 index 0. The depth 2 of current_template_parms however
means that find_template_parameters when it sees V within the atomic
constraint will recurse into its TREE_TYPE, an auto of level 2, and mark
the atomic constraint as also depending on the template parameter of
depth 2 index 0, which is clearly wrong. Later during constraint
checking for B we ICE within the satisfaction cache since we lack two
levels of template arguments supposedly needed by the cached atomic
constraint.
I think when find_template_parameters sees an NTTP, it doesn't need to
walk its TREE_TYPE because NTTP substitution is done obliviously with
respect to its type -- only the corresponding NTTP argument matters,
not other template arguments possibly used within its type. This is
most clearly true for (unconstrained) auto NTTPs as in the testcase, but
also true for other NTTPs. Doing so fixes the testcase because we no
longer record any depth 2 when walking V within the atomic constraint.
PR c++/121981
gcc/cp/ChangeLog:
* pt.cc (any_template_parm_r) <case TEMPLATE_TYPE_PARM>:
Don't walk TREE_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-placeholder15.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
PR c++/119048
gcc/cp/ChangeLog:
* lambda.cc (compare_lambda_sig): Only skip first parameter for
object members.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/static-operator-call8.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
|
|
It's now possible to see an active member of a union that has not actually
been initialized, so let's clarify the diagnostic.
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_component_reference): Clarify diagnostic.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-98122.C: Adjust diagnostic.
* g++.dg/cpp26/constexpr-new6a.C: New test.
|
|
Since Jakub's P2795R5 work removes the initial clobber from constructors,
let's add a clobber for new of all non-empty classes.
gcc/cp/ChangeLog:
* init.cc (build_new_1): Clobber classes.
gcc/testsuite/ChangeLog:
* g++.dg/analyzer/pr97116.C: Adjust diagnostic.
* g++.dg/warn/Warray-bounds-20.C: Likewise.
|
|
r16-3022 changed placement new to clobber the object, and improved constexpr
handling to do more with clobbers. But it occurred to me that in a lot of
cases we don't need to introduce a constructor_elt to represent an
uninitialized member of an uninitialized struct/array.
gcc/cp/ChangeLog:
* constexpr.cc (get_or_insert_ctor_field): -2 means don't insert.
(cxx_eval_component_reference): Handle finding void_node.
(cxx_eval_store_expression): Don't represent initial clobber
unless we need to activate a union member.
(cxx_eval_statement_list): Don't ask for a void prvalue.
(cxx_eval_loop_expr): The expr is discarded-value.
(cxx_eval_constant_expression): A loose clobber is non-constant.
Handle getting void_node instead of a real result.
(potential_constant_expression_1): A local temp is
potentially-constant.
* init.cc (build_new_1): Don't clobber empty types or
in a template.
(build_vec_init): Fix clobber handling.
gcc/testsuite/ChangeLog:
* g++.dg/init/pr25811.C: Tweak diagnostic.
* g++.dg/warn/Warray-bounds-12.C: Likewise.
* g++.dg/warn/Warray-bounds-13.C: Likewise.
* g++.dg/cpp26/constexpr-new6.C: New test.
|
|
With new (nothrow) we need to check whether the allocation returned null,
and the resulting COND_EXPR was confusing -Wmismatched-new-delete-2 at -O0.
Let's help it out by appending the address if it's the same on both arms.
gcc/cp/ChangeLog:
* init.cc (build_new_1): Append alloc_node to checking COND_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wmismatched-new-delete-2.C: Remove xfail.
|
|
|
|
Comment #2 of PR c++/121966 notes that the "inherited here" messages
should be nested *within* the note they describe.
Implemented by this patch, which also nests other notes emitted for
rejection_reason within the first note of print_z_candidate.
gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidate): Consolidate instances of
auto_diagnostic_nesting_level into one, above the "inherited here"
message so that any such message is nested within the note,
and any messages emitted due to the switch on rejection_reason are
similarly nested within the note.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
In r15-6116-gd3dd24acd74605 I updated print_z_candidates to show the
number of candidates, and a number for each candidate.
PR c++/121966 notes that the printed count is sometimes higher than
what's actually printed: I missed the case where candidates in the
list aren't printed due to not being viable.
Fixed thusly.
gcc/cp/ChangeLog:
PR c++/121966
* call.cc (print_z_candidates): Copy the filtering logic on viable
candidates from the printing loop to the counting loop, so that
num_candidates matches the number of iterations of the latter
loop.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
|
|
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
gcc/cp/ChangeLog:
* mangle.cc (write_real_cst): Replace 8 spaces with Tab.
|
|
|
|
We weren't explicitly treating a pack index specifier as a non-deduced
context (as per [temp.deduct.type]/5), leading to an ICE for the first
testcase below.
PR c++/121795
gcc/cp/ChangeLog:
* pt.cc (unify) <case PACK_INDEX_TYPE>: New non-deduced context
case.
gcc/testsuite/ChangeLog:
* g++.dg/cpp26/pack-indexing17.C: New test.
* g++.dg/cpp26/pack-indexing17a.C: New test.
Reviewed-by: Marek Polacek <polacek@redhat.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
My r16-3559-gc2e567a6edb563 reworked ADL for modules, including a change
to allow seeing module-linkage declarations if they only exist on the
instantiation path. This caused a crash however as I neglected to
unwrap the stat hack wrapper when we were happy to see all declarations,
allowing search_adl to add non-functions to the overload set.
PR c++/121893
gcc/cp/ChangeLog:
* name-lookup.cc (name_lookup::adl_namespace_fns): Unwrap the
STAT_HACK also when on_inst_path.
gcc/testsuite/ChangeLog:
* g++.dg/modules/adl-10_a.C: New test.
* g++.dg/modules/adl-10_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
|
|
|
|
Don't upgrade TLS model when cplus_decl_attributes is called on a thread
local variable whose TLS model isn't set yet.
gcc/cp/
PR c++/121889
* decl2.cc (cplus_decl_attributes): Don't upgrade TLS model if
TLS model isn't set yet.
gcc/testsuite/
PR c++/121889
* g++.dg/tls/pr121889.C: New test.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
A static member template doesn't always have a DECL_INITIAL, as in the
below testcase, and so checking its TREE_CODE performs a null-pointer
dereference. I don't think we need to specially detect this case as
traits we care about are unlikely to be members, so this just adds the
missing null check.
PR c++/121859
gcc/cp/ChangeLog:
* constraint.cc (maybe_diagnose_standard_trait): Check if expr
is non-null.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-traits5.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
|
|
On Fri, Sep 05, 2025 at 09:57:06PM +0200, Matthias Kretz wrote:
> > Hmm, would this fail for x86 long double, which is 80 bits? OK, just
> > checked. It's mangled as 12/16 bytes on i686/x86_64.
>
> It seems that Clang and GCC disagree on mangling 80-Bit long double:
>
> I like Clang's interpretation of https://itanium-cxx-abi.github.io/cxx-abi/
> abi.html#mangle.float better.
This patch changes the mangling of 80-bit long double literals from
24 or 32 digits (on m68k with padding bits in the middle, on x86
at the start) to just 20 hex digits.
2025-09-10 Jakub Jelinek <jakub@redhat.com>
* mangle.cc (write_real_cst): Mangle Intel/Motorola extended
80-bit formats using 20 hex digits instead of 24 or 32.
* g++.target/i386/mangle-ldbl-1.C: New test.
* g++.target/i386/mangle-ldbl-2.C: New test.
* g++.target/m68k/mangle-ldbl-1.C: New test.
* g++.target/m68k/mangle-ldbl-2.C: New test.
|
|
|
|
This patch fixes some issues with import handling.
The main functional change is to allow importing a module's interface
file into its implementation file indirectly. [module.import] p9
forbids an explicit 'import M;' declaration, but there's no provision
against having 'import X;' where module X itself imports M, so this
patch splits up the detection of circular imports to handle this better.
I also updated the errors to be closer to the standard wording.
A second issue I found while testing this is that we don't properly
handle name visibility when a partition implementation unit imports its
primary module interface (g++.dg/modules/part-10). This is resolved by
setting 'module_p' on the primary interface when it gets imported.
Solving this I incidentally removed the assertion that PR121808 was
failing on, which was never valid: we can enter import_module for a
module previously seen as a module-declaration if parsing bails before
declare_module is called. I experimented with guaranteeing that
declare_module always gets called for a module_state generated during
preprocessing if at all possible, but the resulting errors didn't seem a
lot better so I've left it as-is for now.
I did make a small adjustment so that a direct import of a module
doesn't overwrite the location of a module-declaration from earlier in
the file; this is important because preprocessing (and thus the
assigning of these locations) seems to happen for the whole file before
parsing begins, which can otherwise cause confusing locations referring
to later in the file than parsing would otherwise indicate.
PR c++/99682
PR c++/121808
gcc/cp/ChangeLog:
* module.cc (class module_state): Add comment to 'parent'.
(module_state::check_not_purview): Rename to...
(module_state::check_circular_import): ...this. Only handle
interface dependencies, adjust diagnostic message.
(module_state::read_imports): Use new function. Pass location
of import as from_loc instead of the module location.
(module_state::do_import): Set module_p when importing the
primary interface for the current module.
(import_module): Split out check for imports in own unit.
Remove incorrect assertion.
(preprocess_module): Don't overwrite module-decl location with
later import.
gcc/testsuite/ChangeLog:
* g++.dg/modules/circ-1_c.C: Adjust diagnostic.
* g++.dg/modules/mod-decl-1.C: Likewise.
* g++.dg/modules/mod-decl-2_b.C: Likewise.
* g++.dg/modules/pr99174.H: Likewise.
* g++.dg/modules/import-3_a.C: New test.
* g++.dg/modules/import-3_b.C: New test.
* g++.dg/modules/import-3_c.C: New test.
* g++.dg/modules/mod-decl-9.C: New test.
* g++.dg/modules/part-10_a.C: New test.
* g++.dg/modules/part-10_b.C: New test.
* g++.dg/modules/part-10_c.C: New test.
* g++.dg/modules/part-10_d.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
A lot of places use (*modules)[0] to refer to the module state for the
current TU. This is a bit awkward to type and not particularly clear
what it represents; make a helper function to clarify it.
gcc/cp/ChangeLog:
* module.cc (this_module): New function.
(import_entity_module): Use it.
(trees_out::decl_node): Likewise.
(get_module): Likewise.
(module_state::check_not_purview): Likewise.
(module_state::read_imports): Likewise.
(module_state::read_using_directives): Likewise.
(module_state::read_initial): Likewise.
(get_import_bitmap): Likewise.
(module_may_redeclare): Likewise.
(direct_import): Likewise.
(declare_module): Likewise.
(name_pending_imports): Likewise.
(preprocess_module): Likewise.
(finish_module_processing): Likewise.
(late_finish_module): Likewise.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
|
|
Apparently an explicitly defined operator<=> isn't required to return
std::foo_ordering, so build_min_non_dep_op_overload needs to be able
to rebuild forms of (x <=> y) @ 0 where the @ resolved to a built-in and
in turn isn't expressed as a function call.
PR c++/121779
gcc/cp/ChangeLog:
* tree.cc (build_min_non_dep_op_overload): Handle comparison
operator expressions rewritten from a <=> that returns a
non-class type.
gcc/testsuite/ChangeLog:
* g++.dg/lookup/operator-8.C: Remove outdated comment about
this test failing.
* g++.dg/lookup/operator-8a.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
gcc/testsuite/ChangeLog:
PR c++/121801
* g++.dg/abi/pr121801.C: New test.
gcc/cp/ChangeLog:
PR c++/121801
* mangle.cc (write_real_cst): Handle 16-bit real and assert
that reals have 16 bits or a multiple of 32 bits.
|
|
|
|
Set a tentative TLS model in grokvardecl and update TLS mode with the
default TLS access model after a TLS variable has been fully processed
if the default TLS access model is stronger.
gcc/cp/
PR c++/107393
* decl.cc (grokvardecl): Set a tentative TLS model which will be
updated by cplus_decl_attributes later.
* decl2.cc (cplus_decl_attributes): Update TLS model with the
default TLS access model if the default TLS access model is
stronger.
* pt.cc (tsubst_decl): Set TLS model only after processing a
variable.
gcc/testsuite/
PR c++/107393
* g++.dg/tls/pr107393-1.C: New test.
* g++.dg/tls/pr107393-2.C: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
Currently we represent exported using-directives as a list of indices
into the namespace array that we stream. However this list of
namespaces doesn't include any namespaces that we don't expose in this
module's purview, and so we ICE.
This patch reworks the handling to instead use the existing depset
tracking for namespaces directly. This means that we don't need to
build up a second lookup map when streaming, and we can reuse the logic
in {read,write}_namespace. We do need to make sure that we create a
depset for namespaces only referenced by a using-directive, though.
I don't expect to be exporting large numbers of using-directives from a
namespace, so for simplicity we stream the names as {parent, target}
pairs.
This also adjusts read handling so that we load the using-directives for
any import (including indirect) if it's in the import list for the
current TU. Otherwise we run into issues if the using-directive is in
a namespace that is otherwise never referenced in the 'export import'ing
module, because we never walk this namespace and so never know that we
need to emit it. To do this the patch ensures that we calculate the
import list before read_language is called.
As a drive-by fix, I noticed that with modules 'add_using_namespace'
will add duplicate using-directives because we compare usings against
the target namespace, but we then push a wrapping USING_DECL instead.
This reworks so that the contents of the structure is equivalent between
modules and non-modules code.
PR c++/121702
gcc/cp/ChangeLog:
* module.cc (enum module_state_counts): New counter.
(depset::hash::add_namespace_entities): Seed using-directive
targets for later streaming.
(module_state::write_namespaces): Don't handle using-directives
here.
(module_state::read_namespaces): Likewise.
(module_state::write_using_directives): New function.
(module_state::read_using_directives): New function.
(module_state::write_counts): Log using-directives.
(module_state::read_counts): Likewise.
(module_state::write_begin): Stream using-directives.
(module_state::read_language): Read using-directives if
directly importing.
(module_state::direct_import): Update current TU import list
before calling read_language.
* name-lookup.cc (add_using_namespace): Fix lookup of previous
using-directives.
* parser.cc (cp_parser_import_declaration): Don't set
MK_EXPORTING when performing import_module.
gcc/testsuite/ChangeLog:
* g++.dg/modules/namespace-10_c.C: Add check for log dump.
* g++.dg/modules/namespace-13_a.C: New test.
* g++.dg/modules/namespace-13_b.C: New test.
* g++.dg/modules/namespace-13_c.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
|
|
[basic.lookup.argdep] p4 says that ADL also finds declarations of
functions or function templates from a point of lookup within the
module, only ignoring discarded (or internal) GM entities.
To implement this we need to create bindings for these entities so that
we can guarantee that name lookup will discover they exist. This raises
some complications, though, as we ideally would like to avoid having
bindings that contain no declarations, or emitting GM namespaces that
only contain discarded or internal functions.
This patch does this by additionally creating a new binding whenever we
call make_dependency on a non-EK_FOR_BINDING decl. We don't do this for
using-decls, as at the point of use of a GM entity we no longer know
whether we called through a using-decl or the declaration directly;
however, this behaviour is explicitly supported by [module.global.frag]
p3.6.
Creating these bindings caused g++.dg/modules/default-arg-4_* to fail.
It turns out that this makes the behaviour look identical to
g++.dg/modules/default-arg-5, which is incorrectly dg-error-ing default
value redeclarations (we only currently error because of PR c++/99000).
This patch removes the otherwise identical test and turns the dg-errors
into xfailed dg-bogus.
As a drive-by fix this also fixes an ICE when debug printing friend
function instantiations.
PR c++/121705
PR c++/117658
gcc/cp/ChangeLog:
* module.cc (depset::hash::make_dependency): Make bindings for
GM functions.
(depset::hash::add_binding_entity): Adjust comment.
(depset::hash::add_deduction_guides): Add log.
* ptree.cc (cxx_print_xnode): Handle friend functions where
TI_TEMPLATE is an OVERLOAD or IDENTIFIER.
gcc/testsuite/ChangeLog:
* g++.dg/modules/default-arg-4_a.C: XFAIL bogus errors.
* g++.dg/modules/default-arg-4_b.C: Likewise.
* g++.dg/modules/default-arg-5_a.C: Remove duplicate test.
* g++.dg/modules/default-arg-5_b.C: Likewise.
* g++.dg/modules/adl-9_a.C: New test.
* g++.dg/modules/adl-9_b.C: New test.
* g++.dg/modules/gmf-5.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
|
|
|
|
Marek Polacek reported to me internally that I've messed up one diagnostic
message in this function, with one word before final double quote on one
line and another word right after opening double quote on the next line,
with no space in between.
Fixed thusly.
2025-09-05 Jakub Jelinek <jakub@redhat.com>
* constexpr.cc (cxx_eval_cxa_builtin_fn): Add missing word separating
space into invalid_nargs diagnostics.
|