File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
Expand file tree Collapse file tree 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(
3232
3333 std::basic_string<unsigned int > value=
3434 unescape_wide_string (std::string (src, 2 , src.size ()-3 ));
35+ // the parser rejects empty character constants
36+ CHECK_RETURN (!value.empty ());
3537
3638 // L is wchar_t, u is char16_t, U is char32_t
3739 typet type=wchar_t_type ();
3840
39- if (value.empty ())
40- throw " empty wide character literal" ;
41- else if (value.size ()==1 )
41+ if (value.size () == 1 )
4242 {
4343 result=from_integer (value[0 ], type);
4444 }
@@ -69,10 +69,10 @@ exprt convert_character_literal(
6969
7070 std::string value=
7171 unescape_string (std::string (src, 1 , src.size ()-2 ));
72+ // the parser rejects empty character constants
73+ CHECK_RETURN (!value.empty ());
7274
73- if (value.empty ())
74- throw " empty character literal" ;
75- else if (value.size ()==1 )
75+ if (value.size () == 1 )
7676 {
7777 typet type=force_integer_type?signed_int_type ():char_type ();
7878 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)
9191
9292 // find start of sequence
9393 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);
9695
9796 // find end of sequence, considering escaping
9897 for (++j; j<src.size () && src[j]!=' "' ; ++j)
9998 if (src[j]==' \\ ' ) // skip next character
10099 ++j;
101100
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 + " '" );
105102
106103 std::string tmp_src=std::string (src, i, j-i+1 );
107104 std::basic_string<unsigned int > tmp_value=
You can’t perform that action at this time.
0 commit comments