[cfe-commits] [libcxx] r171173 - in /libcxx/trunk/src: locale.cpp thread.cpp

Howard Hinnant hhinnant at apple.com
Thu Dec 27 19:28:27 PST 2012


I guess I should have had someone test this change under gcc before I committed it.  When I tested Saleem's patch under clang I got:

../src/locale.cpp:4613:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4761:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC diagnositc pop
            ^
../src/locale.cpp:4917:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4956:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4962:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5318:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5845:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5930:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
8 warnings generated.
../src/locale.cpp:4613:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4761:13: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma GCC diagnositc pop
            ^
../src/locale.cpp:4917:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4956:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:4962:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5318:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5845:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
../src/locale.cpp:5930:24: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
#pragma GCC diagnostic pop
                       ^
8 warnings generated.

So I modified it to quiet clang and clang didn't object.  Patch to quiet gcc is welcome.

Howard


On Dec 27, 2012, at 10:10 PM, Erik Schwiebert <eriksc at microsoft.com> wrote:

> shouldn't the order of the push and the ignores be reversed?
> 
> +#pragma GCC diagnostic ignored "-Wextra"
> +#pragma GCC diagnostic push
> 
> this just pushes the new state with the ignored pragma, instead of pushing the current state and then ignoring the pragma, right?
> 
> Schwieb
> 
> On Dec 27, 2012, at 3:24 PM, Howard Hinnant <hhinnant at apple.com> wrote:
> 
>> Author: hhinnant
>> Date: Thu Dec 27 17:24:31 2012
>> New Revision: 171173
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=171173&view=rev
>> Log:
>> Saleem Abdulrasool:  cleanup a few more compile warnings emitted by GCC.
>> 
>> Modified:
>>   libcxx/trunk/src/locale.cpp
>>   libcxx/trunk/src/thread.cpp
>> 
>> Modified: libcxx/trunk/src/locale.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=171173&r1=171172&r2=171173&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/locale.cpp (original)
>> +++ libcxx/trunk/src/locale.cpp Thu Dec 27 17:24:31 2012
>> @@ -224,6 +224,11 @@
>> #endif  // _LIBCPP_NO_EXCEPTIONS
>> }
>> 
>> +// NOTE(saleem) avoid the `base class should be explicitly initialized in the
>> +// copy constructor` warning emitted by GCC
>> +#pragma GCC diagnostic ignored "-Wextra"
>> +#pragma GCC diagnostic push
>> +
>> locale::__imp::__imp(const __imp& other)
>>    : facets_(max<size_t>(N, other.facets_.size())),
>>      name_(other.name_)
>> @@ -234,6 +239,8 @@
>>            facets_[i]->__add_shared();
>> }
>> 
>> +#pragma GCC diagnostic pop
>> +
>> locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
>>    : facets_(N),
>>      name_("*")
>> @@ -4601,7 +4608,10 @@
>> string
>> __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
>> {
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    tm t = {0};
>> +#pragma GCC diagnostic pop
>>    t.tm_sec = 59;
>>    t.tm_min = 55;
>>    t.tm_hour = 23;
>> @@ -4747,7 +4757,10 @@
>> wstring
>> __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
>> {
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    tm t = {0};
>> +#pragma GCC diagnositc pop
>>    t.tm_sec = 59;
>>    t.tm_min = 55;
>>    t.tm_hour = 23;
>> @@ -4901,7 +4914,10 @@
>> void
>> __time_get_storage<char>::init(const ctype<char>& ct)
>> {
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    tm t = {0};
>> +#pragma GCC diagnostic pop
>>    char buf[100];
>>    // __weeks_
>>    for (int i = 0; i < 7; ++i)
>> @@ -4938,11 +4954,17 @@
>> void
>> __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
>> {
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    tm t = {0};
>> +#pragma GCC diagnostic pop
>>    char buf[100];
>>    wchar_t wbuf[100];
>>    wchar_t* wbe;
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    mbstate_t mb = {0};
>> +#pragma GCC diagnostic pop
>>    // __weeks_
>>    for (int i = 0; i < 7; ++i)
>>    {
>> @@ -5296,7 +5318,10 @@
>>    char __nar[100];
>>    char* __ne = __nar + 100;
>>    __do_put(__nar, __ne, __tm, __fmt, __mod);
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    mbstate_t mb = {0};
>> +#pragma GCC diagnostic pop
>>    const char* __nb = __nar;
>> #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
>>    size_t j = mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
>> @@ -5821,7 +5846,10 @@
>>        __thousands_sep_ = base::do_thousands_sep();
>>    __grouping_ = lc->mon_grouping;
>>    wchar_t wbuf[100];
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    mbstate_t mb = {0};
>> +#pragma GCC diagnostic pop
>>    const char* bb = lc->currency_symbol;
>> #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
>>    size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
>> @@ -5904,7 +5932,10 @@
>>        __thousands_sep_ = base::do_thousands_sep();
>>    __grouping_ = lc->mon_grouping;
>>    wchar_t wbuf[100];
>> +#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
>> +#pragma GCC diagnostic push
>>    mbstate_t mb = {0};
>> +#pragma GCC diagnostic pop
>>    const char* bb = lc->int_curr_symbol;
>> #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
>>    size_t j = mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
>> 
>> Modified: libcxx/trunk/src/thread.cpp
>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=171173&r1=171172&r2=171173&view=diff
>> ==============================================================================
>> --- libcxx/trunk/src/thread.cpp (original)
>> +++ libcxx/trunk/src/thread.cpp Thu Dec 27 17:24:31 2012
>> @@ -67,8 +67,10 @@
>>    return n;
>> #elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && defined(_SC_NPROCESSORS_ONLN)
>>    long result = sysconf(_SC_NPROCESSORS_ONLN);
>> -    if (result < 0 || result > UINT_MAX)
>> -        result = 0;
>> +    // sysconf returns -1 if the name is invalid, the option does not exist or
>> +    // does not have a definite limit.
>> +    if (result == -1)
>> +        return 0;
>>    return result;
>> #else  // defined(CTL_HW) && defined(HW_NCPU)
>>    // TODO: grovel through /proc or check cpuid on x86 and similar
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> 
>> 
> 
> 




More information about the cfe-commits mailing list