From f84b6c964e3a1747ac27f60576743ef918f482db Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 27 Jun 2004 18:56:46 +0000 Subject: [PATCH] re PR c++/16193 (Bootstrap failure in libstdc++-v3) PR c++/16193 * parser.c (cp_parser_set_decl_spec_type): Refine test for redefinition of built-in types. PR c++/16193 * g++.dg/parse/redef1.C: New test. From-SVN: r83740 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 22 +++++++++++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/redef1.C | 10 ++++++++++ 4 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/redef1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 92eb2c7d7a1..9dabcca1ee7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-06-27 Mark Mitchell + + PR c++/16193 + * parser.c (cp_parser_set_decl_spec_type): Refine test for + redefinition of built-in types. + 2004-06-27 Gabriel Dos Reis * error.c (pp_template_argument_list_start): Remove. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 1b989dbe283..174c56a5e1d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15427,13 +15427,21 @@ cp_parser_set_decl_spec_type (cp_decl_specifier_seq *decl_specs, bool user_defined_p) { decl_specs->any_specifiers_p = true; - if (decl_specs->type) - { - if (decl_specs->specs[(int)ds_typedef] && !user_defined_p) - decl_specs->redefined_builtin_type = type_spec; - else - decl_specs->multiple_types_p = true; - } + + /* If the user tries to redeclare a built-in type (with, for example, + in "typedef int wchar_t;") we remember that this is what + happened. In system headers, we ignore these declarations so + that G++ can work with system headers that are not C++-safe. */ + if (decl_specs->specs[(int) ds_typedef] + && !user_defined_p + && (decl_specs->type + || decl_specs->specs[(int) ds_long] + || decl_specs->specs[(int) ds_short] + || decl_specs->specs[(int) ds_unsigned] + || decl_specs->specs[(int) ds_signed])) + decl_specs->redefined_builtin_type = type_spec; + else if (decl_specs->type) + decl_specs->multiple_types_p = true; else { decl_specs->type = type_spec; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d559086c58c..619bfa38812 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-06-27 Mark Mitchell + + PR c++/16193 + * g++.dg/parse/redef1.C: New test. + 2004-06-27 Joseph S. Myers * gcc.c-torture/compile/20021123-1.c: Remove duplicate of diff --git a/gcc/testsuite/g++.dg/parse/redef1.C b/gcc/testsuite/g++.dg/parse/redef1.C new file mode 100644 index 00000000000..0235ffb72e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/redef1.C @@ -0,0 +1,10 @@ +// { dg-options "" } +// PR c++/16193 + +# 1 "syshdr1.C" +# 1 "syshdr1.h" 1 3 +// Redefinitions of built-in types are allowed in system headers so +// that G++ will work with system headers that are not fully +// C++-aware. +typedef long wchar_t; +# 2 "syshdr1.C" 2 -- 2.30.2