Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
252f11f8
Commit
252f11f8
authored
Jun 04, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a bogus MSVC warning about unreachable code, take 2
parent
81d56638
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
include/fmt/core.h
include/fmt/core.h
+2
-2
include/fmt/format.h
include/fmt/format.h
+27
-6
No files found.
include/fmt/core.h
View file @
252f11f8
...
@@ -740,8 +740,8 @@ class basic_parse_context : private ErrorHandler {
...
@@ -740,8 +740,8 @@ class basic_parse_context : private ErrorHandler {
FMT_CONSTEXPR
bool
check_arg_id
(
unsigned
)
{
FMT_CONSTEXPR
bool
check_arg_id
(
unsigned
)
{
if
(
next_arg_id_
>
0
)
{
if
(
next_arg_id_
>
0
)
{
return
on_error
(
on_error
(
"cannot switch from automatic to manual argument indexing"
);
"cannot switch from automatic to manual argument indexing"
),
false
;
return
false
;
}
}
next_arg_id_
=
-
1
;
next_arg_id_
=
-
1
;
return
true
;
return
true
;
...
...
include/fmt/format.h
View file @
252f11f8
...
@@ -98,7 +98,23 @@
...
@@ -98,7 +98,23 @@
#ifndef FMT_THROW
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# if FMT_EXCEPTIONS
# define FMT_THROW(x) throw x
# if FMT_MSC_VER
FMT_BEGIN_NAMESPACE
namespace
internal
{
template
<
typename
Exception
>
inline
void
do_throw
(
const
Exception
&
x
)
{
// Silence unreachable code warnings in MSVC because these are nearly
// impossible to fix in a generic code.
volatile
bool
b
=
true
;
if
(
b
)
throw
x
;
}
}
FMT_END_NAMESPACE
# define FMT_THROW(x) fmt::internal::do_throw(x)
# else
# define FMT_THROW(x) throw x
# endif
# else
# else
# define FMT_THROW(x) assert(false)
# define FMT_THROW(x) assert(false)
# endif
# endif
...
@@ -1322,7 +1338,8 @@ template <typename Char, typename ErrorHandler>
...
@@ -1322,7 +1338,8 @@ template <typename Char, typename ErrorHandler>
FMT_CONSTEXPR
unsigned
basic_parse_context
<
Char
,
ErrorHandler
>::
next_arg_id
()
{
FMT_CONSTEXPR
unsigned
basic_parse_context
<
Char
,
ErrorHandler
>::
next_arg_id
()
{
if
(
next_arg_id_
>=
0
)
if
(
next_arg_id_
>=
0
)
return
internal
::
to_unsigned
(
next_arg_id_
++
);
return
internal
::
to_unsigned
(
next_arg_id_
++
);
return
on_error
(
"cannot switch from manual to automatic argument indexing"
),
0
;
on_error
(
"cannot switch from manual to automatic argument indexing"
);
return
0
;
}
}
struct
format_string
{};
struct
format_string
{};
...
@@ -1702,7 +1719,8 @@ class width_checker: public function<unsigned long long> {
...
@@ -1702,7 +1719,8 @@ class width_checker: public function<unsigned long long> {
template
<
typename
T
>
template
<
typename
T
>
FMT_CONSTEXPR
typename
std
::
enable_if
<
FMT_CONSTEXPR
typename
std
::
enable_if
<
!
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
)
{
!
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
)
{
return
handler_
.
on_error
(
"width is not integer"
),
0
;
handler_
.
on_error
(
"width is not integer"
);
return
0
;
}
}
private:
private:
...
@@ -1725,7 +1743,8 @@ class precision_checker: public function<unsigned long long> {
...
@@ -1725,7 +1743,8 @@ class precision_checker: public function<unsigned long long> {
template
<
typename
T
>
template
<
typename
T
>
FMT_CONSTEXPR
typename
std
::
enable_if
<
FMT_CONSTEXPR
typename
std
::
enable_if
<
!
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
)
{
!
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
)
{
return
handler_
.
on_error
(
"precision is not integer"
),
0
;
handler_
.
on_error
(
"precision is not integer"
);
return
0
;
}
}
private:
private:
...
@@ -2056,8 +2075,10 @@ FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) {
...
@@ -2056,8 +2075,10 @@ FMT_CONSTEXPR Iterator parse_format_specs(Iterator it, SpecHandler &&handler) {
}
}
if
(
align
!=
ALIGN_DEFAULT
)
{
if
(
align
!=
ALIGN_DEFAULT
)
{
if
(
p
!=
it
)
{
if
(
p
!=
it
)
{
if
(
c
==
'{'
)
if
(
c
==
'{'
)
{
return
handler
.
on_error
(
"invalid fill character '{'"
),
it
;
handler
.
on_error
(
"invalid fill character '{'"
);
return
it
;
}
it
+=
2
;
it
+=
2
;
handler
.
on_fill
(
c
);
handler
.
on_fill
(
c
);
}
else
++
it
;
}
else
++
it
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment