This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/91338 - P1161R3: Deprecate a[b,c]


On 8/3/19 9:54 PM, Marek Polacek wrote:
This patch implements P1161R3, Deprecate uses of the comma operator in
subscripting expressions:
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1161r3.html>
which made its way to C++20.  New [depr.comma.subscript] shows:

   void f(int *a, int b, int c) {
     a[b,c];                     // deprecated
     a[(b,c)];                   // OK
   }

I've added a new option, -Wcomma-subscript, so that this warning can be
selectively turned off in c++2a, where it is enabled by default, and turned
on in lower standards, to check if your codebase has any occurrences of it,
without needing to change the -std=.

+  /* -Wcomma-subscript is enabled by default in C++20.  */
+  if (!global_options_set.x_warn_comma_subscript)
+    warn_comma_subscript = cxx_dialect >= cxx2a;

Let's add "&& warn_deprecated" here, so -Wno-deprecated also turns it off.

OK with that change.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]