comparison libcpp/charset.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* CPP Library - charsets 1 /* CPP Library - charsets
2 Copyright (C) 1998-2017 Free Software Foundation, Inc. 2 Copyright (C) 1998-2018 Free Software Foundation, Inc.
3 3
4 Broken out of c-lex.c Apr 2003, adding valid C99 UCN ranges. 4 Broken out of c-lex.c Apr 2003, adding valid C99 UCN ranges.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
1691 cpp_string *to, enum cpp_ttype type) 1691 cpp_string *to, enum cpp_ttype type)
1692 { 1692 {
1693 return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL); 1693 return cpp_interpret_string_1 (pfile, from, count, to, type, NULL, NULL);
1694 } 1694 }
1695 1695
1696 /* A "do nothing" error-handling callback for use by 1696 /* A "do nothing" diagnostic-handling callback for use by
1697 cpp_interpret_string_ranges, so that it can temporarily suppress 1697 cpp_interpret_string_ranges, so that it can temporarily suppress
1698 error-handling. */ 1698 diagnostic-handling. */
1699 1699
1700 static bool 1700 static bool
1701 noop_error_cb (cpp_reader *, int, int, rich_location *, 1701 noop_diagnostic_cb (cpp_reader *, enum cpp_diagnostic_level,
1702 const char *, va_list *) 1702 enum cpp_warning_reason, rich_location *,
1703 const char *, va_list *)
1703 { 1704 {
1704 /* no-op. */ 1705 /* no-op. */
1705 return true; 1706 return true;
1706 } 1707 }
1707 1708
1735 struct cset_converter cvt = converter_for_type (pfile, type); 1736 struct cset_converter cvt = converter_for_type (pfile, type);
1736 if (cvt.func != convert_no_conversion) 1737 if (cvt.func != convert_no_conversion)
1737 return "execution character set != source character set"; 1738 return "execution character set != source character set";
1738 1739
1739 /* For on-demand strings we have already lexed the strings, so there 1740 /* For on-demand strings we have already lexed the strings, so there
1740 should be no errors. However, if we have bogus source location 1741 should be no diagnostics. However, if we have bogus source location
1741 data (or stringified macro arguments), the attempt to lex the 1742 data (or stringified macro arguments), the attempt to lex the
1742 strings could fail with an error. Temporarily install an 1743 strings could fail with an diagnostic. Temporarily install an
1743 error-handler to catch the error, so that it can lead to this call 1744 diagnostic-handler to catch the diagnostic, so that it can lead to this call
1744 failing, rather than being emitted as a user-visible diagnostic. 1745 failing, rather than being emitted as a user-visible diagnostic.
1745 If an error does occur, we should see it via the return value of 1746 If an diagnostic does occur, we should see it via the return value of
1746 cpp_interpret_string_1. */ 1747 cpp_interpret_string_1. */
1747 bool (*saved_error_handler) (cpp_reader *, int, int, rich_location *, 1748 bool (*saved_diagnostic_handler) (cpp_reader *, enum cpp_diagnostic_level,
1748 const char *, va_list *) 1749 enum cpp_warning_reason, rich_location *,
1750 const char *, va_list *)
1749 ATTRIBUTE_FPTR_PRINTF(5,0); 1751 ATTRIBUTE_FPTR_PRINTF(5,0);
1750 1752
1751 saved_error_handler = pfile->cb.error; 1753 saved_diagnostic_handler = pfile->cb.diagnostic;
1752 pfile->cb.error = noop_error_cb; 1754 pfile->cb.diagnostic = noop_diagnostic_cb;
1753 1755
1754 bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type, 1756 bool result = cpp_interpret_string_1 (pfile, from, count, NULL, type,
1755 loc_readers, out); 1757 loc_readers, out);
1756 1758
1757 /* Restore the saved error-handler. */ 1759 /* Restore the saved diagnostic-handler. */
1758 pfile->cb.error = saved_error_handler; 1760 pfile->cb.diagnostic = saved_diagnostic_handler;
1759 1761
1760 if (!result) 1762 if (!result)
1761 return "cpp_interpret_string_1 failed"; 1763 return "cpp_interpret_string_1 failed";
1762 1764
1763 /* Success. */ 1765 /* Success. */