[cfe-dev] [Patch] Fix out of line constructor definition parsing.

Piotr Rak piotr.rak at gmail.com
Wed Feb 25 12:37:35 PST 2009


Hi,

I found small bug with where clang does not like:

namespace A {
  struct S {
    S();
    S(int);
    void f1();
    void f2();
    operator int ();
    ~S();
  };
}

A::S::S() {}

void A::S::f1() {}

struct S {};

A::S::S(int) {}

void A::S::f2() {}

A::S::operator int() { return 1; }

A::S::~S() {}

t2.cc:18:7: error: out-of-line definition does not match any declaration in 'S'
A::S::S(int) {}
~~~~~ ^
t2.cc:24:7: error: out-of-line definition does not match any declaration in 'S'
A::S::~S() {}
~~~~~ ^

Problem was that CXXScopeSpec was not passed to Actions.getTypeName(),
and unqualified lookup was performed instead of qualified.
Attached fix_ctor_parsing.patch solves this issue.

Also 'make test' was pretty much broken. I needed small fix for cmake
build to put generated headers in lib/clang/1.0/include instead of
Headers/ like before.
correct_headers_path.patch fixes it.

Other issue is missing float.h, limits.h
adding /usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/ search path
should fix that for my system (gentoo stable).

Last issue is that clang fails to parse my system stdio.h (form
glibc-2.6.1) namely:

typedef union
{
  struct __gconv_info __cd;
  struct
  {
    struct __gconv_info __cd;
    struct __gconv_step_data __data;
  } __combined;
} _G_iconv_t;

found in /usr/include/_G_config.h
Attached 'make report' result here, should I open PR for that?

