[PATCH] [libc++] Fix GCC unknown pragma warning.

Logan Chien tzuhsiang.chien at gmail.com
Wed Dec 11 09:14:57 PST 2013


We should check defined(__clang__) before the usage of the
clang diagnostic pragmas.

The [-Wswitch] warning in src/future.cpp should be ignored.
As the result, the equivalent GCC pragma is added.

http://llvm-reviews.chandlerc.com/D2385

Files:
  src/future.cpp
  src/regex.cpp

Index: src/future.cpp
===================================================================
--- src/future.cpp
+++ src/future.cpp
@@ -26,8 +26,13 @@
     return "future";
 }
 
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wswitch"
+#elif defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+#endif
 
 string
 __future_error_category::message(int ev) const
@@ -50,7 +55,11 @@
     return string("unspecified future_errc value\n");
 }
 
+#if defined(__clang__)
 #pragma clang diagnostic pop
+#elif defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic pop
+#endif
 
 const error_category&
 future_category() _NOEXCEPT
Index: src/regex.cpp
===================================================================
--- src/regex.cpp
+++ src/regex.cpp
@@ -69,16 +69,20 @@
 
 namespace {
 
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpadded"
+#endif
 
 struct collationnames
 {
     const char* elem_;
     char char_;
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic pop
+#endif
 
 const collationnames collatenames[] =
 {
@@ -195,16 +199,20 @@
     {"zero", 0x30}
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpadded"
+#endif
 
 struct classnames
 {
     const char* elem_;
     ctype_base::mask mask_;
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic pop
+#endif
 
 const classnames ClassNames[] =
 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2385.1.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131211/aa5d816c/attachment.bin>


More information about the cfe-commits mailing list