lex.c: Get WCHAR_TYPE_SIZE from wchar_type_node.
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 23 Sep 1999 21:04:10 +0000 (21:04 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Sep 1999 21:04:10 +0000 (17:04 -0400)
* lex.c: Get WCHAR_TYPE_SIZE from wchar_type_node.
* lang-specs.h: If -fshort-wchar, override __WCHAR_TYPE__.
* decl2.c (lang_f_options): Add -fshort-wchar.
* cp-tree.h: Declare flag_short_wchar.
* decl.c (init_decl_processing): If -fshort-wchar, use 'short unsigned
int' for wchar_t.

From-SVN: r29639

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/lang-specs.h
gcc/cp/lex.c

index 3323506aba226428f8cf70c95c01adfbb8c0489a..51f48da76f5add68bb25734e74d6759d28dd3dcd 100644 (file)
@@ -1,3 +1,12 @@
+1999-09-23  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * lex.c: Get WCHAR_TYPE_SIZE from wchar_type_node.
+       * lang-specs.h: If -fshort-wchar, override __WCHAR_TYPE__.
+       * decl2.c (lang_f_options): Add -fshort-wchar.
+       * cp-tree.h: Declare flag_short_wchar.
+       * decl.c (init_decl_processing): If -fshort-wchar, use 'short unsigned 
+       int' for wchar_t.
+
 1999-09-23  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
 
        * ir.texi: Fix formatting errors and typos.
index 78ec70e13144ed5275b8151dc587fb122298d90e..d601543f7b32d29a5999c3ae4f85b43f10c86ef0 100644 (file)
@@ -930,6 +930,10 @@ extern int name_mangling_version;
 /* Nonzero means that guiding declarations are allowed.  */
 extern int flag_guiding_decls;
 
+/* Nonzero if wchar_t should be `unsigned short' instead of whatever it
+   would normally be, for use with WINE.  */
+extern int flag_short_wchar;
+
 /* Nonzero if squashed mangling is to be performed. 
    This uses the B and K codes to reference previously seen class types 
    and class qualifiers.       */
index 1e63523cdaede8b382896aa3c2f175169dab24b7..86c17053f3e7fee37b6b2b57c7963eca6f6fc196 100644 (file)
@@ -6247,8 +6247,10 @@ init_decl_processing ()
   TYPE_REFERENCE_TO (unknown_type_node) = unknown_type_node;
 
   /* This is special for C++ so functions can be overloaded.  */
-  wchar_type_node
-    = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (WCHAR_TYPE)));
+  wchar_type_node = get_identifier (flag_short_wchar
+                                   ? "short unsigned int"
+                                   : WCHAR_TYPE);
+  wchar_type_node = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (wchar_type_node));
   wchar_type_size = TYPE_PRECISION (wchar_type_node);
   signed_wchar_type_node = make_signed_type (wchar_type_size);
   unsigned_wchar_type_node = make_unsigned_type (wchar_type_size);
index 0b8083aac6154d8d74e15ea31b024834d1a53878..3b80f6825a7e2d3f7b3434640453768405f733f2 100644 (file)
@@ -456,6 +456,10 @@ int name_mangling_version = 2;
 /* Nonzero means that guiding declarations are allowed.  */
 int flag_guiding_decls;
 
+/* Nonzero if wchar_t should be `unsigned short' instead of whatever it
+   would normally be, for use with WINE.  */
+int flag_short_wchar;
+
 /* Nonzero if squashed mangling is to be performed. 
    This uses the B and K codes to reference previously seen class types 
    and class qualifiers.       */
@@ -491,6 +495,7 @@ lang_f_options[] =
   {"unsigned-bitfields", &flag_signed_bitfields, 0},
   {"short-enums", &flag_short_enums, 1},
   {"short-double", &flag_short_double, 1},
+  {"short-wchar", &flag_short_wchar, 1},
   {"cond-mismatch", &flag_cond_mismatch, 1},
   {"asm", &flag_no_asm, 0},
   {"builtin", &flag_no_builtin, 0},
index 48a6ac5f69087280b5c85e75cf8bb0f572d52079..692583ccc8f7beefa86c1a174a50db939afc59b0 100644 (file)
@@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA.  */
        %{!fno-exceptions:-D__EXCEPTIONS}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}}\n}\
       %{!E:%{!M:%{!MM:cc1plus %i %1 %2\
@@ -50,6 +51,7 @@ Boston, MA 02111-1307, USA.  */
                             %{!fno-exceptions:-D__EXCEPTIONS}\
                             %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
                            %{ffast-math:-D__FAST_MATH__}\
+                           %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
                             %{trigraphs}\
                            %{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} %{a}\
                            %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
@@ -71,6 +73,7 @@ Boston, MA 02111-1307, USA.  */
        %{!fno-exceptions:-D__EXCEPTIONS}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}} %{trigraphs}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
        %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
         %i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
     "%{!M:%{!MM:%{!E:cc1plus %{!pipe:%g.ii} %1 %2\
index af78b7f0f7ccfd95f1785289d2253d3ce5f65ddb..c396a5031886f826df8b6c0b44c4a9f00a16b93b 100644 (file)
@@ -348,13 +348,8 @@ int interface_unknown;             /* whether or not we know this class
 
 /* lexical analyzer */
 
-#ifndef WCHAR_TYPE_SIZE
-#ifdef INT_TYPE_SIZE
-#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
-#else
-#define WCHAR_TYPE_SIZE        BITS_PER_WORD
-#endif
-#endif
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE TYPE_PRECISION (wchar_type_node)
 
 /* Number of bytes in a wide character.  */
 #define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)