Patchwork [c++] : PR/47213] New: ICE: SIGSEGV in determine_visibility (decl2.c:2076) with -fvisibility-ms-compat

login
register
mail settings
Submitter Kai Tietz
Date Jan. 8, 2011, 3:19 p.m.
Message ID <AANLkTikvmwa_O3zD3DWW+u7WbB36HemyxSbaTuoTubcR@mail.gmail.com>
Download mbox | patch
Permalink /patch/77955/
State New
Headers show

Comments

Kai Tietz - Jan. 8, 2011, 3:19 p.m.
Bug c++/47213] New: ICE: SIGSEGV in determine_visibility
(decl2.c:2076) with -fvisibility-ms-compat

2011-01-08  Kai Tietz

	PR c++/47213
	* decl2.c (determine_visibility): Check that
	TYPE_NAME isn't nil.

Tested with x86_64-pc-linux-gnu. Ok for apply?

Regards,
Kai

PS: I notice that default_assemble_visibility() in varasm.c always
warns for targets without
visibility feature. This looks a bit strange, as attribute isn't set
by user. So it should check
if decl has a visibility attribute by user set before warning. At
least with option -fvisibility-ms-compat cause
that c++ FE set attributes which get warned then.
Jason Merrill - Jan. 9, 2011, 10:49 p.m.
On 01/08/2011 10:19 AM, Kai Tietz wrote:
>            if (underlying_vis == VISIBILITY_ANON
> -             || CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type))
> +             || (TYPE_NAME (underlying_type)
> +                 &&  CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)))
>              constrain_visibility (decl, underlying_vis);

This should check CLASS_TYPE_P rather than TYPE_NAME.  And looking at 
this I realize that CLASSTYPE_VISIBILITY/_SPECIFIED should use 
TYPE_MAIN_DECL rather than TYPE_NAME.

Jason

Patch

Index: decl2.c
===================================================================
--- decl2.c     (revision 168596)
+++ decl2.c     (working copy)
@@ -2073,7 +2073,8 @@ 
          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))
+             || (TYPE_NAME (underlying_type)
+                 && CLASSTYPE_VISIBILITY_SPECIFIED (underlying_type)))
            constrain_visibility (decl, underlying_vis);
          else
            DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;