aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2002-03-12 23:36:55 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2002-03-12 23:36:55 +0100
commit62ae25292b0fc269e22127fa350221fb957f2ad8 (patch)
tree42cb4e2538ed7a1b69b7e899ac95bf8a7e172c8d /gcc
parent46f56f54c4965ef4aceb93d50d3f0497b3743cda (diff)
downloadgcc-62ae25292b0fc269e22127fa350221fb957f2ad8.zip
gcc-62ae25292b0fc269e22127fa350221fb957f2ad8.tar.gz
gcc-62ae25292b0fc269e22127fa350221fb957f2ad8.tar.bz2
c-lex.c (cb_ident, c_lex): Remove unnecessary cast.
* c-lex.c (cb_ident, c_lex): Remove unnecessary cast. (lex_string): Use unsigned char pointers. * gcc.c-torture/execute/wchar_t-1.c: New test. From-SVN: r50689
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-lex.c18
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c16
4 files changed, 34 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5f02f15..a8d6824 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2002-03-12 Jakub Jelinek <jakub@redhat.com>
+
+ * c-lex.c (cb_ident, c_lex): Remove unnecessary cast.
+ (lex_string): Use unsigned char pointers.
+
2002-03-12 Ulrich Weigand <uweigand@de.ibm.com>
* reload1.c (reload): Ignore MEM REG_EQUIV notes if the equivalent
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 8c5c3e7..d157a3f 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -85,7 +85,8 @@ static int ignore_escape_flag;
static void parse_float PARAMS ((PTR));
static tree lex_number PARAMS ((const char *, unsigned int));
-static tree lex_string PARAMS ((const char *, unsigned int, int));
+static tree lex_string PARAMS ((const unsigned char *, unsigned int,
+ int));
static tree lex_charconst PARAMS ((const cpp_token *));
static void update_header_times PARAMS ((const char *));
static int dump_one_header PARAMS ((splay_tree_node, void *));
@@ -239,7 +240,7 @@ cb_ident (pfile, line, str)
if (! flag_no_ident)
{
/* Convert escapes in the string. */
- tree value = lex_string ((const char *)str->text, str->len, 0);
+ tree value = lex_string (str->text, str->len, 0);
ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (value));
}
#endif
@@ -807,8 +808,8 @@ c_lex (value)
case CPP_STRING:
case CPP_WSTRING:
- *value = lex_string ((const char *)tok->val.str.text,
- tok->val.str.len, tok->type == CPP_WSTRING);
+ *value = lex_string (tok->val.str.text, tok->val.str.len,
+ tok->type == CPP_WSTRING);
break;
/* These tokens should not be visible outside cpplib. */
@@ -1282,14 +1283,14 @@ lex_number (str, len)
static tree
lex_string (str, len, wide)
- const char *str;
+ const unsigned char *str;
unsigned int len;
int wide;
{
tree value;
char *buf = alloca ((len + 1) * (wide ? WCHAR_BYTES : 1));
char *q = buf;
- const char *p = str, *limit = str + len;
+ const unsigned char *p = str, *limit = str + len;
unsigned int c;
unsigned width = wide ? WCHAR_TYPE_SIZE
: TYPE_PRECISION (char_type_node);
@@ -1305,7 +1306,7 @@ lex_string (str, len, wide)
wchar_t wc;
int char_len;
- char_len = local_mbtowc (&wc, p, limit - p);
+ char_len = local_mbtowc (&wc, (const char *) p, limit - p);
if (char_len == -1)
{
warning ("ignoring invalid multibyte character");
@@ -1329,8 +1330,7 @@ lex_string (str, len, wide)
mask = ((unsigned int) 1 << width) - 1;
else
mask = ~0;
- c = cpp_parse_escape (parse_in, (const unsigned char **) &p,
- (const unsigned char *) limit, mask);
+ c = cpp_parse_escape (parse_in, &p, limit, mask);
}
/* Add this single character into the buffer either as a wchar_t
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ebaf73f..ae6ec90 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2002-03-12 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c-torture/execute/wchar_t-1.c: New test.
+
2002-03-12 David Edelsohn <edelsohn@gnu.org>
* gcc.dg/20020103-1.c: Add rs6000 target and macro.
diff --git a/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c b/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c
new file mode 100644
index 0000000..51f91d6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/wchar_t-1.c
@@ -0,0 +1,16 @@
+typedef __WCHAR_TYPE__ wchar_t;
+wchar_t x[] = L"Ä";
+wchar_t y = L'Ä';
+extern void abort (void);
+extern void exit (int);
+
+int main (void)
+{
+ if (sizeof (x) / sizeof (wchar_t) != 2)
+ abort ();
+ if (x[0] != L'Ä' || x[1] != L'\0')
+ abort ();
+ if (y != L'Ä')
+ abort ();
+ exit (0);
+}