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

            Bug ID: 16093
           Summary: -Wshadow not suppressed in Macro defined in system
                    header
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

The following program (which must be saved as clang.cpp for the self-inclusion
to work) results in a warning when compiled with clang r182233 and -Wshadow:

#ifdef IS_INCLUDE_FILE
#pragma clang system_header

#define M(a) \
    __extension__({ int v = a; v; })

#else
#define IS_INCLUDE_FILE
#include "clang.cpp"

int main()
{
    int i = M(M(1));
}
#endif


This results in:

% % ~/LLVM/build/Release+Asserts/bin/clang++ -Wshadow -v clang.cpp
clang version 3.4 (trunk 182233)
[...]
clang.cpp:13:12: warning: declaration shadows a local variable [-Wshadow]
        int i = M(M(1));
                  ^
clang.cpp:5:22: note: expanded from macro 'M'
        __extension__({ int v = a; v; })
                            ^
clang.cpp:5:26: note: expanded from macro 'M'
        __extension__({ int v = a; v; })
                                ^
clang.cpp:13:10: note: previous declaration is here
        int i = M(M(1));
                ^
clang.cpp:5:22: note: expanded from macro 'M'
        __extension__({ int v = a; v; })
                            ^
1 warning generated.


I'm filing this bug mainly because the SSE2 header file emmintrin.h provided
with clang contains (among others) the macro _mm_shufflelo_epi16 which when
nested trips this warning; the original code that caused the warning was:

  _mm_shufflelo_epi16(_mm_shufflehi_epi16(v, MASK_HI), MASK_LO)

(I'm actually not sure if the macros in emmintrin.h really need to define a
local variable to store the macro's parameter in, as the parameter is used only
once in the macro.)

-- 
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