Re: dependency tee from c parser entities downto token

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

 




No, that would be a no go. I don't mind allow dependence program
have the option to keep the token around. However, for other C back
ends, the token serve no purpose. It just sit there waste memory. So
I don't want the token become mandatory.


Ok, one more try:
  Your question is: Why is is meaningful to
  have tokens saved even in the parse stage.
I tried to come up with some meaningful example.

Take the 2 files b.c and a.h.

vvvvvv b.c vvvvv
#define d1
#include "a.h"
struct s0 { int x; };
int main(int a, char **b) {
  struct s0 v;
  d2(m);
};
^^^^^^ b.c ^^^^^^

vvvvvv a.h vvvvv
#ifdef d2
#define m v
#else
#define m n
#endif

#ifdef d1
#define d2(a) while(a.x) { }
#endif
^^^^^^ a.h ^^^^^^

Now use sparse and you get:
$./sparse b.c
b.c:6:3: error: cannot dereference this type

The error was that you forgot in b.c:
+#define d2
 #define d1
 ...

When you have a dependency tree what you can printout is:

$./sparse b.c
b.c:6:3: error: cannot dereference this type
 +macro expansion of d2 defined in a.h:8
   + defined because of #ifdef d1 in a.h:7
    + dependent of d1 defined at b.c:1
 +> argument 0 expansion at b.c:6
   + macro expansion m defined in a.h:4
     + defined because of else of #ifdef d2
       + dependend of d2 (not defined)

Or you can print it out human readable:

$./sparse b.c
b.c:6:3: error: cannot dereference this type
#define d1
#include "a.h"
 #ifdef d2
 #else
 #define m n
 #endif
 #ifdef d1
 #define d2(a) while(a.x) { }
 #endif

I've improviced a bit, the "human readable" ouput
is the whole of a.h and b.c because there is
no nondependent part to strip...

Now tell me that this is not useful and this is the
last post on this subject. Dont you think that gcc's
...
 In file included from ./b.c:3:0:
 In file included from ./x.c13:0:
...
is useful? With macro dependency saved you can
printout all.

-- Konrad




--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux