Commit 45148 fixes the bug below.

Thanks for the report (Oliver),

snaroff

On Dec 15, 2007, at 11:30 AM, Steve Naroff wrote:

I have a look later today...

Glad to hear you are feeling better!

snaroff

On Dec 15, 2007, at 9:38 AM, Chris Lattner wrote:


On Dec 14, 2007, at 11:57 PM, Oliver Hunt wrote:

So i'm looking at this failure:
typedef struct { char name[100]; } entry;
char f1(entry *e) { return *e->name; }


The problem appears to be CodeGenFunction::EmitScalarExpr being called on e->name as it believes
e->name is an array type rather than a scalar, so we assert.

I'm not sure what the appropriate correction should be -- should i fix
CodeGenFunction::EmitLoadOfLValue
So that it can handle an array type -- emitting an array type as an lvalue should just be to emit a getElementPtr(array, 0)

Or alternatively have a step during merge to convert *array to array[0]

Hi Oliver,

Sorry for the delay, I've been majorly sick since thursday night. I don't think this is a codegen bug, I think it's a sema bug:

$ clang t3.c -ast-dump
typedef char *__builtin_va_list;
typedef struct <anonymous> entry;

char f1(entry *e)
(CompoundStmt 0x8061e0 <t3.c:2:19, col:38>
  (ReturnStmt 0x8061d0 <col:21, col:32>
    (UnaryOperator 0x8061b0 <col:28, col:32> 'char' prefix '*'
(MemberExpr 0x806180 <col:29, col:32> 'char [100]' ->name 0x805f00 (DeclRefExpr 0x806160 <col:29> 'entry *' ParmVar='e' 0x806120)))))

Sema is properly inferring that the * has type char, but it isn't inserting an implicit cast. I'd expect to see something like this:

clang t3.c -ast-dump
typedef char *__builtin_va_list;
typedef struct <anonymous> entry;

char f1(entry *e)
(CompoundStmt 0x8061e0 <t3.c:2:19, col:38>
  (ReturnStmt 0x8061d0 <col:21, col:32>
    (UnaryOperator 0x8061b0 <col:28, col:32> 'char' prefix '*'
      (ImplicitCast char*
(MemberExpr 0x806180 <col:29, col:32> 'char [100]' ->name 0x805f00 (DeclRefExpr 0x806160 <col:29> 'entry *' ParmVar='e' 0x806120))))))

Maybe Steve can take a look if he has a chance,

-Chris
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to