aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-30 01:49:21 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-30 01:49:21 +0100
commitcc67d95dc100706ea665e8cce581d59466aba62e (patch)
tree2b9e8d39d7f513aa182d163c7ec29776820eb0d1 /gcc/doc
parent20dcb7926bef7546fb1abdf45781d15578756893 (diff)
downloadgcc-cc67d95dc100706ea665e8cce581d59466aba62e.zip
gcc-cc67d95dc100706ea665e8cce581d59466aba62e.tar.gz
gcc-cc67d95dc100706ea665e8cce581d59466aba62e.tar.bz2
c++: Implement C++26 P3176R1 - The Oxford variadic comma
While we are already in stage3, I wonder if implementing this small paper wouldn't be useful even for GCC 15, so that we have in the GCC world one extra year of deprecation of variadic ellipsis without preceding comma. The paper just deprecates something, I'd hope most of the C++ code in the wild when it uses variadic functions at all uses the comma before the ellipsis. 2024-11-30 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c.opt (Wdeprecated-variadic-comma-omission): New option. * c.opt.urls: Regenerate. * c-opts.cc (c_common_post_options): Default to -Wdeprecated-variadic-comma-omission for C++26 or -Wpedantic. gcc/cp/ * parser.cc: Implement C++26 P3176R1 - The Oxford variadic comma. (cp_parser_parameter_declaration_clause): Emit -Wdeprecated-variadic-comma-omission warnings. gcc/ * doc/invoke.texi (-Wdeprecated-variadic-comma-omission): Document. gcc/testsuite/ * g++.dg/cpp26/variadic-comma1.C: New test. * g++.dg/cpp26/variadic-comma2.C: New test. * g++.dg/cpp26/variadic-comma3.C: New test. * g++.dg/cpp26/variadic-comma4.C: New test. * g++.dg/cpp26/variadic-comma5.C: New test. * g++.dg/cpp1z/fold10.C: Expect a warning for C++26. * g++.dg/ext/attrib33.C: Likewise. * g++.dg/cpp1y/lambda-generic-variadic19.C: Likewise. * g++.dg/cpp2a/lambda-generic10.C: Likewise. * g++.dg/cpp0x/lambda/lambda-const3.C: Likewise. * g++.dg/cpp0x/variadic164.C: Likewise. * g++.dg/cpp0x/variadic17.C: Likewise. * g++.dg/cpp0x/udlit-args-neg.C: Likewise. * g++.dg/cpp0x/variadic28.C: Likewise. * g++.dg/cpp0x/gen-attrs-33.C: Likewise. * g++.dg/cpp23/explicit-obj-diagnostics3.C: Likewise. * g++.old-deja/g++.law/operators15.C: Likewise. * g++.old-deja/g++.mike/p811.C: Likewise. * g++.old-deja/g++.mike/p12306.C (printf): Add , before ... . * g++.dg/analyzer/fd-bind-pr107783.C (bind): Likewise. * g++.dg/cpp0x/vt-65790.C (printf): Likewise. libstdc++-v3/ * include/std/functional (_Bind_check_arity): Add , before ... . * include/bits/refwrap.h (_Mem_fn_traits, _Weak_result_type_impl): Likewise. * include/tr1/type_traits (is_function): Likewise.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/invoke.texi21
1 files changed, 19 insertions, 2 deletions
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 18a5754..fa2532f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4069,6 +4069,22 @@ string operator "" _i18n(const char*, std::size_t); // deprecated
string operator ""_i18n(const char*, std::size_t); // preferred
@end smallexample
+@opindex Wdeprecated-variadic-comma-omission
+@opindex Wno-deprecated-variadic-comma-omission
+@item -Wdeprecated-variadic-comma-omission @r{(C++ and Objective-C++ only)}
+Warn that omitting a comma before the varargs @code{...} at the end of
+a function parameter list is deprecated. This warning is enabled by
+default in C++26, or with explicit @option{-Wdeprecated}.
+
+@smallexample
+void f1(int...); // deprecated
+void f1(int, ...); // preferred
+template <typename ...T>
+void f2(T...); // ok
+template <typename ...T>
+void f3(T......); // deprecated
+@end smallexample
+
@opindex Welaborated-enum-base
@opindex Wno-elaborated-enum-base
@item -Wno-elaborated-enum-base
@@ -10348,8 +10364,9 @@ In C++, explicitly specifying @option{-Wdeprecated} also enables
warnings about some features that are deprecated in later language
standards, specifically @option{-Wcomma-subscript},
@option{-Wvolatile}, @option{-Wdeprecated-enum-float-conversion},
-@option{-Wdeprecated-enum-enum-conversion}, and
-@option{-Wdeprecated-literal-operator}.
+@option{-Wdeprecated-enum-enum-conversion},
+@option{-Wdeprecated-literal-operator}, and
+@option{-Wdeprecated-variadic-comma-omission}.
@opindex Wno-deprecated-declarations
@opindex Wdeprecated-declarations