@@ -3125,6 +3125,43 @@ static void preprocess_files()
3125
3125
}
3126
3126
}
3127
3127
3128
+ static void safe_api ()
3129
+ {
3130
+ #if defined(__cpp_lib_string_view) || defined(__cpp_lib_span)
3131
+ std::vector<std::string> filenames;
3132
+ # if defined(__cpp_lib_string_view)
3133
+ {
3134
+ const char input[] = " code" ;
3135
+ const std::string_view sv = input;
3136
+ // std::string_view can be implicitly converted into a std::span
3137
+ simplecpp::TokenList (sv,filenames," " );
3138
+ }
3139
+ # endif
3140
+ # ifdef __cpp_lib_span
3141
+ {
3142
+ char input[] = " code" ;
3143
+ const std::span<char , 5 > sp = input;
3144
+ simplecpp::TokenList (sp,filenames," " );
3145
+ }
3146
+ {
3147
+ const char input[] = " code" ;
3148
+ const std::span<const char , 5 > sp = input;
3149
+ simplecpp::TokenList (sp,filenames," " );
3150
+ }
3151
+ {
3152
+ unsigned char input[] = " code" ;
3153
+ const std::span<unsigned char , 5 > sp = input;
3154
+ simplecpp::TokenList (sp,filenames," " );
3155
+ }
3156
+ {
3157
+ const unsigned char input[] = " code" ;
3158
+ const std::span<const unsigned char , 5 > sp = input;
3159
+ simplecpp::TokenList (sp,filenames," " );
3160
+ }
3161
+ # endif
3162
+ #endif
3163
+ }
3164
+
3128
3165
static void fuzz_crash ()
3129
3166
{
3130
3167
{
@@ -3390,6 +3427,8 @@ int main(int argc, char **argv)
3390
3427
3391
3428
TEST_CASE (preprocess_files);
3392
3429
3430
+ TEST_CASE (safe_api);
3431
+
3393
3432
TEST_CASE (fuzz_crash);
3394
3433
3395
3434
return numberOfFailedAssertions > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
0 commit comments