1# "#pragma deprecated" and "#pragma intrinsic" not (yet?) handled in the "if
2# (LangOpts.MicrosoftExt)" block in Preprocessor::RegisterBuiltinPragmas in
3# Clang's lib/Lex/Pragma.cpp:
4--- nspr/pr/include/pratom.h
5+++ nspr/pr/include/pratom.h
6@@ -83,7 +83,7 @@
7
8 #include <intrin.h>
9
10-#ifdef _MSC_VER
11+#if defined _WIN32 && !defined __clang__
12 #pragma intrinsic(_InterlockedIncrement)
13 #pragma intrinsic(_InterlockedDecrement)
14 #pragma intrinsic(_InterlockedExchange)
15--- nspr/pr/include/prbit.h
16+++ nspr/pr/include/prbit.h
17@@ -14,7 +14,7 @@
18 */
19 #if defined(_WIN32) && (_MSC_VER >= 1300) && \
20     (defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || \
21-     defined(_M_ARM64))
22+     defined(_M_ARM64)) && !defined __clang__
23 # include <intrin.h>
24 # pragma  intrinsic(_BitScanForward,_BitScanReverse)
25 __forceinline static int __prBitScanForward32(unsigned int val)
26@@ -32,7 +32,7 @@
27 # define pr_bitscan_ctz32(val)  __prBitScanForward32(val)
28 # define pr_bitscan_clz32(val)  __prBitScanReverse32(val)
29 # define  PR_HAVE_BUILTIN_BITSCAN32
30-#elif ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
31+#elif defined __GNUC__ && ((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && \
32        (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
33         defined(__aarch64__))
34 # define pr_bitscan_ctz32(val)  __builtin_ctz(val)
35@@ -136,7 +136,7 @@
36 */
37
38 #if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \
39-    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64))
40+    defined(_M_X64) || defined(_M_ARM) || defined(_M_ARM64)) && !defined __clang__
41 #include <stdlib.h>
42 #pragma intrinsic(_rotl, _rotr)
43 #define PR_ROTATE_LEFT32(a, bits) _rotl(a, bits)
44--- nss/lib/certdb/certdb.h
45+++ nss/lib/certdb/certdb.h
46@@ -21,7 +21,7 @@
47 /* On Windows, Mac, and Linux (and other gcc platforms), we can give compile
48  * time deprecation warnings when applications use the old CERTDB_VALID_PEER
49  * define */
50-#if __GNUC__ > 3
51+#if defined __GNUC__ && __GNUC__ > 3
52 #if (__GNUC__ == 4) && (__GNUC_MINOR__ < 5)
53 typedef unsigned int __CERTDB_VALID_PEER __attribute__((deprecated));
54 #else
55@@ -30,7 +30,7 @@
56 #endif
57 #define CERTDB_VALID_PEER ((__CERTDB_VALID_PEER)CERTDB_TERMINAL_RECORD)
58 #else
59-#ifdef _WIN32
60+#if defined _WIN32 && !defined __clang__
61 #pragma deprecated(CERTDB_VALID_PEER)
62 #endif
63 #define CERTDB_VALID_PEER CERTDB_TERMINAL_RECORD
64--- nss/lib/util/pkcs11n.h
65+++ nss/lib/util/pkcs11n.h
66@@ -426,7 +426,7 @@
67 /* keep the old value for compatibility reasons*/
68 #define CKT_NSS_MUST_VERIFY ((__CKT_NSS_MUST_VERIFY)(CKT_NSS + 4))
69 #else
70-#ifdef _WIN32
71+#if defined _WIN32 && !defined __clang__
72 /* This magic gets the windows compiler to give us a deprecation
73  * warning */
74 #pragma deprecated(CKT_NSS_UNTRUSTED, CKT_NSS_MUST_VERIFY, CKT_NSS_VALID)
75
76# While MSVC uses
77#  #pragma warning(disable : 4103)
78# in the inner pkcs11p.h, clang-cl wants
79#  #pragma clang diagnostic ignored "-Wpragma-pack"
80# in the outer pkcs11t.h:
81--- nss/lib/util/pkcs11t.h
82+++ nss/lib/util/pkcs11t.h
83@@ -72,7 +72,14 @@
84 #define CK_INVALID_HANDLE 0
85
86 /* pack */
87+#if defined __clang__ && defined _MSC_VER
88+#pragma clang diagnostic push
89+#pragma clang diagnostic ignored "-Wpragma-pack"
90+#endif
91 #include "pkcs11p.h"
92+#if defined __clang__ && defined _MSC_VER
93+#pragma clang diagnostic pop
94+#endif
95
96 typedef struct CK_VERSION {
97     CK_BYTE major; /* integer portion of version number */
98@@ -1795,6 +1802,13 @@
99 #include "pkcs11n.h"
100
101 /* undo packing */
102+#if defined __clang__ && defined _MSC_VER
103+#pragma clang diagnostic push
104+#pragma clang diagnostic ignored "-Wpragma-pack"
105+#endif
106 #include "pkcs11u.h"
107+#if defined __clang__ && defined _MSC_VER
108+#pragma clang diagnostic pop
109+#endif
110
111 #endif
112