Skip to content

Commit

Permalink
[gcc] Implement a stub version of __is_trivially_relocatable(T)
Browse files Browse the repository at this point in the history
It's just a synonym for `__is_trivially_copyable(T)`, but it's enough
to get started with.
  • Loading branch information
Quuxplusone committed Dec 25, 2023
1 parent ed60b28 commit 5742fba
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gcc/cp/constraint.cc
Expand Up @@ -3822,6 +3822,9 @@ diagnose_trait_expr (tree expr, tree args)
case CPTK_IS_TRIVIALLY_COPYABLE:
inform (loc, " %qT is not trivially copyable", t1);
break;
case CPTK_IS_TRIVIALLY_RELOCATABLE:
inform (loc, " %qT is not trivially relocatable", t1);
break;
case CPTK_IS_UNION:
inform (loc, " %qT is not a union", t1);
break;
Expand Down
1 change: 1 addition & 0 deletions gcc/cp/cp-trait.def
Expand Up @@ -90,6 +90,7 @@ DEFTRAIT_EXPR (IS_TRIVIAL, "__is_trivial", 1)
DEFTRAIT_EXPR (IS_TRIVIALLY_ASSIGNABLE, "__is_trivially_assignable", 2)
DEFTRAIT_EXPR (IS_TRIVIALLY_CONSTRUCTIBLE, "__is_trivially_constructible", -1)
DEFTRAIT_EXPR (IS_TRIVIALLY_COPYABLE, "__is_trivially_copyable", 1)
DEFTRAIT_EXPR (IS_TRIVIALLY_RELOCATABLE, "__is_trivially_relocatable", 1)
DEFTRAIT_EXPR (IS_UNION, "__is_union", 1)
DEFTRAIT_EXPR (REF_CONSTRUCTS_FROM_TEMPORARY, "__reference_constructs_from_temporary", 2)
DEFTRAIT_EXPR (REF_CONVERTS_FROM_TEMPORARY, "__reference_converts_from_temporary", 2)
Expand Down
1 change: 1 addition & 0 deletions gcc/cp/cp-tree.h
Expand Up @@ -7951,6 +7951,7 @@ extern bool layout_pod_type_p (const_tree);
extern bool std_layout_type_p (const_tree);
extern bool trivial_type_p (const_tree);
extern bool trivially_copyable_p (const_tree);
extern bool trivially_relocatable_p (const_tree);
extern bool type_has_unique_obj_representations (const_tree);
extern bool scalarish_type_p (const_tree);
extern bool structural_type_p (tree, bool = false);
Expand Down
3 changes: 3 additions & 0 deletions gcc/cp/semantics.cc
Expand Up @@ -12495,6 +12495,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
case CPTK_IS_TRIVIALLY_COPYABLE:
return trivially_copyable_p (type1);

case CPTK_IS_TRIVIALLY_RELOCATABLE:
return trivially_relocatable_p (type1);

case CPTK_IS_UNION:
return type_code1 == UNION_TYPE;

Expand Down
11 changes: 11 additions & 0 deletions gcc/cp/tree.cc
Expand Up @@ -4635,6 +4635,17 @@ trivially_copyable_p (const_tree t)
return scalarish_type_p (t);
}

/* Returns 1 iff type T is a trivially relocatable type, as defined in
[basic.types] and [class.prop]. For now, this just reports trivially
copyable types, and ignores anything to do with transitivity or
attributes. TODO FIXME BUG HACK. */

bool
trivially_relocatable_p (const_tree t)
{
return trivially_copyable_p (t);
}

/* Returns 1 iff type T is a trivial type, as defined in [basic.types] and
[class]. */

Expand Down

0 comments on commit 5742fba

Please sign in to comment.