On 5/2/07, Mark Mitchell <[EMAIL PROTECTED]> wrote:
Seongbae Park wrote:
> On 5/1/07, Andrew Pinski <[EMAIL PROTECTED]> wrote:
>> On 01 May 2007 14:28:07 -0700, Ian Lance Taylor <[EMAIL PROTECTED]> wrote:
>> > I agree that it would be appropriate to backport the patch to gcc 4.2.
>>
>> Lets first get the patch which fixes the ICE regression that this
>> patch causes approved :).
>>
>> Which can be found at:
>> http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01746.html

This patch is OK for mainline.

Attached is the patch I commited just now.

As for backporting to 4.2, this isn't a regression, so the default
answer would be "no".  I'm unconvinced that this is a sufficiently
serious problem to merit violating that policy; after all, we're only
talking about a spurious warning.  (However, the other bug here is that
we don't have a warning option for this, so users can't use
-Wno-<something> to turn this off.)

In any case, we're not going to do this for 4.2.0.  As per the policy I
posted recently on PRs, please find a C++ maintainer who wants to argue
for backporting this and ask them to mark the PR as P3 with an argument
as to why this is important to backport.

Thanks,

My guess is that this will be big enough nuisance to be worth backporting,
but I agree that this isn't a regression
- I won't bother other c++ maintainers for this.
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com";
Index: gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h
===================================================================
--- gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h   (revision 0)
+++ gcc/testsuite/g++.dg/warn/anonymous-namespace-2.h   (revision 0)
@@ -0,0 +1,3 @@
+namespace {
+  struct bad { };
+}
Index: gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C
===================================================================
--- gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C   (revision 0)
+++ gcc/testsuite/g++.dg/warn/anonymous-namespace-2.C   (revision 0)
@@ -0,0 +1,29 @@
+// Test for the warning of exposing types from an anonymous namespace
+// { dg-do compile }
+//
+#include "anonymous-namespace-2.h"
+
+namespace {
+    struct good { };
+}
+
+struct g1 {
+    good * A;
+};
+struct b1 { // { dg-warning "uses the anonymous namespace" }
+    bad * B;
+};
+
+struct g2 {
+    good * A[1];
+};
+struct b2 { // { dg-warning "uses the anonymous namespace" }
+    bad * B[1];
+};
+
+struct g3 {
+    good (*A)[1];
+};
+struct b3 { // { dg-warning "uses the anonymous namespace" }
+    bad (*B)[1];
+};
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c      (revision 124362)
+++ gcc/cp/decl2.c      (working copy)
@@ -1856,7 +1856,7 @@ constrain_class_visibility (tree type)
   for (t = TYPE_FIELDS (type); t; t = TREE_CHAIN (t))
     if (TREE_CODE (t) == FIELD_DECL && TREE_TYPE (t) != error_mark_node)
       {
-       tree ftype = strip_array_types (TREE_TYPE (t));
+       tree ftype = strip_pointer_or_array_types (TREE_TYPE (t));
        int subvis = type_visibility (ftype);
 
        if (subvis == VISIBILITY_ANON)
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c      (revision 124362)
+++ gcc/c-common.c      (working copy)
@@ -3894,6 +3894,15 @@ strip_pointer_operator (tree t)
   return t;
 }
 
+/* Recursively remove pointer or array type from TYPE. */
+tree
+strip_pointer_or_array_types (tree t)
+{
+  while (TREE_CODE (t) == ARRAY_TYPE || POINTER_TYPE_P (t))
+    t = TREE_TYPE (t);
+  return t;
+}
+
 /* Used to compare case labels.  K1 and K2 are actually tree nodes
    representing case labels, or NULL_TREE for a `default' label.
    Returns -1 if K1 is ordered before K2, -1 if K1 is ordered after
Index: gcc/c-common.h
===================================================================
--- gcc/c-common.h      (revision 124362)
+++ gcc/c-common.h      (working copy)
@@ -727,6 +727,7 @@ extern bool c_promoting_integer_type_p (
 extern int self_promoting_args_p (tree);
 extern tree strip_array_types (tree);
 extern tree strip_pointer_operator (tree);
+extern tree strip_pointer_or_array_types (tree);
 extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
 
 /* This is the basic parsing function.  */

Reply via email to