[cfe-dev] core dump, how to best investigate

Chris Lattner clattner at apple.com
Tue Jul 24 10:01:47 PDT 2007


> typedef unsigned __uint32_t;
>
> #define __byte_swap_int_var(x) \
> __extension__ ({ register __uint32_t __X = (x); \
>     __asm ("bswap %0" : "+r" (__X)); \
>     __X; })
>
> int test(int _x) {
>     return (__byte_swap_int_var(_x));
> }
>
> In any case, I'll add the AST node and get the example working.   
> Thanks!

Here ya go:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of- 
Mon-20070723/001371.html

This implements ast building and semantic analysis, but not codegen  
support.  On the example above, you get:

$ clang test/Sema/stmt_exprs.c -parse-ast-print
typedef unsigned int __uint32_t;
test/Sema/stmt_exprs.c:11:10: warning: expression result unused
return (__byte_swap_int_var(_x));
         ^~~~~~~~~~~~~~~~~~~

int test(int _x) {
   return (__extension__({
     register __uint32_t __X = (_x);
     __X;
   }));
}

1 diagnostic generated.


There are two issues here:
   1. We don't currently build an AST node for GNU inline asm stmts,  
so the dump above doesn't include it.
   2. We emit an 'expression result unused' warning for the "__X;"  
statement at the end of the compound stmt, even though it is used by  
the stmt expr.

If you'd be interested in helping out with either of these, go for it :)

-Chris



More information about the cfe-dev mailing list