public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Mark Mitchell <mark@codesourcery.com>
Cc: Ian Lance Taylor <iant@google.com>, gcc-patches@gcc.gnu.org
Subject: Re: PATCH RFC: PR 33094: Test DECL_INITIAL in make_rtl_for_nonlocal_decl
Date: Sun, 30 Sep 2007 13:26:00 -0000	[thread overview]
Message-ID: <46FF0C97.7030807@redhat.com> (raw)
In-Reply-To: <46FD4C8A.3020707@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

Since I'm about to go off to the C++ meeting, I've gone ahead and fixed 
the crash by allowing !TREE_PUBLIC as well as DECL_EXTERN.  And added a 
test to make sure that we are emitting static member variables iff they 
have an out-of-class definition.

Tested x86_64-pc-linux-gnu, applied to trunk.  I'd like to apply this to 
4.2 as well; OK, Mark?



[-- Attachment #2: anon-static.patch --]
[-- Type: text/x-patch, Size: 3388 bytes --]

2007-09-28  Jason Merrill  <jason@redhat.com>

	PR c++/33094
	* decl.c (make_rtl_for_nonlocal_decl): It's ok for a member 
	constant to not have DECL_EXTERNAL if it's file-local.

Index: cp/decl.c
===================================================================
*** cp/decl.c	(revision 128841)
--- cp/decl.c	(working copy)
*************** make_rtl_for_nonlocal_decl (tree decl, t
*** 5092,5098 ****
        /* An in-class declaration of a static data member should be
  	 external; it is only a declaration, and not a definition.  */
        if (init == NULL_TREE)
! 	gcc_assert (DECL_EXTERNAL (decl));
      }
  
    /* We don't create any RTL for local variables.  */
--- 5092,5098 ----
        /* An in-class declaration of a static data member should be
  	 external; it is only a declaration, and not a definition.  */
        if (init == NULL_TREE)
! 	gcc_assert (DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl));
      }
  
    /* We don't create any RTL for local variables.  */
Index: cp/cp-tree.h
===================================================================
*** cp/cp-tree.h	(revision 128841)
--- cp/cp-tree.h	(working copy)
*************** more_aggr_init_expr_args_p (const aggr_i
*** 3225,3231 ****
  
  /* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
     so that assemble_external will work properly.  So we have this flag to
!    tell us whether the decl is really not external.  */
  #define DECL_NOT_REALLY_EXTERN(NODE) \
    (DECL_LANG_SPECIFIC (NODE)->decl_flags.not_really_extern)
  
--- 3225,3235 ----
  
  /* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
     so that assemble_external will work properly.  So we have this flag to
!    tell us whether the decl is really not external.
! 
!    This flag does not indicate whether or not the decl is defined in the
!    current translation unit; it indicates whether or not we should emit the
!    decl at the end of compilation if it is defined and needed.  */
  #define DECL_NOT_REALLY_EXTERN(NODE) \
    (DECL_LANG_SPECIFIC (NODE)->decl_flags.not_really_extern)
  
Index: cp/decl2.c
===================================================================
*** cp/decl2.c	(revision 128844)
--- cp/decl2.c	(working copy)
*************** coerce_delete_type (tree type)
*** 1314,1319 ****
--- 1314,1322 ----
    return type;
  }
  \f
+ /* DECL is a VAR_DECL for a vtable: walk through the entries in the vtable
+    and mark them as needed.  */
+ 
  static void
  mark_vtable_entries (tree decl)
  {
Index: testsuite/g++.dg/ext/visibility/anon6.C
===================================================================
*** testsuite/g++.dg/ext/visibility/anon6.C	(revision 0)
--- testsuite/g++.dg/ext/visibility/anon6.C	(revision 0)
***************
*** 0 ****
--- 1,28 ----
+ // PR c++/33094
+ // { dg-final { scan-assembler "1BIiE1cE" } }
+ // { dg-final { scan-assembler-not "globl.*1BIiE1cE" } }
+ // { dg-final { scan-assembler-not "1CIiE1cE" } }
+ 
+ // Test that B<int>::c is emitted as an internal symbol, and C<int>::c is
+ // not emitted.
+ 
+ namespace
+ {
+   template <typename T>
+   class A
+   {
+     virtual T f1() { return c; }
+     static const T c = 0;
+   };
+ 
+   template <typename T>
+   class B
+   {
+     static const T c = 0;
+   };
+ 
+   template <typename T> const T B<T>::c;
+ 
+   template class A<int>;
+   template class B<int>;
+ }

  reply	other threads:[~2007-09-30  2:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-17 15:27 Ian Lance Taylor
2007-08-18  0:09 ` Mark Mitchell
2007-08-18  0:12   ` Andrew Pinski
2007-08-18  0:15     ` Mark Mitchell
2007-08-18  1:46       ` Gabriel Dos Reis
2007-09-28 21:49   ` Jason Merrill
2007-09-30 13:26     ` Jason Merrill [this message]
2007-09-30 21:59     ` Mark Mitchell
2007-10-01  6:58       ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46FF0C97.7030807@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iant@google.com \
    --cc=mark@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).