From: Mark Mitchell <mark@codesourcery.com>
To: dave@hiauly1.hia.nrc.ca
Cc: chastain@cygnus.com, law@redhat.com, gcc@gcc.gnu.org,
libstdc++@gcc.gnu.org, gcc-patches@gc.gnu.org
Subject: Re: GCC 3.0 Status Report
Date: Thu, 19 Apr 2001 15:41:00 -0000 [thread overview]
Message-ID: <20010419154019D.mitchell@codesourcery.com> (raw)
In-Reply-To: <200104192006.QAA29881@hiauly1.hia.nrc.ca>
Here is the patch I committed.
Tested on i6868-pc-linux-gnu, committed on the branch and on the
mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2001-04-19 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (DECL_LANGUAGE): Don't assume DECL_LANG_SPECIFIC is
set.
(SET_DECL_LANGUAGE): New macro.
* decl.c (duplicate_decls): Use SET_DECL_LANGUAGE.
(pushdecl): Likewise.
(build_library_fn_1): Likewise.
(build_cp_library_fn): Likewise.
(grokfndecl): Likewise.
(grokvardecl): Mark `extern "C"' variables as having C linkage.
* decl2.c (grokclassfn): Use SET_DECL_LANGUAGE.
* lex.c (retrofit_lang_decl): Likewise.
* mangle.c (mangle_decl_string): Don't mangle the names of
variables declared with C language linkage.
* semantics.c (finish_member_declaration): Use SET_DECL_LANGUAGE.
Index: testsuite/g++.old-deja/g++.other/linkage7.C
===================================================================
RCS file: linkage7.C
diff -N linkage7.C
*** /dev/null Tue May 5 13:32:27 1998
--- linkage7.C Thu Apr 19 15:38:25 2001
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+
+ namespace N {
+ extern "C" int i;
+
+ void f () {
+ i = 3;
+ }
+ };
+
+ int i;
+
+ int main () { N::f (); }
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.572.2.18
diff -c -p -r1.572.2.18 cp-tree.h
*** cp-tree.h 2001/04/16 05:49:55 1.572.2.18
--- cp-tree.h 2001/04/19 22:38:28
*************** struct lang_decl
*** 1929,1937 ****
#define DECL_IN_MEMORY_P(NODE) \
(DECL_RTL_SET_P (NODE) && GET_CODE (DECL_RTL (NODE)) == MEM)
! /* For FUNCTION_DECLs: return the language in which this decl
! was declared. */
! #define DECL_LANGUAGE(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.language)
/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */
#define DECL_CONSTRUCTOR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_attr)
--- 1929,1952 ----
#define DECL_IN_MEMORY_P(NODE) \
(DECL_RTL_SET_P (NODE) && GET_CODE (DECL_RTL (NODE)) == MEM)
! /* For a FUNCTION_DECL or a VAR_DECL, the language linkage for the
! declaration. Some entities (like a member function in a local
! class, or a local variable) do not have linkage at all, and this
! macro should not be used in those cases.
!
! Implementation note: A FUNCTION_DECL without DECL_LANG_SPECIFIC was
! created by language-independent code, and has C linkage. Most
! VAR_DECLs have C++ linkage, and do not have DECL_LANG_SPECIFIC, but
! we do create DECL_LANG_SPECIFIC for variables with non-C++ linkage. */
! #define DECL_LANGUAGE(NODE) \
! (DECL_LANG_SPECIFIC (NODE) \
! ? DECL_LANG_SPECIFIC(NODE)->decl_flags.language \
! : (TREE_CODE (NODE) == FUNCTION_DECL \
! ? lang_c : lang_cplusplus))
!
! /* Set the language linkage for NODE to LANGUAGE. */
! #define SET_DECL_LANGUAGE(NODE, LANGUAGE) \
! (DECL_LANG_SPECIFIC (NODE)->decl_flags.language = LANGUAGE)
/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */
#define DECL_CONSTRUCTOR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_attr)
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.747.2.17
diff -c -p -r1.747.2.17 decl.c
*** decl.c 2001/04/12 14:16:58 1.747.2.17
--- decl.c 2001/04/19 22:38:31
*************** duplicate_decls (newdecl, olddecl)
*** 3193,3199 ****
/* Make the old declaration consistent with the new one so
that all remnants of the builtin-ness of this function
will be banished. */
! DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl),
--- 3193,3199 ----
/* Make the old declaration consistent with the new one so
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_ASSEMBLER_NAME (olddecl, newdecl);
SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl),
*************** duplicate_decls (newdecl, olddecl)
*** 3353,3359 ****
is OK. */
if (current_lang_stack
== &VARRAY_TREE (current_lang_base, 0))
! DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
else
{
cp_error_at ("previous declaration of `%#D' with %L linkage",
--- 3353,3359 ----
is OK. */
if (current_lang_stack
== &VARRAY_TREE (current_lang_base, 0))
! SET_DECL_LANGUAGE (newdecl, DECL_LANGUAGE (olddecl));
else
{
cp_error_at ("previous declaration of `%#D' with %L linkage",
*************** duplicate_decls (newdecl, olddecl)
*** 3667,3673 ****
if (! types_match)
{
! DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl);
SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
}
--- 3667,3673 ----
if (! types_match)
{
! SET_DECL_LANGUAGE (olddecl, DECL_LANGUAGE (newdecl));
COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl);
SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
}
*************** duplicate_decls (newdecl, olddecl)
*** 3682,3688 ****
if (new_defines_function)
/* If defining a function declared with other language
linkage, use the previously declared language linkage. */
! DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
else if (types_match)
{
/* If redeclaring a builtin function, and not a definition,
--- 3682,3688 ----
if (new_defines_function)
/* If defining a function declared with other language
linkage, use the previously declared language linkage. */
! SET_DECL_LANGUAGE (newdecl, DECL_LANGUAGE (olddecl));
else if (types_match)
{
/* If redeclaring a builtin function, and not a definition,
*************** pushdecl (x)
*** 3971,3977 ****
if (DECL_NON_THUNK_FUNCTION_P (x) && ! DECL_LANG_SPECIFIC (x))
{
retrofit_lang_decl (x);
! DECL_LANGUAGE (x) = lang_c;
}
if (DECL_NON_THUNK_FUNCTION_P (x) && ! DECL_FUNCTION_MEMBER_P (x))
--- 3971,3977 ----
if (DECL_NON_THUNK_FUNCTION_P (x) && ! DECL_LANG_SPECIFIC (x))
{
retrofit_lang_decl (x);
! SET_DECL_LANGUAGE (x, lang_c);
}
if (DECL_NON_THUNK_FUNCTION_P (x) && ! DECL_FUNCTION_MEMBER_P (x))
*************** build_library_fn_1 (name, operator_code,
*** 6716,6722 ****
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, operator_code);
! DECL_LANGUAGE (fn) = lang_c;
return fn;
}
--- 6716,6722 ----
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, operator_code);
! SET_DECL_LANGUAGE (fn, lang_c);
return fn;
}
*************** build_cp_library_fn (name, operator_code
*** 6743,6749 ****
tree fn = build_library_fn_1 (name, operator_code, type);
TREE_NOTHROW (fn) = TYPE_NOTHROW_P (type);
DECL_CONTEXT (fn) = FROB_CONTEXT (current_namespace);
! DECL_LANGUAGE (fn) = lang_cplusplus;
set_mangled_name_for_decl (fn);
return fn;
}
--- 6743,6749 ----
tree fn = build_library_fn_1 (name, operator_code, 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;
}
*************** grokfndecl (ctype, type, declarator, ori
*** 8750,8756 ****
&& ctype == NULL_TREE
/* NULL_TREE means global namespace. */
&& DECL_CONTEXT (decl) == NULL_TREE)
! DECL_LANGUAGE (decl) = lang_c;
/* Should probably propagate const out from type to decl I bet (mrs). */
if (staticp)
--- 8750,8756 ----
&& ctype == NULL_TREE
/* NULL_TREE means global namespace. */
&& DECL_CONTEXT (decl) == NULL_TREE)
! SET_DECL_LANGUAGE (decl, lang_c);
/* Should probably propagate const out from type to decl I bet (mrs). */
if (staticp)
*************** grokvardecl (type, declarator, specbits_
*** 9022,9030 ****
else
context = NULL_TREE;
! if (processing_template_decl && context)
! /* For global variables, declared in a template, we need the
! full lang_decl. */
decl = build_lang_decl (VAR_DECL, declarator, type);
else
decl = build_decl (VAR_DECL, declarator, type);
--- 9022,9034 ----
else
context = NULL_TREE;
! /* For namespace-scope variables, declared in a template, we
! need the full lang_decl. The same is true for
! namespace-scope variables that do not have C++ language
! linkage. */
! if (context
! && (processing_template_decl
! || current_lang_name != lang_name_cplusplus))
decl = build_lang_decl (VAR_DECL, declarator, type);
else
decl = build_decl (VAR_DECL, declarator, type);
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.437.2.11
diff -c -p -r1.437.2.11 decl2.c
*** decl2.c 2001/04/06 06:30:08 1.437.2.11
--- decl2.c 2001/04/19 22:38:33
*************** grokclassfn (ctype, function, flags, qua
*** 1020,1026 ****
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
! DECL_LANGUAGE (function) = lang_cplusplus;
if (fn_name == NULL_TREE)
{
--- 1020,1026 ----
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
! SET_DECL_LANGUAGE (function, lang_cplusplus);
if (fn_name == NULL_TREE)
{
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.237.2.3
diff -c -p -r1.237.2.3 lex.c
*** lex.c 2001/04/12 14:17:00 1.237.2.3
--- lex.c 2001/04/19 22:38:33
*************** retrofit_lang_decl (t)
*** 1513,1523 ****
DECL_LANG_SPECIFIC (t) = ld;
if (current_lang_name == lang_name_cplusplus)
! DECL_LANGUAGE (t) = lang_cplusplus;
else if (current_lang_name == lang_name_c)
! DECL_LANGUAGE (t) = lang_c;
else if (current_lang_name == lang_name_java)
! DECL_LANGUAGE (t) = lang_java;
else my_friendly_abort (64);
#ifdef GATHER_STATISTICS
--- 1513,1523 ----
DECL_LANG_SPECIFIC (t) = ld;
if (current_lang_name == lang_name_cplusplus)
! SET_DECL_LANGUAGE (t, lang_cplusplus);
else if (current_lang_name == lang_name_c)
! SET_DECL_LANGUAGE (t, lang_c);
else if (current_lang_name == lang_name_java)
! SET_DECL_LANGUAGE (t, lang_java);
else my_friendly_abort (64);
#ifdef GATHER_STATISTICS
Index: cp/mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.26.4.6
diff -c -p -r1.26.4.6 mangle.c
*** mangle.c 2001/04/16 05:49:55 1.26.4.6
--- mangle.c 2001/04/19 22:38:33
*************** mangle_decl_string (decl)
*** 2085,2101 ****
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
else if (/* The names of `extern "C"' functions are not mangled. */
! (TREE_CODE (decl) == FUNCTION_DECL
/* But overloaded operator names *are* mangled. */
! && !DECL_OVERLOADED_OPERATOR_P (decl)
! /* If there's no DECL_LANG_SPECIFIC, it's a function built
! by language-independent code, which never builds
! functions with C++ linkage. */
! && (!DECL_LANG_SPECIFIC (decl)
! || DECL_EXTERN_C_FUNCTION_P (decl)))
/* The names of global variables aren't mangled either. */
|| (TREE_CODE (decl) == VAR_DECL
! && CP_DECL_CONTEXT (decl) == global_namespace))
write_string (IDENTIFIER_POINTER (DECL_NAME (decl)));
else
{
--- 2085,2099 ----
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
else if (/* The names of `extern "C"' functions are not mangled. */
! (DECL_EXTERN_C_FUNCTION_P (decl)
/* But overloaded operator names *are* mangled. */
! && !DECL_OVERLOADED_OPERATOR_P (decl))
/* The names of global variables aren't mangled either. */
|| (TREE_CODE (decl) == VAR_DECL
! && CP_DECL_CONTEXT (decl) == global_namespace)
! /* And neither are `extern "C"' variables. */
! || (TREE_CODE (decl) == VAR_DECL
! && DECL_EXTERN_C_P (decl)))
write_string (IDENTIFIER_POINTER (DECL_NAME (decl)));
else
{
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.189.2.7
diff -c -p -r1.189.2.7 semantics.c
*** semantics.c 2001/04/18 07:52:56 1.189.2.7
--- semantics.c 2001/04/19 22:38:34
*************** finish_member_declaration (decl)
*** 1858,1864 ****
A C language linkage is ignored for the names of class members
and the member function type of class member functions. */
if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
! DECL_LANGUAGE (decl) = lang_cplusplus;
/* Put functions on the TYPE_METHODS list and everything else on the
TYPE_FIELDS list. Note that these are built up in reverse order.
--- 1858,1864 ----
A C language linkage is ignored for the names of class members
and the member function type of class member functions. */
if (DECL_LANG_SPECIFIC (decl) && DECL_LANGUAGE (decl) == lang_c)
! SET_DECL_LANGUAGE (decl, lang_cplusplus);
/* Put functions on the TYPE_METHODS list and everything else on the
TYPE_FIELDS list. Note that these are built up in reverse order.
next prev parent reply other threads:[~2001-04-19 15:41 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200104182009.NAA09066@bosch.cygnus.com>
2001-04-19 13:07 ` John David Anglin
2001-04-19 13:34 ` Mark Mitchell
2001-04-19 13:39 ` John David Anglin
2001-04-19 15:41 ` Mark Mitchell [this message]
2001-04-19 17:43 ` Joe Buck
2001-04-19 17:54 ` Mark Mitchell
2001-04-19 17:30 ` Benjamin Kosnik
2001-04-22 8:41 ` Fergus Henderson
2001-06-12 17:42 Robert Schweikert
2001-06-12 18:38 ` Mark Mitchell
-- strict thread matches above, loose matches on Subject: below --
2001-06-11 21:48 Mark Mitchell
2001-06-11 22:31 ` Loren James Rittle
2001-06-12 0:56 ` Joseph S. Myers
2001-06-12 1:17 ` Mark Mitchell
2001-06-12 1:57 ` Nathan Sidwell
2001-06-12 9:37 ` Tom Tromey
2001-06-12 3:42 ` Joseph S. Myers
2001-06-12 5:01 ` Franz Sirl
2001-06-12 19:39 ` Stan Shebs
2001-06-13 9:39 ` Mark Mitchell
2001-06-13 11:58 ` Franz Sirl
2001-06-12 5:32 ` Bernd Schmidt
2001-06-12 8:01 ` Geert Bosch
2001-06-12 16:16 ` Roman Zippel
2001-06-12 16:21 ` Mark Mitchell
2001-06-13 5:11 ` Joseph S. Myers
2001-06-13 6:00 ` Gerald Pfeifer
2001-06-13 9:45 ` Mark Mitchell
2001-06-05 13:23 Mark Mitchell
2001-06-05 13:49 ` Richard Henderson
2001-06-05 14:15 ` Rainer Orth
2001-06-05 18:09 ` Mark Mitchell
2001-06-06 4:54 ` Rainer Orth
2001-06-05 15:16 ` Joseph S. Myers
2001-06-05 15:33 ` benjamin kosnik
2001-06-05 15:56 ` Mark Mitchell
2001-06-05 15:56 ` Franz Sirl
2001-06-05 16:04 ` Mark Mitchell
2001-06-05 21:04 ` Alexandre Petit-Bianco
2001-06-05 23:08 ` Mark Mitchell
2001-05-21 18:48 Mark Mitchell
2001-05-21 20:23 ` Daniel Berlin
2001-05-22 1:44 ` Dennis Bjorklund
2001-05-22 2:33 ` Joseph S. Myers
2001-05-22 7:58 ` Mark Mitchell
2001-05-22 10:52 ` Dennis Bjorklund
2001-05-22 3:37 ` Joseph S. Myers
2001-05-22 3:53 ` Gerald Pfeifer
2001-05-22 13:51 ` Phil Edwards
2001-05-22 14:02 ` Mark Mitchell
2001-05-22 14:22 ` Toon Moene
2001-05-22 14:37 ` Mark Mitchell
2001-05-17 2:29 Christian Iseli
2001-05-14 14:28 Mark Mitchell
2001-05-14 16:44 ` Joseph S. Myers
2001-05-17 9:27 ` Joe Buck
2001-06-11 10:08 ` Joern Rennecke
2001-05-02 16:09 Mike Stump
2001-05-07 9:14 ` Joe Buck
2001-05-01 18:56 Mike Stump
2001-05-02 8:47 ` Mark Mitchell
2001-05-01 17:22 Mark Mitchell
2001-04-19 23:33 Michael Elizabeth Chastain
2001-04-19 13:27 Michael Elizabeth Chastain
2001-04-19 13:32 ` John David Anglin
2001-04-18 12:34 Michael Elizabeth Chastain
[not found] <1654.987568477@slagheap.cygnus.com>
2001-04-18 10:38 ` John David Anglin
[not found] <no.id>
2001-04-17 19:11 ` John David Anglin
2001-04-18 0:55 ` Mark Mitchell
2001-04-18 9:00 ` John David Anglin
2001-04-18 13:51 ` John David Anglin
2001-04-20 13:36 ` Mark Mitchell
2001-04-17 16:13 John David Anglin
2001-04-17 16:38 ` Gabriel Dos Reis
2001-04-17 18:40 ` John David Anglin
2001-04-17 10:32 Michael Elizabeth Chastain
2001-04-17 0:32 Mark Mitchell
2001-04-17 16:31 ` Toon Moene
2001-04-17 16:37 ` Mark Mitchell
2001-04-18 7:02 ` Andreas Schwab
2001-04-18 19:51 ` Mark Mitchell
2001-04-19 2:13 ` Gabriel Dos Reis
2001-04-19 8:33 ` Mark Mitchell
2001-04-19 13:36 ` Phil Edwards
2001-04-03 10:38 Mark Mitchell
2001-04-03 13:24 ` Joseph S. Myers
2001-04-03 14:22 ` Toon Moene
2001-03-27 8:55 Mark Mitchell
2001-03-27 9:51 ` David Edelsohn
2001-03-20 4:18 Peter Bienstman
2001-03-19 12:23 Mark Mitchell
2001-03-19 13:35 ` Craig Rodrigues
2001-03-19 16:04 ` Mark Mitchell
2001-03-19 17:16 ` Geoff Keating
2001-03-19 17:26 ` Mark Mitchell
2001-03-19 18:42 ` Stan Shebs
2001-03-19 19:07 ` Daniel Berlin
2001-03-19 19:53 ` Stan Shebs
2001-03-19 20:18 ` Mark Mitchell
2001-03-19 17:43 ` Daniel Berlin
2001-03-19 18:15 ` Geoff Keating
2001-03-19 18:11 ` Daniel Berlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010419154019D.mitchell@codesourcery.com \
--to=mark@codesourcery.com \
--cc=chastain@cygnus.com \
--cc=dave@hiauly1.hia.nrc.ca \
--cc=gcc-patches@gc.gnu.org \
--cc=gcc@gcc.gnu.org \
--cc=law@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).