Skip to content

Commit

Permalink
trac-9882: fix gcc -Wshadow errors and warnings enabled by trac-3606
Browse files Browse the repository at this point in the history
  • Loading branch information
jeking3 committed Jan 2, 2018
1 parent f4a980c commit 21b9c4d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 80 deletions.
104 changes: 52 additions & 52 deletions include/boost/date_time/gregorian/gregorian_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, d);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, d);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, d);
Expand Down Expand Up @@ -138,14 +138,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dd);
Expand Down Expand Up @@ -202,14 +202,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dp);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dp);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dp);
Expand Down Expand Up @@ -261,14 +261,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, m);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, m);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, m);
Expand Down Expand Up @@ -318,14 +318,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, wd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, wd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, wd);
Expand Down Expand Up @@ -359,14 +359,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gd);
Expand Down Expand Up @@ -400,14 +400,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gy);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gy);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gy);
Expand Down Expand Up @@ -458,14 +458,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, pd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, pd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pd);
Expand Down Expand Up @@ -515,14 +515,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, nday);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, nday);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, nday);
Expand Down Expand Up @@ -573,14 +573,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkd);
Expand Down Expand Up @@ -631,14 +631,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, lkd);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, lkd);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, lkd);
Expand Down Expand Up @@ -690,14 +690,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fka);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fka);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fka);
Expand Down Expand Up @@ -749,14 +749,14 @@ namespace gregorian {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;

std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet>(is.getloc())) {
std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkb);
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkb);
}
else {
date_input_facet* f = new date_input_facet();
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkb);
Expand Down
24 changes: 12 additions & 12 deletions include/boost/date_time/posix_time/posix_time_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, pt);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, pt);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pt);
Expand Down Expand Up @@ -141,13 +141,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, tp);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, tp);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, tp);
Expand Down Expand Up @@ -205,13 +205,13 @@ namespace posix_time {
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, td);
if(std::has_facet<time_input_facet_local>(is.getloc())) {
std::use_facet<time_input_facet_local>(is.getloc()).get(sit, str_end, is, td);
}
else {
time_input_facet* f = new time_input_facet();
time_input_facet_local* f = new time_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, td);
Expand Down
2 changes: 2 additions & 0 deletions include/boost/date_time/time_facet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ namespace date_time {
break;
// %s is the same as %S%f so we drop through into %f
}
/* Falls through. */
case 'f':
{
// check for decimal, check special_values if missing
Expand Down Expand Up @@ -1139,6 +1140,7 @@ namespace date_time {
// %s is the same as %S%f so we drop through into %f if we are
// not at the end of the stream
}
/* Falls through. */
case 'f':
{
// check for decimal, check SV if missing
Expand Down
4 changes: 2 additions & 2 deletions test/local_time/testlocal_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ main()
try{
local_date_time blt(d, h, ny_tz, true);
check("Did not catch expected exception (dst_not_valid)", false);
}catch(dst_not_valid& d){
check(std::string("Caught expected exception (dst_not_valid) ") + d.what(), true);
}catch(dst_not_valid& e){
check(std::string("Caught expected exception (dst_not_valid) ") + e.what(), true);
}catch(std::exception& e){
check(std::string("Caught unexpected exception ") + e.what(), false);
}
Expand Down
28 changes: 14 additions & 14 deletions test/posix_time/testdst_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ main()

//The following defines the US dst boundaries, except that the
//start and end dates are hard coded.
typedef boost::date_time::us_dst_rules<date, time_duration, 120, 60> us_dst;
typedef boost::date_time::us_dst_rules<date, time_duration, 120, 60> us_dst_local;
date dst_start(2002,Apr, 7);
date dst_end(2002,Oct, 27);

Expand All @@ -68,29 +68,29 @@ main()
ptime t8(dst_end, time_duration(1,59,59)); //ambiguous
ptime t9(dst_end, time_duration(2,0,0)); //always not dst

check("dst start", us_dst::local_dst_start_day(2002) == dst_start);
check("dst end", us_dst::local_dst_end_day(2002) == dst_end);
check("dst boundary", us_dst::is_dst_boundary_day(dst_start));
check("dst boundary", us_dst::is_dst_boundary_day(dst_end));
check("dst start", us_dst_local::local_dst_start_day(2002) == dst_start);
check("dst end", us_dst_local::local_dst_end_day(2002) == dst_end);
check("dst boundary", us_dst_local::is_dst_boundary_day(dst_start));
check("dst boundary", us_dst_local::is_dst_boundary_day(dst_end));
check("check if time is dst -- not",
us_dst::local_is_dst(t.date(), t.time_of_day())==boost::date_time::is_not_in_dst);
us_dst_local::local_is_dst(t.date(), t.time_of_day())==boost::date_time::is_not_in_dst);
check("label on dst boundary invalid",
us_dst::local_is_dst(t3a.date(),t3a.time_of_day())==boost::date_time::invalid_time_label);
us_dst_local::local_is_dst(t3a.date(),t3a.time_of_day())==boost::date_time::invalid_time_label);
check("label on dst boundary invalid",
us_dst::local_is_dst(t3b.date(),t3b.time_of_day())==boost::date_time::invalid_time_label);
us_dst_local::local_is_dst(t3b.date(),t3b.time_of_day())==boost::date_time::invalid_time_label);
check("check if time is dst -- not",
us_dst::local_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst);
us_dst_local::local_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst);
check("check if time is dst -- yes",
us_dst::local_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_in_dst);
us_dst_local::local_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_in_dst);

check("check if time is dst -- not",
us_dst::local_is_dst(t6.date(),t6.time_of_day())==boost::date_time::is_in_dst);
us_dst_local::local_is_dst(t6.date(),t6.time_of_day())==boost::date_time::is_in_dst);
check("check if time is dst -- ambig",
us_dst::local_is_dst(t7.date(),t7.time_of_day())==boost::date_time::ambiguous);
us_dst_local::local_is_dst(t7.date(),t7.time_of_day())==boost::date_time::ambiguous);
check("check if time is dst -- ambig",
us_dst::local_is_dst(t8.date(),t8.time_of_day())==boost::date_time::ambiguous);
us_dst_local::local_is_dst(t8.date(),t8.time_of_day())==boost::date_time::ambiguous);
check("check if time is dst -- not",
us_dst::local_is_dst(t9.date(),t9.time_of_day())==boost::date_time::is_not_in_dst);
us_dst_local::local_is_dst(t9.date(),t9.time_of_day())==boost::date_time::is_not_in_dst);


//Now try a local without dst
Expand Down

0 comments on commit 21b9c4d

Please sign in to comment.