This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: GCC 3.0 Status Report
- To: dave at hiauly1 dot hia dot nrc dot ca
- Subject: Re: GCC 3.0 Status Report
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 19 Apr 2001 15:40:19 -0700
- Cc: chastain at cygnus dot com, law at redhat dot com, gcc at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org, gcc-patches at gc dot gnu dot org
- Organization: CodeSourcery, LLC
- References: <200104182009.NAA09066@bosch.cygnus.com><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.