[PATCH] D122224: Allow -Wno-gnu to silence GNU extensions related to pointer arithmetic

2022-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks for the review! I've landed in c3fe8ddd8385832fde9f16a261908afbaf9878a4 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D14/new/

https://reviews.llvm.org/D14

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122224: Allow -Wno-gnu to silence GNU extensions related to pointer arithmetic

2022-03-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

TIL about `Extension<>` and `-verify=`. Thanks @aaron.ballman !


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D14/new/

https://reviews.llvm.org/D14

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122224: Allow -Wno-gnu to silence GNU extensions related to pointer arithmetic

2022-03-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: nickdesaulniers, andrew.w.kaylor, eli.friedman, 
erichkeane.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

These diagnostics were added to a diagnostic group, but that diagnostic group 
was not under `-Wgnu`. I've now split them into their own diagnostic group that 
is added both to the original group (so user's currently opting in or out of 
these should not see a change) and under the `-Wgnu` group so that `-Wno-gnu` 
can be used to disable all GNU extension diagnostics. This fixes Issue 5.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D14

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/pointer-addition.c

Index: clang/test/Sema/pointer-addition.c
===
--- clang/test/Sema/pointer-addition.c
+++ clang/test/Sema/pointer-addition.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11
-// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify -pedantic -Wextra -std=c11
-// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -verify=gnu,expected -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify=gnu,expected -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -Wno-gnu -std=c11
 
 #include 
 
@@ -10,22 +11,22 @@
   void (*fp)(int) = 0;
   b++;   // expected-error {{arithmetic on a pointer to an incomplete type}}
   b += 1;// expected-error {{arithmetic on a pointer to an incomplete type}}
-  c++;   // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
-  c += 1;// expected-warning {{arithmetic on a pointer to void is a GNU extension}}
-  c--;   // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
-  c -= 1;// expected-warning {{arithmetic on a pointer to void is a GNU extension}}
-  (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
+  c++;   // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
+  c += 1;// gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
+  c--;   // gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
+  c -= 1;// gnu-warning {{arithmetic on a pointer to void is a GNU extension}}
+  (void) c[1]; // gnu-warning {{subscript of a pointer to void is a GNU extension}}
   b = 1+b;   // expected-error {{arithmetic on a pointer to an incomplete type}}
   /* The next couple tests are only pedantic warnings in gcc */
   void (*d)(S*,void*) = a;
-  d += 1;// expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
-  d++;   // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
-  d--;   // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
-  d -= 1;// expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
-  (void)(1 + d); // expected-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+  d += 1;// gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+  d++;   // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+  d--;   // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+  d -= 1;// gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
+  (void)(1 + d); // gnu-warning {{arithmetic on a pointer to the function type 'void (S *, void *)' (aka 'void (struct S *, void *)') is a GNU extension}}
   e++;   // expected-error {{arithmetic on a pointer to an incomplete type}}
   intptr_t i = (intptr_t)b;
-  char *f = (char*)0 + i; // expected-warning {{arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension}}
+  char *f = (char*)0 + i; // gnu-warning {{arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension}}
   // Cases that don't match the G