tst-wmemstream5.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (C) 2021-2026 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <https://www.gnu.org/licenses/>. */
  14. #include <wchar.h>
  15. extern int fclose (FILE*);
  16. #if defined __GNUC__ && __GNUC__ >= 11
  17. /* Verify that calling fclose on the result of open_wmemstream doesn't
  18. trigger GCC -Wmismatched-dealloc with fclose forward-declared and
  19. without <stdio.h> included in the same translation unit. */
  20. #pragma GCC diagnostic push
  21. #pragma GCC diagnostic error "-Wmismatched-dealloc"
  22. #endif
  23. static int
  24. do_test (void)
  25. {
  26. {
  27. wchar_t *buf;
  28. size_t size;
  29. FILE *f = open_wmemstream (&buf, &size);
  30. fclose (f);
  31. }
  32. {
  33. FILE* (*pf)(wchar_t**, size_t*) = open_wmemstream;
  34. wchar_t *buf;
  35. size_t size;
  36. FILE *f = pf (&buf, &size);
  37. fclose (f);
  38. }
  39. return 0;
  40. }
  41. #if defined __GNUC__ && __GNUC__ >= 11
  42. /* Restore -Wmismatched-dealloc setting. */
  43. # pragma GCC diagnostic pop
  44. #endif
  45. #define TEST_FUNCTION do_test ()
  46. #include "../test-skeleton.c"