aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-06-20 08:34:54 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-06-20 08:34:54 +0000
commit84b8b0e04d42732ea65d452aa74e3575f75de10b (patch)
tree77c6f2ecee8dfe71ed0ec15fc16f213965dbd4dc /gcc/cp
parent14f661f16c1aabf017bcd7b0fea29786366b502f (diff)
downloadgcc-84b8b0e04d42732ea65d452aa74e3575f75de10b.zip
gcc-84b8b0e04d42732ea65d452aa74e3575f75de10b.tar.gz
gcc-84b8b0e04d42732ea65d452aa74e3575f75de10b.tar.bz2
c-common.h (has_c_linkage): New interface.
* c-common.h (has_c_linkage): New interface. * c-cppbuiltin.c: Include target.h. (c_cpp_builtins): Define __PRAGMA_REDEFINE_EXTNAME and __PRAGMA_EXTERN_PREFIX when appropriate. * c-pragma.c: Include target.h. Document clarified semantics of symbol-renaming #pragmas. (handle_pragma_redefine_extname, handle_pragma_extern_prefix) (maybe_apply_renaming_pragma): Rewrite according to clarified semantics. Always recognize, but do not necessarily execute. (init_pragma): Unconditionally register symbol-renaming pragmas. * system.h: Poison HANDLE_PRAGMA_REDEFINE_EXTNAME and HANDLE_PRAGMA_EXTERN_PREFIX. * target.h (struct gcc_target): Add handle_pragma_redefine_extname and handle_pragma_extern_prefix flags. * target-def.h: Add defaults for TARGET_HANDLE_PRAGMA_REDEFINE_EXTNAME and TARGET_HANDLE_PRAGMA_EXTERN_PREFIX. * Makefile.in (c-pragma.o, c-cppbuiltin.o): Update dependencies. * config/sol2.h: Define TARGET_HANDLE_PRAGMA_REDEFINE_EXTNAME, not HANDLE_PRAGMA_REDEFINE_EXTNAME. (TARGET_OS_CPP_BUILTINS): No need to define __PRAGMA_REDEFINE_EXTNAME. (TRANSFER_FROM_TRAMPOLINE): Prototype mprotect. * config/alpha/osf.h: Define TARGET_HANDLE_PRAGMA_EXTERN_PREFIX, not HANDLE_PRAGMA_EXTERN_PREFIX. (TARGET_OS_CPP_BUILTINS): No need to define __PRAGMA_EXTERN_PREFIX. * doc/extend.texi (Solaris Pragmas, Tru64 Pragmas): Combine into one section "Symbol-Renaming Pragmas"; clarify; document adjusted semantics. * builtins.c (expand_builtin): Do not issue error for a builtin with no special case code and no DECL_ASSEMBLER_NAME; just do the library call. * c-decl.c (builtin_function): Don't call make_decl_rtl. * c-objc-common.c (has_c_linkage): Stub implementation. * cgraphunit.c (cgraph_expand_function) (cgraph_remove_unreachable_nodes): Don't clear DECL_ARGUMENTS. cp: * cp-lang.c (has_c_linkage): Implement. * cp-tree.h (set_mangled_name_for_decl): Don't prototype. * decl.c (duplicate_decls): Use COPY_DECL_RTL. (builtin_function_1): Don't call make_decl_rtl. (build_cp_library_fn): Don't call set_mangled_name_for_decl. (grokvardecl): Don't call mangle_decl. * except.c (nothrow_libfn_p): Look at DECL_NAME, not DECL_ASSEMBLER_NAME. * method.c (set_mangled_name_for_decl): Delete. * name-lookup.c (pushdecl): When a local extern shadows a file-scope declaration of the same object, give both DECLs the same DECL_UID. * typeck.c (cxx_mark_addressable): Don't set TREE_ADDRESSABLE on DECL_ASSEMBLER_NAME. testsuite: * g++.dg/expr/enum1.C, g++.dg/opt/const3.C: Declare abort with extern "C". * g++.dg/other/pragma-re-1.C: Add comments. From-SVN: r83405
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog30
-rw-r--r--gcc/cp/cp-lang.c7
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c16
-rw-r--r--gcc/cp/except.c5
-rw-r--r--gcc/cp/method.c14
-rw-r--r--gcc/cp/name-lookup.c12
-rw-r--r--gcc/cp/typeck.c1
8 files changed, 48 insertions, 38 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 73ead05..e3048d3 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,21 @@
+2004-06-20 Zack Weinberg <zack@codesourcery.com>
+
+ * cp-lang.c (has_c_linkage): Implement.
+
+ * cp-tree.h (set_mangled_name_for_decl): Don't prototype.
+ * decl.c (duplicate_decls): Use COPY_DECL_RTL.
+ (builtin_function_1): Don't call make_decl_rtl.
+ (build_cp_library_fn): Don't call set_mangled_name_for_decl.
+ (grokvardecl): Don't call mangle_decl.
+ * except.c (nothrow_libfn_p): Look at DECL_NAME, not
+ DECL_ASSEMBLER_NAME.
+ * method.c (set_mangled_name_for_decl): Delete.
+ * name-lookup.c (pushdecl): When a local extern shadows a
+ file-scope declaration of the same object, give both DECLs the
+ same DECL_UID.
+ * typeck.c (cxx_mark_addressable): Don't set TREE_ADDRESSABLE
+ on DECL_ASSEMBLER_NAME.
+
2004-06-19 Richard Henderson <rth@redhat.com>
* cp-gimplify.c: Remove unnecessary prototypes.
@@ -15,7 +33,7 @@
(finish_cond): Rewrite to handle template DECL_STMTs specially.
Assume that non-template decls go land before the conditional.
(simplify_loop_decl_cond): Likewise.
- (begin_if_stmt, finish_if_stmt_cond, begin_while_stmt,
+ (begin_if_stmt, finish_if_stmt_cond, begin_while_stmt,
finish_while_stmt_cond, finish_for_init_stmt, finish_for_cond,
begin_switch_stmt, finish_switch_cond): Update to match.
@@ -165,7 +183,7 @@
* cp-tree.h: Fix typo.
* cp-tree.h: Include cgraph.h
- (DECL_NEEDED_P): Use cgraph_*node on the decl instead of
+ (DECL_NEEDED_P): Use cgraph_*node on the decl instead of
TREE_SYMBOL_REFERENCED on the DECL_ASSEMBLER_NAME of the decl.
2004-06-12 Jason Merrill <jason@redhat.com>
@@ -288,8 +306,8 @@
PR c++/15554
* pt.c (tsubst_copy): Do not try to substitute for an enumeration
- constant in a non-dependent context.
-
+ constant in a non-dependent context.
+
PR c++/15057
* except.c (build_throw): Ensure that temp_expr has been
initialized.
@@ -316,7 +334,7 @@
* decl2.c (maybe_emit_vtables): If TARGET_WEAK_NOT_IN_ARCHIVE_TOC
is nonzero, and if we see a noninline definition of a key method,
make the vtables nonweak.
-
+
2004-06-02 Matt Austern <austern@apple.com>
* cp-tree.h (instantiate_decl): new boolean parameter,
@@ -335,7 +353,7 @@
change it to an implicit instantiation.
(instantiate_pending_templates): Add new argument to instantiate_decl.
* tree.c (cp_cannot_inline_tree_fn): Likewise.
-
+
2004-06-02 Andrew Pinski <pinskia@physics.uc.edu>
* cp-tree.h: Fix typo.
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index eb0e221..757ca08 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -353,3 +353,10 @@ void
pop_file_scope (void)
{
}
+
+/* c-pragma.c needs to query whether a decl has extern "C" linkage. */
+bool
+has_c_linkage (tree decl)
+{
+ return DECL_EXTERN_C_P (decl);
+}
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 7a0c41d..1838c82 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3855,7 +3855,6 @@ extern void cxx_finish (void);
/* in method.c */
extern void init_method (void);
-extern void set_mangled_name_for_decl (tree);
extern tree make_thunk (tree, bool, tree, tree);
extern void finish_thunk (tree);
extern void use_thunk (tree, bool);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b794b9e..dfdfe56 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1259,7 +1259,7 @@ duplicate_decls (tree newdecl, tree olddecl)
return NULL_TREE;
/* Replace the old RTL to avoid problems with inlining. */
- SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
+ COPY_DECL_RTL (newdecl, olddecl);
}
/* Even if the types match, prefer the new declarations type
for anticipated built-ins, for exception lists, etc... */
@@ -1288,7 +1288,7 @@ duplicate_decls (tree newdecl, tree olddecl)
that all remnants of the builtin-ness of this function
will be banished. */
SET_DECL_LANGUAGE (olddecl, DECL_LANGUAGE (newdecl));
- SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
+ COPY_DECL_RTL (newdecl, olddecl);
}
}
else if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
@@ -1827,7 +1827,7 @@ duplicate_decls (tree newdecl, tree olddecl)
{
SET_DECL_LANGUAGE (olddecl, DECL_LANGUAGE (newdecl));
COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl);
- SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
+ COPY_DECL_RTL (newdecl, olddecl);
}
if (! types_match || new_defines_function)
{
@@ -1851,7 +1851,7 @@ duplicate_decls (tree newdecl, tree olddecl)
DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
/* If we're keeping the built-in definition, keep the rtl,
regardless of declaration matches. */
- SET_DECL_RTL (newdecl, DECL_RTL (olddecl));
+ COPY_DECL_RTL (olddecl, newdecl);
}
DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
@@ -3183,7 +3183,6 @@ builtin_function_1 (const char* name,
function in the namespace. */
if (libname)
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
- make_decl_rtl (decl, NULL);
/* Warn if a function in the namespace for users
is used without an occasion to consider it declared. */
@@ -3271,7 +3270,6 @@ build_cp_library_fn (tree name, enum tree_code operator_code, tree type)
TREE_NOTHROW (fn) = TYPE_NOTHROW_P (type);
DECL_CONTEXT (fn) = FROB_CONTEXT (current_namespace);
SET_DECL_LANGUAGE (fn, lang_cplusplus);
- set_mangled_name_for_decl (fn);
return fn;
}
@@ -5829,12 +5827,6 @@ grokvardecl (tree type,
else
DECL_CONTEXT (decl) = scope;
- if (name && scope && current_lang_name != lang_name_c)
- /* We can't mangle lazily here because we don't have any
- way to recover whether or not a variable was `extern
- "C"' later. */
- mangle_decl (decl);
-
if (RIDBIT_SETP (RID_EXTERN, specbits))
{
DECL_THIS_EXTERN (decl) = 1;
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 7e6e54e..e978a54 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -841,7 +841,10 @@ nothrow_libfn_p (tree fn)
/* Can't be a C library function. */
return 0;
- id = DECL_ASSEMBLER_NAME (fn);
+ /* Being a C library function, DECL_ASSEMBLER_NAME == DECL_NAME
+ unless the system headers are playing rename tricks, and if
+ they are, we don't want to be confused by them. */
+ id = DECL_NAME (fn);
return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
}
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 364cc06..357ea86 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -71,20 +71,6 @@ init_method (void)
{
init_mangle ();
}
-
-
-/* Set the mangled name (DECL_ASSEMBLER_NAME) for DECL. */
-
-void
-set_mangled_name_for_decl (tree decl)
-{
- if (processing_template_decl)
- /* There's no need to mangle the name of a template function. */
- return;
-
- mangle_decl (decl);
-}
-
/* Return a this or result adjusting thunk to FUNCTION. THIS_ADJUSTING
indicates whether it is a this or result adjusting thunk.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 401f6505..1b755c9 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -677,9 +677,15 @@ pushdecl (tree x)
if (decls_match (x, t))
/* The standard only says that the local extern
inherits linkage from the previous decl; in
- particular, default args are not shared. It would
- be nice to propagate inlining info, though. FIXME. */
- TREE_PUBLIC (x) = TREE_PUBLIC (t);
+ particular, default args are not shared. We must
+ also tell cgraph to treat these decls as the same,
+ or we may neglect to emit an "unused" static - we
+ do this by making the DECL_UIDs equal, which should
+ be viewed as a kludge. FIXME. */
+ {
+ TREE_PUBLIC (x) = TREE_PUBLIC (t);
+ DECL_UID (x) = DECL_UID (t);
+ }
}
else if (TREE_CODE (t) == PARM_DECL)
{
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index bcdd316..9504083 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4318,7 +4318,6 @@ cxx_mark_addressable (tree exp)
case FUNCTION_DECL:
TREE_ADDRESSABLE (x) = 1;
- TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
return true;
case CONSTRUCTOR: