File tree 2 files changed +8
-11
lines changed
2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,13 @@ exprt convert_character_literal(
32
32
33
33
std::basic_string<unsigned int > value=
34
34
unescape_wide_string (std::string (src, 2 , src.size ()-3 ));
35
+ // the parser rejects empty character constants
36
+ CHECK_RETURN (!value.empty ());
35
37
36
38
// L is wchar_t, u is char16_t, U is char32_t
37
39
typet type=wchar_t_type ();
38
40
39
- if (value.empty ())
40
- throw " empty wide character literal" ;
41
- else if (value.size ()==1 )
41
+ if (value.size () == 1 )
42
42
{
43
43
result=from_integer (value[0 ], type);
44
44
}
@@ -69,10 +69,10 @@ exprt convert_character_literal(
69
69
70
70
std::string value=
71
71
unescape_string (std::string (src, 1 , src.size ()-2 ));
72
+ // the parser rejects empty character constants
73
+ CHECK_RETURN (!value.empty ());
72
74
73
- if (value.empty ())
74
- throw " empty character literal" ;
75
- else if (value.size ()==1 )
75
+ if (value.size () == 1 )
76
76
{
77
77
typet type=force_integer_type?signed_int_type ():char_type ();
78
78
result=from_integer (value[0 ], type);
Original file line number Diff line number Diff line change @@ -91,17 +91,14 @@ exprt convert_string_literal(const std::string &src)
91
91
92
92
// find start of sequence
93
93
std::size_t j=src.find (' "' , i);
94
- if (j==std::string::npos)
95
- throw " invalid string constant '" + src + " '" ;
94
+ CHECK_RETURN (j != std::string::npos);
96
95
97
96
// find end of sequence, considering escaping
98
97
for (++j; j<src.size () && src[j]!=' "' ; ++j)
99
98
if (src[j]==' \\ ' ) // skip next character
100
99
++j;
101
100
102
- assert (j<=src.size ());
103
- if (j==src.size ())
104
- throw " non-terminated string constant '" + src + " '" ;
101
+ INVARIANT (j < src.size (), " non-terminated string constant '" + src + " '" );
105
102
106
103
std::string tmp_src=std::string (src, i, j-i+1 );
107
104
std::basic_string<unsigned int > tmp_value=
You can’t perform that action at this time.
0 commit comments