This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [Ada] Fix parsing for expressions with attributes and characters


*** TEST RESULTS FOR COMMIT af39b3270a1385027b2a5d145b9ba7564bd39f7a ***

Author: Pierre-Marie de Rodat <derodat@adacore.com>
Branch: master
Commit: af39b3270a1385027b2a5d145b9ba7564bd39f7a

[Ada] Fix parsing for expressions with attributes and characters

Before this change, trying to evaluate the following Ada expression
yielded a syntax error, even though it's completely legal:

    (gdb) p s'first = 'a'
    Error in expression, near `'.

The problem lies in the lexer (gdb/ada-lex.l): at the point we reach "'a'",
we're still in the BEFORE_QUAL_QUOTE start condition (the mechanism to
distinguish character literals from other "tick" usages: qualified
expressions and attributes), so we consider that this quote is actually a
separate "tick".

This changes resets the start condition to INITIAL in the
{TICK}[a-zA-Z][a-zA-Z]+ rule (for attributes): attributes activate this
BEFORE_QUAL_QUOTE condition and in this case the above rule is always
executed rather than the <BEFORE_QUAL_QUOTE>"'" one (in flex, it's
always the longest match that is chosen). We now have instead:

    (gdb) p s'first = 'a'
    $1 = true

gdb/ChangeLog:

	* ada-lex.l: Reset the start condition to INITIAL in the rule
	that matches attributes.

gdb/testsuite/ChangeLog:

	* gdb.ada/attr_ref_and_charlit.exp: New testcase.
	* gdb.ada/attr_ref_and_charlit/foo.adb: New file.

Tested on x86_64-linux, no regression.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]