Piotr
-------------- next part --------------
make[1]: Wej?cie do katalogu `/home/prak/projects/llvm.git/tools/clang/test'
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Analysis/ObjCRetSigs.m' FAILED! ********************
Command: 
 clang -analyze -warn-objc-methodsigs -verify /home/prak/projects/llvm.git/tools/clang/test/Analysis/ObjCRetSigs.m
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
Warnings expected but not seen:
  Line 21: types are incompatible
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Analysis/ObjCRetSigs.m' FAILED! ********************
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/rdr-6095112-alias-references-inline.c': // XFAIL
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c' FAILED! ********************
Command: 
 clang -emit-llvm /home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c -o - | grep 'declare i32 @printf' | count 1 &&
 clang -O2 -emit-llvm /home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c -o - | grep 'declare i32 @puts' | count 1 &&
 clang -ffreestanding -O2 -emit-llvm /home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c -o - | grep 'declare i32 @puts' | count 0
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c:5:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
count: expected 1 lines and got 0.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/PR3589-freestanding-libcalls.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/mandel.c' FAILED! ********************
Command: 
 clang -emit-llvm /home/prak/projects/llvm.git/tools/clang/test/CodeGen/mandel.c -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/mandel.c.out.tmp
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGen/mandel.c:30:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/mandel.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c' FAILED! ********************
Command: 
 clang -triple i386-apple-darwin9 -emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c && 
 grep define Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c.out.tmp | count 1 &&
 clang -triple i386-apple-darwin9 -g -emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c && 
 grep define Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c.out.tmp | count 1
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c:7:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/mmintrin-test.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c' FAILED! ********************
Command: 
 clang -emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c &&
 not grep __builtin Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c.out.tmp
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c:4:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/builtins.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c' FAILED! ********************
Command: 
 clang -emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c &&
 grep -e "global_ctors.*@A" Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c.out.tmp &&
 grep -e "global_dtors.*@B" Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c.out.tmp &&
 grep -e "global_ctors.*@C" Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c.out.tmp &&
 grep -e "global_dtors.*@D" Output//home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c.out.tmp
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c:7:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGen/constructor-attribute.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax-1.m' FAILED! ********************
Command: 
 clang -fnext-runtime --emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax-1.m.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax-1.m
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax-1.m:3:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax-1.m' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/property.m' FAILED! ********************
Command: 
 clang -fnext-runtime --emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/property.m.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/property.m
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/property.m:3:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/property.m' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax.m' FAILED! ********************
Command: 
 clang -fnext-runtime --emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax.m.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax.m
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax.m:3:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/dot-syntax.m' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m' FAILED! ********************
Command: 
 clang -emit-llvm -triple=i686-apple-darwin8 -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m -O2 &&
 grep 'ret i32' Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m.out.tmp | count 1 &&
 grep 'ret i32 1' Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m.out.tmp | count 1
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m:5:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/synchronized.m' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/messages-2.m' FAILED! ********************
Command: 
 clang -fnext-runtime --emit-llvm -o Output//home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/messages-2.m.out.tmp /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/messages-2.m
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/messages-2.m:3:
In file included from /usr/include/stdio.h:75:
In file included from /usr/include/libio.h:32:
/usr/include/_G_config.h:50:25: error: variable sized type '__cd' must be at end of struct or class
    struct __gconv_info __cd;
                        ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/CodeGenObjC/messages-2.m' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Lexer/digraph.c' FAILED! ********************
Command: 
 clang -fsyntax-only -verify < /home/prak/projects/llvm.git/tools/clang/test/Lexer/digraph.c
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Lexer/digraph.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Misc/diag-checker.c' FAILED! ********************
Command: 
 clang -fsyntax-only -verify /home/prak/projects/llvm.git/tools/clang/test/Misc/diag-checker.c
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Misc/diag-checker.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c' FAILED! ********************
Command: 
 clang -E /home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c
Incorrect Output:
In file included from /home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c:3:
/usr/include/limits.h:125:16: fatal error: 'limits.h' file not found
# include_next <limits.h>
               ^
# 1 "/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c"
# 1 "/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c" 1
# 1 "<predefines>" 1
# 1 "/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c" 2


# 1 "/usr/include/limits.h" 1 3 4
# 27 "/usr/include/limits.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 322 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 324 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 325 "/usr/include/sys/cdefs.h" 2 3 4
# 323 "/usr/include/features.h" 2 3 4
# 345 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4



# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 5 "/usr/include/gnu/stubs.h" 2 3 4


# 1 "/usr/include/gnu/stubs-32.h" 1 3 4
# 8 "/usr/include/gnu/stubs.h" 2 3 4
# 346 "/usr/include/features.h" 2 3 4
# 28 "/usr/include/limits.h" 2 3 4
# 145 "/usr/include/limits.h" 3 4
# 1 "/usr/include/bits/posix1_lim.h" 1 3 4
# 153 "/usr/include/bits/posix1_lim.h" 3 4
# 1 "/usr/include/bits/local_lim.h" 1 3 4
# 36 "/usr/include/bits/local_lim.h" 3 4
# 1 "/usr/include/linux/limits.h" 1 3 4
# 37 "/usr/include/bits/local_lim.h" 2 3 4
# 154 "/usr/include/bits/posix1_lim.h" 2 3 4
# 146 "/usr/include/limits.h" 2 3 4



# 1 "/usr/include/bits/posix2_lim.h" 1 3 4
# 150 "/usr/include/limits.h" 2 3 4
# 4 "/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c" 2

1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/clang_headers.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/include-directive2.c' FAILED! ********************
Command: 
 clang -Eonly /home/prak/projects/llvm.git/tools/clang/test/Preprocessor/include-directive2.c 
Incorrect Output:
/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/include-directive2.c:4:12: fatal error: 'float.h' file not found
#  include HEADER
           ^
/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/include-directive2.c:2:18: note: instantiated from:
#  define HEADER <float.h>
                 ^
1 diagnostic generated.
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Preprocessor/include-directive2.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/block-byref-args.c' FAILED! ********************
Command: 
 clang /home/prak/projects/llvm.git/tools/clang/test/Sema/block-byref-args.c -fsyntax-only -verify -fblocks
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/block-byref-args.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/block-storageclass.c' FAILED! ********************
Command: 
 clang /home/prak/projects/llvm.git/tools/clang/test/Sema/block-storageclass.c -fsyntax-only -verify -fblocks
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/block-storageclass.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/check-increment.c' FAILED! ********************
Command: 
 clang -fsyntax-only -verify /home/prak/projects/llvm.git/tools/clang/test/Sema/check-increment.c
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/check-increment.c' FAILED! ********************
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/format-strings.c' FAILED! ********************
Command: 
 clang -fsyntax-only -verify /home/prak/projects/llvm.git/tools/clang/test/Sema/format-strings.c
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/Sema/format-strings.c' FAILED! ********************
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/SemaCXX/member-name-lookup.cpp': // XFAIL
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/SemaCXX/using-directive.cpp': // XFAIL
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/SemaCXX/nested-name-spec.cpp': // XFAIL
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/SemaObjC/rdr-6211479-array-property.m': // XFAIL
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/SemaObjC/unused.m' FAILED! ********************
Command: 
 clang /home/prak/projects/llvm.git/tools/clang/test/SemaObjC/unused.m -verify -fsyntax-only
Incorrect Output:
Errors seen but not expected:
  Line 50: variable sized type '__cd' must be at end of struct or class
******************** TEST '/home/prak/projects/llvm.git/tools/clang/test/SemaObjC/unused.m' FAILED! ********************
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/SemaObjC/conditional-expr-4.m': // XFAIL
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/Serialization/complex.c': // XFAIL
XFAILED '/home/prak/projects/llvm.git/tools/clang/test/Serialization/stmt_exprs.c': // XFAIL
make[1]: Opuszczenie katalogu `/home/prak/projects/llvm.git/tools/clang/test'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_ctor_parsing.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090225/ad8175e1/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: correct_headers_path.patch
Type: text/x-patch
Size: 618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090225/ad8175e1/attachment-0001.bin>


More information about the cfe-dev mailing list