[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Struct variable named as struct is not indexed correctly.

From: Shigio YAMAGUCHI
Subject: Re: Struct variable named as struct is not indexed correctly.
Date: Sun, 13 Mar 2016 09:55:27 +0900

This is the present specification. The difference between
'foo' and 'foobar' is whether it has definitions or not.

At first, current C parser assumes varables as a reference.

[Source code] [Judgment]
struct foo(1) (1) definition
    int n(2); (2) reference

struct foo(3) foo(4); (3) reference, (4) reference
struct foo(5) foobar(6); (5) reference, (6) reference

If a symbol has definitions and references,
it is treated as definitions and references.

$ global -x foo -d
foo                 1 test.h           struct foo
$ global -x foo -r
foo                 5 test.h           struct foo foo;
foo                 6 test.h           struct foo foobar;

If a symbol has only references, it is treated as 'other symbols'.

$ global -x foobar -s
foobar              6 test.h           struct foo foobar;

[Treatment of variable definitions]
n(2), foo(4) and foobar(6) should be treated as a definition
originally. But in the current C parser, a variable definition
is treated as a reference.

Reason 1:
In source code reading, definition of function, macro, typedef,
struct, class, enum are important. On the other hand, variable
definition is not so important, because there isn't information
so much.

Reason 2:
It was difficult for me to recognize a variable definition.

I request someone to write a new parser on a different way of


2016-03-13 2:13 GMT+09:00 Jacek Migacz <address@hidden>:
I've observed undesired behavior with variable named exactly as it's type (w/o struct keyword).

For given source:

struct foo
    int n;

struct foo foo;
struct foo foobar;

global -s foo
^ returns nothing

global -s foobar
^ returns correct location

I'm using global-6.5.1(1.fc23).

Jacek Migacz

Bug-global mailing list

Shigio YAMAGUCHI <address@hidden>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3

reply via email to

[Prev in Thread] Current Thread [Next in Thread]