Patchwork C++ PATCH for c++/49353 (emitting functions with DECL_EXTERNAL set)

login
register
mail settings
Submitter Jason Merrill
Date July 7, 2011, 2:26 a.m.
Message ID <4E15194E.9060905@redhat.com>
Download mbox | patch
Permalink /patch/103601/
State New
Headers show

Comments

Jason Merrill - July 7, 2011, 2:26 a.m.
The C++ front end sets DECL_EXTERNAL on functions and variables with 
vague linkage during most of compilation, and then clears the flag at 
EOF if we actually want to emit them.  But we were failing to clear 
DECL_EXTERNAL in the case of inlines that we are emitting because of 
-fkeep-inline-functions.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 600157c6ee5b6425f47b24d03dceaa4b5ac06359
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jul 6 18:01:40 2011 -0400

    	PR c++/49353
    	* semantics.c (expand_or_defer_fn_1): Clear DECL_EXTERNAL
    	on kept inlines.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 6fcf0da..5caeafe 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3634,7 +3634,10 @@  expand_or_defer_fn_1 (tree fn)
 	   && !DECL_REALLY_EXTERN (fn))
 	  || (flag_keep_inline_dllexport
 	      && lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn))))
-	mark_needed (fn);
+	{
+	  mark_needed (fn);
+	  DECL_EXTERNAL (fn) = 0;
+	}
     }
 
   /* There's no reason to do any of the work here if we're only doing