Steve Naroff | 1 Dec 2007 01:04
Picon
Favicon

Re: regression with function pointers


On Nov 30, 2007, at 3:17 PM, Nuno Lopes wrote:

> Hi,
>
> There was some kind of regression in function pointers handling.  
> Attached is a file that triggers an assert failure (when run with  
> e.g. -ast-dump):
>
> clang: /cvs/llvm/include/llvm/Support/Casting.h:199: typename  
> llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =  
> clang::FunctionTypeProto, Y = clang::Type*]: Assertion `isa<X>(Val)  
> && "cast<Ty>() argument of incompatible type!"' failed.
> (...)
> /lib/libc.so.6(__assert_fail+0xf5)[0xb7d287a5]
> ../../Debug/bin/clang(llvm::cast_retty<clang::FunctionTypeProto,  
> clang::Type*>::ret_type llvm::cast<clang::FunctionTypeProto,  
> clang::Type*>(clang::Type* const&)+0x4b)[0x831125d]
> ../../Debug/bin/clang(clang::FunctionDecl::getNumParams() const+0x3a) 
> [0x831f92a]
> ../../Debug/bin/clang((anonymous  
> namespace)::DeclPrinter::PrintFunctionDeclStart(clang::FunctionDecl*) 
> +0x169)[0x826cd33]
> ../../Debug/bin/clang((anonymous  
> namespace)::ASTDumper::HandleTopLevelDecl(clang::Decl*)+0x30) 
> [0x826fc80]
> ../../Debug/bin/clang(clang::ParseAST(clang::Preprocessor&, unsigned  
> int, clang::ASTConsumer*, bool)+0x107)[0x82dc1c7]
>
>
(Continue reading)

Chris Lattner | 1 Dec 2007 06:27
Picon
Favicon

Re: Yet another random failure :(

On Nov 30, 2007, at 11:27 AM, Oliver Hunt wrote:

> Having got passed that last failure, here's the next:
> clang --emit-llvm
>
> void f(){
>     switch(0){
>     default:
>         if (0) {
>
>         }
>     }
> }

Fixed, thanks!

-Chris
Chris Lattner | 1 Dec 2007 06:40
Picon
Favicon

initializer bug

Hi Steve,

Can you please investigate this code when you get a chance?

typedef struct { double x,y,z; } VECTOR;
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };

t.c:2:26: error: incompatible types assigning 'double' to 'VECTOR'
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                          ^~~
t.c:2:26: warning: excess elements in array initializer
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                          ^~~
t.c:2:31: error: incompatible types assigning 'double' to 'VECTOR'
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                               ^~~
t.c:2:31: warning: excess elements in array initializer
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                               ^~~
t.c:2:36: error: incompatible types assigning 'double' to 'VECTOR'
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                                    ^~~
t.c:2:36: warning: excess elements in array initializer
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                                    ^~~
t.c:2:45: error: incompatible types assigning 'double' to 'VECTOR'
VECTOR Skycolor[2] = { { 0.5, 0.3, 0.7 }, { 0.0, 0.0, 0.2 } };
                                             ^~~
...

(Continue reading)

Cédric Venet | 1 Dec 2007 13:11
Picon
Picon

Small Patch and VS2005 enum pb

Hi,

A small patch for adding:
- a missing include <string> in a header
- a missing file ASTConsumer.cpp in clangAST projet for VS

This allow to compile on VS2005 but there is still the old problem that enum
are signed by default on VS2005. This cause clang to assert on code like

Struct A { int I; }; struct A a;

More specifically, the problem is in DeclSpec.h at the line 64 and 111 and
174:

=========

  enum TST {
    TST_unspecified,
    TST_void,
[... 14 other enumerated type ...]
  };

TST TypeSpecType : 4;

TST getTypeSpecType() const { return TypeSpecType; }

=========

And VS2005 as the good idea to return -4 instead of 12 for struct type (same
problem for all the type >=8).
(Continue reading)

Cédric Venet | 1 Dec 2007 19:02
Picon
Picon

C++ typedef merging

Hi,

Small patch for the merging of typedef as defined in C++ std. So this become
valid in c++ mode:

===============
typedef int I;
typedef int J;
typedef J L;
typedef int I;
typedef L I;
typedef I I;
===============

However this code should produce an error (and don't):

===============
struct complex { /* ... */ };
typedef int complex; // error: redefinition
===============

but since at the time, tag name are in a different identifier namespace as
typedef even in C++, the function of merging is note called.

I don't have the C standard and didn't find the equivalent of

  /// IdentifierNamespace - According to C99 6.2.3, there are four
namespaces,
  /// labels, tags, members and ordinary identifiers.

(Continue reading)

Chris Lattner | 1 Dec 2007 20:01
Picon
Favicon

Re: Small Patch and VS2005 enum pb

On Dec 1, 2007, at 4:11 AM, Cédric Venet wrote:
> A small patch for adding:
> - a missing include <string> in a header

Applied!

> - a missing file ASTConsumer.cpp in clangAST projet for VS

This part conflicted when I applied it.  Please ensure it is relative  
to an updated tree.

> More specifically, the problem is in DeclSpec.h at the line 64 and  
> 111 and
> 174:

Ok.

>
> TST TypeSpecType : 4;
>
> TST getTypeSpecType() const { return TypeSpecType; }
>
> =========
>
> And VS2005 as the good idea to return -4 instead of 12 for struct  
> type (same
> problem for all the type >=8).

I think the best way to solve this is to change the definition of  
TypeSpecType to:
(Continue reading)

Cédric Venet | 1 Dec 2007 22:15
Picon
Picon

Re: Small Patch and VS2005 enum pb

> 
> > - a missing file ASTConsumer.cpp in clangAST projet for VS
> 
> This part conflicted when I applied it.  Please ensure it is relative
> to an updated tree.

Strange, my tree was up to date (I just updated and there was no change on
this file).
It was perhaps caused by the version number which changed from 8.0 to 8,0
following my system local... I removed this modification from this patch, it
will perhaps work now...

> 
> > More specifically, the problem is in DeclSpec.h at the line 64 and
> 
> Ok.

In fact, all the enum of the class are affected, so I patched them all (hope
there isn't more hiding somewhere)

> 
> I think the best way to solve this is to change the definition of
> TypeSpecType to:
> 
> unsigned TypeSpecType : 4;  // really should be TST, marking this
> 'unsigned' for MSVC++

I put /*TST*/unsigned TypeSpecType : 4;

Forgot the commentary, sorry, can redo if needed
(Continue reading)

Chris Lattner | 2 Dec 2007 01:47
Picon
Favicon

Re: Small Patch and VS2005 enum pb


On Dec 1, 2007, at 1:15 PM, Cédric Venet wrote:

>>
>>> - a missing file ASTConsumer.cpp in clangAST projet for VS
>>
>> This part conflicted when I applied it.  Please ensure it is relative
>> to an updated tree.
>
> Strange, my tree was up to date (I just updated and there was no  
> change on
> this file).
> It was perhaps caused by the version number which changed from 8.0  
> to 8,0
> following my system local... I removed this modification from this  
> patch, it
> will perhaps work now...

Your new patch still doesn't apply.  It may be a newline issue  
(windows vs unix).  If you just send me the whole new file, I can  
commit it.

>>> More specifically, the problem is in DeclSpec.h at the line 64 and
>>
>> Ok.
>
> In fact, all the enum of the class are affected, so I patched them  
> all (hope
> there isn't more hiding somewhere)

(Continue reading)

Oliver Hunt | 2 Dec 2007 03:49
Picon
Favicon

Problem with generation of function names if prototype has already been used.

A relatively simple piece of code:
// RUN: clang -emit-llvm %s
int g(int);

int foo(int i) {
	return g(i);
}

int g(int i) {
	return i;
}

Is compiled incorrectly to:
; ModuleID = 'foo'
target triple = "i686-apple-darwin9"

define i32  <at> foo(i32 %i) {
entry:
...
	%call = call i32  <at> g( i32 %tmp )		; <i32> [#uses=1]
	ret i32 %call
}

declare i32  <at> g(i32)

define i32  <at> g1(i32 %i) {
entry:
...
}

(Continue reading)

Chris Lattner | 2 Dec 2007 07:33
Picon
Favicon

regression test failures

These two tests are failing:

******************** TEST 'Sema/array-constraint.c' FAILED!  
********************
******************** TEST 'Sema/array-init.c' FAILED!  
********************

-Chris

Gmane