[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    [cfe-dev] core dump, how to best investigate
From:       clattner () apple ! com (Chris Lattner)
Date:       2007-07-24 17:01:47
Message-ID: 8F1BA52B-E6DB-4B07-B3D4-0826F3448E7A () apple ! com
[Download RAW message or body]

> 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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic