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: [BUG] Parser error for "pointer to a function pointer"


On Sun, Sep 4, 2011 at 4:07 PM, Abhijit Halder
<abhijit.k.halder@gmail.com> wrote:
> On Sun, Sep 4, 2011 at 2:08 PM, Abhijit Halder
> <abhijit.k.halder@gmail.com> wrote:
>> Hello everybody,
>>
>> While working with gdb I have encountered the following problem.
>>
>> GNU gdb (GDB) 7.3.50.20110814-cvs
>> Copyright (C) 2011 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law. ?Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-linux-gnu".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>.
>> (gdb) ptype int(**)(void)
>> A syntax error in expression, near `*)(void)'.
>>
>>
>> I have made the following changes to fix this issue.
>>
>>
>> --- src/gdb/c-exp.y ? ? 2011-05-06 19:42:17.000000000 +0530
>> +++ dst/gdb/c-exp.y ? ? 2011-09-04 13:57:16.082207664 +0530
>> @@ -19,7 +19,7 @@
>> ? ?along with this program. ?If not, see <http://www.gnu.org/licenses/>. ?*/
>>
>> ?/* Parse a C expression from text in a string,
>> - ? and return the result as a ?struct expression ?pointer.
>> + ? and return the result as a ?struct expression pointer.
>> ? ?That structure contains arithmetic operations in reverse polish,
>> ? ?with constants represented by operations that are followed by special data.
>> ? ?See expression.h for the details of the format.
>> @@ -926,12 +926,12 @@ const_or_volatile_or_space_identifier:
>>
>> ?abs_decl: ? ? ?'*'
>> ? ? ? ? ? ? ? ? ? ? ? ?{ push_type (tp_pointer); $$ = 0; }
>> - ? ? ? | ? ? ? '*' abs_decl
>> - ? ? ? ? ? ? ? ? ? ? ? { push_type (tp_pointer); $$ = $2; }
>> + ? ? ? | ? ? ? abs_decl '*'
>> + ? ? ? ? ? ? ? ? ? ? ? { push_type (tp_pointer); $$ = $1; }
>> ? ? ? ?| ? ? ? '&'
>> ? ? ? ? ? ? ? ? ? ? ? ?{ push_type (tp_reference); $$ = 0; }
>> - ? ? ? | ? ? ? '&' abs_decl
>> - ? ? ? ? ? ? ? ? ? ? ? { push_type (tp_reference); $$ = $2; }
>> + ? ? ? | ? ? ? abs_decl '&'
>> + ? ? ? ? ? ? ? ? ? ? ? { push_type (tp_reference); $$ = $1; }
>> ? ? ? ?| ? ? ? direct_abs_decl
>> ? ? ? ?;
>>
>> Thanks,
>> Abhijit Halder
>>
>
> A regression happens with the above fix.
> The above fix is not working for the following:
> (gdb)ptype int (*(*(*)(char))(short int))(long int
                          ^^^
>
> The following is working fine.
>
> --- src/gdb/c-exp.y ? ? 2011-05-06 19:42:17.000000000 +0530
> +++ dst/gdb/c-exp.y ? ? 2011-09-04 15:57:51.212167205 +0530
> @@ -926,6 +926,8 @@ const_or_volatile_or_space_identifier:
>
> ?abs_decl: ? ? ?'*'
> ? ? ? ? ? ? ? ? ? ? ? ?{ push_type (tp_pointer); $$ = 0; }
> + ? ? ? | ? ? ? abs_decl '*'
> + ? ? ? ? ? ? ? ? ? ? ? { push_type (tp_pointer); $$ = $1; }
> ? ? ? ?| ? ? ? '*' abs_decl
> ? ? ? ? ? ? ? ? ? ? ? ?{ push_type (tp_pointer); $$ = $2; }
> ? ? ? ?| ? ? ? '&'
>
>
>
> Thanks,
> Abhijit Halder
>


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