public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C PATCH] Fix -Wc++-compat (PR c/44772)
@ 2010-11-05 17:51 Jakub Jelinek
  2010-11-05 23:41 ` Joseph S. Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-11-05 17:51 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches

Hi!

pointer_set_contains is documented that it must not be called with NULL.
We don't try to store NULL into tset (which doesn't work either), but
pointer_set_contains (tset, NULL) just always returns 1.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-11-05  Jakub Jelinek  <jakub@redhat.com>

	PR c/44772
	* c-decl.c (warn_cxx_compat_finish_struct): Don't call
	pointer_set_contains if DECL_NAME is NULL.

	* gcc.dg/Wcxx-compat-21.c: New test.

--- gcc/c-decl.c.jj	2010-11-01 09:07:22.000000000 +0100
+++ gcc/c-decl.c	2010-11-05 14:35:08.000000000 +0100
@@ -6877,7 +6877,8 @@ warn_cxx_compat_finish_struct (tree fiel
 
       for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x))
 	{
-	  if (pointer_set_contains (tset, DECL_NAME (x)))
+	  if (DECL_NAME (x) != NULL_TREE
+	      && pointer_set_contains (tset, DECL_NAME (x)))
 	    {
 	      warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat,
 			  ("using %qD as both field and typedef name is "
--- gcc/testsuite/gcc.dg/Wcxx-compat-21.c.jj	2010-11-05 14:37:35.000000000 +0100
+++ gcc/testsuite/gcc.dg/Wcxx-compat-21.c	2010-11-05 14:41:11.000000000 +0100
@@ -0,0 +1,25 @@
+/* PR c/44772 */
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+typedef enum { E1, E2 } E;
+
+typedef struct
+{
+  E e;
+  union
+  {
+    int i;
+    char *c;
+  };			/* { dg-bogus "as both field and typedef name" } */
+} S;
+
+S s;
+
+typedef int T;
+
+struct U
+{
+  T t;
+  union { int i; };	/* { dg-bogus "as both field and typedef name" } */
+};

	Jakub

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

* Re: [C PATCH] Fix -Wc++-compat (PR c/44772)
  2010-11-05 17:51 [C PATCH] Fix -Wc++-compat (PR c/44772) Jakub Jelinek
@ 2010-11-05 23:41 ` Joseph S. Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph S. Myers @ 2010-11-05 23:41 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Fri, 5 Nov 2010, Jakub Jelinek wrote:

> Hi!
> 
> pointer_set_contains is documented that it must not be called with NULL.
> We don't try to store NULL into tset (which doesn't work either), but
> pointer_set_contains (tset, NULL) just always returns 1.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2010-11-05 23:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-05 17:51 [C PATCH] Fix -Wc++-compat (PR c/44772) Jakub Jelinek
2010-11-05 23:41 ` Joseph S. Myers

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).