]> gcc.gnu.org Git - gcc.git/commitdiff
toplev.c (documented_lang_options): Add -fshort-wchar.
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 23 Sep 1999 21:03:53 +0000 (21:03 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 23 Sep 1999 21:03:53 +0000 (17:03 -0400)
* toplev.c (documented_lang_options): Add -fshort-wchar.
* c-decl.c (c_decode_option): Likewise.
(init_decl_processing): If -fshort-wchar, use 'short unsigned int'
for wchar_t.
* c-common.c, c-lex.c: Get WCHAR_TYPE_SIZE from wchar_type_node.
* gcc.c (default_compilers): If -fshort-wchar,
override __WCHAR_TYPE__.
* tm.texi (C Dialect Options): Add -fshort-wchar.

From-SVN: r29638

gcc/ChangeLog
gcc/c-common.c
gcc/c-decl.c
gcc/c-lex.c
gcc/gcc.c
gcc/toplev.c

index f2f868d7759636b53eb1165f71d2585b2b0b2ee2..aea059ce5028a2e01c56513c62bf421eec6a28cd 100644 (file)
@@ -1,5 +1,14 @@
 Thu Sep 23 13:40:02 1999  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * toplev.c (documented_lang_options): Add -fshort-wchar.
+       * c-decl.c (c_decode_option): Likewise.
+       (init_decl_processing): If -fshort-wchar, use 'short unsigned int'
+       for wchar_t.
+       * c-common.c, c-lex.c: Get WCHAR_TYPE_SIZE from wchar_type_node.
+       * gcc.c (default_compilers): If -fshort-wchar, 
+       override __WCHAR_TYPE__.
+       * tm.texi (C Dialect Options): Add -fshort-wchar.
+
        * dwarf2out.c (output_aranges): Use DW_AT_location to find the
        symbol for a variable.
 
index cd2baab58ced8a3d08e49bdf56a6cde4d6398798..2fa89e6fc3f04e48fb7237a52baca64e012f3c0f 100644 (file)
@@ -38,13 +38,8 @@ cpp_options parse_options;
 enum cpp_token cpp_token;
 #endif
 
-#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)
 
 /* The following symbols are subsumed in the c_global_trees array, and
    listed here individually for documentation purposes. 
index 75b8ee02b842e3961aff8e74cc8c221c411d89ec..b2f32c6b9368b5d3984cc62d97539c47dc3f3fe5 100644 (file)
@@ -304,6 +304,10 @@ int flag_cond_mismatch;
 
 int flag_short_double;
 
+/* Nonzero means give `wchar_t' the same size as `short'.  */
+
+int flag_short_wchar;
+
 /* Nonzero means don't recognize the keyword `asm'.  */
 
 int flag_no_asm;
@@ -580,6 +584,10 @@ c_decode_option (argc, argv)
     flag_short_enums = 1;
   else if (!strcmp (p, "-fno-short-enums"))
     flag_short_enums = 0;
+  else if (!strcmp (p, "-fshort-wchar"))
+    flag_short_wchar = 1;
+  else if (!strcmp (p, "-fno-short-wchar"))
+    flag_short_wchar = 0;
   else if (!strcmp (p, "-fcond-mismatch"))
     flag_cond_mismatch = 1;
   else if (!strcmp (p, "-fno-cond-mismatch"))
@@ -2984,8 +2992,10 @@ init_decl_processing ()
   pushdecl (build_decl (TYPE_DECL,
                        ridpointers[(int) RID_VOID], void_type_node));
 
-  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 = signed_type (wchar_type_node);
   unsigned_wchar_type_node = unsigned_type (wchar_type_node);
index bd171abe248382265ec8514e5f2ab49c9eedab42..55f9acb797acf34245185f67fea5fac7eb587016 100644 (file)
@@ -135,13 +135,8 @@ extern int yydebug;
 /* File used for outputting assembler code.  */
 extern FILE *asm_out_file;
 
-#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)
index aa98df02f071b5fc5d5eba4adcfa13b9ab10b15b..343811f3c872a8aa3c1844a0ee50b9fbd24e8c75 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -610,6 +610,7 @@ static struct compiler default_compilers[] =
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
         %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{fleading-underscore} %{fno-leading-underscore}\
@@ -624,6 +625,8 @@ static struct compiler default_compilers[] =
                  %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
                   %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
                  %{ffast-math:-D__FAST_MATH__}\
+                 %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
+                 %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
                   %{H} %C %{D*} %{U*} %{i*} %Z\
                   %{ftraditional:-traditional}\
                   %{traditional-cpp:-traditional}\
@@ -646,6 +649,7 @@ static struct compiler default_compilers[] =
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
         %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{fleading-underscore} %{fno-leading-underscore}\
@@ -674,6 +678,7 @@ static struct compiler default_compilers[] =
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
         %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{fleading-underscore} %{fno-leading-underscore}\
@@ -691,6 +696,8 @@ static struct compiler default_compilers[] =
        %{!undef:%{!std=*:%p}%{std=gnu*:%p} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
         %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{fleading-underscore} %{fno-leading-underscore}\
@@ -720,6 +727,7 @@ static struct compiler default_compilers[] =
         -$ %{!undef:%p %P} -D__ASSEMBLER__ \
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
+       %{fshort-wchar:-D__WCHAR_TYPE__=short\\ unsigned\\ int}\
         %{traditional} %{ftraditional:-traditional}\
         %{traditional-cpp:-traditional}\
        %{fleading-underscore} %{fno-leading-underscore}\
index 9f08f7d5aabc5e412a4ac01759fa3eb7193ffa11..a126de002b73a0fbc0c076511fea5d8694f36c0d 100644 (file)
@@ -1043,6 +1043,8 @@ documented_lang_options[] =
   { "-fno-short-double", "" },
   { "-fshort-enums", "Use the smallest fitting integer to hold enums"},
   { "-fno-short-enums", "" },
+  { "-fshort-wchar", "Override the underlying type for wchar_t to `unsigned short'" },
+  { "-fno-short-wchar", "" },
 
   { "-Wall", "Enable most warning messages" },
   { "-Wbad-function-cast",
This page took 0.108535 seconds and 5 git commands to generate.