This is the mail archive of the gdb-patches@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]

Re: [PATCH v2] Do not classify C struct members as a filename


On 2018-01-24 11:51, Leszek Swirski via gdb-patches wrote:
There is existing logic in C/C++ expression parsing to avoid classifying
names as a filename when they are a field on the this object. This
change extends this logic to also avoid classifying names after a
struct-op (-> or .) as a filename, which otherwise causes a syntax
error.

Thus, it is now possible in the file

    #include <map>
    struct D {
        void map();
    }
    D d;

to call

    (gdb) print d.map()

where previously this would have been a syntax error.

Tested on gdb.cp/*.exp

Hi Leszek,

I was able to reproduce the problem and confirmed that the patch fixes it. I'm not very strong in the lexing/parsing area, but the change in c-exp.y makes sense to me. I'd like to give others a chance to comment, so let's wait a few days. If nobody answer, we can merge it. One nit, since we are now using C++, can you use bool instead of int? It won't match the old surrounding code, but that's a good reason to modernize the existing code later :).

Do you know if we have a test for the same thing, but with the "this" pointer (which was already worked before this patch)? If not, it would be nice to add it to the test as well. You could add a call to D::includefile and continue/break there. From there, you could test calling this->includefile().

Simon


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