From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [PATCH] Move class temp_source_file from input.c to selftest.c/h
Date: Wed, 10 Aug 2016 00:58:00 -0000 [thread overview]
Message-ID: <1470792402-8528-1-git-send-email-dmalcolm@redhat.com> (raw)
I have followup patches that use this class in selftests in various
places, so this patch moves it to selftest.h.
Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.
OK for trunk?
gcc/ChangeLog:
* input.c (class selftest::temp_source_file): Move to
selftest.h.
(selftest::temp_source_file::temp_source_file): Move to
selftest.c.
(selftest::temp_source_file::~temp_source_file): Likewise.
* selftest.c (selftest::temp_source_file::temp_source_file): Move
here from input.c.
(selftest::temp_source_file::~temp_source_file): Likewise.
* selftest.h (class selftest::temp_source_file): Move here from
input.c
---
gcc/input.c | 42 ------------------------------------------
gcc/selftest.c | 26 ++++++++++++++++++++++++++
gcc/selftest.h | 16 ++++++++++++++++
3 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/gcc/input.c b/gcc/input.c
index 790de93..0c5f817 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -1472,48 +1472,6 @@ namespace selftest {
/* Selftests of location handling. */
-/* A class for writing out a temporary sourcefile for use in selftests
- of input handling. */
-
-class temp_source_file
-{
- public:
- temp_source_file (const location &loc, const char *suffix,
- const char *content);
- ~temp_source_file ();
-
- const char *get_filename () const { return m_filename; }
-
- private:
- char *m_filename;
-};
-
-/* Constructor. Create a tempfile using SUFFIX, and write CONTENT to
- it. Abort if anything goes wrong, using LOC as the effective
- location in the problem report. */
-
-temp_source_file::temp_source_file (const location &loc, const char *suffix,
- const char *content)
-{
- m_filename = make_temp_file (suffix);
- ASSERT_NE (m_filename, NULL);
-
- FILE *out = fopen (m_filename, "w");
- if (!out)
- ::selftest::fail_formatted (loc, "unable to open tempfile: %s",
- m_filename);
- fprintf (out, "%s", content);
- fclose (out);
-}
-
-/* Destructor. Delete the tempfile. */
-
-temp_source_file::~temp_source_file ()
-{
- unlink (m_filename);
- free (m_filename);
-}
-
/* Helper function for verifying location data: when location_t
values are > LINE_MAP_MAX_LOCATION_WITH_COLS, they are treated
as having column 0. */
diff --git a/gcc/selftest.c b/gcc/selftest.c
index 2951c3c..0a7192e 100644
--- a/gcc/selftest.c
+++ b/gcc/selftest.c
@@ -87,6 +87,32 @@ selftest::assert_streq (const location &loc,
desc_expected, desc_actual, val_expected, val_actual);
}
+/* Constructor. Create a tempfile using SUFFIX, and write CONTENT to
+ it. Abort if anything goes wrong, using LOC as the effective
+ location in the problem report. */
+
+selftest::temp_source_file::temp_source_file (const location &loc,
+ const char *suffix,
+ const char *content)
+{
+ m_filename = make_temp_file (suffix);
+ ASSERT_NE (m_filename, NULL);
+
+ FILE *out = fopen (m_filename, "w");
+ if (!out)
+ ::selftest::fail_formatted (loc, "unable to open tempfile: %s",
+ m_filename);
+ fprintf (out, "%s", content);
+ fclose (out);
+}
+
+/* Destructor. Delete the tempfile. */
+
+selftest::temp_source_file::~temp_source_file ()
+{
+ unlink (m_filename);
+ free (m_filename);
+}
/* Selftests for the selftest system itself. */
diff --git a/gcc/selftest.h b/gcc/selftest.h
index 55601ef..72de61f 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -69,6 +69,22 @@ extern void assert_streq (const location &loc,
const char *desc_expected, const char *desc_actual,
const char *val_expected, const char *val_actual);
+/* A class for writing out a temporary sourcefile for use in selftests
+ of input handling. */
+
+class temp_source_file
+{
+ public:
+ temp_source_file (const location &loc, const char *suffix,
+ const char *content);
+ ~temp_source_file ();
+
+ const char *get_filename () const { return m_filename; }
+
+ private:
+ char *m_filename;
+};
+
/* Declarations for specific families of tests (by source file), in
alphabetical order. */
extern void bitmap_c_tests ();
--
1.8.5.3
next reply other threads:[~2016-08-10 0:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-10 0:58 David Malcolm [this message]
2016-08-16 16:17 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1470792402-8528-1-git-send-email-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).