re PR c++/47213 (ICE: SIGSEGV in determine_visibility (decl2.c:2076) with -fvisibilit...
authorKai Tietz <kai.tietz@onevision.com>
Thu, 13 Jan 2011 20:01:57 +0000 (20:01 +0000)
committerKai Tietz <ktietz@gcc.gnu.org>
Thu, 13 Jan 2011 20:01:57 +0000 (21:01 +0100)
2011-01-13  Kai Tietz  <kai.tietz@onevision.com>

PR c++/47213
* g++.dg/ext/pr47213.C: New.

2011-01-13  Kai Tietz  <kai.tietz@onevision.com>

PR c++/47213
* cp-tree.h (CLASSTYPE_VISIBILITY): Use
TYPE_MAIN_DECL instead of TYPE_NAME.
(CLASSTYPE_VISIBILITY_SPECIFIED): Likewise.
* decl2.c (determine_visibility): Add check
of CLASS_TYPE_P for underlying_type.

2011-01-13  Kai Tietz  <kai.tietz@onevision.com>

PR c++/47213
* config/i386/cygming.h (TARGET_ASM_ASSEMBLE_VISIBILITY):
PE specific hook.
* config/i386/i386-protos.h (i386_pe_assemble_visibility):
New function prototype.
* config/i386/winnt.c (i386_pe_assemble_visibility):
Warn only if attribute was specified by user.

From-SVN: r168763

gcc/ChangeLog
gcc/config/i386/cygming.h
gcc/config/i386/i386-protos.h
gcc/config/i386/winnt.c
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/pr47213.C [new file with mode: 0644]

index b96f8121b32b571ffca82f23c3971165409bb382..9d053ab0325a47e93a59045df63e731074645ddf 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-13  Kai Tietz  <kai.tietz@onevision.com>
+
+       PR c++/47213
+       * config/i386/cygming.h (TARGET_ASM_ASSEMBLE_VISIBILITY):
+       PE specific hook.
+       * config/i386/i386-protos.h (i386_pe_assemble_visibility):
+       New function prototype.
+       * config/i386/winnt.c (i386_pe_assemble_visibility):
+       Warn only if attribute was specified by user.
+
 2011-01-13  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/47251
index be97d80613258c2c9ca4a15fb903b54588e84c2c..9c32dda2e96521965a6e1ba1a77a6596256c7478 100644 (file)
@@ -465,6 +465,9 @@ do {                                                \
 #define TARGET_CXX_ADJUST_CLASS_AT_DEFINITION i386_pe_adjust_class_at_definition
 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME i386_pe_mangle_decl_assembler_name
 
+#undef TARGET_ASM_ASSEMBLE_VISIBILITY
+#define TARGET_ASM_ASSEMBLE_VISIBILITY i386_pe_assemble_visibility
+
 /* Static stack checking is supported by means of probes.  */
 #define STACK_CHECK_STATIC_BUILTIN 1
 
index 1180e8ce4da36ffeecb7094d4139775c5e3d9e01..4f90b502167a580b094f806612fc38d05f2d1a56 100644 (file)
@@ -225,6 +225,7 @@ extern void i386_pe_asm_output_aligned_decl_common (FILE *, tree,
 extern void i386_pe_file_end (void);
 extern void i386_pe_start_function (FILE *, const char *, tree);
 extern void i386_pe_end_function (FILE *, const char *, tree);
+extern void i386_pe_assemble_visibility (tree, int);
 extern tree i386_pe_mangle_decl_assembler_name (tree, tree);
 extern tree i386_pe_mangle_assembler_name (const char *);
 
index c413bb0a3ebb6a16f424fbcb8057dbe3edcc1d64..169832fd36a954f0076b1357e5af6cc26f7bb85c 100644 (file)
@@ -232,6 +232,22 @@ i386_pe_maybe_mangle_decl_assembler_name (tree decl, tree id)
   return new_id;
 }
 
+/* Emit an assembler directive to set symbol for DECL visibility to
+   the visibility type VIS, which must not be VISIBILITY_DEFAULT.
+   As for PE there is no hidden support in gas, we just warn for
+   user-specified visibility attributes.  */
+
+void
+i386_pe_assemble_visibility (tree decl,
+                            int vis ATTRIBUTE_UNUSED)
+{
+  if (!decl
+      || !lookup_attribute ("visibility", DECL_ATTRIBUTES (decl)))
+    return;
+  warning (OPT_Wattributes, "visibility attribute not supported "
+          "in this configuration; ignored");
+}
+
 /* This is used as a target hook to modify the DECL_ASSEMBLER_NAME
    in the language-independent default hook
    langhooks,c:lhd_set_decl_assembler_name ()
index 5088ba06f716d62de6ff6037642b65c081ba602e..a57f978716527248f08a54fcd2bdfb5c09525044 100644 (file)
@@ -1,3 +1,12 @@
+2011-01-13  Kai Tietz  <kai.tietz@onevision.com>
+
+       PR c++/47213
+       * cp-tree.h (CLASSTYPE_VISIBILITY): Use
+       TYPE_MAIN_DECL instead of TYPE_NAME.
+       (CLASSTYPE_VISIBILITY_SPECIFIED): Likewise.
+       * decl2.c (determine_visibility): Add check
+       of CLASS_TYPE_P for underlying_type.
+
 2011-01-12  Rodrigo Rivas Costa <rodrigorivascosta@gmail.com>
 
        * cp-tree.h (begin_for_scope): New prototype.
index dddbc01fb4a98c3c3fca4c06a21596e93c1bad23..3d39b5567c140fe9f6d31ce3e430c2129b64de12 100644 (file)
@@ -1221,9 +1221,9 @@ enum languages { lang_c, lang_cplusplus, lang_java };
 
 /* Gives the visibility specification for a class type.  */
 #define CLASSTYPE_VISIBILITY(TYPE)             \
-       DECL_VISIBILITY (TYPE_NAME (TYPE))
+       DECL_VISIBILITY (TYPE_MAIN_DECL (TYPE))
 #define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE)   \
-       DECL_VISIBILITY_SPECIFIED (TYPE_NAME (TYPE))
+       DECL_VISIBILITY_SPECIFIED (TYPE_MAIN_DECL (TYPE))
 
 typedef struct GTY (()) tree_pair_s {
   tree purpose;
index 0c64a5d4f0c2eb59005532c166cacf5ab04c24c4..72570c3cbb6a9833efe10e18d736bd0cb1713d7e 100644 (file)
@@ -2073,7 +2073,8 @@ determine_visibility (tree decl)
          tree underlying_type = TREE_TYPE (DECL_NAME (decl));
          int underlying_vis = type_visibility (underlying_type);
          if (underlying_vis == VISIBILITY_ANON
-             || CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type))
+             || (CLASS_TYPE_P (underlying_type)
+                 && CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)))
            constrain_visibility (decl, underlying_vis);
          else
            DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
index b574148e9b9aeb8a1ff44664e2702ad582aab334..8762f9ac31b045373960a49e7d23d9968dd32006 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-13  Kai Tietz  <kai.tietz@onevision.com>
+
+       PR c++/47213
+       * g++.dg/ext/pr47213.C: New.
+
 2011-01-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gfortran.dg/cray_pointers_2.f90: Use dg-timeout-factor 4.
diff --git a/gcc/testsuite/g++.dg/ext/pr47213.C b/gcc/testsuite/g++.dg/ext/pr47213.C
new file mode 100644 (file)
index 0000000..b39013c
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-fvisibility-ms-compat" }
+#include <typeinfo>
+
+template < typename T > void
+bar ()
+{
+  typeid (T);
+}
+
+void
+foo ()
+{
+  bar < int () > ();
+}