public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] c++/63619 Use -Wdelete-incomplete for "deleting 'void' is undefined" warning
@ 2014-10-23 20:02 Jonathan Wakely
  2014-10-23 20:37 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2014-10-23 20:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: jason

[-- Attachment #1: Type: text/plain, Size: 35 bytes --]

Tested x86_64-linux. OK for trunk?

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1153 bytes --]

commit c3ce106375d17223bacaaccbf36bd15fcef3f560
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Oct 23 18:11:22 2014 +0100

    gcc/cp:
    	PR c++/63619
    	* decl2.c (delete_sanity): Use OPT_Wdelete_incomplete in warning.
    
    gcc/testsuite:
    	PR c++/63619
    	* g++.dg/warn/Wdelete-incomplete-3.C: New.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 4be4847..60c8a63 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -478,7 +478,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
   /* Deleting ptr to void is undefined behavior [expr.delete/3].  */
   if (VOID_TYPE_P (TREE_TYPE (type)))
     {
-      warning (0, "deleting %qT is undefined", type);
+      warning (OPT_Wdelete_incomplete, "deleting %qT is undefined", type);
       doing_vec = 0;
     }
 
diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C
new file mode 100644
index 0000000..2202d60
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C
@@ -0,0 +1,6 @@
+// PR c++/63619
+
+int main() {
+   void* p;
+   delete p;    // { dg-warning "undefined" }
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] c++/63619 Use -Wdelete-incomplete for "deleting 'void' is undefined" warning
  2014-10-23 20:02 [patch] c++/63619 Use -Wdelete-incomplete for "deleting 'void' is undefined" warning Jonathan Wakely
@ 2014-10-23 20:37 ` Jason Merrill
  2014-10-23 21:19   ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2014-10-23 20:37 UTC (permalink / raw)
  To: Jonathan Wakely, gcc-patches; +Cc: jason

On 10/23/2014 03:59 PM, Jonathan Wakely wrote:
> Tested x86_64-linux. OK for trunk?

Shouldn't there be another test that there's no warning if 
-Wno-delete-incomplete or that it's an error with 
-Werror=delete-incomplete?  OK that way.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] c++/63619 Use -Wdelete-incomplete for "deleting 'void' is undefined" warning
  2014-10-23 20:37 ` Jason Merrill
@ 2014-10-23 21:19   ` Jonathan Wakely
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2014-10-23 21:19 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches, jason

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

On 23/10/14 16:01 -0400, Jason Merrill wrote:
>On 10/23/2014 03:59 PM, Jonathan Wakely wrote:
>>Tested x86_64-linux. OK for trunk?
>
>Shouldn't there be another test that there's no warning if 
>-Wno-delete-incomplete or that it's an error with 
>-Werror=delete-incomplete?  OK that way.

Oh yes, of course - here's what I've committed then.

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1570 bytes --]

commit 9066b282eed98c3ba62f04ff9338b3772c04224e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Oct 23 18:11:22 2014 +0100

    PR c++/63619
    
    gcc/cp:
    	PR c++/63619
    	* decl2.c (delete_sanity): Use OPT_Wdelete_incomplete in warning.
    
    gcc/testsuite:
    	PR c++/63619
    	* g++.dg/warn/Wdelete-incomplete-3.C: New.
    	* g++.dg/warn/Wdelete-incomplete-4.C: New.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 4be4847..60c8a63 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -478,7 +478,7 @@ delete_sanity (tree exp, tree size, bool doing_vec, int use_global_delete,
   /* Deleting ptr to void is undefined behavior [expr.delete/3].  */
   if (VOID_TYPE_P (TREE_TYPE (type)))
     {
-      warning (0, "deleting %qT is undefined", type);
+      warning (OPT_Wdelete_incomplete, "deleting %qT is undefined", type);
       doing_vec = 0;
     }
 
diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C
new file mode 100644
index 0000000..2202d60
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-3.C
@@ -0,0 +1,6 @@
+// PR c++/63619
+
+int main() {
+   void* p;
+   delete p;    // { dg-warning "undefined" }
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C
new file mode 100644
index 0000000..f2eb5ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wdelete-incomplete-4.C
@@ -0,0 +1,7 @@
+// PR c++/63619
+// { dg-options -Wno-delete-incomplete }
+
+int main() {
+   void* p;
+   delete p;
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-23 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-23 20:02 [patch] c++/63619 Use -Wdelete-incomplete for "deleting 'void' is undefined" warning Jonathan Wakely
2014-10-23 20:37 ` Jason Merrill
2014-10-23 21:19   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).