From 1482e9f1fcff4a88a184c2cff99709bd4657bdb9 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 27 Jul 2008 01:58:01 +0000 Subject: gdb: PR gdb/1136: * macroexp.c (get_punctuator) : Rearrange to put longer tokens first. gdb/testsuite: * gdb.base/macscp.exp: Add test for macro lexing bug. --- gdb/ChangeLog | 6 ++++++ gdb/macroexp.c | 29 ++++++++++++++++++++--------- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/macscp.exp | 5 +++++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index d1458ad4bf9..5db0b0c53cf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2008-07-26 Tom Tromey + + PR gdb/1136: + * macroexp.c (get_punctuator) : Rearrange to put + longer tokens first. + 2008-07-26 Vladimir Prus Kill cmd_async_ok. diff --git a/gdb/macroexp.c b/gdb/macroexp.c index 0cb9575678e..8102bc081f0 100644 --- a/gdb/macroexp.c +++ b/gdb/macroexp.c @@ -416,16 +416,27 @@ get_punctuator (struct macro_buffer *tok, char *p, char *end) { /* Here, speed is much less important than correctness and clarity. */ - /* ISO/IEC 9899:1999 (E) Section 6.4.6 Paragraph 1 */ + /* ISO/IEC 9899:1999 (E) Section 6.4.6 Paragraph 1. + Note that this table is ordered in a special way. A punctuator + which is a prefix of another punctuator must appear after its + "extension". Otherwise, the wrong token will be returned. */ static const char * const punctuators[] = { - "[", "]", "(", ")", "{", "}", ".", "->", - "++", "--", "&", "*", "+", "-", "~", "!", - "/", "%", "<<", ">>", "<", ">", "<=", ">=", "==", "!=", - "^", "|", "&&", "||", - "?", ":", ";", "...", - "=", "*=", "/=", "%=", "+=", "-=", "<<=", ">>=", "&=", "^=", "|=", - ",", "#", "##", - "<:", ":>", "<%", "%>", "%:", "%:%:", + "[", "]", "(", ")", "{", "}", "?", ";", ",", "~", + "...", ".", + "->", "--", "-=", "-", + "++", "+=", "+", + "*=", "*", + "!=", "!", + "&&", "&=", "&", + "/=", "/", + "%>", "%:%:", "%:", "%=", "%", + "^=", "^", + "##", "#", + ":>", ":", + "||", "|=", "|", + "<<=", "<<", "<=", "<:", "<%", "<", + ">>=", ">>", ">=", ">", + "==", "=", 0 }; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 1a07bc1defe..4047c48bca0 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-07-26 Tom Tromey + + * gdb.base/macscp.exp: Add test for macro lexing bug. + 2008-07-18 Tom Tromey * gdb.base/macscp.exp: Add macro tests. diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp index 90c2d9531f3..15d3f2f6430 100644 --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp @@ -472,3 +472,8 @@ gdb_test "macro undef M" \ gdb_test "print M" \ "No symbol \"M\" in current context\." \ "print expression with macro after user undef." + +# Regression test; this used to emit the wrong error. +gdb_test "macro expand SPLICE(x, y)" \ + "Token splicing is not implemented yet." \ + "macro splicing lexes correctly" -- cgit v1.2.1