https://bugs.llvm.org/show_bug.cgi?id=45903

            Bug ID: 45903
           Summary: overrestrictive asm goto gotolabels limitations
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

First of all, I apologize if this is the wrong venue for this bug report.
The following does not compile, even though I believe it should:
---------------------------------------------------
cleanup_cb(*p1) {}

foo(int n) {
  int cond;

  if (({
        asm goto("" ::"r"(cond) : : label0);
        1;
      }))
  label0:;

  int a[n];

  if (({
        asm goto("" ::"r"(cond) : : label1);
        1;
      }))
  label1:;

}

main() {}
---------------------------------------------------
jshufro@660:~/asmgoto$ clang-10 main.c
main.c:1:13: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]
cleanup_cb(*p1) {}
            ^
main.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
cleanup_cb(*p1) {}
^
main.c:1:18: warning: non-void function does not return a value [-Wreturn-type]
cleanup_cb(*p1) {}
                 ^
main.c:3:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
foo(int n) {
^
main.c:7:9: error: cannot jump from this asm goto statement to one of its
possible targets
        asm goto("" ::"r"(cond) : : label0);
        ^
main.c:18:3: note: possible target of asm goto statement
  label1:;
  ^
main.c:12:7: note: jump bypasses initialization of variable length array
  int a[n];
      ^
main.c:22:1: warning: type specifier missing, defaults to 'int'
[-Wimplicit-int]
main() {}
^
5 warnings and 1 error generated.
---------------------------------------------------

This is C-Reduced to be fairly minimal. Replacing the variable length array
with an __attribute__((cleanup)) variable causes a similar issue. It's worth
noting that the error is noting a possible target of asm goto that isn't listed
in the GoToLabels.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to