| 1 |
# Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with GCC; see the file COPYING3. If not see |
| 15 |
# <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
# Test the functionality of the GCC plugin support |
| 18 |
|
| 19 |
load_lib target-supports.exp |
| 20 |
load_lib g++-dg.exp |
| 21 |
|
| 22 |
global TESTING_IN_BUILD_TREE |
| 23 |
global ENABLE_PLUGIN |
| 24 |
|
| 25 |
# The plugin testcases currently only work when the build tree is available. |
| 26 |
# Also check whether the host supports plugins. |
| 27 |
if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } { |
| 28 |
return |
| 29 |
} |
| 30 |
|
| 31 |
# If a testcase doesn't have special options, use these. |
| 32 |
global DEFAULT_CXXFLAGS |
| 33 |
if ![info exists DEFAULT_CXXFLAGS] then { |
| 34 |
set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long" |
| 35 |
} |
| 36 |
|
| 37 |
# The procedures in plugin-support.exp need these parameters. |
| 38 |
set default_flags $DEFAULT_CXXFLAGS |
| 39 |
|
| 40 |
if $tracelevel then { |
| 41 |
strace $tracelevel |
| 42 |
} |
| 43 |
|
| 44 |
# Load support procs. |
| 45 |
load_lib plugin-support.exp |
| 46 |
|
| 47 |
# These tests don't run runtest_file_p consistently if it |
| 48 |
# doesn't return the same values, so disable parallelization |
| 49 |
# of this *.exp file. The first parallel runtest to reach |
| 50 |
# this will run all the tests serially. |
| 51 |
if ![gcc_parallel_test_run_p plugin] { |
| 52 |
return |
| 53 |
} |
| 54 |
gcc_parallel_test_enable 0 |
| 55 |
|
| 56 |
# Specify the plugin source file and the associated test files in a list. |
| 57 |
# plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } |
| 58 |
set plugin_test_list [list \ |
| 59 |
{ attribute_plugin.cc attribute_plugin-test-1.C } \ |
| 60 |
{ pragma_plugin.cc pragma_plugin-test-1.C } \ |
| 61 |
{ selfassign.cc self-assign-test-1.C self-assign-test-2.C self-assign-test-3.C } \ |
| 62 |
{ dumb_plugin.cc dumb-plugin-test-1.C } \ |
| 63 |
{ header_plugin.cc header-plugin-test.C } \ |
| 64 |
{ decl_plugin.cc decl-plugin-test.C } \ |
| 65 |
{ def_plugin.cc def-plugin-test.C } \ |
| 66 |
{ ../../gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.cc \ |
| 67 |
diagnostic-test-expressions-1.C } \ |
| 68 |
{ ../../gcc.dg/plugin/diagnostic_plugin_test_inlining.cc \ |
| 69 |
diagnostic-test-inlining-1.C } \ |
| 70 |
{ ../../gcc.dg/plugin/diagnostic_plugin_test_string_literals.cc \ |
| 71 |
../../gcc.dg/plugin/diagnostic-test-string-literals-1.c \ |
| 72 |
../../gcc.dg/plugin/diagnostic-test-string-literals-2.c \ |
| 73 |
../../gcc.dg/plugin/diagnostic-test-string-literals-3.c \ |
| 74 |
../../gcc.dg/plugin/diagnostic-test-string-literals-4.c } \ |
| 75 |
{ ../../gcc.dg/plugin/location_overflow_plugin.cc \ |
| 76 |
location-overflow-test-pr96391.c \ |
| 77 |
location-overflow-test-pr100796.c } \ |
| 78 |
{ show_template_tree_color_plugin.cc \ |
| 79 |
show-template-tree-color.C \ |
| 80 |
show-template-tree-color-no-highlight-colors.C \ |
| 81 |
show-template-tree-color-labels.C \ |
| 82 |
show-template-tree-color-no-elide-type.C } \ |
| 83 |
{ comment_plugin.cc comments-1.C } \ |
| 84 |
] |
| 85 |
|
| 86 |
foreach plugin_test $plugin_test_list { |
| 87 |
# Replace each source file with its full-path name |
| 88 |
for {set i 0} {$i < [llength $plugin_test]} {incr i} { |
| 89 |
set basename [lindex $plugin_test $i] |
| 90 |
set plugin_test [lreplace $plugin_test $i $i $srcdir/$subdir/$basename] |
| 91 |
} |
| 92 |
set plugin_src [lindex $plugin_test 0] |
| 93 |
# If we're only testing specific files and this isn't one of them, skip it. |
| 94 |
if ![runtest_file_p $runtests $plugin_src] then { |
| 95 |
continue |
| 96 |
} |
| 97 |
set plugin_input_tests [lreplace $plugin_test 0 0] |
| 98 |
plugin-test-execute $plugin_src $plugin_input_tests |
| 99 |
} |
| 100 |
|
| 101 |
gcc_parallel_test_enable 1 |