This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Kill -fhonor-std
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] Kill -fhonor-std
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Thu, 02 Aug 2001 11:53:49 +0100
- Organization: Codesourcery LLC
Hi,
I've committed this to the mainline which expunges -fno-honor-std.
I'll shortly disable it on the 3.0 branch with a much lighter patch.
booted & tested on i686-pc-linux-gnu.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
gcc
2001-08-02 Nathan Sidwell <nathan@codesourcery.com>
Kill -fhonor-std.
* doc/c-tree.texi (Namespaces): Remove std & -fhonor-std
interaction.
* doc/invoke.texi (C++ Dialect Options): Remove -fno-honor-std.
cp:
2001-08-02 Nathan Sidwell <nathan@codesourcery.com>
Kill -fhonor-std.
* NEWS: Document.
* cp-tree.h (flag_honor_std): Remove.
(CPTI_FAKE_STD): Remove.
(std_node): Remove comment about it being NULL.
(fake_std_node): Remove.
* decl.c (in_fake_std): Remove.
(walk_namespaces_r): Remove fake_std_node check.
(push_namespace): Remove in_fake_std code.
(pop_namespace): Likewise.
(lookup_name_real): Remove fake_std_node check.
(init_decl_processing): Always create std_node. Always add
std:: things there.
(builtin_function): Always put non '_' fns in std.
* decl2.c (flag_honor_std): Remove.
(lang_f_options): Remove honor-std.
(unsupported_options): Add honor-std.
(set_decl_namespace): Remove fake_std_node check.
(validate_nonmember_using_decl): Likewise.
(do_using_directive): Likewise.
(handle_class_head): Likewise.
* dump.c (cp_dump_tree): Likewise.
* except.c (init_exception_processing): Adjust.
* init.c (build_member_call): Remove fake_std_node check.
(build_offset_ref): Likewise.
* lang-options.h: Remove -fhonor-std, -fno-honor-std.
* rtti.c (init_rtti_processing): Adjust.
testsuite
2001-08-02 Nathan Sidwell <nathan@codesourcery.com>
Kill -fhonor-std.
* g++.old-deja/g++.ns/ns14.C: Remove special options.
* g++.old-deja/g++.other/std1.C: Likewise.
* g++.old-deja/g++.robertl/eb133.C: Likewise. Add using directive.
Index: cp/NEWS
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/NEWS,v
retrieving revision 1.28
diff -c -3 -p -r1.28 NEWS
*** NEWS 2001/07/19 04:27:15 1.28
--- NEWS 2001/08/02 09:54:21
***************
*** 1,5 ****
--- 1,9 ----
*** Changes in GCC 3.1:
+ * -fhonor-std and -fno-honor-std have been removed. -fno-honor-std was
+ a workaround to allow std compliant code to work with the non-std
+ compliant libstdc++-v2. libstdc++-v3 is std compliant.
+
* The C++ ABI has been changed to correctly handle this code:
struct A {
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.633
diff -c -3 -p -r1.633 cp-tree.h
*** cp-tree.h 2001/07/31 16:12:03 1.633
--- cp-tree.h 2001/08/02 09:54:33
*************** Boston, MA 02111-1307, USA. */
*** 209,218 ****
extern int flag_use_cxa_atexit;
- /* Nonzero to not ignore namespace std. */
-
- extern int flag_honor_std;
-
/* Nonzero means generate 'rtti' that give run-time type information. */
extern int flag_rtti;
--- 209,214 ----
*************** enum cp_tree_index
*** 526,532 ****
CPTI_VTBL_TYPE,
CPTI_VTBL_PTR_TYPE,
CPTI_STD,
- CPTI_FAKE_STD,
CPTI_ABI,
CPTI_TYPE_INFO_TYPE,
CPTI_TINFO_DECL_TYPE,
--- 522,527 ----
*************** extern tree cp_global_trees[CPTI_MAX];
*** 613,626 ****
#define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE]
#define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE]
#define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE]
- /* When the `std' namespace is a real namespace, this is the
- corresponding NAMESPACE_DECL. When the `std' namespace is an alias
- for the global namespace, this is NULL_TREE. */
#define std_node cp_global_trees[CPTI_STD]
- /* When the `std' namespace is a real namespace, this is the
- ERROR_MARK_NODE. Otherwise, this is a dummy NAMESPACE_DECL that
- should be treated like the global namespace. */
- #define fake_std_node cp_global_trees[CPTI_FAKE_STD]
#define abi_node cp_global_trees[CPTI_ABI]
#define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE]
#define tinfo_decl_type cp_global_trees[CPTI_TINFO_DECL_TYPE]
--- 608,614 ----
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.806
diff -c -3 -p -r1.806 decl.c
*** decl.c 2001/07/26 08:07:55 1.806
--- decl.c 2001/08/02 09:54:37
*************** tree cp_global_trees[CPTI_MAX];
*** 206,216 ****
static tree global_type_node;
- /* If non-zero, this is the number of times we have entered the `std'
- namespace when we are treating that namespace as an alias for the
- global namespace. */
- static int in_fake_std;
-
/* Expect only namespace names now. */
static int only_namespace_names;
--- 206,211 ----
*************** walk_namespaces_r (namespace, f, data)
*** 1794,1805 ****
if (TREE_CODE (current) != NAMESPACE_DECL
|| DECL_NAMESPACE_ALIAS (current))
continue;
- if (!DECL_LANG_SPECIFIC (current))
- {
- /* Hmm. std. */
- my_friendly_assert (current == fake_std_node, 393);
- continue;
- }
/* We found a namespace. */
result |= walk_namespaces_r (current, f, data);
--- 1789,1794 ----
*************** push_namespace (name)
*** 2279,2291 ****
need_new = 0;
implicit_use = 1;
}
- else if (current_namespace == global_namespace
- && !flag_honor_std
- && name == std_identifier)
- {
- in_fake_std++;
- return;
- }
else
{
/* Check whether this is an extended namespace definition. */
--- 2268,2273 ----
*************** push_namespace (name)
*** 2331,2342 ****
void
pop_namespace ()
{
! if (current_namespace == global_namespace)
! {
! my_friendly_assert (in_fake_std > 0, 980421);
! in_fake_std--;
! return;
! }
current_namespace = CP_DECL_CONTEXT (current_namespace);
/* The binding level is not popped, as it might be re-opened later. */
suspend_binding_level ();
--- 2313,2319 ----
void
pop_namespace ()
{
! my_friendly_assert (current_namespace != global_namespace, 20010801);
current_namespace = CP_DECL_CONTEXT (current_namespace);
/* The binding level is not popped, as it might be re-opened later. */
suspend_binding_level ();
*************** lookup_name_real (name, prefer_type, non
*** 5892,5901 ****
if (looking_for_template)
flags |= LOOKUP_TEMPLATES_EXPECTED;
- /* std:: becomes :: for now. */
- if (got_scope && got_scope == fake_std_node)
- got_scope = void_type_node;
-
if (got_scope)
type = got_scope;
else if (got_object != error_mark_node)
--- 5869,5874 ----
*************** init_decl_processing ()
*** 6377,6396 ****
declare_namespace_level ();
/* Create the `std' namespace. */
! if (flag_honor_std)
! {
! push_namespace (std_identifier);
! std_node = current_namespace;
! pop_namespace ();
! fake_std_node = error_mark_node;
! }
! else
! {
! fake_std_node = build_decl (NAMESPACE_DECL,
! std_identifier,
! void_type_node);
! pushdecl (fake_std_node);
! }
c_common_nodes_and_builtins ();
--- 6350,6358 ----
declare_namespace_level ();
/* Create the `std' namespace. */
! push_namespace (std_identifier);
! std_node = current_namespace;
! pop_namespace ();
c_common_nodes_and_builtins ();
*************** init_decl_processing ()
*** 6492,6503 ****
tree bad_alloc_type_node, newtype, deltype;
tree ptr_ftype_sizetype;
! if (flag_honor_std)
! push_namespace (std_identifier);
bad_alloc_type_node = xref_tag
(class_type_node, get_identifier ("bad_alloc"), 1);
! if (flag_honor_std)
! pop_namespace ();
ptr_ftype_sizetype
= build_function_type (ptr_type_node,
tree_cons (NULL_TREE,
--- 6454,6463 ----
tree bad_alloc_type_node, newtype, deltype;
tree ptr_ftype_sizetype;
! push_namespace (std_identifier);
bad_alloc_type_node = xref_tag
(class_type_node, get_identifier ("bad_alloc"), 1);
! pop_namespace ();
ptr_ftype_sizetype
= build_function_type (ptr_type_node,
tree_cons (NULL_TREE,
*************** builtin_function (name, type, code, clas
*** 6666,6678 ****
/* All builtins that don't begin with an `_' should go in the `std'
namespace. */
! if (flag_honor_std && name[0] != '_')
{
push_namespace (std_identifier);
DECL_CONTEXT (decl) = std_node;
}
pushdecl (decl);
! if (flag_honor_std && name[0] != '_')
pop_namespace ();
/* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME,
--- 6626,6638 ----
/* All builtins that don't begin with an `_' should go in the `std'
namespace. */
! if (name[0] != '_')
{
push_namespace (std_identifier);
DECL_CONTEXT (decl) = std_node;
}
pushdecl (decl);
! if (name[0] != '_')
pop_namespace ();
/* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME,
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.480
diff -c -3 -p -r1.480 decl2.c
*** decl2.c 2001/07/30 18:04:33 1.480
--- decl2.c 2001/08/02 09:54:39
*************** int flag_weak = 1;
*** 378,387 ****
int flag_use_cxa_atexit;
- /* Nonzero to not ignore namespace std. */
-
- int flag_honor_std = 1;
-
/* 0 if we should not perform inlining.
1 if we should expand functions calls inline at the tree level.
2 if we should consider *all* functions to be inline
--- 378,383 ----
*************** lang_f_options[] =
*** 448,454 ****
{"for-scope", &flag_new_for_scope, 2},
{"gnu-keywords", &flag_no_gnu_keywords, 0},
{"handle-exceptions", &flag_exceptions, 1},
- {"honor-std", &flag_honor_std, 1},
{"implement-inlines", &flag_implement_inlines, 1},
{"implicit-inline-templates", &flag_implicit_inline_templates, 1},
{"implicit-templates", &flag_implicit_templates, 1},
--- 444,449 ----
*************** static const char * const unsupported_op
*** 473,478 ****
--- 468,474 ----
"cond-mismatch",
"enum-int-equiv",
"guiding-decls",
+ "honor-std",
"huge-objects",
"labels-ok",
"new-abi",
*************** set_decl_namespace (decl, scope, friendp
*** 4403,4410 ****
int friendp;
{
tree old;
! if (scope == fake_std_node)
! scope = global_namespace;
/* Get rid of namespace aliases. */
scope = ORIGINAL_NAMESPACE (scope);
--- 4399,4405 ----
int friendp;
{
tree old;
!
/* Get rid of namespace aliases. */
scope = ORIGINAL_NAMESPACE (scope);
*************** validate_nonmember_using_decl (decl, sco
*** 4913,4925 ****
tree *scope;
tree *name;
{
! if (TREE_CODE (decl) == SCOPE_REF
! && TREE_OPERAND (decl, 0) == fake_std_node)
! {
! *scope = global_namespace;
! *name = TREE_OPERAND (decl, 1);
! }
! else if (TREE_CODE (decl) == SCOPE_REF)
{
*scope = TREE_OPERAND (decl, 0);
*name = TREE_OPERAND (decl, 1);
--- 4908,4914 ----
tree *scope;
tree *name;
{
! if (TREE_CODE (decl) == SCOPE_REF)
{
*scope = TREE_OPERAND (decl, 0);
*name = TREE_OPERAND (decl, 1);
*************** void
*** 5156,5163 ****
do_using_directive (namespace)
tree namespace;
{
- if (namespace == fake_std_node)
- return;
if (building_stmt_tree ())
add_stmt (build_stmt (USING_STMT, namespace));
--- 5145,5150 ----
*************** handle_class_head (aggr, scope, id)
*** 5260,5267 ****
if (current == NULL_TREE)
current = current_namespace;
- if (scope == fake_std_node)
- scope = global_namespace;
if (scope == NULL_TREE)
scope = global_namespace;
--- 5247,5252 ----
Index: cp/dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/dump.c,v
retrieving revision 1.57
diff -c -3 -p -r1.57 dump.c
*** dump.c 2001/06/05 08:03:45 1.57
--- dump.c 2001/08/02 09:54:39
*************** cp_dump_tree (di, t)
*** 158,167 ****
break;
case NAMESPACE_DECL:
- /* The fake `::std' namespace does not have DECL_LANG_SPECIFIC,
- and therefore many other macros do not work on it. */
- if (t == fake_std_node)
- break;
if (DECL_NAMESPACE_ALIAS (t))
dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
else if (!dump_flag (di, TDF_SLIM, t))
--- 158,163 ----
Index: cp/except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/except.c,v
retrieving revision 1.135
diff -c -3 -p -r1.135 except.c
*** except.c 2001/06/19 13:32:55 1.135
--- except.c 2001/08/02 09:54:39
*************** init_exception_processing ()
*** 62,77 ****
{
tree tmp;
- if (flag_honor_std)
- push_namespace (std_identifier);
-
/* void std::terminate (); */
tmp = build_function_type (void_type_node, void_list_node);
terminate_node = build_cp_library_fn_ptr ("terminate", tmp);
TREE_THIS_VOLATILE (terminate_node) = 1;
TREE_NOTHROW (terminate_node) = 1;
! if (flag_honor_std)
! pop_namespace ();
/* void __cxa_call_unexpected(void *); */
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
--- 62,74 ----
{
tree tmp;
/* void std::terminate (); */
+ push_namespace (std_identifier);
tmp = build_function_type (void_type_node, void_list_node);
terminate_node = build_cp_library_fn_ptr ("terminate", tmp);
TREE_THIS_VOLATILE (terminate_node) = 1;
TREE_NOTHROW (terminate_node) = 1;
! pop_namespace ();
/* void __cxa_call_unexpected(void *); */
tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.247
diff -c -3 -p -r1.247 init.c
*** init.c 2001/07/21 09:42:18 1.247
--- init.c 2001/08/02 09:54:41
*************** build_member_call (type, name, parmlist)
*** 1503,1511 ****
if (DECL_P (name))
name = DECL_NAME (name);
- if (type == fake_std_node)
- return build_x_function_call (do_scoped_id (name, 0), parmlist,
- current_class_ref);
if (TREE_CODE (type) == NAMESPACE_DECL)
return build_x_function_call (lookup_namespace_name (type, name),
parmlist, current_class_ref);
--- 1503,1508 ----
*************** build_offset_ref (type, name)
*** 1637,1645 ****
/* class templates can come in as TEMPLATE_DECLs here. */
if (TREE_CODE (name) == TEMPLATE_DECL)
return name;
-
- if (type == fake_std_node)
- return do_scoped_id (name, 0);
if (processing_template_decl || uses_template_parms (type))
return build_min_nt (SCOPE_REF, type, name);
--- 1634,1639 ----
Index: cp/lang-options.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lang-options.h,v
retrieving revision 1.40
diff -c -3 -p -r1.40 lang-options.h
*** lang-options.h 2001/06/11 21:29:39 1.40
--- lang-options.h 2001/08/02 09:54:41
*************** DEFINE_LANG_NAME ("C++")
*** 64,72 ****
N_("Do not recognise GNU defined keywords") },
{ "-fhandle-exceptions", "" },
{ "-fno-handle-exceptions", "" },
- { "-fhonor-std", "" },
- { "-fno-honor-std",
- N_("Do not treat the namespace `std' as a normal namespace") },
{ "-fhuge-objects",
N_("Enable support for huge objects") },
{ "-fno-huge-objects", "" },
--- 64,69 ----
Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.119
diff -c -3 -p -r1.119 rtti.c
*** rtti.c 2001/07/31 16:12:04 1.119
--- rtti.c 2001/08/02 09:54:42
*************** static int doing_runtime = 0;
*** 71,82 ****
void
init_rtti_processing ()
{
! if (flag_honor_std)
! push_namespace (std_identifier);
type_info_type_node = xref_tag
(class_type_node, get_identifier ("type_info"), 1);
! if (flag_honor_std)
! pop_namespace ();
tinfo_decl_type =
build_qualified_type (type_info_type_node, TYPE_QUAL_CONST);
}
--- 71,80 ----
void
init_rtti_processing ()
{
! push_namespace (std_identifier);
type_info_type_node = xref_tag
(class_type_node, get_identifier ("type_info"), 1);
! pop_namespace ();
tinfo_decl_type =
build_qualified_type (type_info_type_node, TYPE_QUAL_CONST);
}
Index: doc/c-tree.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/c-tree.texi,v
retrieving revision 1.14
diff -c -3 -p -r1.14 c-tree.texi
*** c-tree.texi 2001/07/19 18:33:30 1.14
--- c-tree.texi 2001/08/02 09:54:43
*************** representation, the global namespace is
*** 620,641 ****
namespace. Thus, in what follows, we describe namespaces generally,
rather than the global namespace in particular.
- The @code{::std} namespace, however, @emph{is} special when
- @code{flag_honor_std} is not set. When @code{flag_honor_std} is set,
- the @code{std} namespace is just like any other namespace. When
- @code{flag_honor_std} is not set, however, the @code{::std} namespace is
- treated as a synonym for the global namespace, thereby allowing users to
- write code that will work with compilers that put the standard library
- in the @code{::std} namespace. The @code{std} namespace is represented
- by the variable @code{std_node}. Although @code{std_node} is a
- @code{NAMESPACE_DECL}, it does not have all the fields required of a
- real namespace, and the macros and functions described here do not work,
- in general. It is safest simply to ignore @code{std_node} should you
- encounter it while examining the internal representation. In
- particular, you will encounter @code{std_node} while looking at the
- members of the global namespace. Just skip it without attempting to
- examine its members.
-
The following macros and functions can be used on a @code{NAMESPACE_DECL}:
@ftable @code
--- 620,625 ----
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.41
diff -c -3 -p -r1.41 invoke.texi
*** invoke.texi 2001/07/31 06:38:28 1.41
--- invoke.texi 2001/08/02 09:54:47
*************** in the following sections.
*** 174,180 ****
-fno-elide-constructors @gol
-fno-enforce-eh-specs -fexternal-templates @gol
-falt-external-templates @gol
! -ffor-scope -fno-for-scope -fno-gnu-keywords -fno-honor-std @gol
-fno-implicit-templates @gol
-fno-implicit-inline-templates @gol
-fno-implement-inlines -fms-extensions @gol
--- 174,180 ----
-fno-elide-constructors @gol
-fno-enforce-eh-specs -fexternal-templates @gol
-falt-external-templates @gol
! -ffor-scope -fno-for-scope -fno-gnu-keywords @gol
-fno-implicit-templates @gol
-fno-implicit-inline-templates @gol
-fno-implement-inlines -fms-extensions @gol
*************** otherwise be invalid, or have different
*** 1355,1373 ****
Do not recognize @code{typeof} as a keyword, so that code can use this
word as an identifier. You can use the keyword @code{__typeof__} instead.
@option{-ansi} implies @option{-fno-gnu-keywords}.
-
- @item -fno-honor-std
- @opindex fno-honor-std
- Ignore @code{namespace std}, instead of treating it as a real namespace.
- With this switch, the compiler will ignore
- @code{namespace-declarations}, @code{using-declarations},
- @code{using-directives}, and @code{namespace-names}, if they involve
- @code{std}.
-
- This option is only useful if you have manually compiled the C++
- run-time library with the same switch. Otherwise, your programs will
- not link. The use of this option is not recommended, and the option may
- be removed from a future version of G++.
@item -fno-implicit-templates
@opindex fno-implicit-templates
--- 1355,1360 ----
Index: testsuite/g++.old-deja/g++.ns/ns14.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.ns/ns14.C,v
retrieving revision 1.2
diff -c -3 -p -r1.2 ns14.C
*** ns14.C 1998/12/16 21:50:45 1.2
--- ns14.C 2001/08/02 09:54:50
***************
*** 1,4 ****
! //Special g++ Options: -fhonor-std
namespace std{
int f(){
return 0;
--- 1,4 ----
!
namespace std{
int f(){
return 0;
Index: testsuite/g++.old-deja/g++.other/std1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.other/std1.C,v
retrieving revision 1.1
diff -c -3 -p -r1.1 std1.C
*** std1.C 2000/10/19 17:57:48 1.1
--- std1.C 2001/08/02 09:54:50
***************
*** 1,5 ****
// Build don't link:
- // Special g++ Options: -fhonor-std
// Origin: Mark Mitchell <mark@codesourcery.com>
extern "C" int memcmp (const void * __s1,
--- 1,4 ----
Index: testsuite/g++.old-deja/g++.robertl/eb133.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb133.C,v
retrieving revision 1.4
diff -c -3 -p -r1.4 eb133.C
*** eb133.C 2000/06/12 23:48:13 1.4
--- eb133.C 2001/08/02 09:54:51
***************
*** 1,8 ****
// Build don't link:
- // Special g++ Options: -fno-honor-std
// Gives ICE 109
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// Reported against EGCS snaps 98/06/28.
int main()
{
--- 1,9 ----
// Build don't link:
// Gives ICE 109
// From: Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de>
// Reported against EGCS snaps 98/06/28.
+
+ using namespace std;
int main()
{