summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-28 22:11:42 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-28 22:11:42 +0000
commit447bd85a6542cee62aa39dd898d75ae8bcd2298c (patch)
tree35aae564506e3c5cfe938e08bca9bf4463d4065c /gcc/cp
parent1bed606aacae6adcda87c8376131e91d20969f7c (diff)
downloadgcc-447bd85a6542cee62aa39dd898d75ae8bcd2298c.tar.gz
PR c++/25999
* decl.c (start_preparsed_function): Call maybe_apply_pragma_weak here, not ... (start_function): ... here. PR c++/25999 * g++.dg/ext/pragmaweak1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110340 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c15
2 files changed, 18 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ad3be507d4e..10718793733 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2006-01-28 Mark Mitchell <mark@codesourcery.com>
+ PR c++/25999
+ * decl.c (start_preparsed_function): Call maybe_apply_pragma_weak
+ here, not ...
+ (start_function): ... here.
+
+2006-01-28 Mark Mitchell <mark@codesourcery.com>
+
PR c++/25855
* class.c (resolve_address_of_overloaded_function): Adjust use of
return value from most_specialized_instantiation.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index e4be9e0f88c..ef7ed3a4fcd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -10287,6 +10287,17 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
DECL_CONTEXT (decl1) = DECL_CONTEXT (DECL_TI_TEMPLATE (decl1));
}
fntype = TREE_TYPE (decl1);
+
+ /* If #pragma weak applies, mark the decl appropriately now.
+ The pragma only applies to global functions. Because
+ determining whether or not the #pragma applies involves
+ computing the mangled name for the declaration, we cannot
+ apply the pragma until after we have merged this declaration
+ with any previous declarations; if the original declaration
+ has a linkage specification, that specification applies to
+ the definition as well, and may affect the mangled name. */
+ if (!DECL_CONTEXT (decl1))
+ maybe_apply_pragma_weak (decl1);
}
/* Determine the ELF visibility attribute for the function. We must
@@ -10458,10 +10469,6 @@ start_function (cp_decl_specifier_seq *declspecs,
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
return 0;
- /* If #pragma weak was used, mark the decl weak now. */
- if (global_scope_p (current_binding_level))
- maybe_apply_pragma_weak (decl1);
-
if (DECL_MAIN_P (decl1))
/* main must return int. grokfndecl should have corrected it
(and issued a diagnostic) if the user got it wrong. */