[llvm-bugs] [Bug 37679] New: -Wc++-compat should warn on implicit conversions from int to enum

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 4 09:08:35 PDT 2018


            Bug ID: 37679
           Summary: -Wc++-compat should warn on implicit conversions from
                    int to enum
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tobias at grosser.es
                CC: llvm-bugs at lists.llvm.org

$cat /tmp/test.c 
enum ENUM {

enum ENUM foo() {
        int x;
        enum ENUM e;

        e = x; // should warn
        x = e; // no warning
        return x; // should warn

enum ENUM bar() {
        return ENUM_A; // no warning

gcc warns here when using `-Wc++-compat`.

$gcc -Wc++-compat /tmp/test.c -c
/tmp/test.c: In function ‘foo’:
/tmp/test.c:10:4: warning: enum conversion in assignment is invalid in C++
  e = x; // should warn
/tmp/test.c:12:9: warning: enum conversion in return is invalid in C++
  return x; // should warn

clang does not warn, but should.

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/20180604/62e1b823/attachment.html>

More information about the llvm-bugs mailing list