public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27369]  New: tree check ICE when attribute externally_visible used
@ 2006-05-01 14:38 gcc-bugzilla at gcc dot gnu dot org
  2006-05-01 14:40 ` [Bug c++/27369] " ned at bike-nomad dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2006-05-01 14:38 UTC (permalink / raw)
  To: gcc-bugs


When compiling a C++ program (for the AVR target) that defines interrupt
vectors using the externally_visible attribute, I get this ICE message:

avrlib/bits/atmega128_usart.cpp:20: internal compiler error: tree check:
expected tree that contains 'decl minimal' structure, have 'omp_atomic'  in
eq_node, at cgraph.c:175

Environment:
System: Darwin Neds-Mini.local 8.6.0 Darwin Kernel Version 8.6.0: Tue Mar 7
16:58:48 PST 2006; root:xnu-792.6.70.obj~1/RELEASE_PPC Power Macintosh powerpc
host: powerpc-apple-darwin8.6.0
build: powerpc-apple-darwin8.6.0
target: avr-unknown-none
configured with:
/opt/local/var/db/dports/build/_Users_ned_src_darwinports_dports_cross_avr-gcc/work/gcc-4.2-20060429/configure
--prefix=/opt/local --infodir=/opt/local/share/info
--mandir=/opt/local/share/man --target=avr --program-prefix=avr-
--with-included-gettext --enable-obsolete
--with-gxx-include-dir=/opt/local/avr/include/c++/4.2-20060429/
--disable-libssp --enable-languages=c,c++

How-To-Repeat:

Compile the attached hw.ii file with:

avr-g++ -fno-exceptions -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -ggdb -O2 -Wall -Wextra -Wshadow -mmcu=atmega128 -xc++ -c -o hw.o
hw.ii


------- Comment #1 from ned at bike-nomad dot com  2006-05-01 14:38 -------
Fix:

Remove the externally_visible attributes on the vector definitions (lines 1998
to 2020) 
in attached file hw.ii and recompile:

sed -e '1998,2020s/, externally_visible//' hw.ii > hwgood.cpp

avr-g++ -fno-exceptions -funsigned-char -funsigned-bitfields -fpack-struct
-fshort-enums -ggdb -O2 -Wall -Wextra -Wshadow -mmcu=atmega128 -xc++ -c -o
hwgood.o hwgood.cpp


-- 
           Summary: tree check ICE when attribute externally_visible used
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ned at bike-nomad dot com
 GCC build triplet: powerpc-apple-darwin8.6.0
  GCC host triplet: powerpc-apple-darwin8.6.0
GCC target triplet: avr-unknown-none


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
@ 2006-05-01 14:40 ` ned at bike-nomad dot com
  2006-05-01 15:38 ` pinskia at gcc dot gnu dot org
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: ned at bike-nomad dot com @ 2006-05-01 14:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ned at bike-nomad dot com  2006-05-01 14:40 -------
Created an attachment (id=11353)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11353&action=view)
precompiled file that causes ICE


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
  2006-05-01 14:40 ` [Bug c++/27369] " ned at bike-nomad dot com
@ 2006-05-01 15:38 ` pinskia at gcc dot gnu dot org
  2006-05-02  6:56 ` pinskia at gcc dot gnu dot org
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-01 15:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-05-01 15:38 -------
This is more likely a GC issue.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |GC, ice-on-valid-code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
  2006-05-01 14:40 ` [Bug c++/27369] " ned at bike-nomad dot com
  2006-05-01 15:38 ` pinskia at gcc dot gnu dot org
@ 2006-05-02  6:56 ` pinskia at gcc dot gnu dot org
  2006-05-02  6:58 ` [Bug c++/27369] [4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-02  6:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-05-02 06:56 -------
Reduced testcase:
void __vector_18(void) __attribute__ ((externally_visible));
void __vector_18(void) __attribute__ ((externally_visible));
void __vector_18 (void)  { }


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|powerpc-apple-darwin8.6.0   |
   GCC host triplet|powerpc-apple-darwin8.6.0   |
 GCC target triplet|avr-unknown-none            |
   Last reconfirmed|0000-00-00 00:00:00         |2006-05-02 06:56:50
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-05-02  6:56 ` pinskia at gcc dot gnu dot org
@ 2006-05-02  6:58 ` pinskia at gcc dot gnu dot org
  2006-05-02  7:01 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-02  6:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2006-05-02 06:58 -------
A regression from 4.1.1.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.2.0
      Known to work|                            |4.1.1
            Summary|tree check ICE when         |[4.2 Regression] tree check
                   |attribute externally_visible|ICE when attribute
                   |used                        |externally_visible used
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-05-02  6:58 ` [Bug c++/27369] [4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-05-02  7:01 ` pinskia at gcc dot gnu dot org
  2006-05-02  7:02 ` pinskia at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-02  7:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-05-02 07:01 -------
Janis using the testcase in comment # 4 with the following options can you do a
regression hunt?
--param ggc-min-expand=0 --param ggc-min-heapsize=0

Thanks,
Pinski


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janis at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-05-02  7:01 ` pinskia at gcc dot gnu dot org
@ 2006-05-02  7:02 ` pinskia at gcc dot gnu dot org
  2006-05-02 18:19 ` janis at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-02  7:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2006-05-02 07:02 -------
I want to say this is related to PR 26660.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |26660


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-05-02  7:02 ` pinskia at gcc dot gnu dot org
@ 2006-05-02 18:19 ` janis at gcc dot gnu dot org
  2006-06-04 18:41 ` mmitchel at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: janis at gcc dot gnu dot org @ 2006-05-02 18:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from janis at gcc dot gnu dot org  2006-05-02 18:18 -------
A regression hunt on powerpc-linux using the test from comment #4 identified
this patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=101295

    r101295 | hubicka | 2005-06-24 15:14:04 +0000 (Fri, 24 Jun 2005)


-- 

janis at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-05-02 18:19 ` janis at gcc dot gnu dot org
@ 2006-06-04 18:41 ` mmitchel at gcc dot gnu dot org
  2006-06-07 15:18 ` [Bug c++/27369] [4.1/4.2 " rguenth at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 18:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-06-04 18:41 ` mmitchel at gcc dot gnu dot org
@ 2006-06-07 15:18 ` rguenth at gcc dot gnu dot org
  2006-06-26 22:16 ` jason at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-07 15:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2006-06-07 15:03 -------
Fails for me with the 4.1 branch, too, as of r114465.

./cc1plus -quiet t.c
t.c:2: internal compiler error: tree check: expected function_decl, have
dl_expr in cgraph_finalize_compilation_unit, at cgraphunit.c:971
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
      Known to fail|4.2.0                       |4.2.0 4.1.2
            Summary|[4.2 Regression] tree check |[4.1/4.2 Regression] tree
                   |ICE when attribute          |check ICE when attribute
                   |externally_visible used     |externally_visible used


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-06-07 15:18 ` [Bug c++/27369] [4.1/4.2 " rguenth at gcc dot gnu dot org
@ 2006-06-26 22:16 ` jason at gcc dot gnu dot org
  2006-07-12 15:46 ` reichelt at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jason at gcc dot gnu dot org @ 2006-06-26 22:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jason at gcc dot gnu dot org  2006-06-26 21:50 -------
The bug is that handle_externally_visible adds the second decl to cgraph_nodes
and then duplicate_decls discards it without removing it from cgraph_nodes.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2006-06-26 22:16 ` jason at gcc dot gnu dot org
@ 2006-07-12 15:46 ` reichelt at gcc dot gnu dot org
  2006-07-21  8:39 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-07-12 15:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from reichelt at gcc dot gnu dot org  2006-07-12 15:45 -------
Fails since GCC 4.1.0 for me.


-- 

reichelt at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |reichelt at gcc dot gnu dot
                   |                            |org
           Keywords|                            |monitored
      Known to fail|4.2.0 4.1.2                 |4.1.0 4.2.0 4.1.2
      Known to work|4.1.1                       |4.0.4
   Target Milestone|4.2.0                       |4.1.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2006-07-12 15:46 ` reichelt at gcc dot gnu dot org
@ 2006-07-21  8:39 ` mmitchel at gcc dot gnu dot org
  2006-07-21 15:13 ` hubicka at ucw dot cz
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-07-21  8:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from mmitchel at gcc dot gnu dot org  2006-07-21 08:38 -------
I think that Comment #10 shows that handle_externally_visible should not be
registering things with cgraph, as we shouldn't ever have anything pointing at
a re-declaration.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2006-07-21  8:39 ` mmitchel at gcc dot gnu dot org
@ 2006-07-21 15:13 ` hubicka at ucw dot cz
  2006-07-23 10:15 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at ucw dot cz @ 2006-07-21 15:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from hubicka at ucw dot cz  2006-07-21 15:13 -------
Subject: Re:  [4.1/4.2 Regression] tree check ICE when attribute
externally_visible used

> 
> 
> ------- Comment #12 from mmitchel at gcc dot gnu dot org  2006-07-21 08:38 -------
> I think that Comment #10 shows that handle_externally_visible should not be
> registering things with cgraph, as we shouldn't ever have anything pointing at
> a re-declaration.

Hi,
in January I made patch for similar problem that simply deffers handling
of externally visible and used attributes after compilation unit is
finalized.  I am going to update it for current tree and re-test.  Does
it look safe?

Hi,
at the present externally_visible on:
extern const char *mystr;       /* normally in a header */
const char *mystr __attribute__ ((externally_visible));
int
main (int argc, char **argv)
{
  mystr = argv[0];
  return (0);
}
is cowardly ignored.  This is because handle_externally_visible_attribute is
called before decl merging and it produce new cgraph node with
externally_visible flag that is never merged to real decl node.

externally_visible is in many ways symmetric to used attribute, so I looked on
how it is implemented, but found it somewhat sliperly to copy.
Used attribute is processed on cgraph_finalize_* machinery first, but since
it might be added retrospectivly, it is also processed by c frontend when
merging decls
and finally it sets TREE_SYMBOL_REFERENCED flag that survive decl merging to
get the early used attributes right.  This is way too crazy and easy to break,
so I moved both attributes to new place - at the end of compilation the
declarations
are travelled and we check whether the attributes are present.

Since this is miscompilation bug, I would like to see it solved in 4.1 too.
I wonder whether this scheme seems safe to others or if I should make less
intrusive approach?  (perhaps moving externally_visible only)

Bootstrapped/regtested i686-pc-gnu-linux, OK for mainline and possibly 4.1?

2006-01-19  Jan Hubicka  <jh@suse.cz>
        * craph.c (cgraph_varpool_nodes): Export.
        (decide_is_variable_needed): Do not worry about "used" attribute.
        * cgraph.h (cgraph_varpool_nodes): Declare.
        * cgraphunit.c (decide_is_function_needed): Do not worry about "used"
attribute
        (process_function_and_variable_attributes): New function.
        (cgraph_finalize_compilation_unit): Call it.
        * c-decl.c (finish_decl): Do not worry about used attribute.
        * c-common.c (handle_externally_visible_attribute): Only validate.

Index: cgraph.c
===================================================================
*** cgraph.c    (revision 109820)
--- cgraph.c    (working copy)
*************** static GTY((param_is (struct cgraph_varp
*** 132,138 ****
  struct cgraph_varpool_node *cgraph_varpool_nodes_queue,
*cgraph_varpool_first_unanalyzed_node;

  /* The linked list of cgraph varpool nodes.  */
! static GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes;

  /* End of the varpool queue.  Needs to be QTYed to work with PCH.  */
  static GTY(()) struct cgraph_varpool_node *cgraph_varpool_last_needed_node;
--- 132,138 ----
  struct cgraph_varpool_node *cgraph_varpool_nodes_queue,
*cgraph_varpool_first_unanalyzed_node;

  /* The linked list of cgraph varpool nodes.  */
! struct cgraph_varpool_node *cgraph_varpool_nodes;

  /* End of the varpool queue.  Needs to be QTYed to work with PCH.  */
  static GTY(()) struct cgraph_varpool_node *cgraph_varpool_last_needed_node;
*************** bool
*** 838,845 ****
  decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
  {
    /* If the user told us it is used, then it must be so.  */
!   if (node->externally_visible
!       || lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
      return true;

    /* ??? If the assembler name is set by hand, it is possible to assemble
--- 838,844 ----
  decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
  {
    /* If the user told us it is used, then it must be so.  */
!   if (node->externally_visible)
      return true;

    /* ??? If the assembler name is set by hand, it is possible to assemble
Index: cgraph.h
===================================================================
*** cgraph.h    (revision 109820)
--- cgraph.h    (working copy)
*************** extern GTY(()) struct cgraph_node *cgrap
*** 242,247 ****
--- 242,248 ----

  extern GTY(()) struct cgraph_varpool_node
*cgraph_varpool_first_unanalyzed_node;
  extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes_queue;
+ extern GTY(()) struct cgraph_varpool_node *cgraph_varpool_nodes;
  extern GTY(()) struct cgraph_asm_node *cgraph_asm_nodes;
  extern GTY(()) int cgraph_order;

Index: cgraphunit.c
===================================================================
*** cgraphunit.c        (revision 109820)
--- cgraphunit.c        (working copy)
*************** decide_is_function_needed (struct cgraph
*** 198,205 ****
      }

    /* If the user told us it is used, then it must be so.  */
!   if (node->local.externally_visible
!       || lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
      return true;

    /* ??? If the assembler name is set by hand, it is possible to assemble
--- 198,204 ----
      }

    /* If the user told us it is used, then it must be so.  */
!   if (node->local.externally_visible)
      return true;

    /* ??? If the assembler name is set by hand, it is possible to assemble
*************** cgraph_analyze_function (struct cgraph_n
*** 906,911 ****
--- 905,950 ----
    current_function_decl = NULL;
  }

+ /* Look for externally_visible and used attributes and mark cgraph nodes
+    accordingly.
+ 
+    This is not easilly doable earlier in handle_*_attribute because they
might
+    be passed different copy of decl before merging.  We can't do that in
+    cgraph_finalize_function either because we want to allow defining the
attributes
+    later, so we do that in separate pass at the end of unit.  */
+ 
+ static void
+ process_function_and_variable_attributes (void)
+ {
+   struct cgraph_node *node;
+   struct cgraph_varpool_node *vnode;
+ 
+   for (node = cgraph_nodes; node; node = node->next)
+     {
+       tree decl = node->decl;
+       if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
+       mark_decl_referenced (decl);
+       if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
+       {
+         if (node->local.finalized)
+           cgraph_mark_needed_node (node);
+         node->externally_visible = true;
+       }
+     }
+   for (vnode = cgraph_varpool_nodes; vnode; vnode = vnode->next)
+     {
+       tree decl = vnode->decl;
+       if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
+       mark_decl_referenced (decl);
+       if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
+       {
+         if (vnode->finalized)
+           cgraph_varpool_mark_needed_node (vnode);
+         vnode->externally_visible = true;
+       }
+     }
+ }
+ 
  /* Analyze the whole compilation unit once it is parsed completely.  */

  void
*************** cgraph_finalize_compilation_unit (void)
*** 916,925 ****
--- 955,965 ----
       intermodule optimization.  */
    static struct cgraph_node *first_analyzed;

+   process_function_and_variable_attributes ();
    finish_aliases_1 ();

    if (!flag_unit_at_a_time)
      {
        cgraph_output_pending_asms ();
        cgraph_assemble_pending_functions ();
        return;
Index: c-decl.c
===================================================================
*** c-decl.c    (revision 109820)
--- c-decl.c    (working copy)
*************** finish_decl (tree decl, tree init, tree 
*** 3498,3507 ****
        }
      }

-   /* If this was marked 'used', be sure it will be output.  */
-   if (lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
-     mark_decl_referenced (decl);
- 
    if (TREE_CODE (decl) == TYPE_DECL)
      {
        if (!DECL_FILE_SCOPE_P (decl)
--- 3498,3503 ----
Index: c-common.c
===================================================================
*** c-common.c  (revision 109820)
--- c-common.c  (working copy)
*************** handle_externally_visible_attribute (tre
*** 4274,4293 ****
               "%qE attribute have effect only on public objects", name);
        *no_add_attrs = true;
      }
!   else if (TREE_CODE (node) == FUNCTION_DECL)
!     {
!       struct cgraph_node *n = cgraph_node (node);
!       n->local.externally_visible = true;
!       if (n->local.finalized)
!       cgraph_mark_needed_node (n);
!     }
!   else if (TREE_CODE (node) == VAR_DECL)
!     {
!       struct cgraph_varpool_node *n = cgraph_varpool_node (node);
!       n->externally_visible = true;
!       if (n->finalized)
!       cgraph_varpool_mark_needed_node (n);
!     }
    else
      {
        warning (OPT_Wattributes, "%qE attribute ignored", name);
--- 4274,4282 ----
               "%qE attribute have effect only on public objects", name);
        *no_add_attrs = true;
      }
!   else if (TREE_CODE (node) == FUNCTION_DECL
!          || TREE_CODE (node) == VAR_DECL)
!     ;
    else
      {
        warning (OPT_Wattributes, "%qE attribute ignored", name);


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2006-07-21 15:13 ` hubicka at ucw dot cz
@ 2006-07-23 10:15 ` patchapp at dberlin dot org
  2006-07-24  0:16 ` hubicka at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: patchapp at dberlin dot org @ 2006-07-23 10:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from patchapp at dberlin dot org  2006-07-23 10:15 -------
Subject: Bug number PR c++/27369

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-07/msg00993.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1/4.2 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (13 preceding siblings ...)
  2006-07-23 10:15 ` patchapp at dberlin dot org
@ 2006-07-24  0:16 ` hubicka at gcc dot gnu dot org
  2007-01-05 19:44 ` [Bug c++/27369] [4.1 " rguenth at gcc dot gnu dot org
  2007-01-05 19:45 ` rguenth at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: hubicka at gcc dot gnu dot org @ 2006-07-24  0:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from hubicka at gcc dot gnu dot org  2006-07-24 00:16 -------
Subject: Bug 27369

Author: hubicka
Date: Mon Jul 24 00:16:16 2006
New Revision: 115693

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115693
Log:
        PR c/25795
        PR c++/27369
        * cgraph.c (cgraph_varpool_nodes): Export.
        (decide_is_variable_needed): Ignored "used" attribute in
        unit-at-a-time mode.
        * cgraph.h (cgraph_varpool_nodes): Declare.
        * cgraphunit.c (decide_is_function_needed): Ignored "used" attribute in
        unit-at-a-time mode.

        * gcc.dg/pr25795.c: New test.
        * gcc.dg/pr25795-1.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/pr25795-1.c
    trunk/gcc/testsuite/gcc.dg/pr25795.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-decl.c
    trunk/gcc/cgraph.c
    trunk/gcc/cgraph.h
    trunk/gcc/cgraphunit.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (14 preceding siblings ...)
  2006-07-24  0:16 ` hubicka at gcc dot gnu dot org
@ 2007-01-05 19:44 ` rguenth at gcc dot gnu dot org
  2007-01-05 19:45 ` rguenth at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-01-05 19:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from rguenth at gcc dot gnu dot org  2007-01-05 19:44 -------
Subject: Bug 27369

Author: rguenth
Date: Fri Jan  5 19:44:10 2007
New Revision: 120495

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120495
Log:
2007-01-05  Richard Guenther  <rguenther@suse.de>

        Backport from mainline:
        2006-06-24  Jan Hubicka  <jh@suse.cz>

        PR c/25795
        PR c++/27369
        * craph.c (cgraph_varpool_nodes): Export.
        (decide_is_variable_needed): Do not worry about "used" attribute.
        * cgraph.h (cgraph_varpool_nodes): Declare.
        * cgraphunit.c (decide_is_function_needed): Do not worry about "used"
        attribute.
        (process_function_and_variable_attributes): New function.
        (cgraph_finalize_compilation_unit): Call it.
        * c-decl.c (finish_decl): Do not worry about used attribute.
        * c-common.c (handle_externally_visible_attribute): Only validate.      

        * gcc.dg/pr25795.c: New testcase.
        * gcc.dg/pr25795-1.c: Likewise.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr25795-1.c
      - copied unchanged from r115693, trunk/gcc/testsuite/gcc.dg/pr25795-1.c
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr25795.c
      - copied unchanged from r115693, trunk/gcc/testsuite/gcc.dg/pr25795.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/c-common.c
    branches/gcc-4_1-branch/gcc/c-decl.c
    branches/gcc-4_1-branch/gcc/cgraph.c
    branches/gcc-4_1-branch/gcc/cgraph.h
    branches/gcc-4_1-branch/gcc/cgraphunit.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Bug c++/27369] [4.1 Regression] tree check ICE when attribute externally_visible used
  2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
                   ` (15 preceding siblings ...)
  2007-01-05 19:44 ` [Bug c++/27369] [4.1 " rguenth at gcc dot gnu dot org
@ 2007-01-05 19:45 ` rguenth at gcc dot gnu dot org
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-01-05 19:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from rguenth at gcc dot gnu dot org  2007-01-05 19:45 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27369


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2007-01-05 19:45 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-01 14:38 [Bug c++/27369] New: tree check ICE when attribute externally_visible used gcc-bugzilla at gcc dot gnu dot org
2006-05-01 14:40 ` [Bug c++/27369] " ned at bike-nomad dot com
2006-05-01 15:38 ` pinskia at gcc dot gnu dot org
2006-05-02  6:56 ` pinskia at gcc dot gnu dot org
2006-05-02  6:58 ` [Bug c++/27369] [4.2 Regression] " pinskia at gcc dot gnu dot org
2006-05-02  7:01 ` pinskia at gcc dot gnu dot org
2006-05-02  7:02 ` pinskia at gcc dot gnu dot org
2006-05-02 18:19 ` janis at gcc dot gnu dot org
2006-06-04 18:41 ` mmitchel at gcc dot gnu dot org
2006-06-07 15:18 ` [Bug c++/27369] [4.1/4.2 " rguenth at gcc dot gnu dot org
2006-06-26 22:16 ` jason at gcc dot gnu dot org
2006-07-12 15:46 ` reichelt at gcc dot gnu dot org
2006-07-21  8:39 ` mmitchel at gcc dot gnu dot org
2006-07-21 15:13 ` hubicka at ucw dot cz
2006-07-23 10:15 ` patchapp at dberlin dot org
2006-07-24  0:16 ` hubicka at gcc dot gnu dot org
2007-01-05 19:44 ` [Bug c++/27369] [4.1 " rguenth at gcc dot gnu dot org
2007-01-05 19:45 ` rguenth at gcc dot gnu dot org

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).