[libcxx] r197314 - Fix GCC unknown pragma warning in libc++.

Logan Chien tzuhsiang.chien at gmail.com
Fri Dec 13 22:45:09 PST 2013


Author: logan
Date: Sat Dec 14 00:45:09 2013
New Revision: 197314

URL: http://llvm.org/viewvc/llvm-project?rev=197314&view=rev
Log:
Fix GCC unknown pragma warning in libc++.

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.


Modified:
    libcxx/trunk/src/future.cpp
    libcxx/trunk/src/regex.cpp

Modified: libcxx/trunk/src/future.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/future.cpp?rev=197314&r1=197313&r2=197314&view=diff
==============================================================================
--- libcxx/trunk/src/future.cpp (original)
+++ libcxx/trunk/src/future.cpp Sat Dec 14 00:45:09 2013
@@ -26,8 +26,13 @@ __future_error_category::name() const _N
     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 @@ __future_error_category::message(int ev)
     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

Modified: libcxx/trunk/src/regex.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/regex.cpp?rev=197314&r1=197313&r2=197314&view=diff
==============================================================================
--- libcxx/trunk/src/regex.cpp (original)
+++ libcxx/trunk/src/regex.cpp Sat Dec 14 00:45:09 2013
@@ -69,8 +69,10 @@ regex_error::~regex_error() throw() {}
 
 namespace {
 
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpadded"
+#endif
 
 struct collationnames
 {
@@ -78,7 +80,9 @@ struct collationnames
     char char_;
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic pop
+#endif
 
 const collationnames collatenames[] =
 {
@@ -195,8 +199,10 @@ const collationnames collatenames[] =
     {"zero", 0x30}
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wpadded"
+#endif
 
 struct classnames
 {
@@ -204,7 +210,9 @@ struct classnames
     ctype_base::mask mask_;
 };
 
+#if defined(__clang__)
 #pragma clang diagnostic pop
+#endif
 
 const classnames ClassNames[] =
 {





More information about the cfe-commits mailing list