Fix obvious bug in aggregate expression
authorTom Tromey <tromey@adacore.com>
Tue, 15 Aug 2023 17:04:17 +0000 (11:04 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 16 Aug 2023 17:43:40 +0000 (11:43 -0600)
commit94c5098e4d9d5b58a6db31064398fb4941ab5efb
treeacc0e32f8c4b0e2cca1e586a75b050d09f85c2ab
parent100dbc6de52e6d4bfaf4b330ee923267e56e936c
Fix obvious bug in aggregate expression

I found an obvious bug in Ada aggregate expression handling:

  if (vvo != nullptr)
      error (_("Invalid record component association."));
    name = vvo->get_symbol ()->natural_name ();

Here the code errors when vvo is not null -- and then proceeds to use
vvo.

This hasn't caused a crash because, I believe, there's currently no
way to reach this code in the null case.  However, I'm not really
willing to assert this...

Fixing this shows another bug, which is that due to the way the parser
works, a field name in an aggregate expression might erroneously be
fully qualified if some global variable with the same base name
exists.

The included test case triggers both bugs.  Note that the test
includes a confounding case for array aggregates as well, but as these
are harder to fix, I've left it as kfail.

As this is Ada-specific, and has already been tested internally at
AdaCore, I am checking it in.
gdb/ada-lang.c
gdb/testsuite/gdb.ada/assoc.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/assoc/main.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/assoc/pck.ads [new file with mode: 0644]
gdb/testsuite/gdb.ada/assoc/xtra.adb [new file with mode: 0644]
gdb/testsuite/gdb.ada/assoc/xtra.ads [new file with mode: 0644]