1 // { dg-do compile { target correct_iso_cpp_string_wchar_protos } }
2 // { dg-options "-O2" }
3 
4 // Copyright (C) 2009-2018 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3.  If not see
19 // <http://www.gnu.org/licenses/>.
20 
21 #include <cwchar>
22 
23 const wchar_t *cw1, *cw2;
24 wchar_t *w1, *w2;
25 
26 void
test01()27 test01 ()
28 {
29   w1 = wmemchr (w2, L'/', 3);
30   w1 = wcschr (w2, L'/');
31   w1 = wcspbrk (w2, L"abc");
32   w1 = wcsrchr (w2, L'c');
33   w1 = wcsstr (w2, L"abc");
34 
35   cw1 = wmemchr (w2, L'/', 3);
36   cw1 = wcschr (w2, L'/');
37   cw1 = wcspbrk (w2, L"abc");
38   cw1 = wcsrchr (w2, L'c');
39   cw1 = wcsstr (w2, L"abc");
40 
41   w1 = wmemchr (cw2, L'/', 3);		// { dg-error "invalid conversion" }
42   w1 = wcschr (cw2, L'/');		// { dg-error "invalid conversion" }
43   w1 = wcsrchr (cw2, L'c');		// { dg-error "invalid conversion" }
44   w1 = wcspbrk (cw2, L"abc");		// { dg-error "invalid conversion" }
45   w1 = wcsstr (cw2, L"abc");		// { dg-error "invalid conversion" }
46 
47   cw1 = wmemchr (cw2, L'/', 3);
48   cw1 = wcschr (cw2, L'/');
49   cw1 = wcspbrk (cw2, L"abc");
50   cw1 = wcsrchr (cw2, L'c');
51   cw1 = wcsstr (cw2, L"abc");
52 }
53