Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLD: invalid code for anonymous union and struct types #102

Closed
PHHargrove opened this issue Jul 1, 2014 · 4 comments
Closed

TLD: invalid code for anonymous union and struct types #102

PHHargrove opened this issue Jul 1, 2014 · 4 comments

Comments

@PHHargrove
Copy link
Contributor

Translation of lockperf w/ pthreads enabled yields:

[benchmarks/lockperf] FAILED: UPC-To-C Translation or Link error        (NEW)
cd /home/phargrov/upc-runtime/BUILD-gcc64/dbg_cupc2c/upc-tests/benchmarks
/home/phargrov/upc-runtime/BUILD-gcc64/dbg_cupc2c/upcc -Ww,-Wno-duplicate-decl-specifier -Ww,-Werror=pointer-arith -g  -network=smp -pthreads -nolink-cache -I. -o lockperf lockperf.upc
upcc: Error building pthread objects with thread-local data:
/home/phargrov/upc-runtime/BUILD-gcc64/dbg_cupc2c/upc-tests/benchmarks/./bupc_collectivev.h:273:9: error: declaration of anonymous union must be a definition
typedef union <anonymous at /home/phargrov/upc-runtime/BUILD-gcc64/dbg_cupc2c/upc-tests/benchmarks/./bupc_collectivev.h:335:10> _bupc_anon_struct0;
        ^

I suspect other tests using bupc_collectivev.h will fail in the same way.

Note the <anonymous at /home/phargrov/upc-runtime/BUILD-gcc64/dbg_cupc2c/upc-tests/benchmarks/./bupc_collectivev.h:335:10> is the problem here. This might have the same root cause as issue #83, but I am not certain of that.

@PHHargrove
Copy link
Contributor Author

bug137d is a test that fails in essentially the same way for an anonymous struct

bug137d.upc:53:36: error: declaration of anonymous struct must be a definition
        for (i = 0; i < sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))) / sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))[0]); ++i) {
                                   ^
bug137d.upc:53:89: error: type name requires a specifier or qualifier
        for (i = 0; i < sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))) / sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))[0]); ++i) {
                                                                                        ^
bug137d.upc:53:122: error: declaration of anonymous struct must be a definition
        for (i = 0; i < sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))) / sizeof ((*(struct <anonymous struct at bug137d.upc:32:1> (*)[12])UPCR_TLD_ADDR(X))[0]); ++i) {

           ^

@PHHargrove PHHargrove changed the title TLD: invalid anonymous union typedef TLD: invalid code for anonymous union and struct types Jul 1, 2014
@PHHargrove
Copy link
Contributor Author

After c0767f1 the failure reported here for bug137d.upc appears to be resolved.

The test lockperf.upc still yields syntax errors in the translated C code, though the have changed since the initial report:

$ upcc -Ww,-Wno-duplicate-decl-specifier -Ww,-Werror=pointer-arith -g  -network=smp -pthreads -I. -nolines -save-all-temps lockperf.upc
upcc: Error building pthread objects with thread-local data: 
lockperf_obj.c:372:15: error: expected '{' before '<' token
lockperf_obj.c:373:1: error: unknown type name '_bupc_anon_struct0'
lockperf_obj.c: In function '_bupc_allv_reduce':
lockperf_obj.c:405:9: warning: unnamed struct/union that defines no instances [enabled by default]
lockperf_obj.c:488:147: error: '_bupc_anon_struct0' undeclared (first use in this function)
lockperf_obj.c:488:147: note: each undeclared identifier is reported only once for each function it appears in
lockperf_obj.c:488:167: error: expected expression before ')' token
lockperf_obj.c:507:167: error: expected expression before ')' token
lockperf_obj.c:526:167: error: expected expression before ')' token
lockperf_obj.c:545:168: error: expected expression before ')' token
lockperf_obj.c:570:168: error: expected expression before ')' token
lockperf_obj.c:589:168: error: expected expression before ')' token
lockperf_obj.c:608:168: error: expected expression before ')' token
lockperf_obj.c:627:168: error: expected expression before ')' token
lockperf_obj.c:652:168: error: expected expression before ')' token
lockperf_obj.c:671:168: error: expected expression before ')' token

The erroneous code on line 372:

typedef union <anonymous at /home/hargrov1/upc-runtime/BUILD-gcc-46/dbg_cupc2c/upc-tests/benchmarks/./bupc_collectivev.h:335:10> _bupc_anon_struct0;

The code on lines 402 - 405, which looks like it was maybe intended to be a (duplicate?) typedef:

        union {
            long double __dummyf1;
            unsigned long __dummyf2;
        };

The remaining errors on liens 408 through 671 are all due to the missing defn of _bupc_anon_struct0 (which was the erroneous code at line 372).

@swatanabe
Copy link
Contributor

The AST makes this a bit inconvenient. The problem is that the declaration of the anonymous union appears immediately before the variable declaration. When we process the union declaration, there isn't enough information to determine whether it needs to be moved to the global scope. I think that means that we need to determine it when processing the entire DeclStmt, and pass this down to TransformDecl somehow.

@nenadv
Copy link

nenadv commented Aug 12, 2014

After applying the latest fix for #102 I am not able to compile any test - with or without pthreads. This is the assertion error I get:

clang-upc2c: /eng/upc/dev/nenad/clang-upc-pthreads/src/llvm/tools/clang/include/clang/AST/Type.h:643: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertio
n `!isNull() && "Cannot retrieve a NULL type pointer"' failed.

I did update my branch with all the changes on the master, just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants