[llvm-bugs] [Bug 40673] New: VS C++ errors for compiler.h

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 9 06:18:19 PST 2019


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

            Bug ID: 40673
           Summary: VS C++ errors for compiler.h
           Product: libraries
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: hans.petter.dahle at hpdahle.com
                CC: llvm-bugs at lists.llvm.org

When including the header file '\llvm\Support\Compiler.h',
Visual Studio's C++ compiler (used from Visual Studio Community 2017) complains
that there are 3 errors in this header file, on lines 127, 230, and 236.

The error message is:
E2512   the argument to a feature-test macro must be a simple identifier

The cause of these error messages is the use of "::" in the argument to
'__has_cpp_attribute'.

My proposal is to wrap each erroneous line and the line following it in a test
to check whether '_MSC_VER' is defined or not. 

E.g. lines 127 and 128 which are 

#elif __has_cpp_attribute(clang::warn_unused_result)
#define LLVM_NODISCARD [[clang::warn_unused_result]]

should be changed to    

#elif !defined(_MSC_VER) 
#if __has_cpp_attribute(clang::warn_unused_result)
#define LLVM_NODISCARD [[clang::warn_unused_result]]
#endif

This change fixes the error for me.

-- 
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/20190209/df93b006/attachment.html>


More information about the llvm-bugs mailing list