http://llvm.org/bugs/show_bug.cgi?id=4700

           Summary: "operation has no effect" for macros that expand to 0 <<
                    1
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


llvm/clang r78480

The following is typical for code that generates enums or error codes where the
top bits are a subsystem ID and the low bits are an individual error code:

[s...@virgon]$ cat foo.c
#define errcode(x, y) (x << 16 | y)
int a = errcode(0, 0);
int b = errcode(1, 0);
[s...@virgon]$ clang -c foo.c -Wall
foo.c:2:9: warning: operation has no effect [-Wall]
int a = errcode(0, 0);
        ^~~~~~~~~~~~~
foo.c:1:26: note: instantiated from:
#define errcode(x, y) (x << 16 | y)
                         ^  ~~
1 diagnostic generated.
[s...@virgon]$ 

This code should not warn. It's expected behavior that sometimes there will be
0 in the top bits.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to