Re: [google/gcc-4_7] Allow static const floats unless -pedantic is passed (issue6212051)
Looks good to me. Yay for kicking the can down the road. ;) On Tue, May 15, 2012 at 12:57 PM, Ollie Wild a...@google.com wrote: To be applied to google/gcc-4_7. Allow static const floats unless -pedantic is passed. This patch allows us to migrate to C++11 more incrementally, since we can leave the static const float initializations in place, flip the switch, and then change it to use constexpr. This is a forward port of r180638 from google/gcc-4_6 (despite the fact that that revision says to NOT forward-port this). Minor additional fixups have been applied. 2012-05-15 Ollie Wild a...@google.com * gcc/cp/decl.c (check_static_variable_definition): Only generate a constexpr warning when -pedantic is enabled. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C: Replace -fpermissive with -pedantic. * gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C: New test. * gcc/testsuite/g++.old-deja/g++.ext/memconst.C: Compile with -pedantic -pedantic-errors to work around test failures with -std=gnu++11. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index bb26d15..d2fe731 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7861,9 +7861,18 @@ check_static_variable_definition (tree decl, tree type) error (in-class initialization of static data member %q#D of incomplete type, decl); else if (literal_type_p (type)) - permerror (input_location, - %constexpr% needed for in-class initialization of - static data member %q#D of non-integral type, decl); + { + /* FIXME google: This local modification allows us to + transition from C++98 to C++11 without moving static + const floats out of the class during the transition. It + should not be forward-ported to a 4.8 branch, since by + then we should be able to just fix the code to use + constexpr. */ + pedwarn (input_location, OPT_pedantic, + %constexpr% needed for in-class initialization of + static data member %q#D of non-integral type, decl); + return 0; + } else error (in-class initialization of static data member %q#D of non-literal type, decl); diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C index 7c84cf8..658a458 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C @@ -1,5 +1,5 @@ // PR c++/50258 -// { dg-options -std=c++0x -fpermissive } +// { dg-options -std=c++0x -pedantic } struct Foo { static const double d = 3.14; // { dg-warning constexpr } diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C new file mode 100644 index 000..28d34a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options -std=c++0x } + +struct Foo { + static const double d = 3.14; // no warning +}; +const double Foo::d; diff --git a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C index d934763..7e86156 100644 --- a/gcc/testsuite/g++.old-deja/g++.ext/memconst.C +++ b/gcc/testsuite/g++.old-deja/g++.ext/memconst.C @@ -1,5 +1,5 @@ // { dg-do assemble } -// { dg-options } +// { dg-options -pedantic -pedantic-errors } // From: ove.ewer...@syscon.uu.se (Ove Ewerlid) // Subject: ss-940630:cc1plus: internal error // Date: Sat, 2 Jul 1994 05:07:20 +0200 -- This patch is available for review at http://codereview.appspot.com/6212051
Re: [google/integration] Extend C++11 UDLs to be compatible with inttypes.h macros (issue6104051)
Could you try to get this into mainline instead of just the google branches? In http://gcc.gnu.org/PR52538, Jonathan sounded like he'd consider accepting it. On Sun, Apr 22, 2012 at 7:54 PM, Ollie Wild a...@google.com wrote: Add new option, -Wreserved-user-defined-literal. This option, which is enabled by default, causes the preprocessor to warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. According to [lex.ext]p10, this is ill-formed. Also modifies the preprocessor to treat such ill-formed suffixes as separate preprocessing tokens. This is consistent with the Clang front end (see http://llvm.org/viewvc/llvm-project?view=revrevision=152287), and enables backwards compatibility with code that uses formatting macros from inttypes.h, as in the following code block: int main() { int64_t i64 = 123; printf(My int64: %PRId64\n, i64); } Google ref b/6377711. 2012-04-22 Ollie Wild a...@google.com * gcc/c-family/c-common.c: * gcc/c-family/c-opts.c (c_common_handle_option): * gcc/c-family/c.opt: * gcc/doc/invoke.texi (struct A): * gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C (test): (main): * libcpp/include/cpplib.h (struct cpp_options): * libcpp/init.c (cpp_create_reader): * libcpp/lex.c (lex_raw_string): (lex_string): diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 1d19251..915dc25 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8724,6 +8724,7 @@ static const struct reason_option_codes_t option_codes[] = { {CPP_W_NORMALIZE, OPT_Wnormalized_}, {CPP_W_INVALID_PCH, OPT_Winvalid_pch}, {CPP_W_WARNING_DIRECTIVE, OPT_Wcpp}, + {CPP_W_RESERVED_USER_LITERALS, OPT_Wreserved_user_defined_literal}, {CPP_W_NONE, 0} }; diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 5118928..dab6ce5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -509,6 +509,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; } + case OPT_Wreserved_user_defined_literal: + cpp_opts-warn_reserved_user_literals = value; + break; + case OPT_Wreturn_type: warn_return_type = value; break; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 40ff96c..f610513 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -589,6 +589,10 @@ Wreorder C++ ObjC++ Var(warn_reorder) Warning Warn when the compiler reorders code +Wreserved-user-defined-literal +C++ ObjC++ Warning +Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. + Wreturn-type C ObjC C++ ObjC++ Var(warn_return_type) Warning Warn whenever a function's return type defaults to \int\ (C), or about inconsistent return types (C++) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1b61e76..d425079 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -198,7 +198,7 @@ in the following sections. -fvisibility-ms-compat @gol -Wabi -Wconversion-null -Wctor-dtor-privacy @gol -Wdelete-non-virtual-dtor -Wnarrowing -Wnoexcept @gol --Wnon-virtual-dtor -Wreorder @gol +-Wnon-virtual-dtor -Wreorder -Wreserved-user-defined-literal @gol -Weffc++ -Wstrict-null-sentinel @gol -Wno-non-template-friend -Wold-style-cast @gol -Woverloaded-virtual -Wno-pmf-conversions @gol @@ -2474,6 +2474,30 @@ struct A @{ The compiler will rearrange the member initializers for @samp{i} and @samp{j} to match the declaration order of the members, emitting a warning to that effect. This warning is enabled by @option{-Wall}. + +@item -Wreserved-user-defined-literal @r{(C++ and Objective-C++ only)} +@opindex Wreserved-user-defined-literal +@opindex Wno-reserved-user-defined-literal +Warn when a string or character literal is followed by a ud-suffix which does +not begin with an underscore. As a conforming extension, GCC treats such +suffixes as separate preprocessing tokens in order to maintain backwards +compatibility with code that uses formatting macros from @code{inttypes.h}. +For example: + +@smallexample +#define __STDC_FORMAT_MACROS +#include inttypes.h +#include stdio.h + +int main() @{ + int64_t i64 = 123; + printf(My int64: %PRId64\n, i64); +@} +@end smallexample + +In this case, @code{PRId64} is treated as a separate preprocessing token. + +This warning is enabled by default. @end table The following @option{-W@dots{}} options are not affected by @option{-Wall}. diff --git a/gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C b/gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C new file mode 100644 index 000..66de5c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C @@ -0,0
Re: [google/integration] Extend C++11 UDLs to be compatible with inttypes.h macros (issue6104051)
Let's let the discussion _start_ before assuming it'll be protracted. ;) I don't think it'll kill us to run the next round of testing in C++98 mode. If the patch doesn't look close to acceptance in a couple days, I think it'll make sense to put the then-current version into the google branches while people are agreeing about what to do in the long run. On Sun, Apr 22, 2012 at 8:14 PM, Ollie Wild a...@google.com wrote: I'd like to get this into the google branches first because this is blocking testing. I fully expect this to result in some protracted discussion before it can be accepted into trunk. Ollie On Sun, Apr 22, 2012 at 10:10 PM, Jeffrey Yasskin jyass...@google.com wrote: Could you try to get this into mainline instead of just the google branches? In http://gcc.gnu.org/PR52538, Jonathan sounded like he'd consider accepting it. On Sun, Apr 22, 2012 at 7:54 PM, Ollie Wild a...@google.com wrote: Add new option, -Wreserved-user-defined-literal. This option, which is enabled by default, causes the preprocessor to warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. According to [lex.ext]p10, this is ill-formed. Also modifies the preprocessor to treat such ill-formed suffixes as separate preprocessing tokens. This is consistent with the Clang front end (see http://llvm.org/viewvc/llvm-project?view=revrevision=152287), and enables backwards compatibility with code that uses formatting macros from inttypes.h, as in the following code block: int main() { int64_t i64 = 123; printf(My int64: %PRId64\n, i64); } Google ref b/6377711. 2012-04-22 Ollie Wild a...@google.com * gcc/c-family/c-common.c: * gcc/c-family/c-opts.c (c_common_handle_option): * gcc/c-family/c.opt: * gcc/doc/invoke.texi (struct A): * gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C (test): (main): * libcpp/include/cpplib.h (struct cpp_options): * libcpp/init.c (cpp_create_reader): * libcpp/lex.c (lex_raw_string): (lex_string): diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 1d19251..915dc25 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8724,6 +8724,7 @@ static const struct reason_option_codes_t option_codes[] = { {CPP_W_NORMALIZE, OPT_Wnormalized_}, {CPP_W_INVALID_PCH, OPT_Winvalid_pch}, {CPP_W_WARNING_DIRECTIVE, OPT_Wcpp}, + {CPP_W_RESERVED_USER_LITERALS, OPT_Wreserved_user_defined_literal}, {CPP_W_NONE, 0} }; diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 5118928..dab6ce5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -509,6 +509,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; } + case OPT_Wreserved_user_defined_literal: + cpp_opts-warn_reserved_user_literals = value; + break; + case OPT_Wreturn_type: warn_return_type = value; break; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 40ff96c..f610513 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -589,6 +589,10 @@ Wreorder C++ ObjC++ Var(warn_reorder) Warning Warn when the compiler reorders code +Wreserved-user-defined-literal +C++ ObjC++ Warning +Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. + Wreturn-type C ObjC C++ ObjC++ Var(warn_return_type) Warning Warn whenever a function's return type defaults to \int\ (C), or about inconsistent return types (C++) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1b61e76..d425079 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -198,7 +198,7 @@ in the following sections. -fvisibility-ms-compat @gol -Wabi -Wconversion-null -Wctor-dtor-privacy @gol -Wdelete-non-virtual-dtor -Wnarrowing -Wnoexcept @gol --Wnon-virtual-dtor -Wreorder @gol +-Wnon-virtual-dtor -Wreorder -Wreserved-user-defined-literal @gol -Weffc++ -Wstrict-null-sentinel @gol -Wno-non-template-friend -Wold-style-cast @gol -Woverloaded-virtual -Wno-pmf-conversions @gol @@ -2474,6 +2474,30 @@ struct A @{ The compiler will rearrange the member initializers for @samp{i} and @samp{j} to match the declaration order of the members, emitting a warning to that effect. This warning is enabled by @option{-Wall}. + +@item -Wreserved-user-defined-literal @r{(C++ and Objective-C++ only)} +@opindex Wreserved-user-defined-literal +@opindex Wno-reserved-user-defined-literal +Warn when a string or character literal is followed by a ud-suffix which does +not begin with an underscore. As a conforming extension, GCC treats such +suffixes as separate preprocessing
Re: [google/integration] Extend C++11 UDLs to be compatible with inttypes.h macros (issue6104051)
Thanks! On Sun, Apr 22, 2012 at 8:32 PM, Ollie Wild a...@google.com wrote: Okay, I'll send out a trunk patch for review now, too. Ollie On Sun, Apr 22, 2012 at 10:29 PM, Jeffrey Yasskin jyass...@google.com wrote: Let's let the discussion _start_ before assuming it'll be protracted. ;) I don't think it'll kill us to run the next round of testing in C++98 mode. If the patch doesn't look close to acceptance in a couple days, I think it'll make sense to put the then-current version into the google branches while people are agreeing about what to do in the long run. On Sun, Apr 22, 2012 at 8:14 PM, Ollie Wild a...@google.com wrote: I'd like to get this into the google branches first because this is blocking testing. I fully expect this to result in some protracted discussion before it can be accepted into trunk. Ollie On Sun, Apr 22, 2012 at 10:10 PM, Jeffrey Yasskin jyass...@google.com wrote: Could you try to get this into mainline instead of just the google branches? In http://gcc.gnu.org/PR52538, Jonathan sounded like he'd consider accepting it. On Sun, Apr 22, 2012 at 7:54 PM, Ollie Wild a...@google.com wrote: Add new option, -Wreserved-user-defined-literal. This option, which is enabled by default, causes the preprocessor to warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. According to [lex.ext]p10, this is ill-formed. Also modifies the preprocessor to treat such ill-formed suffixes as separate preprocessing tokens. This is consistent with the Clang front end (see http://llvm.org/viewvc/llvm-project?view=revrevision=152287), and enables backwards compatibility with code that uses formatting macros from inttypes.h, as in the following code block: int main() { int64_t i64 = 123; printf(My int64: %PRId64\n, i64); } Google ref b/6377711. 2012-04-22 Ollie Wild a...@google.com * gcc/c-family/c-common.c: * gcc/c-family/c-opts.c (c_common_handle_option): * gcc/c-family/c.opt: * gcc/doc/invoke.texi (struct A): * gcc/testsuite/g++.dg/cpp0x/Wreserved-user-defined-literal.C (test): (main): * libcpp/include/cpplib.h (struct cpp_options): * libcpp/init.c (cpp_create_reader): * libcpp/lex.c (lex_raw_string): (lex_string): diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 1d19251..915dc25 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8724,6 +8724,7 @@ static const struct reason_option_codes_t option_codes[] = { {CPP_W_NORMALIZE, OPT_Wnormalized_}, {CPP_W_INVALID_PCH, OPT_Winvalid_pch}, {CPP_W_WARNING_DIRECTIVE, OPT_Wcpp}, + {CPP_W_RESERVED_USER_LITERALS, OPT_Wreserved_user_defined_literal}, {CPP_W_NONE, 0} }; diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 5118928..dab6ce5 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -509,6 +509,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, break; } + case OPT_Wreserved_user_defined_literal: + cpp_opts-warn_reserved_user_literals = value; + break; + case OPT_Wreturn_type: warn_return_type = value; break; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 40ff96c..f610513 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -589,6 +589,10 @@ Wreorder C++ ObjC++ Var(warn_reorder) Warning Warn when the compiler reorders code +Wreserved-user-defined-literal +C++ ObjC++ Warning +Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. + Wreturn-type C ObjC C++ ObjC++ Var(warn_return_type) Warning Warn whenever a function's return type defaults to \int\ (C), or about inconsistent return types (C++) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1b61e76..d425079 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -198,7 +198,7 @@ in the following sections. -fvisibility-ms-compat @gol -Wabi -Wconversion-null -Wctor-dtor-privacy @gol -Wdelete-non-virtual-dtor -Wnarrowing -Wnoexcept @gol --Wnon-virtual-dtor -Wreorder @gol +-Wnon-virtual-dtor -Wreorder -Wreserved-user-defined-literal @gol -Weffc++ -Wstrict-null-sentinel @gol -Wno-non-template-friend -Wold-style-cast @gol -Woverloaded-virtual -Wno-pmf-conversions @gol @@ -2474,6 +2474,30 @@ struct A @{ The compiler will rearrange the member initializers for @samp{i} and @samp{j} to match the declaration order of the members, emitting a warning to that effect. This warning is enabled by @option{-Wall
Re: [patch] Fix PR52822 (stable_partition move-assigns object to itself) in trunk, 4.7, and 4.6
On Wed, Apr 4, 2012 at 11:09 PM, Paolo Carlini paolo.carl...@oracle.com wrote: Hi, The attached patches fix http://gcc.gnu.org/PR52822, and have been tested with `make check-c++` on linux-x86_64. The trunk patch applies and tests cleanly on gcc-4_7-branch. The gcc-4_6-branch patch is significantly simpler, as Paolo suggested on the bug. A few small issues. For the 4.6 version of the patch, you want to use std::__addressof, instead of simply , which may be overloaded. And by the way what's wrong with just comparing the iterators? Nothing's wrong with comparing the iterators. Switched. For the mainline/4.7 version, you want to cast __pred to bool: !bool(__pred(*__first)). Also, isn't clear to me why you have __local_len in __find_if_not_n instead of just working on __len (and in any case please prefer just __local_len as condition instead of the redundant __local_len != 0; likewise in many other similar situations). I was micro-optimizing, since the compiler might think __len is modified in __pred if it doesn't inline enough. I've removed __local_len, casted pred results to bool, and avoided !=0. Also, very minor nit, you will be touching the libstdc++-v3 Changelog thus no libstdc++-v3 prefixes in the ChangeLog entry. Yep, done. pr52822_gcc46.patch Description: Binary data pr52822_trunk.patch Description: Binary data
[patch] Fix PR52822 (stable_partition move-assigns object to itself) in trunk, 4.7, and 4.6
The attached patches fix http://gcc.gnu.org/PR52822, and have been tested with `make check-c++` on linux-x86_64. The trunk patch applies and tests cleanly on gcc-4_7-branch. The gcc-4_6-branch patch is significantly simpler, as Paolo suggested on the bug. The test is still inadequate, but given that there's no way to force get_temporary_buffer to return a short buffer, I'm not sure how to improve it. It might be possible to use set_memory_limits(), but that would require a very complex test program to make sure exactly the right operator new call fails. Jeffrey Yasskin pr52822_trunk.patch Description: Binary data pr52822_gcc46.patch Description: Binary data
[google] Fix PR52822 in google's gcc-4.6 branch (issue5975063)
I'll send the patches for trunk, gcc-4_7-branch, and gcc-4_6-branch in a separate thread later today or tomorrow, but I need to get the google branch fixed before that. Paolo suggested this simple fix was the right approach for the gcc-4_6-branch, so I'm using it for google/gcc-4_6 too. I'll be happy to fix up the google branch to match whatever gets accepted for gcc-4_6-branch once that's decided. Tested with `make check` on x86-64-linux, and I'll check this against the build I originally noticed the problem in before committing it. 2012-04-02 Jeffrey Yasskin jyass...@google.com * libstdc++-v3/include/bits/stl_algo.h (__stable_partition_adaptive): Avoid move-assigning an object to itself by explicitly testing for identity. * libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc: Test vectors, which have a destructive self-move-assignment. * libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc (test02): Test with rvalstruct, which explicitly checks self-move-assignment. Index: libstdc++-v3/include/bits/stl_algo.h === --- libstdc++-v3/include/bits/stl_algo.h(revision 186093) +++ libstdc++-v3/include/bits/stl_algo.h(working copy) @@ -1844,7 +1844,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION for (; __first != __last; ++__first) if (__pred(*__first)) { - *__result1 = _GLIBCXX_MOVE(*__first); +if (*__result1 != *__first) + *__result1 = _GLIBCXX_MOVE(*__first); ++__result1; } else Index: libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc === --- libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc (revision 0) +++ libstdc++-v3/testsuite/25_algorithms/stable_partition/pr52822.cc (revision 0) @@ -0,0 +1,43 @@ +// { dg-options -std=gnu++0x } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// http://www.gnu.org/licenses/. + +// 25.2.12 [lib.alg.partitions] Partitions. + +#include algorithm +#include vector +#include testsuite_hooks.h + +bool true_vector_pred(const std::vectorint) { return true; } + +void +test01() +{ + std::vectorstd::vectorint v(1); + v[0].push_back(7); + VERIFY( v[0].size() == 1 ); + std::stable_partition(v.begin(), v.end(), true_vector_pred); + VERIFY( v[0].size() == 1 ); +} + +int +main() +{ + test01(); + return 0; +} Index: libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc === --- libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc (revision 186093) +++ libstdc++-v3/testsuite/25_algorithms/stable_partition/moveable.cc (working copy) @@ -1,6 +1,6 @@ // { dg-options -std=gnu++0x } -// Copyright (C) 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -39,6 +39,12 @@ const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17}; const int N = sizeof(A) / sizeof(int); +// Check that starting with a value the predicate returns true for +// works too. (PR52822) +const int A2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; +const int B2[] = {2, 4, 6, 8, 10, 12, 14, 16, 3, 5, 7, 9, 11, 13, 15, 17}; +const int N2 = sizeof(A2) / sizeof(int); + struct Pred { bool @@ -46,7 +52,8 @@ struct Pred { return (x.val % 2) == 0; } }; -// 25.2.12 stable_partition() +// 25.2.12 stable_partition(), starting with a value for which the +// predicate returns false. void test01() { @@ -60,9 +67,25 @@ test01() VERIFY( std::equal(s1, s1 + N, B) ); } +// 25.2.12 stable_partition(), starting with a value for which the +// predicate returns true. +void +test02() +{ + bool test __attribute__((unused)) = true; + + rvalstruct s1[N2]; + std::copy(A2, A2 + N2, s1); + Container con(s1, s1 + N2); + + std::stable_partition(con.begin(), con.end(), Pred()); + VERIFY
[google] Work around PR52796 by replacing empty packs with explicit overloads. (issue5971053)
Work around http://gcc.gnu.org/PR52796 in gcc-4.6 by adding an overload of each function that passes a parameter pack directly as the only arguments of an object's constructor, which explicitly takes no arguments in place of the pack. Tested with check-c++ and by trying to provoke the bug in valgrind for each changed location. Some of the insert_aux locations appear inaccessible because of missing emplace() functions. I plan to only apply this to the google/gcc-4_6 branch, since gcc-4.7 already makes these cases work properly. 2012-03-30 Jeffrey Yasskin jyass...@google.com * libstdc++-v3/include/ext/pool_allocator.h: Add 1-argument construct() method. * libstdc++-v3/include/ext/bitmap_allocator.h: Likewise. * libstdc++-v3/include/ext/new_allocator.h: Likewise. * libstdc++-v3/include/ext/malloc_allocator.h: Likewise. * libstdc++-v3/include/ext/array_allocator.h: Likewise. * libstdc++-v3/include/ext/mt_allocator.h: Likewise. * libstdc++-v3/include/ext/extptr_allocator.h: Likewise. * libstdc++-v3/include/bits/stl_construct.h:Add 1-argument _Construct function. * libstdc++-v3/include/bits/stl_list.h: Add default _List_node constructor. * libstdc++-v3/include/bits/hashtable_policy.h: Add default _Hash_node constructor. * libstdc++-v3/include/bits/forward_list.h:Add default _Fwd_list_node constructor. * libstdc++-v3/include/bits/stl_tree.h:Add default _Rb_tree_node constructor. * libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/assign_neg.cc: Update line numbers. * libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/insert_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_1_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/forward_list/requirements/dr438/constructor_2_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc: Likewise. * libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc: Likewise. Index: libstdc++-v3/include/ext/pool_allocator.h === --- libstdc++-v3/include/ext/pool_allocator.h (revision 186024) +++ libstdc++-v3/include/ext/pool_allocator.h (working copy) @@ -165,6 +165,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { ::new((void *)__p) _Tp(__val); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ + // Work around PR52796 by avoiding 0-length parameter packs + // passed to constructors. + void + construct(pointer __p) + { ::new((void *)__p) _Tp(); } + templatetypename... _Args void construct(pointer __p, _Args... __args) Index: libstdc++-v3/include/ext/bitmap_allocator.h === --- libstdc++-v3/include/ext/bitmap_allocator.h (revision 186024) +++ libstdc++-v3/include/ext/bitmap_allocator.h (working copy) @@ -1058,6 +1058,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { ::new((void *)__p) value_type(__data); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ + // Work around PR52796 by avoiding 0-length parameter packs + // passed to constructors. + void + construct(pointer __p) + { ::new((void *)__p) _Tp(); } + templatetypename... _Args void construct(pointer __p, _Args... __args) @@ -1109,4 +1115,3 @@ _GLIBCXX_END_NAMESPACE_VERSION } // namespace __gnu_cxx #endif - Index: libstdc++-v3/include/ext/new_allocator.h === --- libstdc++-v3/include/ext/new_allocator.h(revision 186024) +++ libstdc++-v3/include/ext/new_allocator.h(working copy) @@ -115,6 +115,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { ::new((void *)__p) _Tp(__val); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ + // Work around PR52796 by avoiding 0-length parameter packs + // passed to constructors. + void + construct(pointer __p) + { ::new((void *)__p) _Tp(); } + templatetypename... _Args void construct(pointer __p, _Args... __args) Index: libstdc++-v3/include/ext/malloc_allocator.h === --- libstdc++-v3/include/ext/malloc_allocator.h (revision 186024) +++ libstdc++-v3/include/ext/malloc_allocator.h (working copy) @@ -111,6 +111,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { ::new((void *)__p) value_type(__val); } #ifdef __GXX_EXPERIMENTAL_CXX0X__ + // Work around PR52796 by avoiding 0-length parameter packs + // passed to constructors. + void + construct(pointer __p) + { ::new((void *)__p) _Tp
[patch][google] Backport r176665 to google/gcc-4_6 making narrowing conversions a pedwarn.
I'm backporting this so that, if we run into a particularly obnoxious set of narrowing conversions in the C++11 transition, we can just -Wno-narrowing instead of rolling a new gcc release. Tested with check-c++ on ubuntu x86_64. Since this is going into a google branch, I'll just commit it in a few hours unless I hear complaints. c-family/ChangeLog.google-4_6: 2011-11-02 Jeffrey Yasskin jyass...@google.com Backport from rev 176665 2011-07-22 Jason Merrill ja...@redhat.com * c.opt (Wnarrowing): New. cp/ChangeLog.google-4_6: 2011-11-02 Jeffrey Yasskin jyass...@google.com Backport from rev 176665 2011-07-22 Jason Merrill ja...@redhat.com * typeck2.c (check_narrowing): Downgrade permerror to pedwarn. Make conditional on -Wnarrowing. testsuite/ChangeLog.google-4_6: 2011-11-02 Jeffrey Yasskin jyass...@google.com Backport from rev 176665 2011-07-22 Jason Merrill ja...@redhat.com * g++.dg/cpp0x/initlist55.C: New. You can also review this at http://codereview.appspot.com/5330065/. Property changes on: . ___ Modified: svn:mergeinfo Merged /trunk:r176665 Property changes on: libjava/classpath ___ Modified: svn:mergeinfo Merged /trunk/libjava/classpath:r176665 Index: gcc/c-family/c.opt === --- gcc/c-family/c.opt (revision 180783) +++ gcc/c-family/c.opt (working copy) @@ -493,6 +493,10 @@ C ObjC C++ ObjC++ Warning Warn about use of multi-character character constants +Wnarrowing +C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(1) +-Wno-narrowing In C++0x mode, ignore ill-formed narrowing conversions within { } + Wnested-externs C ObjC Var(warn_nested_externs) Warning Warn about \extern\ declarations not at file scope Property changes on: gcc/testsuite/gcc.target/powerpc/ppc-round.c ___ Modified: svn:mergeinfo Merged /trunk/gcc/testsuite/gcc.target/powerpc/ppc-round.c:r176665 Index: gcc/testsuite/g++.dg/cpp0x/initlist5.C === --- gcc/testsuite/g++.dg/cpp0x/initlist5.C (revision 180783) +++ gcc/testsuite/g++.dg/cpp0x/initlist5.C (working copy) @@ -1,5 +1,5 @@ // Test for narrowing diagnostics -// { dg-options -std=c++0x } +// { dg-options -std=c++0x -pedantic-errors } #include initializer_list Index: gcc/testsuite/g++.dg/cpp0x/initlist7.C === --- gcc/testsuite/g++.dg/cpp0x/initlist7.C (revision 180783) +++ gcc/testsuite/g++.dg/cpp0x/initlist7.C (working copy) @@ -1,5 +1,5 @@ // PR c++/37932 -// { dg-options -std=c++0x } +// { dg-options -std=c++0x -pedantic-errors } typedef enum { AA=1, BB=2 } my_enum; Index: gcc/testsuite/g++.dg/cpp0x/initlist17.C === --- gcc/testsuite/g++.dg/cpp0x/initlist17.C (revision 180783) +++ gcc/testsuite/g++.dg/cpp0x/initlist17.C (working copy) @@ -1,4 +1,4 @@ -// { dg-options -std=c++0x } +// { dg-options -std=c++0x -pedantic-errors } void f(int i); Index: gcc/testsuite/g++.dg/cpp0x/initlist36.C === --- gcc/testsuite/g++.dg/cpp0x/initlist36.C (revision 180783) +++ gcc/testsuite/g++.dg/cpp0x/initlist36.C (working copy) @@ -1,5 +1,5 @@ // PR c++/44358 -// { dg-options -std=c++0x } +// { dg-options -std=c++0x -pedantic-errors } #include initializer_list Index: gcc/cp/typeck2.c === --- gcc/cp/typeck2.c (revision 180783) +++ gcc/cp/typeck2.c (working copy) @@ -733,7 +733,7 @@ bool ok = true; REAL_VALUE_TYPE d; - if (!ARITHMETIC_TYPE_P (type)) + if (!warn_narrowing || !ARITHMETIC_TYPE_P (type)) return; init = maybe_constant_value (init); @@ -781,8 +781,8 @@ } if (!ok) -permerror (input_location, narrowing conversion of %qE from %qT to %qT inside { }, - init, ftype, type); +pedwarn (input_location, OPT_Wnarrowing, narrowing conversion of %qE + from %qT to %qT inside { }, init, ftype, type); } /* Process the initializer INIT for a variable of type TYPE, emitting Property changes on: gcc/config/rs6000/rs6000.c ___ Modified: svn:mergeinfo Merged /trunk/gcc/config/rs6000/rs6000.c:r176665 Property changes on: gcc/config/rs6000/rs6000.h ___ Modified: svn:mergeinfo Merged /trunk/gcc/config/rs6000/rs6000.h:r176665
Re: [patch][google] Allow static const floats unless -pedantic is passed. (issue 5306071)
Thanks Diego, Here's a new version of the patch with fixes for your comments. I'll submit it in a couple hours unless I hear objections. On Fri, Oct 28, 2011 at 7:57 AM, Diego Novillo dnovi...@google.com wrote: On Thu, Oct 27, 2011 at 09:27, jyass...@google.com wrote: Reviewers: Diego Novillo, Message: This patch is intended for the google/gcc-4_6 branch. Tested with make check-c++ on ubuntu x86-64. Should this go to gcc-patches@gcc.gnu.org too, or just the internal list? As you prefer. Strictly speaking, yes, in case other C++ maintainers have feedback on your patch. But given that it is a patch that you intend to keep in a google release only, then it does not really matter all that much. Description: This patch allows us to migrate to C++11 more incrementally, since we can leave the static const float initializations in place, flip the switch, and then change them to use constexpr. We should NOT forward-port this to any gcc-4.7 branches. gcc/cp/ChangeLog.google-4_6 2011-10-28 Jeffrey Yasskin jyass...@google.com google ref 5514746; backport of r179121 Modified locally to only block static const literals in -pedantic mode. 2011-09-23 Paolo Carlini paolo.carl...@oracle.com * decl.c (check_static_variable_definition): Allow in-class initialization of static data member of non-integral type in permissive mode. gcc/testsuite/ChangeLog.google-4_6 2011-10-28 Jeffrey Yasskin jyass...@google.com google ref 5514746; backport of r179121 Modified locally to only block static const literals in -pedantic mode. * g++.dg/cpp0x/constexpr-static8_nonpedantic.C: New. 2011-09-23 Paolo Carlini paolo.carl...@oracle.com * g++.dg/cpp0x/constexpr-static8.C: New. You can review this at http://codereview.appspot.com/5306071/ Affected files: M gcc/cp/ChangeLog.google-4_6 M gcc/cp/decl.c M gcc/testsuite/ChangeLog.google-4_6 A gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C A gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C ... Index: gcc/cp/decl.c === --- gcc/cp/decl.c (revision 180546) +++ gcc/cp/decl.c (working copy) @@ -7508,8 +7508,12 @@ check_static_variable_definition (tree decl, tree else if (cxx_dialect = cxx0x !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { if (literal_type_p (type)) - error (%constexpr% needed for in-class initialization of static - data member %q#D of non-integral type, decl); + { + pedwarn (input_location, OPT_pedantic, + %constexpr% needed for in-class initialization of + static data member %q#D of non-integral type, decl); + return 0; + } Add a 'FIXME google' here? Describe why this is different than upstream. Helps with merge conflicts. Done. OK with those changes. Diego. Index: gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C === --- gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/constexpr-static8.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options -std=c++0x -pedantic } + +struct Foo { + static const double d = 3.14; // { dg-warning constexpr } +}; +const double Foo::d; Index: gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C === --- gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/constexpr-static8_nonpedantic.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/50258 +// { dg-options -std=c++0x } + +struct Foo { + static const double d = 3.14; // no warning +}; +const double Foo::d; Index: gcc/cp/decl.c === --- gcc/cp/decl.c (revision 180546) +++ gcc/cp/decl.c (working copy) @@ -7508,8 +7508,18 @@ else if (cxx_dialect = cxx0x !INTEGRAL_OR_ENUMERATION_TYPE_P (type)) { if (literal_type_p (type)) - error (%constexpr% needed for in-class initialization of static - data member %q#D of non-integral type, decl); +{ + /* FIXME google: This local modification allows us to + transition from C++98 to C++11 without moving static + const floats out of the class during the transition. It + should not be forward-ported to a 4.7 branch, since by + then we should be able to just fix the code to use + constexpr. */ + pedwarn (input_location, OPT_pedantic, + %constexpr% needed for in-class initialization of + static data member %q#D of non-integral type, decl); + return 0; +} else error (in-class initialization of static data member
Re: [PATCH] Propagate source locations from function_decls to their template_decls
Thanks. Committed to gcc-4_6-branch in r176851 and the google/gcc-4_6 branch in r177072. On Wed, Jul 27, 2011 at 11:46 AM, Jason Merrill ja...@redhat.com wrote: Yes. Jeffrey Yasskin jyass...@google.com wrote: Thanks. I'll commit to trunk in the morning when I can be around to watch for breakage. Is this also ok for gcc-4_6-branch? On Tue, Jul 26, 2011 at 7:16 PM, Jason Merrill ja...@redhat.com wrote: Ok. Jeffrey Yasskin jyass...@google.com wrote: Hi Jason. Paolo suggested I ping you directly about this patch for the C++ parser. Thanks in advance for taking a look. On Tue, Jul 26, 2011 at 2:20 PM, Jeffrey Yasskin jyass...@google.com wrote: This patch copies the source location of a FUNCTION_DECL to the TEMPLATE_DECL that build_template_decl() builds out of it. Otherwise, the TEMPLATE_DECL's location becomes input_location, which is the end of the parameter list, while the FUNCTION_DECL's location is the location of the name of the function. Depending on what order templates are defined and used, gcc may emit either the FUNCTION_DECL's or TEMPLATE_DECL's location into the debug location, which causes gold's ODR checker to emit false positives. Tested with a bootstrap+`make -k check-c++` on x86_64-unknown-linux-gnu. I'm looking to check it in to trunk, and will propagate it to the gcc-4_6-branch if you think that's the right thing to do. No more tests fail than in http://gcc.gnu.org/ml/gcc-testresults/2011-07/msg02995.html. gcc/cp/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* pt.c (build_template_decl): Copy the function_decl's source ? ? ? ?location to the new template_decl. gcc/testsuite/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* g++.old-deja/g++.pt/crash60.C: Updated. libstdc++-v3/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Updated.
Re: [google][patch] Put make_heap's declaration on a single line to work around inconsistent debug locations
And reverted in r177083 because I fixed the underlying problem. On Fri, Jul 22, 2011 at 11:06 PM, Ollie Wild a...@google.com wrote: Ok for inclusion in google/gcc-4_6. Ollie On Fri, Jul 22, 2011 at 5:46 PM, Jeffrey Yasskin jyass...@google.com wrote: For the google/gcc-4_6 branch _only_. I'll fix the inconsistency in debug locations later for trunk and google/main. In some translation units the debug location of make_heap is the location of its name; in other TUs it's the location of the closing ')'. This causes false positives in gold's ODR checker. Until I can find why the locations are inconsistent, we can work around the problem by putting the name and closing ')' on the same line. libstdc++-v3/ChangeLog 2011-07-22 Jeffrey Yasskin jyass...@google.com * include/bits/stl_heap.h(make_heap): Remove a newline.
Re: [PATCH] Propagate source locations from function_decls to their template_decls
Thanks. I'll commit to trunk in the morning when I can be around to watch for breakage. Is this also ok for gcc-4_6-branch? On Tue, Jul 26, 2011 at 7:16 PM, Jason Merrill ja...@redhat.com wrote: Ok. Jeffrey Yasskin jyass...@google.com wrote: Hi Jason. Paolo suggested I ping you directly about this patch for the C++ parser. Thanks in advance for taking a look. On Tue, Jul 26, 2011 at 2:20 PM, Jeffrey Yasskin jyass...@google.com wrote: This patch copies the source location of a FUNCTION_DECL to the TEMPLATE_DECL that build_template_decl() builds out of it. Otherwise, the TEMPLATE_DECL's location becomes input_location, which is the end of the parameter list, while the FUNCTION_DECL's location is the location of the name of the function. Depending on what order templates are defined and used, gcc may emit either the FUNCTION_DECL's or TEMPLATE_DECL's location into the debug location, which causes gold's ODR checker to emit false positives. Tested with a bootstrap+`make -k check-c++` on x86_64-unknown-linux-gnu. I'm looking to check it in to trunk, and will propagate it to the gcc-4_6-branch if you think that's the right thing to do. No more tests fail than in http://gcc.gnu.org/ml/gcc-testresults/2011-07/msg02995.html. gcc/cp/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* pt.c (build_template_decl): Copy the function_decl's source ? ? ? ?location to the new template_decl. gcc/testsuite/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* g++.old-deja/g++.pt/crash60.C: Updated. libstdc++-v3/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Updated.
[PATCH] Propagate source locations from function_decls to their template_decls
This patch copies the source location of a FUNCTION_DECL to the TEMPLATE_DECL that build_template_decl() builds out of it. Otherwise, the TEMPLATE_DECL's location becomes input_location, which is the end of the parameter list, while the FUNCTION_DECL's location is the location of the name of the function. Depending on what order templates are defined and used, gcc may emit either the FUNCTION_DECL's or TEMPLATE_DECL's location into the debug location, which causes gold's ODR checker to emit false positives. Tested with a bootstrap+`make -k check-c++` on x86_64-unknown-linux-gnu. I'm looking to check it in to trunk, and will propagate it to the gcc-4_6-branch if you think that's the right thing to do. No more tests fail than in http://gcc.gnu.org/ml/gcc-testresults/2011-07/msg02995.html. gcc/cp/ChangeLog: 2011-07-26 Jeffrey Yasskin jyass...@google.com * pt.c (build_template_decl): Copy the function_decl's source location to the new template_decl. gcc/testsuite/ChangeLog: 2011-07-26 Jeffrey Yasskin jyass...@google.com * g++.old-deja/g++.pt/crash60.C: Updated. libstdc++-v3/ChangeLog: 2011-07-26 Jeffrey Yasskin jyass...@google.com * testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Updated. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 178685c..b9e09af 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4121,6 +4121,7 @@ build_template_decl (tree decl, tree parms, bool member_template_p) tree tmpl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), NULL_TREE); DECL_TEMPLATE_PARMS (tmpl) = parms; DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl); + DECL_SOURCE_LOCATION (tmpl) = DECL_SOURCE_LOCATION (decl); DECL_MEMBER_TEMPLATE_P (tmpl) = member_template_p; return tmpl; diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash60.C b/gcc/testsuite/g++.old-deja/g++.pt/crash60.C index 747af9b..1be4678 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/crash60.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/crash60.C @@ -5,9 +5,9 @@ // We ICE'd rather than fail to instantiate. template typename SID, class SDR -void k( SID sid, SDR* p, +void k( SID sid, SDR* p, // { dg-error no type named 'T' } void (SDR::*) - ( typename SID::T ) ); // { dg-error no type named 'T' } + ( typename SID::T ) ); struct E { }; struct S { void f( int ); }; diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc index df18712..6eecc2d 100644 --- a/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc +++ b/libstdc++-v3/testsuite/20_util/weak_ptr/comparison/cmp_neg.cc @@ -44,16 +44,16 @@ main() // { dg-warning note { target *-*-* } 370 } // { dg-warning note { target *-*-* } 365 } -// { dg-warning note { target *-*-* } 357 } +// { dg-warning note { target *-*-* } 356 } // { dg-warning note { target *-*-* } 1103 } // { dg-warning note { target *-*-* } 1098 } -// { dg-warning note { target *-*-* } 1090 } +// { dg-warning note { target *-*-* } 1089 } // { dg-warning note { target *-*-* } 485 } // { dg-warning note { target *-*-* } 479 } -// { dg-warning note { target *-*-* } 469 } -// { dg-warning note { target *-*-* } 814 } -// { dg-warning note { target *-*-* } 1056 } -// { dg-warning note { target *-*-* } 1050 } -// { dg-warning note { target *-*-* } 342 } -// { dg-warning note { target *-*-* } 292 } +// { dg-warning note { target *-*-* } 468 } +// { dg-warning note { target *-*-* } 813 } +// { dg-warning note { target *-*-* } 1055 } +// { dg-warning note { target *-*-* } 1049 } +// { dg-warning note { target *-*-* } 341 } +// { dg-warning note { target *-*-* } 291 } // { dg-warning note { target *-*-* } 224 }
[google][patch] Put make_heap's declaration on a single line to work around inconsistent debug locations
For the google/gcc-4_6 branch _only_. I'll fix the inconsistency in debug locations later for trunk and google/main. In some translation units the debug location of make_heap is the location of its name; in other TUs it's the location of the closing ')'. This causes false positives in gold's ODR checker. Until I can find why the locations are inconsistent, we can work around the problem by putting the name and closing ')' on the same line. libstdc++-v3/ChangeLog 2011-07-22 Jeffrey Yasskin jyass...@google.com * include/bits/stl_heap.h(make_heap): Remove a newline. Index: libstdc++-v3/include/bits/stl_heap.h === --- libstdc++-v3/include/bits/stl_heap.h (revision 176544) +++ libstdc++-v3/include/bits/stl_heap.h (working copy) @@ -412,8 +412,7 @@ */ templatetypename _RandomAccessIterator, typename _Compare void -make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, - _Compare __comp) +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { typedef typename iterator_traits_RandomAccessIterator::value_type _ValueType;
[google] Merge r173574 to google/gcc-4_6 to fix an incompatibility between C++98 and C++0x (issue4592057)
In C++0x mode, without this patch, calls to a user-defined trunc() function with an argument in namespace std and a parameter type that has an implicit conversion from the argument's type, cause infinite recursion in std::trunc(). This patch also includes http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/26_numerics/headers/cmath/overloads_c%2B%2B0x_neg.cc?view=markuppathrev=173574 and http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc?view=markuppathrev=173574, but `svn diff` didn't capture them. Tested with `make check-c++` on x86_64-unknown-linux-gnu. 2011-06-14 Jeffrey Yasskin jyass...@google.com Merge r173574 to google/gcc-4_6. * include/c_global/cmath (acosh, asinh, atanh, cbrt, copysign, erf, erfc, exp2, expm1, fdim, fma, fmax, hypot, ilogb, lgamma, llrint, llround, log1p, log2, logb, lrint, lround, nearbyint, nextafter, nexttoward, remainder, remquo, rint, round, scalbln, scalbn, tgamma, trunc): Use __enable_if on the return type. * include/tr1/cmath: Likewise. * testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc: New. * testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc: Likewise. Property changes on: . ___ Modified: svn:mergeinfo Merged /trunk:r173574 Index: libstdc++-v3/include/c_global/cmath === --- libstdc++-v3/include/c_global/cmath (revision 175001) +++ libstdc++-v3/include/c_global/cmath (working copy) @@ -1,7 +1,7 @@ // -*- C++ -*- C forwarding header. // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, -// 2006, 2007, 2008, 2009, 2010 +// 2006, 2007, 2008, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -1120,12 +1120,10 @@ { return __builtin_acoshl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline typename __gnu_cxx::__enable_if__is_integer_Tp::__value, + double::__type acosh(_Tp __x) -{ - typedef typename __gnu_cxx::__promote_Tp::__type __type; - return acosh(__type(__x)); -} +{ return __builtin_acosh(__x); } inline float asinh(float __x) @@ -1136,12 +1134,10 @@ { return __builtin_asinhl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline typename __gnu_cxx::__enable_if__is_integer_Tp::__value, + double::__type asinh(_Tp __x) -{ - typedef typename __gnu_cxx::__promote_Tp::__type __type; - return asinh(__type(__x)); -} +{ return __builtin_asinh(__x); } inline float atanh(float __x) @@ -1152,12 +1148,10 @@ { return __builtin_atanhl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline typename __gnu_cxx::__enable_if__is_integer_Tp::__value, + double::__type atanh(_Tp __x) -{ - typedef typename __gnu_cxx::__promote_Tp::__type __type; - return atanh(__type(__x)); -} +{ return __builtin_atanh(__x); } inline float cbrt(float __x) @@ -1168,12 +1162,10 @@ { return __builtin_cbrtl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline typename __gnu_cxx::__enable_if__is_integer_Tp::__value, + double::__type cbrt(_Tp __x) -{ - typedef typename __gnu_cxx::__promote_Tp::__type __type; - return cbrt(__type(__x)); -} +{ return __builtin_cbrt(__x); } inline float copysign(float __x, float __y) @@ -1184,7 +1176,11 @@ { return __builtin_copysignl(__x, __y); } templatetypename _Tp, typename _Up -inline typename __gnu_cxx::__promote_2_Tp, _Up::__type +inline +typename __gnu_cxx::__promote_2 +typename __gnu_cxx::__enable_if__is_arithmetic_Tp::__value +__is_arithmetic_Up::__value, + _Tp::__type, _Up::__type copysign(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2_Tp, _Up::__type __type; @@ -1200,12 +1196,10 @@ { return __builtin_erfl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline typename __gnu_cxx::__enable_if__is_integer_Tp::__value, + double::__type erf(_Tp __x) -{ - typedef typename __gnu_cxx::__promote_Tp::__type __type; - return erf(__type(__x)); -} +{ return __builtin_erf(__x); } inline float erfc(float __x) @@ -1216,12 +1210,10 @@ { return __builtin_erfcl(__x); } templatetypename _Tp -inline typename __gnu_cxx::__promote_Tp::__type +inline
Re: [google] Merge r173574 to google/gcc-4_6 to fix an incompatibility between C++98 and C++0x (issue4592057)
On Tue, Jun 14, 2011 at 12:38 PM, Diego Novillo dnovi...@google.com wrote: On Tue, Jun 14, 2011 at 14:45, Jeffrey Yasskin jyass...@google.com wrote: In C++0x mode, without this patch, calls to a user-defined trunc() function with an argument in namespace std and a parameter type that has an implicit conversion from the argument's type, cause infinite recursion in std::trunc(). This patch also includes http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/26_numerics/headers/cmath/overloads_c%2B%2B0x_neg.cc?view=markuppathrev=173574 and http://gcc.gnu.org/viewcvs/trunk/libstdc%2B%2B-v3/testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc?view=markuppathrev=173574, but `svn diff` didn't capture them. Yeah, svn diff never picks up added files. Silly thing. Tested with `make check-c++` on x86_64-unknown-linux-gnu. 2011-06-14 Jeffrey Yasskin jyass...@google.com Merge r173574 to google/gcc-4_6. * include/c_global/cmath (acosh, asinh, atanh, cbrt, copysign, erf, erfc, exp2, expm1, fdim, fma, fmax, hypot, ilogb, lgamma, llrint, llround, log1p, log2, logb, lrint, lround, nearbyint, nextafter, nexttoward, remainder, remquo, rint, round, scalbln, scalbn, tgamma, trunc): Use __enable_if on the return type. * include/tr1/cmath: Likewise. * testsuite/26_numerics/headers/cmath/overloads_c++0x_neg.cc: New. * testsuite/tr1/8_c_compatibility/cmath/overloads_neg.cc: Likewise. Any reason not to put this in google/main? It's already in trunk, so my impression was that it was going to be automatically merged to google/main. I only need a manual merge to get it into our release branches. Jeffrey
[patch] Import iota and is_sorted from std to __gnu_cxx in C++0x mode. (issue4384043)
In C++0x mode, import iota and is_sorted from namespace std into namespace __gnu_cxx to avoid ambiguous call errors. copy_n would be a good candidate for this too, except it was standardized with a different return type. I think this is a candidate to backport to libstdc++-4.6.1. Tested: `make -k check-c++` on x86_64-unknown-linux-gnu. (still running) libstdc++-v3/ChangeLog: 2011-04-06 Jeffrey Yasskin jyass...@google.com * include/ext/algorithm (is_sorted): In C++0x mode import from namespace std. * include/ext/numeric (iota): In C++0x mode import from namespace std. * testsuite/ext/is_sorted/cxx0x.cc: New. * testsuite/ext/iota/cxx0x.cc: New. diff --git a/libstdc++-v3/include/ext/algorithm b/libstdc++-v3/include/ext/algorithm index 368b591..417a03a 100644 --- a/libstdc++-v3/include/ext/algorithm +++ b/libstdc++-v3/include/ext/algorithm @@ -471,6 +471,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using std::is_sorted; +#else // is_sorted, a predicated testing whether a range is sorted in // nondescending order. This is an extension, not part of the C++ // standard. @@ -526,6 +529,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; return true; } +#endif // __GXX_EXPERIMENTAL_CXX0X__ /** * @brief Find the median of three values. diff --git a/libstdc++-v3/include/ext/numeric b/libstdc++-v3/include/ext/numeric index d4a367f..b389177 100644 --- a/libstdc++-v3/include/ext/numeric +++ b/libstdc++-v3/include/ext/numeric @@ -123,6 +123,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION power(_Tp __x, _Integer __n) { return __power(__x, __n); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using std::iota; +#else /** * This is an SGI extension. * @ingroup SGIextensions @@ -141,9 +144,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION while (__first != __last) *__first++ = __value++; } +#endif // __GXX_EXPERIMENTAL_CXX0X__ _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif - diff --git a/libstdc++-v3/testsuite/ext/iota/cxx0x.cc b/libstdc++-v3/testsuite/ext/iota/cxx0x.cc new file mode 100644 index 000..84917ad --- /dev/null +++ b/libstdc++-v3/testsuite/ext/iota/cxx0x.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options -std=gnu++0x } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// http://www.gnu.org/licenses/. + +#include ext/numeric +#include vector + +void foo() +{ + std::vectorint v; + iota(v.begin(), v.end(), 0); +} diff --git a/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc b/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc new file mode 100644 index 000..518716c --- /dev/null +++ b/libstdc++-v3/testsuite/ext/is_sorted/cxx0x.cc @@ -0,0 +1,28 @@ +// { dg-do compile } +// { dg-options -std=gnu++0x } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// http://www.gnu.org/licenses/. + +#include ext/algorithm +#include vector + +void foo() +{ + std::vectorint v; + is_sorted(v.begin(), v.end()); +} -- This patch is available for review at http://codereview.appspot.com/4384043
[patch] Fix two C++ errors in libstdc++. (issue4341041)
I think this is a candidate to backport to libstdc++-4.6.1. exception_ptr.h needs the forward declaration because it's included from typeinfo before typeinfo defines std::type_info. Tested: `make check` in x86_64-unknown-linux-gnu/libstdc++-v3. The abi_check test fails, but also did before this change. libstdc++-v3/ChangeLog: 2011-03-31 Jeffrey Yasskin jyass...@google.com * libsupc++/exception_ptr.h: Forward-declare std::type_info. * libsupc++/nested_exception.h (__throw_with_nested): Remove a redundant default argument from std::__throw_with_nested. diff --git a/libstdc++-v3/libsupc++/exception_ptr.h b/libstdc++-v3/libsupc++/exception_ptr.h index ef826f6..26117cd 100644 --- a/libstdc++-v3/libsupc++/exception_ptr.h +++ b/libstdc++-v3/libsupc++/exception_ptr.h @@ -137,7 +137,7 @@ namespace std operator==(const exception_ptr, const exception_ptr) throw() __attribute__ ((__pure__)); - const type_info* + const class type_info* __cxa_exception_type() const throw() __attribute__ ((__pure__)); }; diff --git a/libstdc++-v3/libsupc++/nested_exception.h b/libstdc++-v3/libsupc++/nested_exception.h index 6a4f04e..d4804bb 100644 --- a/libstdc++-v3/libsupc++/nested_exception.h +++ b/libstdc++-v3/libsupc++/nested_exception.h @@ -117,7 +117,7 @@ namespace std // with a type that has an accessible nested_exception base. templatetypename _Ex inline void -__throw_with_nested(_Ex __ex, const nested_exception* = 0) +__throw_with_nested(_Ex __ex, const nested_exception*) { throw __ex; } templatetypename _Ex -- This patch is available for review at http://codereview.appspot.com/4341041
Re: [patch] Fix two C++ errors in libstdc++. (issue4341041)
On Thu, Mar 31, 2011 at 12:49 PM, Paolo Carlini paolo.carl...@oracle.com wrote: On 03/31/2011 09:41 PM, Paolo Carlini wrote: I think this is a candidate to backport to libstdc++-4.6.1. exception_ptr.h needs the forward declaration because it's included fromtypeinfo beforetypeinfo defines std::type_info. before going ahead with the patch - I'm not at all sure it's enough, for exception itself for example I had a closer look to what we have and indeed the patch seems enough to solve the existing issues. Thanks. I think we want indeed to apply the patchlet to mainline and 4_6-branch, but my basic puzzlement stays, indeed it's the real reason why the problem remained unnoticed for so much time! Thanks. Is that an OK that I can commit this to mainline and 4_6-branch? [For libstdc++@ people, the patch is at http://codereview.appspot.com/4341041 and http://gcc.gnu.org/ml/gcc-patches/2011-03/msg02261.html]