Giter Club home page Giter Club logo

Comments (9)

rjodinchr avatar rjodinchr commented on June 16, 2024

Could you provide an example showing this message please?

from clspv.

stolk avatar stolk commented on June 16, 2024

Here is an example kernel:

#define uint32_t        uint

__kernel
void foo
(
        __global uint32_t* __restrict__ a,
        __global uint32_t* __restrict__ b,
        __global uint32_t* __restrict__ c
)
{
        const uint32_t pindex = get_global_id(0);
        uint32_t aa = a[pindex] * a[pindex];
        if (aa < 1)
                aa = 1;
        uint32_t bb = b[pindex] * b[pindex];
        if (bb < 1)
                bb = 1;
        c[pindex] = aa + bb;
}

Which will give the compiler warning:

$ ~/src/clspv/build/bin/clspv foo.cl 
foo.cl:15:11: warning: mixing declarations and code is incompatible with standards before C99
   15 |         uint32_t bb = b[pindex] * b[pindex];
      |    

... which makes no sense, as OpenCL follows C99.

from clspv.

rjodinchr avatar rjodinchr commented on June 16, 2024

clspv is build to enable all warnings, which is equivalent to compiling with -Weverything.

Compiling a simple C code can produce the message even with C11:

$ clang -std=c11 test.c  -Weverything
test.c:7:9: warning: mixing declarations and code is incompatible with standards before C99 [-Wdeclaration-after-statement]
    int toto = 0;

For more information: llvm/llvm-project#53438

@alan-baker should we add no-declaration-after-statement in the warning list of clspv?

from clspv.

rjodinchr avatar rjodinchr commented on June 16, 2024

Note that the behavior is the same with gcc, expect that -Weverything does not exist, thus one need to use -Wdeclaration-after-statement to trigger the warning message (even with C11 or newer).

from clspv.

stolk avatar stolk commented on June 16, 2024

I think clspv needs to add a flag internally, because it will not accept it on its own command line:

~/src/clspv/build/bin/clspv -Wno-declaration-after-statement -o foo.spirv foo.cl 
clspv: Unknown command line argument '-Wno-declaration-after-statement'.  Try: '/home/bram/src/clspv/build/bin/clspv --help'
clspv: Did you mean '--enable-ext-tsp-block-placement'?

from clspv.

rjodinchr avatar rjodinchr commented on June 16, 2024

I don't think we want to make it configurable. Either we want to remove this warning from clspv, or we want to keep it like it is today.
Is this blocking something on your side for some reason?

from clspv.

stolk avatar stolk commented on June 16, 2024

No, it is not blocking. It is just unnecessary noise.

You can close it if you don't think it needs addressing.

from clspv.

rjodinchr avatar rjodinchr commented on June 16, 2024

I think this is worth discussing. Let's wait for @alan-baker opinion before closing it.
Thank you for reporting it.

from clspv.

alan-baker avatar alan-baker commented on June 16, 2024

I generally prefer to have as few deviations from clang as possible. If anything I'd rather expose an option that can be forwarded to clang to let the user control which warnings they want.

from clspv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.