Skip to content

Should @diagnostic be allowed in the middle of lines? #4595

Closed

Description

@mwyrzykowski

Hi, there was recently a report that https://philogb.github.io/page/indraspearls/ did not work in Safari, which was quickly root-caused to this line:

for (var i = 0; i < 250; i++) @diagnostic(off,derivative_uniformity) {

I can't see anything in the WGSL specification disallowing this, but should it be allowed to have @diagnostic statements in the middle of the line?

I'm not so familiar with how other languages handle this, but, pragma warning for instance in Clang is not allowed in the middle of a line.

    std::cout << 
        #pragma clang diagnostic ignored "-Werror" 
        "Hello, world!\n";

compiles whereas

    std::cout <<  #pragma clang diagnostic ignored "-Werror"  "Hello, world!\n";

does not.

Is it actually desirable to support this or should it be excluded from the specification?

Activity

  1. added
    wgsl
    on Apr 23, 2024
  2. ben-clayton commented on Apr 23, 2024

    @ben-clayton
    Contributor

    The placement of this diagnostic is explicitly called out at: https://www.w3.org/TR/WGSL/#diagnostic-filtering

    See:

    Immediately before the opening brace ('{') of the loop body of a loop, while, or for loop.

  3. jimblandy commented on Apr 30, 2024

    @jimblandy
    Contributor

    The grammar says the WGSL directive is allowed at that point, which seems like the right call to me. I don't think the analogy with C++ #pragma is very strong.

  4. mwyrzykowski commented on Apr 30, 2024

    @mwyrzykowski
    Author

    Sounds good to me, thanks for pointing out the places where this is allowed @ben-clayton - sorry I missed that grepping the specification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgsl

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions