Skip to content

Commit 340370b

Browse files
author
foxfromabyss
committed
[Clang][Diagnostics] Use "structured binding" instead of "decomposition"
P0615R0 changed the term "decomposition" to "structured binding". Some diagnostic messages were created before this paper. These messages should be updated using "structured binding" to avoid making users confused. See for context: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0615r0.html
1 parent d72cd24 commit 340370b

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ def err_expected_end_of_enumerator : Error<
504504
def err_expected_coloncolon_after_super : Error<
505505
"expected '::' after '__super'">;
506506

507-
def ext_decomp_decl_empty : ExtWarn<
508-
"ISO C++17 does not allow a decomposition group to be empty">,
509-
InGroup<DiagGroup<"empty-decomposition">>;
507+
def ext_decomp_decl_empty
508+
: ExtWarn<
509+
"ISO C++17 does not allow a structured binding group to be empty">,
510+
InGroup<DiagGroup<"empty-structured-binding">>;
510511

511512
def err_function_parameter_limit_exceeded : Error<
512513
"too many function parameters; subsequent parameters will be ignored">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ defm constexpr_body_multiple_return : CXX14Compat<
3131
defm variable_template : CXX14Compat<"variable templates are">;
3232

3333
// C++17 compatibility with C++14 and earlier.
34-
defm decomp_decl : CXX17Compat<"decomposition declarations are">;
34+
defm decomp_decl : CXX17Compat<"structured binding declarations are">;
3535
defm inline_variable : CXX17Compat<"inline variables are">;
3636

3737
// C++20 compatibility with C++17 and earlier.
3838
defm decomp_decl_spec
39-
: CXX20Compat<"decomposition declaration declared '%0' is">;
39+
: CXX20Compat<"structured binding declaration declared '%0' is">;
4040
defm constexpr_local_var_no_init : CXX20Compat<
4141
"uninitialized variable in a constexpr %select{function|constructor}0 is">;
4242
defm constexpr_function_try_block : CXX20Compat<
@@ -589,60 +589,59 @@ def warn_modifying_shadowing_decl :
589589
"field of %1">,
590590
InGroup<ShadowFieldInConstructorModified>, DefaultIgnore;
591591

592-
// C++ decomposition declarations
593-
def err_decomp_decl_context : Error<
594-
"decomposition declaration not permitted in this context">;
592+
// C++ structured binding declarations
593+
def err_decomp_decl_context
594+
: Error<"structured binding declaration not permitted in this context">;
595595
def err_decomp_decl_spec
596-
: Error<"decomposition declaration cannot be declared '%0'">;
597-
def err_decomp_decl_type : Error<
598-
"decomposition declaration cannot be declared with type %0; "
599-
"declared type must be 'auto' or reference to 'auto'">;
600-
def err_decomp_decl_constraint : Error<
601-
"decomposition declaration cannot be declared with constrained 'auto'">;
602-
def err_decomp_decl_parens : Error<
603-
"decomposition declaration cannot be declared with parentheses">;
604-
def err_decomp_decl_template : Error<
605-
"decomposition declaration cannot be a template">;
606-
def err_decomp_decl_not_alone : Error<
607-
"decomposition declaration must be the only declaration in its group">;
608-
def err_decomp_decl_requires_init : Error<
609-
"decomposition declaration %0 requires an initializer">;
610-
def err_decomp_decl_wrong_number_bindings : Error<
611-
"type %0 decomposes into %3 %plural{1:element|:elements}2, but "
612-
"%select{%plural{0:no|:only %1}1|%1}4 "
613-
"%plural{1:name was|:names were}1 provided">;
614-
def err_decomp_decl_unbindable_type : Error<
615-
"cannot decompose %select{union|non-class, non-array}1 type %2">;
616-
def err_decomp_decl_multiple_bases_with_members : Error<
617-
"cannot decompose class type %1: "
618-
"%select{its base classes %2 and|both it and its base class}0 %3 "
619-
"have non-static data members">;
620-
def err_decomp_decl_ambiguous_base : Error<
621-
"cannot decompose members of ambiguous base class %1 of %0:%2">;
622-
def err_decomp_decl_inaccessible_base : Error<
623-
"cannot decompose members of inaccessible base class %1 of %0">,
624-
AccessControl;
625-
def err_decomp_decl_inaccessible_field : Error<
626-
"cannot decompose %select{private|protected}0 member %1 of %3">,
627-
AccessControl;
628-
def err_decomp_decl_lambda : Error<
629-
"cannot decompose lambda closure type">;
630-
def err_decomp_decl_anon_union_member : Error<
631-
"cannot decompose class type %0 because it has an anonymous "
632-
"%select{struct|union}1 member">;
633-
def err_decomp_decl_std_tuple_element_not_specialized : Error<
634-
"cannot decompose this type; 'std::tuple_element<%0>::type' "
635-
"does not name a type">;
636-
def err_decomp_decl_std_tuple_size_not_constant : Error<
637-
"cannot decompose this type; 'std::tuple_size<%0>::value' "
638-
"is not a valid integral constant expression">;
596+
: Error<"structured binding declaration cannot be declared '%0'">;
597+
def err_decomp_decl_type
598+
: Error<"structured binding declaration cannot be declared with type %0; "
599+
"declared type must be 'auto' or reference to 'auto'">;
600+
def err_decomp_decl_constraint : Error<"structured binding declaration cannot "
601+
"be declared with constrained 'auto'">;
602+
def err_decomp_decl_parens
603+
: Error<
604+
"structured binding declaration cannot be declared with parentheses">;
605+
def err_decomp_decl_template
606+
: Error<"structured binding declaration cannot be a template">;
607+
def err_decomp_decl_not_alone : Error<"structured binding declaration must be "
608+
"the only declaration in its group">;
609+
def err_decomp_decl_requires_init
610+
: Error<"structured binding declaration %0 requires an initializer">;
611+
def err_decomp_decl_wrong_number_bindings
612+
: Error<"type %0 binds to %3 %plural{1:element|:elements}2, but "
613+
"%select{%plural{0:no|:only %1}1|%1}4 "
614+
"%plural{1:name was|:names were}1 provided">;
615+
def err_decomp_decl_unbindable_type
616+
: Error<"cannot bind %select{union|non-class, non-array}1 type %2">;
617+
def err_decomp_decl_multiple_bases_with_members
618+
: Error<"cannot bind class type %1: "
619+
"%select{its base classes %2 and|both it and its base class}0 %3 "
620+
"have non-static data members">;
621+
def err_decomp_decl_ambiguous_base
622+
: Error<"cannot bind members of ambiguous base class %1 of %0:%2">;
623+
def err_decomp_decl_inaccessible_base
624+
: Error<"cannot bind members of inaccessible base class %1 of %0">,
625+
AccessControl;
626+
def err_decomp_decl_inaccessible_field
627+
: Error<"cannot bind %select{private|protected}0 member %1 of %3">,
628+
AccessControl;
629+
def err_decomp_decl_lambda : Error<"cannot bind lambda closure type">;
630+
def err_decomp_decl_anon_union_member
631+
: Error<"cannot bind class type %0 because it has an anonymous "
632+
"%select{struct|union}1 member">;
633+
def err_decomp_decl_std_tuple_element_not_specialized
634+
: Error<"cannot bind this type; 'std::tuple_element<%0>::type' "
635+
"does not name a type">;
636+
def err_decomp_decl_std_tuple_size_not_constant
637+
: Error<"cannot bind this type; 'std::tuple_size<%0>::value' "
638+
"is not a valid integral constant expression">;
639639
def err_decomp_decl_std_tuple_size_invalid
640-
: Error<"cannot decompose this type; 'std::tuple_size<%0>::value' "
640+
: Error<"cannot bind this type; 'std::tuple_size<%0>::value' "
641641
"is not a valid size: %1">;
642642
def note_in_binding_decl_init : Note<
643643
"in implicit initialization of binding declaration %0">;
644-
def err_arg_is_not_destructurable : Error<
645-
"type %0 cannot be decomposed">;
644+
def err_arg_is_not_destructurable : Error<"type %0 cannot be bound">;
646645

647646
def err_std_type_trait_not_class_template : Error<
648647
"unsupported standard library implementation: "
@@ -2618,9 +2617,9 @@ def err_auto_variable_cannot_appear_in_own_initializer
26182617
"%VarTemplateExplicitSpec{variable template explicit "
26192618
"specialization}}0 %1 "
26202619
"declared with deduced type %2 cannot appear in its own initializer">;
2621-
def err_binding_cannot_appear_in_own_initializer : Error<
2622-
"binding %0 cannot appear in the initializer of its own "
2623-
"decomposition declaration">;
2620+
def err_binding_cannot_appear_in_own_initializer
2621+
: Error<"binding %0 cannot appear in the initializer of its own "
2622+
"structured binding declaration">;
26242623
def err_new_array_of_auto : Error<
26252624
"cannot allocate array of 'auto'">;
26262625
def err_auto_not_allowed : Error<

0 commit comments

Comments
 (0)