Comments (6)
clang-upc2c should produce the code that would not cause a warning.
On 3/7/14, 5:19 PM, Paul H. Hargrove wrote:
I've just tried for the first time using the clang built with clang-upc2c as the backend compiler. There are /many/
new "expect pass but got warning" failures in a harness run, and more investigation of those is needed (most are
probably due to the tests themselves). HOWEVER, one at least is the result of the translator.Given
| upc_forall(int i=0; i<N; i++; i)
if (A[i] != MYTHREAD) errflag=1;
|the .trans.c contains the following translation of the |upc_forall|:
| if (upcrt_forall_control)
for (int i = 0; i < N; i++)
if ((upcr_get_pshared(&_bupc_spilld0, upcr_add_pshared1(A, 4U, i), 0U, 4U) , _bupc_spilld0) != (int)upcr_mythread())
errflag = 1;
else {
upcrt_forall_control = 1;
for (int i = 0; i < N; i++)
if ((i) % upcr_threads() == upcr_mythread())
if ((upcr_get_pshared(&_bupc_spilld0, upcr_add_pshared1(A, 4U, i), 0U, 4U) , _bupc_spilld0) != (int)upcr_mythread())
errflag = 1;
upcrt_forall_control = 0;
}
|That is /entirely/ valid C code, but notice that the line immediately before the translator-supplied instance of
|else| in that code is the |if| from the user's code. This results in the /backend/ clang warning:|foo.trans.c:18:9: warning: add explicit braces to avoid dangling else [-Wdangling-else]
else {
^
1 warning generated.
|If necessary, I am OK with passing |Wno-dangling-else| to clang as a backend if that is necessary. However, I wanted
to first report the issue here to see if it is reasonable to instead ask/expect/require that clang-upc2c generate
output that clang itself is willing to accept as input. Thoughts?—
Reply to this email directly or view it on GitHub #44.
from clang-upc.
On 03/07/2014 05:19 PM, Paul H. Hargrove wrote:
That is entirely valid C code, but notice that the line immediately before the translator-supplied instance of
else
in that code is theif
from the user's code. This results in the backend clang warning:
Just because it's valid doesn't mean that it does what you want.
In this case, the warning is correct. The translation needs
to add braces.
from clang-upc.
In this case, the warning is correct.
Ah, right. So the .trans.c code is actually wrong!
The translation needs to add braces.
Is this likely to be a matter of the translation or a problem with StmtPrinter thinking it can omit the braces when the body was a single statement?
from clang-upc.
On 03/07/2014 06:14 PM, Paul H. Hargrove wrote:
The translation needs to add braces.
Is this likely to be a matter of the translation or a problem with StmtPrinter thinking it can omit the braces when the body was a single statement?
It's a problem with the translation. StmtPrinter never
adds braces. The CompoundStmt needs to be represented
in the AST.
from clang-upc.
It's a problem with the translation. StmtPrinter never adds braces.
Well, then I guess I reported the issue against the wrong repo. ;)
from clang-upc.
Fixed in clangupc/upc2c@93b2422
from clang-upc.
Related Issues (20)
- Gasnet testslice fails after 4.0.1 update
- [CG]UPC should not place upc_*.h headers in the include path for UPCR mode
- Build failures with recent clang HOT 2
- apple m1 cargo build failed: LLVM ERROR: Global variable '_ZN12node_runtime1_16SECTION_CONTENTS17h28c19e8d9889aa72E' has an invalid section specifier 'runtime_version': mach-o section specifier requires a segment and section separated by a comma.
- Build errors with gcc 10 HOT 2
- warning on void * - discrad qualifiers HOT 1
- 3.8.0 - build failure on x86_64 HOT 2
- 3.8 - Intrepid's test04 fails to compile with 'struct' configuration HOT 4
- "ld: cannot find -lupc" on OpenBSD HOT 3
- 3.8 update: no link script build fails HOT 1
- 3.8 update: Linking on Mac OS X fails
- 3.8 merge: "ld: cannot find -lupc" on OpenBSD/i386 HOT 1
- 3.8 merge: "ld: cannot find -lupc" on Solaris HOT 1
- Clang-upc ICE on user's example code HOT 3
- MIPS "n32" ABI support HOT 1
- MIPS64 barrier failures HOT 7
- Crash in UPCR's TLD initialization when compiled with clang HOT 5
- 3.9.1 merge - Shared static initialization does not work with optimizations HOT 2
- ppc64 LE - bug3198 gets assertion error in Struct-Debug branch HOT 1
- freebsd 386 - test_int_precision tests fail HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clang-upc.