Bug 25795 - Proccessing the attribute externally_visible too early
Summary: Proccessing the attribute externally_visible too early
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2006-01-15 16:45 UTC by Andrew Pinski
Modified: 2006-08-15 21:08 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-28 04:09:43


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2006-01-15 16:45:44 UTC
extern const char *mystr;       /* normally in a header */
const char *mystr __attribute__ ((externally_visible));
----------------------------------------
What happens is that we call cgraph_varpool_node from handle_externally_visible_attribute
which adds the "second" decl (which will not exist soon).  And then we do a merge with the second and first decls and get back the first decl and then we use the first decl always.
Comment 1 Andrew Pinski 2006-01-28 04:09:43 UTC
Confirmed.
Comment 2 Jan Hubicka 2006-07-24 00:16:27 UTC
Subject: Bug 25795

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

Comment 3 Andrew Pinski 2006-08-15 21:08:05 UTC
Fixed.
Comment 4 Andrew Pinski 2006-08-15 21:08:29 UTC
*** Bug 28744 has been marked as a duplicate of this bug. ***
Comment 5 Richard Biener 2007-01-05 19:44:25 UTC
Subject: Bug 25795

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