aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c.opt
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-08-27 17:28:28 -0400
committerJason Merrill <jason@redhat.com>2021-08-30 16:48:28 -0400
commite18e56c76be35e6a799e07a01c24e0fff3eb1978 (patch)
tree766fbe1a70cbdf41dd9b401101eda0e8451d02c6 /gcc/c-family/c.opt
parent9213ff13247739d6d335064a6b568278a872a991 (diff)
downloadgcc-e18e56c76be35e6a799e07a01c24e0fff3eb1978.zip
gcc-e18e56c76be35e6a799e07a01c24e0fff3eb1978.tar.gz
gcc-e18e56c76be35e6a799e07a01c24e0fff3eb1978.tar.bz2
c++: Add warning about missing 'requires'
I noticed that concepts-lambda14.C had two useless requires-expressions: static_assert(requires { C<T>; }); always succeeds, because C<T> is always a valid expression for any type, regardless of whether C is satisfied for a particular type. Presumably the user means static_assert(requires { requires C<T>; }); to make the C<T> a nested-requirement. Of course, static_assert(C<T>); is much simpler and means the same thing; this is more relevant in the middle of a longer requires-expression, such as the bug this warning found in cmcstl2: template<class I> META_CONCEPT input_iterator = input_or_output_iterator<I> && readable<I> && requires(I& i, const I& ci) { typename iterator_category_t<I>; derived_from<iterator_category_t<I>, input_iterator_tag>; i++; }; where 'requires' is missing before 'derived_from'. gcc/ChangeLog: * doc/invoke.texi: Document -Wmissing-requires. gcc/c-family/ChangeLog: * c.opt: Add -Wmissing-requires. gcc/cp/ChangeLog: * parser.c (cp_parser_simple_requirement): Warn about missing requires. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-lambda14.C: Add expected warnings.
Diffstat (limited to 'gcc/c-family/c.opt')
-rw-r--r--gcc/c-family/c.opt4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 9192970..c5fe900 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -839,6 +839,10 @@ Wmissing-field-initializers
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.