]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/44772 (-Wc++-compat warns incorrectly for anonymous unions)
authorJakub Jelinek <jakub@redhat.com>
Sat, 6 Nov 2010 00:07:50 +0000 (01:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 6 Nov 2010 00:07:50 +0000 (01:07 +0100)
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.

From-SVN: r166384

gcc/ChangeLog
gcc/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wcxx-compat-21.c [new file with mode: 0644]

index 34b3601e938717d82894fb70dc0e353eb767a805..1e55c844042f53f5b637fd302418b13eca8e0309 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2010-11-05  Ian Lance Taylor  <iant@google.com>
 
        PR target/46084
index bb7cf64553bda730abb6a18fca8dd02670e28c61..7d27dfe8f0f0078f928381a2adebd3a11556bdb5 100644 (file)
@@ -6877,7 +6877,8 @@ warn_cxx_compat_finish_struct (tree fieldlist)
 
       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 "
index b2642c1dfc08f9f276b842aa94d301d465f55327..0cc58bf84af2f4202a567316f1fd129f1b41a65a 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/44772
+       * gcc.dg/Wcxx-compat-21.c: New test.
+
 2010-11-05  Ian Lance Taylor  <iant@google.com>
 
        PR target/46084
diff --git a/gcc/testsuite/gcc.dg/Wcxx-compat-21.c b/gcc/testsuite/gcc.dg/Wcxx-compat-21.c
new file mode 100644 (file)
index 0000000..183f0f1
--- /dev/null
@@ -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" } */
+};