On 06/22/2017 06:20 PM, David Malcolm wrote:
> Currently the "make selftest" target run during each stage of the
> build just runs the selftests within cc1.
>
> As part of the fix for PR c++/81167 I want to be able to write
> C++-specific selftests (to exercise the C++ implementation of
> the pp's format_decoder).
>
> Hence this patch generalizes the existing selftest logic in
> Makefile.in so that selftests are run for both cc1 and cc1plus.
> It also adds convenience methods for running them under
> gdb and under valgrind.
>
> It also reorganizes the existing lang-specific selftests, splitting
> them into ones shared by c-family, and those that are specific
> to individual members of the c family. There aren't any of the
> latter yet, but the followup adds some for C++.
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu in
> combination with the followup patch; the number of reported passes
> from -fself-test for cc1 at each stage was unaffected by the kit:
> -fself-test: 39233 pass(es),
> and cc1plus gained a similar line of output.
>
> OK for trunk?
>
> gcc/ChangeLog:
> * Makefile.in (SELFTEST_FLAGS): Drop "-x c", moving it to...
> (C_SELFTEST_FLAGS): New.
> (CPP_SELFTEST_FLAGS): New.
> (SELFTEST_DEPS): New, from deps of s-selftest.
> (C_SELFTEST_DEPS): New, from deps of s-selftest.
> (CPP_SELFTEST_DEPS): New.
> (selftest): Add dependency on s-selftest-c++.
> (s-selftest): Rename to...
> (s-selftest-c): ...this, moving deps to SELFTEST_DEPS
> and C_SELFTEST_DEPS, and using C_SELFTEST_FLAGS rather
> than SELFTEST_FLAGS.
> (selftest-gdb): Rename to...
> (selftest-c-gdb): ...this, using C_SELFTEST_DEPS and
> C_SELFTEST_FLAGS.
> (selftest-gdb): Reintroduce as an alias for selftest-c-gdb.
> (selftest-valgrind): Rename to...
> (selftest-c-valgrind): ...this, using C_SELFTEST_DEPS and
> C_SELFTEST_FLAGS.
> (selftest-valgrind): Reintroduce as an alias for
> selftest-c-valgrind.
> (s-selftest-c++): New.
> (selftest-c++-gdb): New.
> (selftest-c++-valgrind): New.
>
> gcc/c-family/ChangeLog:
> * c-common.c (selftest::c_family_tests): New.
> * c-common.h (selftest::run_c_tests): Move decl to c/c-lang.h.
> (selftest::c_family_tests): New decl.
>
> gcc/c/ChangeLog:
> * c-lang.c (selftest::run_c_tests): Move body to c_family_tests,
> and call that instead.
> * c-tree.h (selftest::run_c_tests): New decl.
>
> gcc/cp/ChangeLog:
> * cp-lang.c (LANG_HOOKS_RUN_LANG_SELFTESTS): Define as
> selftest::run_cp_tests.
> (selftest::run_cp_tests): New function.
> * cp-tree.h (selftest::run_cp_tests): New decl.
OK.
jeff