[llvm-bugs] [Bug 38111] New: function attribute "diagnose_if" doesn't show error if the argument uses statements and declarations in expressions

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 9 14:25:14 PDT 2018


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

            Bug ID: 38111
           Summary: function attribute "diagnose_if" doesn't show error if
                    the argument uses statements and declarations in
                    expressions
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: naruse at airemix.jp
                CC: llvm-bugs at lists.llvm.org

If the target function of "diagnose_if" attribute receives an argument which
uses GCC extension, statements and declarations in expressions, clang doesn't
show error.
If there're only statements, it works.
But if there're also declarations, it doesn't show any errors.

```
%  cat b.c
int scan_args(char *fmt)
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
    return 0;
}


int
main(int argc, char **argv) {
    return scan_args(__extension__({"20";}));
}
%  clang b.c
b.c:10:44: error: invalid format string
    return scan_args(__extension__({"20";}));
                                           ^
b.c:2:20: note: from 'diagnose_if' attribute on 'scan_args':
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
                   ^           ~~~~~~~~~
1 error generated.
```

```
%  cat b.c
int scan_args(char *fmt)
    __attribute__((diagnose_if(fmt[0]!=2,"invalid format string","error")))
{
    return 0;
}


int
main(int argc, char **argv) {
    return scan_args(__extension__({char *s="20";s;}));
}
%  clang b.c
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180709/9f8a57b0/attachment.html>


More information about the llvm-bugs mailing list