C ObjC C++ ObjC++ Var(warn_missing_field_initializers) Warning EnabledBy(Wextra)
Warn about missing fields in struct initializers.
+Wmissing-requires
+C++ ObjC++ Var(warn_missing_requires) Init(1) Warning
+Warn about likely missing requires keyword.
+
Wmultistatement-macros
C ObjC C++ ObjC++ Var(warn_multistatement_macros) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
Warn about unsafe macros expanding to multiple statements used as a body of a clause such as if, else, while, switch, or for.
if (expr.get_location() == UNKNOWN_LOCATION)
expr.set_location (start);
+ for (tree t = expr; ; )
+ {
+ if (TREE_CODE (t) == TRUTH_ANDIF_EXPR
+ || TREE_CODE (t) == TRUTH_ORIF_EXPR)
+ {
+ t = TREE_OPERAND (t, 0);
+ continue;
+ }
+ if (concept_check_p (t))
+ {
+ gcc_rich_location richloc (get_start (start));
+ richloc.add_fixit_insert_before (start, "requires ");
+ warning_at (&richloc, OPT_Wmissing_requires, "testing "
+ "if a concept-id is a valid expression; add "
+ "%<requires%> to check satisfaction");
+ }
+ break;
+ }
+
return finish_simple_requirement (expr.get_location (), expr);
}
This warning is included in @option{-Wextra}. To get other @option{-Wextra}
warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
+@item -Wno-missing-requires
+@opindex Wmissing-requires
+@opindex Wno-missing-requires
+
+By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
+
+@smallexample
+bool satisfied = requires @{ C<T> @};
+@end smallexample
+
+Here @samp{satisfied} will be true if @samp{C<T>} is a valid
+expression, which it is for all T. Presumably the user meant to write
+
+@smallexample
+bool satisfied = requires @{ requires C<T> @};
+@end smallexample
+
+so @samp{satisfied} is only true if concept @samp{C} is satisfied for
+type @samp{T}.
+
+This warning can be disabled with @option{-Wno-missing-requires}.
+
@item -Wno-multichar
@opindex Wno-multichar
@opindex Wmultichar
template<typename U>
auto f() {
- return []<typename T>(T, bool a = requires { C<T>; }){
+ return []<typename T>(T, bool a = requires { C<T>; }){ // { dg-warning Wmissing-requires }
static_assert(requires { requires C<U> && (C<T> || C<T>); }); // { dg-error "assert" }
- static_assert(requires { C<T>; });
+ static_assert(requires { C<T>; }); // { dg-warning Wmissing-requires }
static_assert(requires { { foo<T>() } noexcept -> C; });
static_assert(!requires { typename T::blah; }); // { dg-error "assert" }
return 0;