Move class temp_source_file from input.c to selftest.c/h
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 16 Aug 2016 18:02:43 +0000 (18:02 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 16 Aug 2016 18:02:43 +0000 (18:02 +0000)
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

From-SVN: r239509

gcc/ChangeLog
gcc/input.c
gcc/selftest.c
gcc/selftest.h

index b99c745c795eedd0c1a57bfe0ef97cbb81b54936..dab437d3906352c1b8ec4d610d2d0b9fd6866db2 100644 (file)
@@ -1,3 +1,16 @@
+2016-08-16  David Malcolm  <dmalcolm@redhat.com>
+
+       * 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
+
 2016-08-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/71910
index 790de936bacfba9f833355eac9bae125df30cb7e..0c5f817e83a52cbd8c3f812f6dc4d8773b6d1a2d 100644 (file)
@@ -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.  */
index 2951c3c9bb8ddd102c33c19d1f1c430e0e87d40c..0a7192efe460b41c6de30c8096e803093eca8432 100644 (file)
@@ -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.  */
 
index 55601efc9f1ae78526c6a4f90123c1d5210cf781..72de61f620e8227ba8220bd395d5fcc33e0ba663 100644 (file)
@@ -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 ();