aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2024-07-11 12:26:36 +0200
committerJan Beulich <jbeulich@suse.com>2024-07-11 12:26:36 +0200
commit296597f53e2a3cf14eafdca4c3141f7a4a7ab14b (patch)
tree07478bc1dce3d0144deed7ef8b33eea5c47e0e4b
parent8ea8012a8bddbc6fbbc86766a1df181cf133c5c6 (diff)
downloadgdb-296597f53e2a3cf14eafdca4c3141f7a4a7ab14b.zip
gdb-296597f53e2a3cf14eafdca4c3141f7a4a7ab14b.tar.gz
gdb-296597f53e2a3cf14eafdca4c3141f7a4a7ab14b.tar.bz2
gas: multi-byte warning adjustments
First input_scrub_next_buffer()'s invocation was wrong, leading to input only being checked from the last newline till the end of the current buffer. Correcting the invocation, however, leads to duplicate checking unless -f (or the #NO_APP equivalent thereof) is in effect. Move the invocation to input_file_give_next_buffer(), to restrict it accordingly. Then, when macros contain multi-byte characters, warning about them again in every expansion isn't useful. Suppress such warnings from sb_scrub_and_add_sb().
-rw-r--r--gas/app.c5
-rw-r--r--gas/as.h2
-rw-r--r--gas/input-file.c15
-rw-r--r--gas/input-scrub.c5
-rw-r--r--gas/sb.c2
-rw-r--r--gas/testsuite/gas/all/gas.exp2
-rw-r--r--gas/testsuite/gas/all/multibyte3.l10
-rw-r--r--gas/testsuite/gas/all/multibyte3.s11
8 files changed, 41 insertions, 11 deletions
diff --git a/gas/app.c b/gas/app.c
index 955de0f..b268b66 100644
--- a/gas/app.c
+++ b/gas/app.c
@@ -406,7 +406,8 @@ scan_for_multibyte_characters (const unsigned char * start,
This is the way the old code used to work. */
size_t
-do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen)
+do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen,
+ bool check_multibyte)
{
char *to = tostart;
char *toend = tostart + tolen;
@@ -510,7 +511,7 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen)
from = input_buffer;
fromend = from + fromlen;
- if (multibyte_handling == multibyte_warn)
+ if (check_multibyte)
(void) scan_for_multibyte_characters ((const unsigned char *) from,
(const unsigned char* ) fromend,
true /* Generate warnings. */);
diff --git a/gas/as.h b/gas/as.h
index 69d7ae2..fe0fae4 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -496,7 +496,7 @@ void input_scrub_insert_line (const char *);
void input_scrub_insert_file (char *);
char * input_scrub_new_file (const char *);
char * input_scrub_next_buffer (char **bufp);
-size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t);
+size_t do_scrub_chars (size_t (*get) (char *, size_t), char *, size_t, bool);
size_t do_scrub_pending (void);
bool scan_for_multibyte_characters (const unsigned char *, const unsigned char *, bool);
int gen_to_words (LITTLENUM_TYPE *, int, long);
diff --git a/gas/input-file.c b/gas/input-file.c
index 9ec255b..89f03a9 100644
--- a/gas/input-file.c
+++ b/gas/input-file.c
@@ -240,9 +240,20 @@ input_file_give_next_buffer (char *where /* Where to place 1st character of new
Since the assembler shouldn't do any output to stdout, we
don't bother to synch output and input. */
if (preprocess)
- size = do_scrub_chars (input_file_get, where, BUFFER_SIZE);
+ size = do_scrub_chars (input_file_get, where, BUFFER_SIZE,
+ multibyte_handling == multibyte_warn);
else
- size = input_file_get (where, BUFFER_SIZE);
+ {
+ size = input_file_get (where, BUFFER_SIZE);
+
+ if (multibyte_handling == multibyte_warn)
+ {
+ const unsigned char *start = (const unsigned char *) where;
+
+ (void) scan_for_multibyte_characters (start, start + size,
+ true /* Generate warnings */);
+ }
+ }
if (size)
return_value = where + size;
diff --git a/gas/input-scrub.c b/gas/input-scrub.c
index 5bfdc53..776d15e 100644
--- a/gas/input-scrub.c
+++ b/gas/input-scrub.c
@@ -386,11 +386,6 @@ input_scrub_next_buffer (char **bufp)
++p;
}
- if (multibyte_handling == multibyte_warn)
- (void) scan_for_multibyte_characters ((const unsigned char *) p,
- (const unsigned char *) limit,
- true /* Generate warnings */);
-
/* We found a newline in the newly read chars. */
partial_where = p;
partial_size = limit - p;
diff --git a/gas/sb.c b/gas/sb.c
index f451da0..e96355d 100644
--- a/gas/sb.c
+++ b/gas/sb.c
@@ -124,7 +124,7 @@ sb_scrub_and_add_sb (sb *ptr, sb *s)
break;
sb_check (ptr, copy);
ptr->len += do_scrub_chars (scrub_from_sb, ptr->ptr + ptr->len,
- ptr->max - ptr->len);
+ ptr->max - ptr->len, false);
}
sb_to_scrub = 0;
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index 32363c5..24376a7 100644
--- a/gas/testsuite/gas/all/gas.exp
+++ b/gas/testsuite/gas/all/gas.exp
@@ -535,3 +535,5 @@ run_dump_test "pr27384"
run_dump_test "pr27381"
run_dump_test "multibyte1"
run_dump_test "multibyte2"
+run_list_test "multibyte3" "--multibyte-handling=warn"
+run_list_test "multibyte3" "-f --multibyte-handling=warn"
diff --git a/gas/testsuite/gas/all/multibyte3.l b/gas/testsuite/gas/all/multibyte3.l
new file mode 100644
index 0000000..9f6f8d2
--- /dev/null
+++ b/gas/testsuite/gas/all/multibyte3.l
@@ -0,0 +1,10 @@
+[^:]*: Assembler messages:
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*: Warning: multibyte character \(.*\) encountered in .*
+[^:]*:[0-9]+: Warning: end of input
diff --git a/gas/testsuite/gas/all/multibyte3.s b/gas/testsuite/gas/all/multibyte3.s
new file mode 100644
index 0000000..303acfa
--- /dev/null
+++ b/gas/testsuite/gas/all/multibyte3.s
@@ -0,0 +1,11 @@
+ .macro m
+UmlautÜ\@:
+ .endm
+
+UmlautÄ:
+ .irpc c,szß
+UmlautÖ\@\c\():
+ m
+ .endr
+
+ .warning "end of input"