From patchwork Wed Jan 12 09:07:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 78525 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A5A61B6EE9 for ; Wed, 12 Jan 2011 20:07:54 +1100 (EST) Received: (qmail 19380 invoked by alias); 12 Jan 2011 09:07:52 -0000 Received: (qmail 19370 invoked by uid 22791); 12 Jan 2011 09:07:50 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 12 Jan 2011 09:07:45 +0000 Received: by qwi2 with SMTP id 2so338359qwi.20 for ; Wed, 12 Jan 2011 01:07:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.81.15 with SMTP id v15mr631537qck.209.1294823263464; Wed, 12 Jan 2011 01:07:43 -0800 (PST) Received: by 10.229.214.131 with HTTP; Wed, 12 Jan 2011 01:07:43 -0800 (PST) In-Reply-To: <4D2A3B79.70202@redhat.com> References: <4D2A3B79.70202@redhat.com> Date: Wed, 12 Jan 2011 10:07:43 +0100 Message-ID: Subject: Re: [patch c++]: PR/47213] New: ICE: SIGSEGV in determine_visibility (decl2.c:2076) with -fvisibility-ms-compat From: Kai Tietz To: Jason Merrill Cc: GCC Patches X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 2011/1/9 Jason Merrill : > 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 > Hello, I adjusted the patch as discussed on IRC. Additionally I found a regression in varasm.c's function default_assemble_visibility(). This caused a lot of testsuite regressions (eg. c-c++-common/torture/complex-sign-mixed-add.c, & co) as here internal visibility sets of C++ FE getting warned. ChangeLog cp/ 2011-01-12 Kai Tietz 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. ChangeLog testsuite/ 2011-01-12 Kai Tietz PR c++/47213 * g++.dg/ext/pr47213.C: New. ChangeLog gcc/ 2011-01-12 Kai Tietz PR c++/47213 * varasm.c (default_assemble_visibility): Warn only if attribute was specified by user. Tested for x86_64-pc-linux-gnu (multilib), and x86_64-w64-mingw32. Ok for apply? Regards, Kai Index: gcc/gcc/cp/cp-tree.h =================================================================== --- gcc.orig/gcc/cp/cp-tree.h 2010-12-15 14:28:07.000000000 +0100 +++ gcc/gcc/cp/cp-tree.h 2011-01-11 12:36:58.410171200 +0100 @@ -1221,9 +1221,9 @@ enum languages { lang_c, lang_cplusplus, /* 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: gcc/gcc/cp/decl2.c =================================================================== --- gcc.orig/gcc/cp/decl2.c 2010-12-15 14:28:07.000000000 +0100 +++ gcc/gcc/cp/decl2.c 2011-01-11 12:35:08.738296200 +0100 @@ -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: gcc/gcc/testsuite/g++.dg/ext/pr47213.C =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gcc/gcc/testsuite/g++.dg/ext/pr47213.C 2011-01-12 09:45:44.864673100 +0100 @@ -0,0 +1,15 @@ +// { dg-do compile } +// { dg-options "-fvisibility-ms-compat" } +#include + +template < typename T > void +bar () +{ + typeid (T); +} + +void +foo () +{ + bar < int () > (); +} Index: gcc/gcc/varasm.c =================================================================== --- gcc.orig/gcc/varasm.c 2010-12-22 09:23:11.000000000 +0100 +++ gcc/gcc/varasm.c 2011-01-12 09:53:21.055968300 +0100 @@ -5799,8 +5799,9 @@ default_assemble_visibility (tree decl A assemble_name (asm_out_file, name); fprintf (asm_out_file, "\n"); #else - warning (OPT_Wattributes, "visibility attribute not supported " - "in this configuration; ignored"); + if (decl && lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl))) + warning (OPT_Wattributes, "visibility attribute not supported " + "in this configuration; ignored"); #endif }