re PR c++/16193 (Bootstrap failure in libstdc++-v3)
authorMark Mitchell <mark@codesourcery.com>
Sun, 27 Jun 2004 18:56:46 +0000 (18:56 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 27 Jun 2004 18:56:46 +0000 (18:56 +0000)
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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/redef1.C [new file with mode: 0644]

index 92eb2c7..9dabcca 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-27  Mark Mitchell  <mark@codesourcery.com>
+
+       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  <gdr@integrable-solutions.net>
 
        * error.c (pp_template_argument_list_start): Remove.
index 1b989db..174c56a 100644 (file)
@@ -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;
index d559086..619bfa3 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-27  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/16193
+       * g++.dg/parse/redef1.C: New test.
+
 2004-06-27  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        * 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 (file)
index 0000000..0235ffb
--- /dev/null
@@ -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