diff options
Diffstat (limited to 'gcc/testsuite')
97 files changed, 2719 insertions, 29 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4551e2d..b2ebcef 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,147 @@ +2025-05-06 Dongyan Chen <chendongyan@isrc.iscas.ac.cn> + + * gcc.target/riscv/arch-47.c: New test. + +2025-05-06 Mingzhu Yan <yanmingzhu@iscas.ac.cn> + + * gcc.target/riscv/arch-45.c: New test. + * gcc.target/riscv/arch-46.c: New test. + +2025-05-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> + + PR fortran/120049 + * gfortran.dg/pr120049_a.f90: New test. + * gfortran.dg/pr120049_b.f90: New test. + +2025-05-06 Thomas Koenig <tkoenig@gcc.gnu.org> + + PR fortran/119928 + * gfortran.dg/interface_60.f90: New test. + +2025-05-06 Martin Jambor <mjambor@suse.cz> + + PR ipa/119852 + * gcc.dg/ipa/pr119852.c: New test. + +2025-05-06 David Malcolm <dmalcolm@redhat.com> + + PR sarif-replay/117988 + * sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif: Add + expected logical location. + * sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif: + Likewise. + * sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif: + Likewise. + * sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif: Likewise. + * sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif: Likewise. + * sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif: Likewise. + +2025-05-06 David Malcolm <dmalcolm@redhat.com> + + * libgdiagnostics.dg/test-nested-logical-locations-json-c.py: New test. + * libgdiagnostics.dg/test-nested-logical-locations-json.c: New test. + * sarif-replay.dg/2.1.0-valid/3.33.7-json-example.sarif: New test. + * sarif-replay.dg/2.1.0-valid/3.33.7-xml-example.sarif: New test. + +2025-05-06 David Malcolm <dmalcolm@redhat.com> + + PR other/116176 + * g++.dg/sarif-output/logical-locations-1.C: New test. + * g++.dg/sarif-output/logical-locations-1.py: New test script. + * g++.dg/sarif-output/logical-locations-2.C: New test. + * g++.dg/sarif-output/logical-locations-2.py: New test script. + * g++.dg/sarif-output/logical-locations-3.C: New test. + * g++.dg/sarif-output/logical-locations-3.py: New test script. + * g++.dg/sarif-output/sarif-output.exp: New script, adapted + from gcc.dg/sarif-output/sarif-output.exp. + * libgdiagnostics.dg/test-logical-location-c.py: Update for using + theRun.logicalLocations. + * libgdiagnostics.dg/test-warning-with-path-c.py: Likewise. + +2025-05-06 David Malcolm <dmalcolm@redhat.com> + + * gcc.dg/plugin/diagnostic_plugin_test_paths.cc: Update for + changes to simple_diagnostic_path. + +2025-05-06 David Malcolm <dmalcolm@redhat.com> + + * libgdiagnostics.dg/test-logical-location.c: Include + <string.h>. + (main): Verify that the accessors work. + * libgdiagnostics.dg/test-logical-location.cc: New test. + +2025-05-06 Shreya Munnangi <smunnangi1@ventanamicro.com> + + PR middle-end/114512 + * gcc.target/riscv/pr114512.c: New test. + +2025-05-06 Pan Li <pan2.li@intel.com> + + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i8.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u8.c: New test. + +2025-05-06 Pan Li <pan2.li@intel.com> + + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i8.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u8.c: New test. + +2025-05-06 Pan Li <pan2.li@intel.com> + + * gcc.target/riscv/rvv/rvv.exp: Add new folder vx_vf for all + vec_dup + vv to vx testcases. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_run.h: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i8.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u8.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i8.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u16.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u32.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u64.c: New test. + * gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u8.c: New test. + +2025-05-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/1157777 + * gcc.dg/vect/bb-slp-pr115777.c: New testcase. + +2025-05-06 Jakub Jelinek <jakub@redhat.com> + + PR tree-optimization/120074 + * gcc.dg/pr120074.c: New test. + +2025-05-06 Richard Biener <rguenther@suse.de> + + PR tree-optimization/120031 + * gcc.target/i386/pr120031.c: New testcase. + 2025-05-05 Jeff Law <jlaw@ventanamicro.com> PR target/119971 diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.C b/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.C new file mode 100644 index 0000000..75ad3b4 --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.C @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-format=sarif-file" } */ + +/* Verify that we can capture the chain of parents of a + logical location (PR 116176). */ + +namespace ns { + class foo + { + void bar () + { + return 0; + } + }; +} + +/* We expect a failing compile due to the error, but the use of + -fdiagnostics-format=sarif-file means there should be no output to stderr. + DejaGnu injects this message; ignore it: + { dg-prune-output "exit status is 1" } */ + +/* Verify that some JSON was written to a file with the expected name: + { dg-final { verify-sarif-file } } */ + +/* Use a Python script to verify various properties about the generated + .sarif file: + { dg-final { run-sarif-pytest logical-locations-1.C "logical-locations-1.py" } } */ diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.py b/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.py new file mode 100644 index 0000000..954f6df --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-1.py @@ -0,0 +1,79 @@ +from sarif import * + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def sarif(): + return sarif_from_env() + +expected_filename = 'logical-locations-1.C' + +def test_result(sarif): + runs = sarif['runs'] + run = runs[0] + results = run['results'] + + # The textual form of the diagnostic would look like this: + # . PATH/logical-locations-1.C: In member function ‘void ns::foo::bar()’: + # . PATH/logical-locations-1.C:12:14: error: return-statement with a value, in function returning ‘void’ [-fpermissive] + # . 12 | return 0; + # . | ^ + assert len(results) == 1 + + result = results[0] + assert result['ruleId'] == '-fpermissive' + assert result['level'] == 'error' + assert result['message']['text'] \ + == "return-statement with a value, in function returning 'void'" + + locations = result['locations'] + assert len(locations) == 1 + + location = locations[0] + assert get_location_artifact_uri(location).endswith(expected_filename) + assert get_location_snippet_text(location) == ' return 0;\n' + +def test_logical_locations(sarif): + runs = sarif['runs'] + run = runs[0] + + # We expect 3 logical locations within the run: + assert len(run['logicalLocations']) == 3 + + assert run['logicalLocations'][0] \ + == {"name": "ns", + "fullyQualifiedName": "ns", + "kind": "namespace", + "index": 0} + assert run['logicalLocations'][1] \ + == {"name": "foo", + # Ideally we'd also have: + # "fullyQualifiedName": "ns::foo", + "kind": "type", + "parentIndex": 0, + "index": 1} + assert run['logicalLocations'][2] \ + == {"name": "bar", + "fullyQualifiedName": "ns::foo::bar", + "decoratedName": "_ZN2ns3foo3barEv", + "kind": "function", + "parentIndex": 1, + "index": 2} + + results = run['results'] + + assert len(results) == 1 + + result = results[0] + + locations = result['locations'] + assert len(locations) == 1 + + location = locations[0] + + # We expect one logical location within the result, referencing + # one in the run + assert len(location['logicalLocations']) == 1 + assert location['logicalLocations'][0] \ + == {'fullyQualifiedName': 'ns::foo::bar', + 'index': 2} diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.C b/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.C new file mode 100644 index 0000000..67aa4c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.C @@ -0,0 +1,69 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-format=sarif-file" } */ + +/* Verify that we correctly consolidate logical locations + involving repeated diagnostics within a nested hierarchy + (PR 116176). */ + +namespace ns_outer { + namespace ns_inner_1 { + class klass_1 + { + void member_fn_1 () + { + return 0; + } + void member_fn_2 () + { + return 0; + } + }; + class klass_2 + { + void member_fn_1 () + { + return 0; + } + void member_fn_2 () + { + return 0; + } + }; + } // ns_inner_1 + namespace ns_inner_2 { + class klass_1 + { + void member_fn_1 () + { + return 0; + } + void member_fn_2 () + { + return 0; + } + }; + class klass_2 + { + void member_fn_1 () + { + return 0; + } + void member_fn_2 () + { + return 0; + } + }; + } // ns_inner_2 +} // ns_outer + +/* We expect a failing compile due to the error, but the use of + -fdiagnostics-format=sarif-file means there should be no output to stderr. + DejaGnu injects this message; ignore it: + { dg-prune-output "exit status is 1" } */ + +/* Verify that some JSON was written to a file with the expected name: + { dg-final { verify-sarif-file } } */ + +/* Use a Python script to verify various properties about the generated + .sarif file: + { dg-final { run-sarif-pytest logical-locations-2.C "logical-locations-2.py" } } */ diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.py b/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.py new file mode 100644 index 0000000..e34531b --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-2.py @@ -0,0 +1,90 @@ +from sarif import * +from pprint import pprint + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def sarif(): + return sarif_from_env() + +expected_filename = 'logical-locations-2.C' + +def test_logical_locations(sarif): + runs = sarif['runs'] + run = runs[0] + + # We expect 15 logical locations within the run expressing + # a logical hierarchy, and 8 results with one logical locations + # in each, referencing back into the run. + + # Generate the "gold" output we expect. + expected_in_run = [] + expected_in_results = [] + + outer_ns_index_in_run = len(expected_in_run) + expected_in_run += [{"name": "ns_outer", + "fullyQualifiedName": "ns_outer", + "kind": "namespace", + "index": outer_ns_index_in_run}] + + for inner_ns in ['ns_inner_1', 'ns_inner_2']: + inner_ns_idx_in_run = len(expected_in_run) + expected_in_run += [{"name": inner_ns, + "fullyQualifiedName": f"ns_outer::{inner_ns}", + "kind": "namespace", + "index": inner_ns_idx_in_run, + "parentIndex": 0}] + for klass in ['klass_1', 'klass_2']: + klass_idx_in_run = len(expected_in_run) + expected_in_run += [{"name": klass, + "kind": "type", + "index": klass_idx_in_run, + "parentIndex": inner_ns_idx_in_run}] + for member_fn in ['member_fn_1', 'member_fn_2']: + fqn = f'ns_outer::{inner_ns}::{klass}::{member_fn}' + member_fn_idx_in_run = len(expected_in_run) + expected_in_run += [{"name": member_fn, + "kind": "function", + "fullyQualifiedName": f"ns_outer::{inner_ns}::{klass}::{member_fn}", + "decoratedName": f"_ZN8ns_outer10{inner_ns}7{klass}11{member_fn}Ev", + "index": member_fn_idx_in_run, + "parentIndex": klass_idx_in_run}] + expected_in_results += [{'fullyQualifiedName': fqn, + 'index': member_fn_idx_in_run}] + + pprint(expected_in_run) + pprint(expected_in_results) + assert len(expected_in_run) == 15 + assert len(expected_in_results) == 8 + + # We expect 15 logical locations within the run: + assert len(run['logicalLocations']) == len(expected_in_run) + for actual, expected in zip(run['logicalLocations'], expected_in_run): + assert actual == expected + + # We expect 8 results with one logical location in each + results = run['results'] + assert len(results) == len(expected_in_results) + + index = 0 + for inner_ns in ['ns_inner_1', 'ns_inner_2']: + for klass in ['klass_1', 'klass_2']: + for member_fn in ['member_fn_1', 'member_fn_2']: + result = results[index] + assert result['ruleId'] == '-fpermissive' + assert result['level'] == 'error' + assert result['message']['text'] \ + == "return-statement with a value, in function returning 'void'" + + locations = result['locations'] + assert len(locations) == 1 + + location = locations[0] + + # We expect one logical location within the result, referencing + # one in the run + assert len(location['logicalLocations']) == 1 + assert location['logicalLocations'][0] \ + == expected_in_results[index] + + index += 1 diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.C b/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.C new file mode 100644 index 0000000..59ed84a --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.C @@ -0,0 +1,85 @@ +/* { dg-do compile } */ +/* { dg-options "-fdiagnostics-format=sarif-file" } */ + +/* Verify that we handle deeply nested logical locations + (PR 116176). */ + +#define NS_OPEN(SUFFIX) namespace ns_##SUFFIX { +#define NS_CLOSE } + +#define NS_OPEN_10(SUFFIX) \ + NS_OPEN(SUFFIX##0) \ + NS_OPEN(SUFFIX##1) \ + NS_OPEN(SUFFIX##2) \ + NS_OPEN(SUFFIX##3) \ + NS_OPEN(SUFFIX##4) \ + NS_OPEN(SUFFIX##5) \ + NS_OPEN(SUFFIX##6) \ + NS_OPEN(SUFFIX##7) \ + NS_OPEN(SUFFIX##8) \ + NS_OPEN(SUFFIX##9) + +#define NS_CLOSE_10 \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE \ + NS_CLOSE + +#define NS_OPEN_100(SUFFIX) \ + NS_OPEN_10(SUFFIX##0) \ + NS_OPEN_10(SUFFIX##1) \ + NS_OPEN_10(SUFFIX##2) \ + NS_OPEN_10(SUFFIX##3) \ + NS_OPEN_10(SUFFIX##4) \ + NS_OPEN_10(SUFFIX##5) \ + NS_OPEN_10(SUFFIX##6) \ + NS_OPEN_10(SUFFIX##7) \ + NS_OPEN_10(SUFFIX##8) \ + NS_OPEN_10(SUFFIX##9) + +#define NS_CLOSE_100 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 \ + NS_CLOSE_10 + +#define NS_OPEN_200 \ + NS_OPEN_100(a) \ + NS_OPEN_100(b) + +#define NS_CLOSE_200 \ + NS_CLOSE_100 \ + NS_CLOSE_100 + +NS_OPEN_200 + +void return_from_void () +{ + return 0; +} + +NS_CLOSE_200 + +/* We expect a failing compile due to the error, but the use of + -fdiagnostics-format=sarif-file means there should be no output to stderr. + DejaGnu injects this message; ignore it: + { dg-prune-output "exit status is 1" } */ + +/* Verify that some JSON was written to a file with the expected name: + { dg-final { verify-sarif-file } } */ + +/* Use a Python script to verify various properties about the generated + .sarif file: + { dg-final { run-sarif-pytest logical-locations-3.C "logical-locations-3.py" } } */ diff --git a/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.py b/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.py new file mode 100644 index 0000000..199299c --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.py @@ -0,0 +1,61 @@ +from sarif import * +from pprint import pprint + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def sarif(): + return sarif_from_env() + +expected_filename = 'logical-locations-3.C' + +def test_logical_locations(sarif): + runs = sarif['runs'] + run = runs[0] + + # We expect a single error with this very long logical location: + # ../../src/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.C: In function ‘void ns_a00::ns_a01::ns_a02::ns_a03::ns_a04::ns_a05::ns_a06::ns_a07::ns_a08::ns_a09::ns_a10::ns_a11::ns_a12::ns_a13::ns_a14::ns_a15::ns_a16::ns_a17::ns_a18::ns_a19::ns_a20::ns_a21::ns_a22::ns_a23::ns_a24::ns_a25::ns_a26::ns_a27::ns_a28::ns_a29::ns_a30::ns_a31::ns_a32::ns_a33::ns_a34::ns_a35::ns_a36::ns_a37::ns_a38::ns_a39::ns_a40::ns_a41::ns_a42::ns_a43::ns_a44::ns_a45::ns_a46::ns_a47::ns_a48::ns_a49::ns_a50::ns_a51::ns_a52::ns_a53::ns_a54::ns_a55::ns_a56::ns_a57::ns_a58::ns_a59::ns_a60::ns_a61::ns_a62::ns_a63::ns_a64::ns_a65::ns_a66::ns_a67::ns_a68::ns_a69::ns_a70::ns_a71::ns_a72::ns_a73::ns_a74::ns_a75::ns_a76::ns_a77::ns_a78::ns_a79::ns_a80::ns_a81::ns_a82::ns_a83::ns_a84::ns_a85::ns_a86::ns_a87::ns_a88::ns_a89::ns_a90::ns_a91::ns_a92::ns_a93::ns_a94::ns_a95::ns_a96::ns_a97::ns_a98::ns_a99::ns_b00::ns_b01::ns_b02::ns_b03::ns_b04::ns_b05::ns_b06::ns_b07::ns_b08::ns_b09::ns_b10::ns_b11::ns_b12::ns_b13::ns_b14::ns_b15::ns_b16::ns_b17::ns_b18::ns_b19::ns_b20::ns_b21::ns_b22::ns_b23::ns_b24::ns_b25::ns_b26::ns_b27::ns_b28::ns_b29::ns_b30::ns_b31::ns_b32::ns_b33::ns_b34::ns_b35::ns_b36::ns_b37::ns_b38::ns_b39::ns_b40::ns_b41::ns_b42::ns_b43::ns_b44::ns_b45::ns_b46::ns_b47::ns_b48::ns_b49::ns_b50::ns_b51::ns_b52::ns_b53::ns_b54::ns_b55::ns_b56::ns_b57::ns_b58::ns_b59::ns_b60::ns_b61::ns_b62::ns_b63::ns_b64::ns_b65::ns_b66::ns_b67::ns_b68::ns_b69::ns_b70::ns_b71::ns_b72::ns_b73::ns_b74::ns_b75::ns_b76::ns_b77::ns_b78::ns_b79::ns_b80::ns_b81::ns_b82::ns_b83::ns_b84::ns_b85::ns_b86::ns_b87::ns_b88::ns_b89::ns_b90::ns_b91::ns_b92::ns_b93::ns_b94::ns_b95::ns_b96::ns_b97::ns_b98::ns_b99::return_from_void()’: + # ../../src/gcc/testsuite/g++.dg/sarif-output/logical-locations-3.C:70:10: error: return-statement with a value, in function returning ‘void’ [-fpermissive] + # 70 | return 0; + # | ^ + + # We expect 201 logical locations within the run expressing + # the logical hierarchy: the 200 nested namespaces, and then + # the function within the innermost namespace. + assert len(run['logicalLocations']) == 201 + + outermost = run['logicalLocations'][0] + assert outermost == {'fullyQualifiedName': 'ns_a00', + 'index': 0, + 'kind': 'namespace', + 'name': 'ns_a00'} + + for i in range(1, 200): + ns_i = run['logicalLocations'][i] + assert ns_i['index'] == i + assert ns_i['kind'] == 'namespace' + assert ns_i['parentIndex'] == i - 1 + expected_name = 'ns_' + 'ab'[i // 100] + '%02i' % (i % 100) + assert ns_i['name'] == expected_name + assert ns_i['fullyQualifiedName'] \ + == run['logicalLocations'][i - 1]['fullyQualifiedName'] + "::" + expected_name + + innermost = run['logicalLocations'][200] + assert innermost['index'] == 200 + assert innermost['kind'] == 'function' + assert innermost['name'] == 'return_from_void' + assert innermost['parentIndex'] == 199 + assert innermost['fullyQualifiedName'] \ + == run['logicalLocations'][199]['fullyQualifiedName'] + '::return_from_void' + + # We expect 1 error in the run, referring to the innermost + # logical location by index within the run's logical locations + results = run['results'] + assert len(results) == 1 + result = results[0] + assert len(result['locations']) == 1 + assert len(result['locations'][0]['logicalLocations']) == 1 + assert result['locations'][0]['logicalLocations'][0]['index'] \ + == innermost['index'] + assert result['locations'][0]['logicalLocations'][0]['fullyQualifiedName'] \ + == innermost['fullyQualifiedName'] diff --git a/gcc/testsuite/g++.dg/sarif-output/sarif-output.exp b/gcc/testsuite/g++.dg/sarif-output/sarif-output.exp new file mode 100644 index 0000000..20b2845 --- /dev/null +++ b/gcc/testsuite/g++.dg/sarif-output/sarif-output.exp @@ -0,0 +1,31 @@ +# Copyright (C) 2012-2025 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib g++-dg.exp + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] "" "" + +# All done. +dg-finish diff --git a/gcc/testsuite/g++.target/i386/pr120036.C b/gcc/testsuite/g++.target/i386/pr120036.C new file mode 100644 index 0000000..a2fc24f --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr120036.C @@ -0,0 +1,113 @@ +/* { dg-do compile { target fpic } } */ +/* { dg-options "-O2 -std=c++11 -march=sapphirerapids -fPIC" } */ + +typedef _Float16 Native; +struct float16_t +{ + Native native; + float16_t (); + float16_t (Native arg) : native (arg) {} + operator Native (); + float16_t + operator+ (float16_t rhs) + { + return native + rhs.native; + } + float16_t + operator* (float16_t) + { + return native * native; + } +}; +template <int N> struct Simd +{ + static constexpr int kPrivateLanes = N; +}; +template <int N> struct ClampNAndPow2 +{ + using type = Simd<N>; +}; +template <int kLimit> struct CappedTagChecker +{ + static constexpr int N = sizeof (int) ? kLimit : 0; + using type = typename ClampNAndPow2<N>::type; +}; +template <typename, int kLimit, int> +using CappedTag = typename CappedTagChecker<kLimit>::type; +template <class D> +int +Lanes (D) +{ + return D::kPrivateLanes; +} +template <class D> int Zero (D); +template <class D> using VFromD = decltype (Zero (D ())); +struct Vec512 +{ + __attribute__ ((__vector_size__ (16))) _Float16 raw; +}; +Vec512 Zero (Simd<2>); +template <class D> void ReduceSum (D, VFromD<D>); +struct Dot +{ + template <int, class D, typename T> + static T + Compute (D d, T *pa, int num_elements) + { + T *pb; + int N = Lanes (d), i = 0; + if (__builtin_expect (num_elements < N, 0)) + { + T sum0 = 0, sum1 = 0; + for (; i + 2 <= num_elements; i += 2) + { + float16_t __trans_tmp_6 = pa[i] * pb[i], + __trans_tmp_5 = sum0 + __trans_tmp_6, + __trans_tmp_8 = pa[i + 1] * pb[1], + __trans_tmp_7 = sum1 + __trans_tmp_8; + sum0 = __trans_tmp_5; + sum1 = __trans_tmp_7; + } + float16_t __trans_tmp_9 = sum0 + sum1; + return __trans_tmp_9; + } + decltype (Zero (d)) sum0; + ReduceSum (d, sum0); + __builtin_trap (); + } +}; +template <int kMul, class Test, int kPow2> struct ForeachCappedR +{ + static void + Do (int min_lanes, int max_lanes) + { + CappedTag<int, kMul, kPow2> d; + Test () (int (), d); + ForeachCappedR<kMul / 2, Test, kPow2>::Do (min_lanes, max_lanes); + } +}; +template <class Test, int kPow2> struct ForeachCappedR<0, Test, kPow2> +{ + static void Do (int, int); +}; +struct TestDot +{ + template <class T, class D> + void + operator() (T, D d) + { + int counts[]{ 1, 3 }; + for (int num : counts) + { + float16_t a; + T __trans_tmp_4 = Dot::Compute<0> (d, &a, num); + } + } +}; +int DotTest_TestAllDot_TestTestBody_max_lanes; +void +DotTest_TestAllDot_TestTestBody () +{ + ForeachCappedR<64, TestDot, 0>::Do ( + 1, DotTest_TestAllDot_TestTestBody_max_lanes); +} diff --git a/gcc/testsuite/g++.target/riscv/redundant-andi.C b/gcc/testsuite/g++.target/riscv/redundant-andi.C new file mode 100644 index 0000000..fe560a7 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/redundant-andi.C @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64gcb -mabi=lp64" { target rv64 } } */ +/* { dg-options "-O2 -march=rv32gcb -mabi=ilp32" { target rv32 } } */ + + +typedef int move_s; +struct state_t +{ + int npieces[13]; +}; +typedef struct state_t state_t; +int +search (state_t *s, int alpha, int beta, int depth, int is_null, int cutnode, + int extend, int wpcs, int bpcs, move_s moves[240]) +{ + int i; + if ((((moves[i]) >> 19) & 0x0F) != 13 + && (((moves[i]) >> 19) & 0x0F) != 1 && (((moves[i]) >> 19) & 0x0F) != 2) + if ((wpcs + bpcs) == 1) + extend += 4; + return extend; +} + +/* A splitter was generating an unnecessary andi instruction. Verify it's + not in our output. */ +/* { dg-final { scan-assembler-not "andi\t\[a-z\]\[0-9\],\[a-z\]\[0-9\],-1" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/pr119852.c b/gcc/testsuite/gcc.dg/ipa/pr119852.c new file mode 100644 index 0000000..eab8d212 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr119852.c @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-ipa-clones" } */ + +typedef struct rtx_def *rtx; +enum rtx_code { + LAST_AND_UNUSED_RTX_CODE}; +extern const char * const rtx_format[((int) LAST_AND_UNUSED_RTX_CODE)]; +struct rtx_def { + enum rtx_code code; +}; +typedef int (*rtx_function) (rtx *, void *); +extern int for_each_rtx (rtx *, rtx_function, void *); +int +replace_label (rtx *x, void *data) +{ + rtx l = *x; + if (l == (rtx) 0) + { + { + rtx new_c, new_l; + for_each_rtx (&new_c, replace_label, data); + } + } +} +static int +for_each_rtx_1 (rtx exp, int n, rtx_function f, void *data) +{ + int result, i, j; + const char *format = (rtx_format[(int) (((enum rtx_code) (exp)->code))]); + rtx *x; + for (; format[n] != '\0'; n++) + { + switch (format[n]) + { + case 'e': + result = (*f) (x, data); + { + result = for_each_rtx_1 (*x, i, f, data); + } + } + } +} +int +for_each_rtx (rtx *x, rtx_function f, void *data) +{ + int i; + return for_each_rtx_1 (*x, i, f, data); +} + +/* { dg-final { scan-ipa-dump-not "(null)" "ipa-clones" } } */ diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc index 954538f..a7963fa 100644 --- a/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc +++ b/gcc/testsuite/gcc.dg/plugin/diagnostic_plugin_test_paths.cc @@ -147,7 +147,9 @@ example_1 () { auto_diagnostic_group d; gcc_rich_location richloc (gimple_location (call_to_PyList_Append)); - simple_diagnostic_path path (global_dc->get_reference_printer ()); + tree_logical_location_manager logical_loc_mgr; + simple_diagnostic_path path (logical_loc_mgr, + global_dc->get_reference_printer ()); diagnostic_event_id_t alloc_event_id = path.add_event (gimple_location (call_to_PyList_New), example_a_fun->decl, 0, @@ -214,7 +216,8 @@ class test_diagnostic_path : public simple_diagnostic_path { public: test_diagnostic_path (pretty_printer *event_pp) - : simple_diagnostic_path (event_pp) + : simple_diagnostic_path (m_logical_loc_mgr, + event_pp) { } diagnostic_event_id_t @@ -262,6 +265,9 @@ class test_diagnostic_path : public simple_diagnostic_path add_event (call_evloc.m_loc, call_evloc.m_fun->decl, caller_stack_depth, "calling %qs", callee); } + +private: + tree_logical_location_manager m_logical_loc_mgr; }; static void diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h new file mode 100644 index 0000000..3dd6434 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h @@ -0,0 +1,6 @@ + + + + +#include "location-overflow-test-pr116047-2.h" +static_assert (__LINE__ == 6, ""); diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h new file mode 100644 index 0000000..048f715 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h @@ -0,0 +1 @@ +int i; diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c new file mode 100644 index 0000000..75161fa --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c @@ -0,0 +1,5 @@ +/* PR preprocessor/116047 */ +/* { dg-do preprocess } */ +/* { dg-options "-nostdinc -std=c23 -fplugin-arg-location_overflow_plugin-value=0x4ffe0180" } */ +#include "location-overflow-test-pr116047-1.h" +/* { dg-final { scan-file location-overflow-test-pr116047.i "static_assert\[^\n\r]\*6\[^\n\r]\*== 6" } } */ diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h new file mode 100644 index 0000000..ebf7704 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h @@ -0,0 +1,6 @@ + + + + +#include "location-overflow-test-pr120061-2.h" + diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h new file mode 100644 index 0000000..048f715 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h @@ -0,0 +1 @@ +int i; diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c new file mode 100644 index 0000000..e8e8038 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c @@ -0,0 +1,6 @@ +/* PR preprocessor/120061 */ +/* { dg-do preprocess } */ +/* { dg-options "-nostdinc -std=c23 -fplugin-arg-location_overflow_plugin-value=0x61000000" } */ +#include "location-overflow-test-pr120061-1.h" +static_assert (__LINE__ == 5, ""); +/* { dg-final { scan-file location-overflow-test-pr120061.i "static_assert\[^\n\r]\*5\[^\n\r]\*== 5" } } */ diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc index f731b14..f770d35 100644 --- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc +++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc @@ -85,9 +85,18 @@ plugin_init (struct plugin_name_args *plugin_info, error_at (UNKNOWN_LOCATION, "missing plugin argument"); /* With 64-bit locations, the thresholds are larger, so shift the base - location argument accordingly. */ + location argument accordingly, basically remap the GCC 14 32-bit + location_t argument values to 64-bit location_t counterparts. There + is one exception for values slightly before the 32-bit location_t + LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES (0x50000000). In that case + remap them to the same amount before the 64-bit location_t + LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES - + ((location_t) 0x50000000) << 31. */ gcc_assert (sizeof (location_t) == sizeof (uint64_t)); - base_location = 1 + ((base_location - 1) << 31); + if (base_location >= 0x4f000000 && base_location <= 0x4fffffff) + base_location += (((location_t) 0x50000000) << 31) - 0x50000000; + else + base_location = 1 + ((base_location - 1) << 31); register_callback (plugin_info->base_name, PLUGIN_PRAGMAS, @@ -107,7 +116,7 @@ plugin_init (struct plugin_name_args *plugin_info, break; default: - error_at (UNKNOWN_LOCATION, "unrecognized value for plugin argument"); + break; } return 0; diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index 90c9162..96e76d2 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -138,7 +138,9 @@ set plugin_test_list [list \ { location_overflow_plugin.cc \ location-overflow-test-1.c \ location-overflow-test-2.c \ - location-overflow-test-pr83173.c } \ + location-overflow-test-pr83173.c \ + location-overflow-test-pr116047.c \ + location-overflow-test-pr120061.c } \ { must_tail_call_plugin.cc \ must-tail-call-1.c \ must-tail-call-2.c } \ diff --git a/gcc/testsuite/gcc.dg/pr120074.c b/gcc/testsuite/gcc.dg/pr120074.c new file mode 100644 index 0000000..3f31516 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr120074.c @@ -0,0 +1,20 @@ +/* PR tree-optimization/120074 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-tree-copy-prop -fno-tree-forwprop -fno-tree-ccp" } */ + +int foo (int); +short a; +int b; + +int +bar (int d, int e) +{ + return d < 0 || d > __INT_MAX__ >> e; +} + +int +main () +{ + int f = bar ((b ^ a) & 3, __SIZEOF_INT__ * __CHAR_BIT__ - 2); + foo (f); +} diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr115777.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr115777.c new file mode 100644 index 0000000..bba0dc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr115777.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +typedef unsigned int T; + +#define SWAP(A, B) do { T tmp = A; A = B; B = tmp; } while (0) + +void +insertion_sort(T *v, int n) +{ + for (int i = 1; i < n; ++i) + for (int k = i; k > 0 && v[k-1] > v[k]; --k) + SWAP(v[k-1], v[k]); +} + +/* { dg-final { scan-tree-dump "using element-wise load" "slp1" { target { { x86_64-*-* i?86-*-* } && { ! ia32 } } } } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_5.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_5.c index f06a74a..05e266a 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_5.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/whilelt_5.c @@ -11,8 +11,7 @@ extern "C" { /* ** load_vl1: -** ptrue (p[0-7])\.[bhsd], vl1 -** ld1h z0\.h, \1/z, \[x0\] +** ldr h0, \[x0\] ** ret */ svint16_t @@ -22,7 +21,12 @@ load_vl1 (int16_t *ptr) } /* -** load_vl2: +** load_vl2: { target aarch64_little_endian } +** ldr s0, \[x0\] +** ret +*/ +/* +** load_vl2: { target aarch64_big_endian } ** ptrue (p[0-7])\.h, vl2 ** ld1h z0\.h, \1/z, \[x0\] ** ret @@ -46,7 +50,12 @@ load_vl3 (int16_t *ptr) } /* -** load_vl4: +** load_vl4: { target aarch64_little_endian } +** ldr d0, \[x0\] +** ret +*/ +/* +** load_vl4: { target aarch64_big_endian } ** ptrue (p[0-7])\.h, vl4 ** ld1h z0\.h, \1/z, \[x0\] ** ret @@ -94,7 +103,12 @@ load_vl7 (int16_t *ptr) } /* -** load_vl8: +** load_vl8: { target aarch64_little_endian } +** ldr q0, \[x0\] +** ret +*/ +/* +** load_vl8: { target aarch64_big_endian } ** ptrue (p[0-7])\.h, vl8 ** ld1h z0\.h, \1/z, \[x0\] ** ret diff --git a/gcc/testsuite/gcc.target/aarch64/sve/ldst_ptrue_pat_128_to_neon.c b/gcc/testsuite/gcc.target/aarch64/sve/ldst_ptrue_pat_128_to_neon.c new file mode 100644 index 0000000..2d47c1f --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/ldst_ptrue_pat_128_to_neon.c @@ -0,0 +1,81 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-require-effective-target aarch64_little_endian } */ + +#include <arm_sve.h> + +#define TEST(TYPE, TY, W, B) \ + sv##TYPE \ + ld1_##TY##W##B##_1 (TYPE *x) \ + { \ + svbool_t pg = svwhilelt_b##B (0, W); \ + return svld1_##TY##B (pg, x); \ + } \ + sv##TYPE \ + ld1_##TY##W##B##_2 (TYPE *x) \ + { \ + svbool_t pg = svptrue_pat_b##B ((enum svpattern) (W > 8 ? 9 : W)); \ + return svld1_##TY##B (pg, x); \ + } \ + void \ + st1_##TY##W##B##_1 (TYPE *x, sv##TYPE data) \ + { \ + svbool_t pg = svwhilelt_b##B (0, W); \ + return svst1_##TY##B (pg, x, data); \ + } \ + void \ + st1_##TY##W##B##_2 (TYPE *x, sv##TYPE data) \ + { \ + svbool_t pg = svptrue_pat_b##B ((enum svpattern) (W > 8 ? 9 : W)); \ + return svst1_##TY##B (pg, x, data); \ + } \ + +#define TEST64(TYPE, TY, B) \ + TEST (TYPE, TY, 1, B) \ + TEST (TYPE, TY, 2, B) \ + +#define TEST32(TYPE, TY, B) \ + TEST64 (TYPE, TY, B) \ + TEST (TYPE, TY, 4, B) \ + +#define TEST16(TYPE, TY, B) \ + TEST32 (TYPE, TY, B) \ + TEST (TYPE, TY, 8, B) \ + +#define TEST8(TYPE, TY, B) \ + TEST16 (TYPE, TY, B) \ + TEST (TYPE, TY, 16, B) + +#define T(TYPE, TY, B) \ + TEST##B (TYPE, TY, B) + +T (bfloat16_t, bf, 16) +T (float16_t, f, 16) +T (float32_t, f, 32) +T (float64_t, f, 64) +T (int8_t, s, 8) +T (int16_t, s, 16) +T (int32_t, s, 32) +T (int64_t, s, 64) +T (uint8_t, u, 8) +T (uint16_t, u, 16) +T (uint32_t, u, 32) +T (uint64_t, u, 64) + +/* { dg-final { scan-assembler-times {\tldr\tq0, \[x0\]} 24 } } */ +/* { dg-final { scan-assembler-times {\tldr\td0, \[x0\]} 24 } } */ +/* { dg-final { scan-assembler-times {\tldr\ts0, \[x0\]} 18 } } */ +/* { dg-final { scan-assembler-times {\tldr\th0, \[x0\]} 12 } } */ +/* { dg-final { scan-assembler-times {\tldr\tb0, \[x0\]} 4 } } */ + +/* { dg-final { scan-assembler-times {\tstr\tq0, \[x0\]} 24 } } */ +/* { dg-final { scan-assembler-times {\tstr\td0, \[x0\]} 24 } } */ +/* { dg-final { scan-assembler-times {\tstr\ts0, \[x0\]} 18 } } */ +/* { dg-final { scan-assembler-times {\tstr\th0, \[x0\]} 12 } } */ +/* { dg-final { scan-assembler-times {\tstr\tb0, \[x0\]} 4 } } */ + +svint8_t foo (int8_t *x) +{ + return svld1_s8 (svptrue_b16 (), x); +} +/* { dg-final { scan-assembler-times {\tptrue\tp[0-7]\.h, all\n\tld1b} 1 } } */
\ No newline at end of file diff --git a/gcc/testsuite/gcc.target/aarch64/sve/while_7.c b/gcc/testsuite/gcc.target/aarch64/sve/while_7.c index a66a20d..ab2fa36 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/while_7.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/while_7.c @@ -19,7 +19,7 @@ TEST_ALL (ADD_LOOP) -/* { dg-final { scan-assembler-times {\tptrue\tp[0-7]\.b, vl8\n} 1 } } */ -/* { dg-final { scan-assembler-times {\tptrue\tp[0-7]\.h, vl8\n} 1 } } */ +/* { dg-final { scan-assembler-times {\tldr\td[0-9]+, \[x0\]} 1 } } */ +/* { dg-final { scan-assembler-times {\tldr\tq[0-9]+, \[x0\]} 1 } } */ /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.s,} 2 } } */ /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.d,} 2 } } */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/while_9.c b/gcc/testsuite/gcc.target/aarch64/sve/while_9.c index dd3f404..99940dd 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/while_9.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/while_9.c @@ -19,7 +19,7 @@ TEST_ALL (ADD_LOOP) -/* { dg-final { scan-assembler-times {\tptrue\tp[0-7]\.b, vl16\n} 1 } } */ +/* { dg-final { scan-assembler-times {\tldr\tq[0-9]+\, \[x0\]} 1 } } */ /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.h,} 2 } } */ /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.s,} 2 } } */ /* { dg-final { scan-assembler-times {\twhilelo\tp[0-7]\.d,} 2 } } */ diff --git a/gcc/testsuite/gcc.target/arm/armv8_2-fp16-arith-1.c b/gcc/testsuite/gcc.target/arm/armv8_2-fp16-arith-1.c index 52b8737..f3fea52 100644 --- a/gcc/testsuite/gcc.target/arm/armv8_2-fp16-arith-1.c +++ b/gcc/testsuite/gcc.target/arm/armv8_2-fp16-arith-1.c @@ -106,8 +106,7 @@ TEST_CMP (greaterthanqual, >=, int16x8_t, float16x8_t) /* { dg-final { scan-assembler-times {vdiv\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 13 } } */ /* For float16_t. */ -/* { dg-final { scan-assembler-times {vcmp\.f32\ts[0-9]+, s[0-9]+} 2 } } */ -/* { dg-final { scan-assembler-times {vcmpe\.f32\ts[0-9]+, s[0-9]+} 4 } } */ +/* { dg-final { scan-assembler-times {vcmp\.f32\ts[0-9]+, s[0-9]+} 6 } } */ /* For float16x4_t. */ /* { dg-final { scan-assembler-times {vceq\.f16\td[0-9]+, d[0-9]+} 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr117839-3a.c b/gcc/testsuite/gcc.target/i386/pr117839-3a.c new file mode 100644 index 0000000..81afa9d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr117839-3a.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-avx -msse2 -mtune=generic" } */ +/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */ + +typedef char v4qi __attribute__((vector_size(4))); +typedef char v16qi __attribute__((vector_size(16))); + +v4qi a; +v16qi b; +void +foo (v4qi* c, v16qi* d) +{ + v4qi sum = __extension__(v4qi){0, 0, 0, 0}; + v16qi sum2 = __extension__(v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +0, 0, 0, 0, 0}; + for (int i = 0; i != 100; i++) + sum += c[i]; + for (int i = 0 ; i != 100; i++) + sum2 += d[i]; + a = sum; + b = sum2; +} diff --git a/gcc/testsuite/gcc.target/i386/pr117839-3b.c b/gcc/testsuite/gcc.target/i386/pr117839-3b.c new file mode 100644 index 0000000..a599c28 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr117839-3b.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=x86-64-v3" } */ +/* { dg-final { scan-assembler-times "xor\[a-z\]*\[\t \]*%xmm\[0-9\]\+,\[^,\]*" 1 } } */ + +#include "pr117839-3a.c" diff --git a/gcc/testsuite/gcc.target/i386/pr119919.c b/gcc/testsuite/gcc.target/i386/pr119919.c index ed64656..e39819f 100644 --- a/gcc/testsuite/gcc.target/i386/pr119919.c +++ b/gcc/testsuite/gcc.target/i386/pr119919.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -msse2 -fdump-tree-vect-details" } */ +/* { dg-options "-O2 -msse2 -fdump-tree-vect-details -mtune=znver1" } */ int a[9*9]; bool b[9]; void test() diff --git a/gcc/testsuite/gcc.target/riscv/arch-45.c b/gcc/testsuite/gcc.target/riscv/arch-45.c new file mode 100644 index 0000000..afffb99 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-45.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_svadu -mabi=lp64" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/arch-46.c b/gcc/testsuite/gcc.target/riscv/arch-46.c new file mode 100644 index 0000000..2a06217 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-46.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_svade -mabi=lp64" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/arch-47.c b/gcc/testsuite/gcc.target/riscv/arch-47.c new file mode 100644 index 0000000..06bc80f --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-47.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_sdtrig_ssstrict -mabi=lp64" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/arch-48.c b/gcc/testsuite/gcc.target/riscv/arch-48.c new file mode 100644 index 0000000..58a558e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/arch-48.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zama16b -mabi=lp64" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/riscv/pr114512.c b/gcc/testsuite/gcc.target/riscv/pr114512.c new file mode 100644 index 0000000..205071c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr114512.c @@ -0,0 +1,109 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcb -mabi=lp64d" { target { rv64 } } } */ +/* { dg-options "-march=rv32gcb -mabi=ilp32" { target { rv32 } } } */ +/* { dg-skip-if "" { *-*-* } { "-O0" "-Og" "-Os" "-Oz" } } */ + +/* We need to adjust the constant so this works for rv32 and rv64. */ +#if __riscv_xlen == 32 +#define ONE 1U +#define MASK 0x1f +typedef unsigned int utype; +#else +#define ONE 1ULL +#define MASK 0x3f +typedef unsigned long utype; +#endif + + +_Bool my_isxdigit_1(unsigned char ch) { + utype mask1 = 0x03FF007E; + if (!((mask1 >> (ch & MASK)) & 1)) + return 0; + + return 1; +} + +_Bool my_isxdigit_1a(unsigned char ch) { + utype mask2 = 0x58; + if (!((mask2 >> (ch >> 4)) & 1)) + return 0; + + return 1; +} + +_Bool my_isxdigit_2(unsigned char ch) { + utype mask1 = 0x03FF007E; + if (!(mask1 & (ONE << (ch & MASK)))) + return 0; + + return 1; +} + +_Bool my_isxdigit_2a(unsigned char ch) { + utype mask2 = 0x58; + if (!(mask2 & (ONE << (ch >> 4)))) + return 0; + + return 1; +} + +_Bool my_isxdigit_3(unsigned char ch) { + utype mask1 = 0x7E00FFC0; + if (!((mask1 << (MASK - (ch & MASK))) >> MASK)) + return 0; + + return 1; +} + +_Bool my_isxdigit_3a(unsigned char ch) { + utype mask2 = 0x7E00FFC0; + if (!((mask2 << (MASK - ((ch >> 4) & MASK))) >> MASK)) + return 0; + + return 1; +} + +_Bool my_isxdigit_1_parm(unsigned char ch, utype mask1) { + if (!((mask1 >> (ch & MASK)) & 1)) + return 0; + + return 1; +} + +_Bool my_isxdigit_1a_parm(unsigned char ch, utype mask2) { + if (!((mask2 >> (ch >> 4)) & 1)) + return 0; + + return 1; +} + +_Bool my_isxdigit_2_parm(unsigned char ch, utype mask1) { + if (!(mask1 & (ONE << (ch & MASK)))) + return 0; + + return 1; +} + +_Bool my_isxdigit_2a_parm(unsigned char ch, utype mask2) { + if (!(mask2 & (ONE << (ch >> 4)))) + return 0; + + return 1; +} + +_Bool my_isxdigit_3_parm(unsigned char ch, utype mask1) { + if (!((mask1 << (MASK - (ch & MASK))) >> MASK)) + return 0; + + return 1; +} + +_Bool my_isxdigit_3a_parm(unsigned char ch, utype mask2) { + if (!((mask2 << (MASK - ((ch >> 4) & MASK))) >> MASK)) + return 0; + + return 1; +} + +/* Each test should generate a single bext. */ +/* { dg-final { scan-assembler-times "bext\t" 12 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h new file mode 100644 index 0000000..66654eb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary.h @@ -0,0 +1,17 @@ +#ifndef HAVE_DEFINED_VX_VF_BINARY_H +#define HAVE_DEFINED_VX_VF_BINARY_H + +#include <stdint.h> + +#define DEF_VX_BINARY(T, OP) \ +void \ +test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \ +{ \ + for (unsigned i = 0; i < n; i++) \ + out[i] = in[i] OP x; \ +} +#define DEF_VX_BINARY_WRAP(T, OP) DEF_VX_BINARY(T, OP) +#define RUN_VX_BINARY(out, in, x, n) test_vx_binary(out, in, x, n) +#define RUN_VX_BINARY_WRAP(out, in, x, n) RUN_VX_BINARY(out, in, x, n) + +#endif diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h new file mode 100644 index 0000000..11a32cb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h @@ -0,0 +1,401 @@ +#ifndef HAVE_DEFINED_VX_BINARY_DATA_H +#define HAVE_DEFINED_VX_BINARY_DATA_H + +#define N 16 + +#define TEST_BINARY_DATA(T, NAME) test_##T##_##NAME##_data +#define TEST_BINARY_DATA_WRAP(T, NAME) TEST_BINARY_DATA(T, NAME) + +int8_t TEST_BINARY_DATA(int8_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + -1, -1, -1, -1, + -2, -2, -2, -2, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 0, 0, 0, 0, + -1, -1, -1, -1, + }, + }, + { + { 127 }, + { + 0, 0, 0, 0, + -1, -1, -1, -1, + -128, -128, -128, -128, + -2, -2, -2, -2, + }, + { + 127, 127, 127, 127, + 126, 126, 126, 126, + -1, -1, -1, -1, + 125, 125, 125, 125, + }, + }, + { + { -128 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 127, 127, 127, 127, + 2, 2, 2, 2, + }, + { + -128, -128, -128, -128, + -127, -127, -127, -127, + -1, -1, -1, -1, + -126, -126, -126, -126, + }, + }, +}; + +int16_t TEST_BINARY_DATA(int16_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + -1, -1, -1, -1, + -2, -2, -2, -2, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 0, 0, 0, 0, + -1, -1, -1, -1, + }, + }, + { + { 32767 }, + { + 0, 0, 0, 0, + -1, -1, -1, -1, + -32768, -32768, -32768, -32768, + -2, -2, -2, -2, + }, + { + 32767, 32767, 32767, 32767, + 32766, 32766, 32766, 32766, + -1, -1, -1, -1, + 32765, 32765, 32765, 32765, + }, + }, + { + { -32768 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 32767, 32767, 32767, 32767, + 2, 2, 2, 2, + }, + { + -32768, -32768, -32768, -32768, + -32767, -32767, -32767, -32767, + -1, -1, -1, -1, + -32766, -32766, -32766, -32766, + }, + }, +}; + +int32_t TEST_BINARY_DATA(int32_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + -1, -1, -1, -1, + -2, -2, -2, -2, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 0, 0, 0, 0, + -1, -1, -1, -1, + }, + }, + { + { 2147483647 }, + { + 0, 0, 0, 0, + -1, -1, -1, -1, + -2147483648, -2147483648, -2147483648, -2147483648, + -2, -2, -2, -2, + }, + { + 2147483647, 2147483647, 2147483647, 2147483647, + 2147483646, 2147483646, 2147483646, 2147483646, + -1, -1, -1, -1, + 2147483645, 2147483645, 2147483645, 2147483645, + }, + }, + { + { -2147483648 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2147483647, 2147483647, 2147483647, 2147483647, + 2, 2, 2, 2, + }, + { + -2147483648, -2147483648, -2147483648, -2147483648, + -2147483647, -2147483647, -2147483647, -2147483647, + -1, -1, -1, -1, + -2147483646, -2147483646, -2147483646, -2147483646, + }, + }, +}; + +int64_t TEST_BINARY_DATA(int64_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + -1, -1, -1, -1, + -2, -2, -2, -2, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 0, 0, 0, 0, + -1, -1, -1, -1, + }, + }, + { + { 9223372036854775807ll }, + { + 0, 0, 0, 0, + -1, -1, -1, -1, + -9223372036854775808ull, -9223372036854775808ull, -9223372036854775808ull, -9223372036854775808ull, + -2, -2, -2, -2, + }, + { + 9223372036854775807ll, 9223372036854775807ll, 9223372036854775807ll, 9223372036854775807ll, + 9223372036854775806ll, 9223372036854775806ll, 9223372036854775806ll, 9223372036854775806ll, + -1, -1, -1, -1, + 9223372036854775805ll, 9223372036854775805ll, 9223372036854775805ll, 9223372036854775805ll, + }, + }, + { + { -9223372036854775808ull }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 9223372036854775807ll, 9223372036854775807ll, 9223372036854775807ll, 9223372036854775807ll, + 2, 2, 2, 2, + }, + { + -9223372036854775808ull, -9223372036854775808ull, -9223372036854775808ull, -9223372036854775808ull, + -9223372036854775807ll, -9223372036854775807ll, -9223372036854775807ll, -9223372036854775807ll, + -1, -1, -1, -1, + -9223372036854775806ll, -9223372036854775806ll, -9223372036854775806ll, -9223372036854775806ll, + }, + }, +}; + +uint8_t TEST_BINARY_DATA(uint8_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 11, 11, 11, 11, + 9, 9, 9, 9, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 12, 12, 12, 12, + 10, 10, 10, 10, + }, + }, + { + { 127 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 127, 127, 127, 127, + 128, 128, 128, 128, + }, + { + 127, 127, 127, 127, + 128, 128, 128, 128, + 254, 254, 254, 254, + 255, 255, 255, 255, + }, + }, + { + { 253 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, 2, + 255, 255, 255, 255, + }, + { + 253, 253, 253, 253, + 254, 254, 254, 254, + 255, 255, 255, 255, + 252, 252, 252, 252, + }, + }, +}; + +uint16_t TEST_BINARY_DATA(uint16_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 11, 11, 11, 11, + 9, 9, 9, 9, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 12, 12, 12, 12, + 10, 10, 10, 10, + }, + }, + { + { 32767 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 32767, 32767, 32767, 32767, + 32768, 32768, 32768, 32768, + }, + { + 32767, 32767, 32767, 32767, + 32768, 32768, 32768, 32768, + 65534, 65534, 65534, 65534, + 65535, 65535, 65535, 65535, + }, + }, + { + { 65533 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, 2, + 65535, 65535, 65535, 65535, + }, + { + 65533, 65533, 65533, 65533, + 65534, 65534, 65534, 65534, + 65535, 65535, 65535, 65535, + 65532, 65532, 65532, 65532, + }, + }, +}; + +uint32_t TEST_BINARY_DATA(uint32_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 11, 11, 11, 11, + 9, 9, 9, 9, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 12, 12, 12, 12, + 10, 10, 10, 10, + }, + }, + { + { 2147483647 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2147483647, 2147483647, 2147483647, 2147483647, + 2147483648, 2147483648, 2147483648, 2147483648, + }, + { + 2147483647, 2147483647, 2147483647, 2147483647, + 2147483648, 2147483648, 2147483648, 2147483648, + 4294967294, 4294967294, 4294967294, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + }, + { + { 4294967293 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, 2, + 4294967295, 4294967295, 4294967295, 4294967295, + }, + { + 4294967293, 4294967293, 4294967293, 4294967293, + 4294967294, 4294967294, 4294967294, 4294967294, + 4294967295, 4294967295, 4294967295, 4294967295, + 4294967292, 4294967292, 4294967292, 4294967292, + }, + }, +}; + +uint64_t TEST_BINARY_DATA(uint64_t, vadd)[][3][N] = +{ + { + { 1 }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 11, 11, 11, 11, + 9, 9, 9, 9, + }, + { + 1, 1, 1, 1, + 2, 2, 2, 2, + 12, 12, 12, 12, + 10, 10, 10, 10, + }, + }, + { + { 9223372036854775807ull }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 9223372036854775807ull, 9223372036854775807ull, 9223372036854775807ull, 9223372036854775807ull, + 9223372036854775808ull, 9223372036854775808ull, 9223372036854775808ull, 9223372036854775808ull, + }, + { + 9223372036854775807ull, 9223372036854775807ull, 9223372036854775807ull, 9223372036854775807ull, + 9223372036854775808ull, 9223372036854775808ull, 9223372036854775808ull, 9223372036854775808ull, + 18446744073709551614ull, 18446744073709551614ull, 18446744073709551614ull, 18446744073709551614ull, + 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, + }, + }, + { + { 18446744073709551613ull }, + { + 0, 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, 2, + 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, + }, + { + 18446744073709551613ull, 18446744073709551613ull, 18446744073709551613ull, 18446744073709551613ull, + 18446744073709551614ull, 18446744073709551614ull, 18446744073709551614ull, 18446744073709551614ull, + 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, 18446744073709551615ull, + 18446744073709551612ull, 18446744073709551612ull, 18446744073709551612ull, 18446744073709551612ull, + }, + }, +}; + +#endif diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_run.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_run.h new file mode 100644 index 0000000..bb35184 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_run.h @@ -0,0 +1,26 @@ +#ifndef HAVE_DEFINED_VX_BINARY_RUN_H +#define HAVE_DEFINED_VX_BINARY_RUN_H + +int +main () +{ + unsigned i, k; + T out[N]; + + for (i = 0; i < sizeof (TEST_DATA) / sizeof (TEST_DATA[0]); i++) + { + T x = TEST_DATA[i][0][0]; + T *in = TEST_DATA[i][1]; + T *expect = TEST_DATA[i][2]; + + TEST_RUN (out, in, x, N); + + for (k = 0; k < N; k++) + if (out[k] != expect[k]) + __builtin_abort (); + } + + return 0; +} + +#endif diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i16.c new file mode 100644 index 0000000..488bc75 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int16_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i32.c new file mode 100644 index 0000000..aeba835 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int32_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i64.c new file mode 100644 index 0000000..ed0b937 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int64_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i8.c new file mode 100644 index 0000000..781d3c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-i8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int8_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u16.c new file mode 100644 index 0000000..c01fc23 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint16_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u32.c new file mode 100644 index 0000000..63198492 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint32_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u64.c new file mode 100644 index 0000000..36eec53 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint64_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u8.c new file mode 100644 index 0000000..6bf4b61 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-1-u8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint8_t, +) + +/* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i16.c new file mode 100644 index 0000000..eb19938 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int16_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i32.c new file mode 100644 index 0000000..24182c5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int32_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i64.c new file mode 100644 index 0000000..b3d3d4b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int64_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i8.c new file mode 100644 index 0000000..fb35315 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-i8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int8_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u16.c new file mode 100644 index 0000000..6ba2658 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint16_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u32.c new file mode 100644 index 0000000..b60412c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint32_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u64.c new file mode 100644 index 0000000..a273294 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint64_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u8.c new file mode 100644 index 0000000..f3c41f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-2-u8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=1" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint8_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i16.c new file mode 100644 index 0000000..f3a2627 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int16_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i32.c new file mode 100644 index 0000000..490854c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int32_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i64.c new file mode 100644 index 0000000..a7448df --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int64_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i8.c new file mode 100644 index 0000000..72c7cd8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-i8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(int8_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u16.c new file mode 100644 index 0000000..552b4ed --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u16.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint16_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u32.c new file mode 100644 index 0000000..e319672 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u32.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint32_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u64.c new file mode 100644 index 0000000..6e2a89e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u64.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint64_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u8.c new file mode 100644 index 0000000..d3383e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-3-u8.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=gpr2vr-cost=15" } */ + +#include "vx_binary.h" + +DEF_VX_BINARY(uint8_t, +) + +/* { dg-final { scan-assembler-not {vadd.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i16.c new file mode 100644 index 0000000..fb5375d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i16.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T int16_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i32.c new file mode 100644 index 0000000..c2c79f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i32.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T int32_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i64.c new file mode 100644 index 0000000..541ed21 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i64.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T int64_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i8.c new file mode 100644 index 0000000..d507bbb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-i8.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T int8_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u16.c new file mode 100644 index 0000000..52c0749 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u16.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T uint16_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u32.c new file mode 100644 index 0000000..70dc347 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u32.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T uint32_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u64.c new file mode 100644 index 0000000..6ce0060 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u64.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T uint64_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u8.c new file mode 100644 index 0000000..a0e80b7 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx_vadd-run-1-u8.c @@ -0,0 +1,14 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 --param=gpr2vr-cost=0" } */ + +#include "vx_binary.h" +#include "vx_binary_data.h" + +#define T uint8_t + +DEF_VX_BINARY_WRAP(T, +) + +#define TEST_DATA TEST_BINARY_DATA_WRAP(T, vadd) +#define TEST_RUN(out, in, x, n) RUN_VX_BINARY_WRAP(out, in, x, n) + +#include "vx_binary_run.h" diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp index 3824997..4283d12 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp +++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp @@ -130,6 +130,8 @@ foreach op $AUTOVEC_TEST_OPTS { "$op" "" dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/sat/*.\[cS\]]] \ "$op" "" + dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/vx_vf/*.\[cS\]]] \ + "$op" "" } # All done. diff --git a/gcc/testsuite/gcc.target/s390/vector/cstoreti-1.c b/gcc/testsuite/gcc.target/s390/vector/cstoreti-1.c new file mode 100644 index 0000000..f2a131b --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/cstoreti-1.c @@ -0,0 +1,127 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -march=z13" } */ +/* { dg-final { check-function-bodies "**" "" } } */ + +/* +** test_le: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** vecg \2,\1 +** jne \.L.+ +** vchlgs %v.,\1,\2 +** lghi %r2,0 +** locghinl %r2,1 +** br %r14 +*/ + +int test_le (__int128 x, __int128 y) { return x <= y; } + +/* +** test_leu: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** veclg \2,\1 +** jne \.L.+ +** vchlgs %v.,\1,\2 +** lghi %r2,0 +** locghinl %r2,1 +** br %r14 +*/ + +int test_leu (unsigned __int128 x, unsigned __int128 y) { return x <= y; } + +/* +** test_lt: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** vecg \1,\2 +** jne \.L.+ +** vchlgs %v.,\2,\1 +** lghi %r2,0 +** locghil %r2,1 +** br %r14 +*/ + +int test_lt (__int128 x, __int128 y) { return x < y; } + +/* +** test_ltu: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** veclg \1,\2 +** jne \.L.+ +** vchlgs %v.,\2,\1 +** lghi %r2,0 +** locghil %r2,1 +** br %r14 +*/ + +int test_ltu (unsigned __int128 x, unsigned __int128 y) { return x < y; } + +/* +** test_ge: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** vecg \1,\2 +** jne \.L.+ +** vchlgs %v.,\2,\1 +** lghi %r2,0 +** locghinl %r2,1 +** br %r14 +*/ + +int test_ge (__int128 x, __int128 y) { return x >= y; } + +/* +** test_geu: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** veclg \1,\2 +** jne \.L.+ +** vchlgs %v.,\2,\1 +** lghi %r2,0 +** locghinl %r2,1 +** br %r14 +*/ + +int test_geu (unsigned __int128 x, unsigned __int128 y) { return x >= y; } + +/* +** test_gt: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** vecg \2,\1 +** jne \.L.+ +** vchlgs %v.,\1,\2 +** lghi %r2,0 +** locghil %r2,1 +** br %r14 +*/ + +int test_gt (__int128 x, __int128 y) { return x > y; } + +/* +** test_gtu: +** vl (%v.),0\(%r2\),3 +** vl (%v.),0\(%r3\),3 +** veclg \2,\1 +** jne \.L.+ +** vchlgs %v.,\1,\2 +** lghi %r2,0 +** locghil %r2,1 +** br %r14 +*/ + +int test_gtu (unsigned __int128 x, unsigned __int128 y) { return x > y; } + +/* { dg-final { scan-assembler-times {vceqgs\t} 4 } } */ +/* { dg-final { scan-assembler-times {locghie\t} 2 } } */ +/* { dg-final { scan-assembler-times {locghine\t} 2 } } */ + +int test_eq (__int128 x, __int128 y) { return x == y; } + +int test_equ (unsigned __int128 x, unsigned __int128 y) { return x == y; } + +int test_ne (__int128 x, __int128 y) { return x != y; } + +int test_neu (unsigned __int128 x, unsigned __int128 y) { return x != y; } diff --git a/gcc/testsuite/gcc.target/s390/vector/cstoreti-2.c b/gcc/testsuite/gcc.target/s390/vector/cstoreti-2.c new file mode 100644 index 0000000..d7b0382 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/vector/cstoreti-2.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -march=z17" } */ +/* { dg-final { scan-assembler-times {vecq\t} 8 } } */ +/* { dg-final { scan-assembler-times {veclq\t} 4 } } */ +/* { dg-final { scan-assembler-times {locghile\t} 1 } } LE */ +/* { dg-final { scan-assembler-times {slbgr\t} 1 } } LEU */ +/* { dg-final { scan-assembler-times {locghil\t} 2 } } LT LTU */ +/* { dg-final { scan-assembler-times {locghihe\t} 2 } } GE GEU */ +/* { dg-final { scan-assembler-times {locghih\t} 1 } } GT */ +/* { dg-final { scan-assembler-times {alcgr\t} 1 } } GTU */ +/* { dg-final { scan-assembler-times {locghie\t} 2 } } EQ EQU */ +/* { dg-final { scan-assembler-times {locghine\t} 2 } } NE NEU */ + +int test_le (__int128 x, __int128 y) { return x <= y; } +int test_leu (unsigned __int128 x, unsigned __int128 y) { return x <= y; } +int test_lt (__int128 x, __int128 y) { return x < y; } +int test_ltu (unsigned __int128 x, unsigned __int128 y) { return x < y; } +int test_ge (__int128 x, __int128 y) { return x >= y; } +int test_geu (unsigned __int128 x, unsigned __int128 y) { return x >= y; } +int test_gt (__int128 x, __int128 y) { return x > y; } +int test_gtu (unsigned __int128 x, unsigned __int128 y) { return x > y; } +int test_eq (__int128 x, __int128 y) { return x == y; } +int test_equ (unsigned __int128 x, unsigned __int128 y) { return x == y; } +int test_ne (__int128 x, __int128 y) { return x != y; } +int test_neu (unsigned __int128 x, unsigned __int128 y) { return x != y; } diff --git a/gcc/testsuite/gfortran.dg/interface_60.f90 b/gcc/testsuite/gfortran.dg/interface_60.f90 new file mode 100644 index 0000000..a7701f6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_60.f90 @@ -0,0 +1,70 @@ +! { dg-do run } +! { dg-options "-Wexternal-argument-mismatch" } +! Originally proc_ptr_52.f90, this gave an error with the warning above. + +module cs + +implicit none + +integer, target :: integer_target + +abstract interface + function classStar_map_ifc(x) result(y) + class(*), pointer :: y + class(*), target, intent(in) :: x + end function classStar_map_ifc +end interface + +contains + + function fun(x) result(y) + class(*), pointer :: y + class(*), target, intent(in) :: x + select type (x) + type is (integer) + integer_target = x ! Deals with dangling target. + y => integer_target + class default + y => null() + end select + end function fun + + function apply(fap, x) result(y) + procedure(classStar_map_ifc) :: fap + integer, intent(in) :: x + integer :: y + class(*), pointer :: p + y = 0 ! Get rid of 'y' undefined warning + p => fap (x) + select type (p) + type is (integer) + y = p + end select + end function apply + + function selector() result(fsel) + procedure(classStar_map_ifc), pointer :: fsel + fsel => fun + end function selector + +end module cs + + +program classStar_map + +use cs +implicit none + +integer :: x, y +procedure(classStar_map_ifc), pointer :: fm + +x = 123654 +fm => selector () ! Fixed by second chunk in patch +y = apply (fm, x) ! Fixed by first chunk in patch +if (x .ne. y) stop 1 + +x = 2 * x +y = apply (fun, x) ! PR93925; fixed as above +if (x .ne. y) stop 2 + +end program classStar_map diff --git a/gcc/testsuite/gfortran.dg/pr119948.f90 b/gcc/testsuite/gfortran.dg/pr119948.f90 index 9ecb080..2e36fae 100644 --- a/gcc/testsuite/gfortran.dg/pr119948.f90 +++ b/gcc/testsuite/gfortran.dg/pr119948.f90 @@ -1,7 +1,8 @@ -! { dg-do compile } +! { dg-do run } ! -! Test the fix for PR119948, which used to fail as indicated below with, -! "Error: Bad allocate-object at (1) for a PURE procedure" +! Test the fix for PR119948, which used to fail as indicated below with: +! (1) "Error: Bad allocate-object at (1) for a PURE procedure" +! (2) "Error: ‘construct_test2 at (1) is not a variable" ! ! Contributed by Damian Rouson <damian@archaeologic.codes> ! @@ -18,33 +19,65 @@ module test_m type(test_t) :: test type(test_t), intent(in) :: arg end function - pure module function construct_test_sub(arg) result(test) + + pure module function construct_test2(arg) + implicit none + type(test_t) construct_test2 + type(test_t), intent(in) :: arg + end function + + pure module function construct_test_3(arg) result(test) implicit none type(test_t) :: test type(test_t), intent(in) :: arg end function + + pure module function construct_test_4(arg) + implicit none + type(test_t) :: construct_test_4 + type(test_t), intent(in) :: arg + end function end interface contains module procedure construct_test - allocate(test%i, source = arg%i) ! Used to fail here + allocate(test%i, source = arg%i) ! Fail #1 + end procedure + + module procedure construct_test2 + allocate(construct_test2%i, source = arg%i) ! Fail #2 end procedure end module submodule (test_m)test_s contains - module procedure construct_test_sub + module procedure construct_test_3 allocate(test%i, source = arg%i) ! This was OK. end procedure + + module procedure construct_test_4 + allocate(construct_test_4%i, source = arg%i) ! This was OK. + end procedure end submodule use test_m type(test_t) :: res, dummy - dummy%i = 42 +! + dummy%i = int (rand () * 1e6) res = construct_test (dummy) if (res%i /= dummy%i) stop 1 - dummy%i = -42 - res = construct_test_sub (dummy) +! + dummy%i = int (rand () * 1e6) + res = construct_test2 (dummy) if (res%i /= dummy%i) stop 2 +! + dummy%i = int (rand () * 1e6) + res = construct_test_3 (dummy) + if (res%i /= dummy%i) stop 3 + + dummy%i = int (rand () * 1e6) + res = construct_test_4 (dummy) + if (res%i /= dummy%i) stop 4 + deallocate (res%i, dummy%i) end diff --git a/gcc/testsuite/gfortran.dg/pr120049_a.f90 b/gcc/testsuite/gfortran.dg/pr120049_a.f90 new file mode 100644 index 0000000..c404a4d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr120049_a.f90 @@ -0,0 +1,15 @@ +! { dg-do preprocess } +! { dg-additional-options "-cpp" } +! +! Test the fix for PR86248 +program tests_gtk_sup + use gtk_sup + implicit none + type(c_ptr), target :: val + if (c_associated(val, c_loc(val))) then + stop 1 + endif + if (c_associated(c_loc(val), val)) then + stop 2 + endif +end program tests_gtk_sup diff --git a/gcc/testsuite/gfortran.dg/pr120049_b.f90 b/gcc/testsuite/gfortran.dg/pr120049_b.f90 new file mode 100644 index 0000000..127db98 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr120049_b.f90 @@ -0,0 +1,8 @@ +! { dg-do run } +! { dg-additional-sources pr120049_a.f90 } +! +! Module for pr120049.f90 +! +module gtk_sup + use, intrinsic :: iso_c_binding +end module gtk_sup diff --git a/gcc/testsuite/libgdiagnostics.dg/test-logical-location-c.py b/gcc/testsuite/libgdiagnostics.dg/test-logical-location-c.py index 7448a1e..55f338b 100644 --- a/gcc/testsuite/libgdiagnostics.dg/test-logical-location-c.py +++ b/gcc/testsuite/libgdiagnostics.dg/test-logical-location-c.py @@ -31,7 +31,16 @@ def test_sarif_output_with_logical_location(sarif): assert len(location['logicalLocations']) == 1 logical_loc = location['logicalLocations'][0] + assert logical_loc['index'] == 0 + assert logical_loc['fullyQualifiedName'] == 'test_qualified_name' + + # Check theRun.logicalLocations + assert 'logicalLocations' in run + assert len(run['logicalLocations']) == 1 + logical_loc = run['logicalLocations'][0] assert logical_loc['name'] == 'test_short_name' assert logical_loc['fullyQualifiedName'] == 'test_qualified_name' assert logical_loc['decoratedName'] == 'test_decorated_name' assert logical_loc['kind'] == 'function' + assert logical_loc['index'] == 0 + diff --git a/gcc/testsuite/libgdiagnostics.dg/test-logical-location.c b/gcc/testsuite/libgdiagnostics.dg/test-logical-location.c index 1408919..b59ece4 100644 --- a/gcc/testsuite/libgdiagnostics.dg/test-logical-location.c +++ b/gcc/testsuite/libgdiagnostics.dg/test-logical-location.c @@ -20,6 +20,7 @@ PRINT "hello world!"; const int line_num = __LINE__ - 2; #include <assert.h> +#include <string.h> int main () @@ -62,6 +63,17 @@ main () diagnostic_finish (d, "can't find %qs", "foo"); /* end quoted source */ + /* Verify that the accessors work. */ + assert (diagnostic_logical_location_get_kind (logical_loc) + == DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION); + assert (!diagnostic_logical_location_get_parent (logical_loc)); + assert (!strcmp (diagnostic_logical_location_get_short_name (logical_loc), + "test_short_name")); + assert (!strcmp (diagnostic_logical_location_get_fully_qualified_name (logical_loc), + "test_qualified_name")); + assert (!strcmp (diagnostic_logical_location_get_decorated_name (logical_loc), + "test_decorated_name")); + /* Verify that creating a diagnostic_logical_location with equal values yields the same instance. */ const diagnostic_logical_location *dup diff --git a/gcc/testsuite/libgdiagnostics.dg/test-logical-location.cc b/gcc/testsuite/libgdiagnostics.dg/test-logical-location.cc new file mode 100644 index 0000000..3080ade --- /dev/null +++ b/gcc/testsuite/libgdiagnostics.dg/test-logical-location.cc @@ -0,0 +1,91 @@ +/* C++ example of using a logical location. + + Intended output is similar to: + +In function 'test_qualified_name': +PATH/test-error-with-note.cc:17:8: error: can't find 'foo' + 17 | PRINT "hello world!"; + | ^~~~~~~~~~~~ + + along with the equivalent in SARIF. */ + +#include "libgdiagnostics++.h" + +/* Placeholder source: +_________111111111122 +123456789012345678901 +PRINT "hello world!"; +*/ +const int line_num = __LINE__ - 2; + +#include <assert.h> +#include <string.h> + +int +main () +{ + libgdiagnostics::manager mgr; + + auto file = mgr.new_file (__FILE__, "c"); + + mgr.add_text_sink (stderr, DIAGNOSTIC_COLORIZE_IF_TTY); + + auto loc_start = mgr.new_location_from_file_line_column (file, line_num, 8); + auto loc_end = mgr.new_location_from_file_line_column (file, line_num, 19); + auto loc_range = mgr.new_location_from_range (loc_start, loc_start, loc_end); + + auto err (mgr.begin_diagnostic (DIAGNOSTIC_LEVEL_ERROR)); + err.set_location (loc_range); + + libgdiagnostics::logical_location logical_loc + = mgr.new_logical_location (DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION, + NULL, /* parent */ + "test_short_name", + "test_qualified_name", + "test_decorated_name"); + err.set_logical_location (logical_loc); + + err.finish ("can't find %qs", "foo"); + + /* Verify that the accessors work. */ + assert (logical_loc.get_kind () + == DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION); + assert (logical_loc.get_parent ().m_inner == nullptr); + assert (!strcmp (logical_loc.get_short_name (), + "test_short_name")); + assert (!strcmp (logical_loc.get_fully_qualified_name (), + "test_qualified_name")); + assert (!strcmp (logical_loc.get_decorated_name (), + "test_decorated_name")); + + /* Verify that libgdiagnostic::logical_location instances created with + equal values compare as equal. */ + libgdiagnostics::logical_location dup + = mgr.new_logical_location (DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION, + NULL, /* parent */ + "test_short_name", + "test_qualified_name", + "test_decorated_name"); + assert (dup == logical_loc); + + /* Verify that libgdiagnostic::logical_location instances created with + differing values compare as non-equal. */ + libgdiagnostics::logical_location other + = mgr.new_logical_location (DIAGNOSTIC_LOGICAL_LOCATION_KIND_FUNCTION, + NULL, /* parent */ + "something_else", + NULL, NULL); + assert (other != logical_loc); + + return 0; +} + +/* Check the output from the text sink. */ +/* { dg-begin-multiline-output "" } +In function 'test_qualified_name': + { dg-end-multiline-output "" } */ +/* { dg-regexp "\[^\n\r\]+test-logical-location.cc:17:8: error: can't find 'foo'" } */ +/* { dg-begin-multiline-output "" } + 17 | PRINT "hello world!"; + | ^~~~~~~~~~~~ + { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json-c.py b/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json-c.py new file mode 100644 index 0000000..39cc1a9 --- /dev/null +++ b/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json-c.py @@ -0,0 +1,79 @@ +from sarif import * + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def sarif(): + return sarif_from_env() + +def test_sarif_output_with_logical_location(sarif): + schema = sarif['$schema'] + assert schema == 'https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json' + + version = sarif['version'] + assert version == '2.1.0' + + runs = sarif['runs'] + run = runs[0] + + tool = run['tool'] + assert tool['driver']['name'] == 'test-nested-logical-locations-json.c.exe' + + results = run['results'] + assert len(results) == 2 + + result = results[0] + assert result['ruleId'] == 'warning' + assert result['level'] == 'warning' + assert result['message']['text'] == "product ID is blank" + assert len(result['locations']) == 1 + location = result['locations'][0] + assert len(location['logicalLocations']) == 1 + logical_loc = location['logicalLocations'][0] + assert logical_loc['index'] == 3 + assert logical_loc['fullyQualifiedName'] == '/orders/0/productIds/1' + + result = results[1] + assert result['ruleId'] == 'warning' + assert result['level'] == 'warning' + assert result['message']['text'] == "value is negative" + assert len(result['locations']) == 1 + location = result['locations'][0] + assert len(location['logicalLocations']) == 1 + logical_loc = location['logicalLocations'][0] + assert logical_loc['index'] == 4 + assert logical_loc['fullyQualifiedName'] == '/orders/0/total' + + # Check theRun.logicalLocations + assert 'logicalLocations' in run + assert len(run['logicalLocations']) == 5 + logical_loc = run['logicalLocations'][0] + assert logical_loc['name'] == 'orders' + assert logical_loc['fullyQualifiedName'] == '/orders' + assert logical_loc['kind'] == 'array' + assert logical_loc['index'] == 0 + logical_loc = run['logicalLocations'][1] + assert logical_loc['name'] == '0' + assert logical_loc['fullyQualifiedName'] == '/orders/0' + assert logical_loc['kind'] == 'object' + assert logical_loc['parentIndex'] == 0 + assert logical_loc['index'] == 1 + logical_loc = run['logicalLocations'][2] + assert logical_loc['name'] == 'productIds' + assert logical_loc['fullyQualifiedName'] == '/orders/0/productIds' + assert logical_loc['kind'] == 'array' + assert logical_loc['parentIndex'] == 1 + assert logical_loc['index'] == 2 + logical_loc = run['logicalLocations'][3] + assert logical_loc['name'] == '1' + assert logical_loc['fullyQualifiedName'] == '/orders/0/productIds/1' + assert logical_loc['kind'] == 'value' + assert logical_loc['parentIndex'] == 2 + assert logical_loc['index'] == 3 + logical_loc = run['logicalLocations'][4] + assert logical_loc['name'] == 'total' + assert logical_loc['fullyQualifiedName'] == '/orders/0/total' + assert logical_loc['kind'] == 'property' + assert logical_loc['parentIndex'] == 1 + assert logical_loc['index'] == 4 + diff --git a/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json.c b/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json.c new file mode 100644 index 0000000..d06450e --- /dev/null +++ b/gcc/testsuite/libgdiagnostics.dg/test-nested-logical-locations-json.c @@ -0,0 +1,165 @@ +/* Example of nested logical locations, based on the JSON example in + SARIF v2.1.0, 3.33.7 "kind" property; + though see https://github.com/oasis-tcs/sarif-spec/issues/670 + + Intended output is similar to: + +In JSON value '/orders/0/productIds/1': +PATH/test-nested-logical-locations-json.c:28:32: warning: product ID is blank + 28 | "productIds": [ "A-101", "", "A-223" ], + | ^~ +In JSON property '/orders/0/total': +PATH/test-nested-logical-locations-json.c:29:16: warning: value is negative + 29 | "total": "-3.25" + | ^~~~~~~ + + along with the equivalent in SARIF, capturing JSON structure + as nested logical locations. */ + +#include "libgdiagnostics.h" +#include "test-helpers.h" + +/* Placeholder source: +_________1111111111222222222233333333334444444444 +1234567890123456789012345678901234567890123456789 +{ + "orders": [ + { + "productIds": [ "A-101", "", "A-223" ], + "total": "-3.25" + } + ] +} +*/ +const int start_line_num = __LINE__ - 9; +const int line_num_of_product_ids = start_line_num + 3; +const int line_num_of_total = line_num_of_product_ids + 1; + +#include <assert.h> + +int +main () +{ + begin_test ("test-nested-logical-locations-json.c.exe", + "test-nested-logical-locations-json.c.sarif", + __FILE__, "c"); + + /* Create tree of logical locations. */ + /* begin quoted source */ + const diagnostic_logical_location *logical_loc_orders_arr + = diagnostic_manager_new_logical_location (diag_mgr, + DIAGNOSTIC_LOGICAL_LOCATION_KIND_ARRAY, + NULL, /* parent */ + "orders", + "/orders", + NULL); + const diagnostic_logical_location *logical_loc_order_0 + = diagnostic_manager_new_logical_location (diag_mgr, + DIAGNOSTIC_LOGICAL_LOCATION_KIND_OBJECT, + logical_loc_orders_arr, /* parent */ + "0", + "/orders/0", + NULL); + const diagnostic_logical_location *logical_loc_product_ids + = diagnostic_manager_new_logical_location (diag_mgr, + DIAGNOSTIC_LOGICAL_LOCATION_KIND_ARRAY, + logical_loc_order_0, /* parent */ + "productIds", + "/orders/0/productIds", + NULL); + const diagnostic_logical_location *logical_loc_element_1 + = diagnostic_manager_new_logical_location (diag_mgr, + DIAGNOSTIC_LOGICAL_LOCATION_KIND_VALUE, + logical_loc_product_ids, /* parent */ + "1", + "/orders/0/productIds/1", + NULL); + const diagnostic_logical_location *logical_loc_total + = diagnostic_manager_new_logical_location (diag_mgr, + DIAGNOSTIC_LOGICAL_LOCATION_KIND_PROPERTY, + logical_loc_order_0, /* parent */ + "total", + "/orders/0/total", + NULL); + /* end quoted source */ + + { + const int line_num = line_num_of_product_ids; + const diagnostic_physical_location *loc_start + = diagnostic_manager_new_location_from_file_line_column (diag_mgr, + main_file, + line_num, + 32); + const diagnostic_physical_location *loc_end + = diagnostic_manager_new_location_from_file_line_column (diag_mgr, + main_file, + line_num, + 33); + const diagnostic_physical_location *loc_range + = diagnostic_manager_new_location_from_range (diag_mgr, + loc_start, + loc_start, + loc_end); + + diagnostic *d = diagnostic_begin (diag_mgr, + DIAGNOSTIC_LEVEL_WARNING); + diagnostic_set_location (d, loc_range); + + diagnostic_set_logical_location (d, logical_loc_element_1); + + diagnostic_finish (d, "product ID is blank"); + } + { + const int line_num = line_num_of_total; + const diagnostic_physical_location *loc_start + = diagnostic_manager_new_location_from_file_line_column (diag_mgr, + main_file, + line_num, + 16); + const diagnostic_physical_location *loc_end + = diagnostic_manager_new_location_from_file_line_column (diag_mgr, + main_file, + line_num, + 22); + const diagnostic_physical_location *loc_range + = diagnostic_manager_new_location_from_range (diag_mgr, + loc_start, + loc_start, + loc_end); + + diagnostic *d = diagnostic_begin (diag_mgr, + DIAGNOSTIC_LEVEL_WARNING); + diagnostic_set_location (d, loc_range); + + diagnostic_set_logical_location (d, logical_loc_total); + + diagnostic_finish (d, "value is negative"); + } + + return end_test (); +} + +/* Check the output from the text sink. */ +/* { dg-begin-multiline-output "" } +In JSON value '/orders/0/productIds/1': + { dg-end-multiline-output "" } */ +/* { dg-regexp "\[^\n\r\]+test-nested-logical-locations-json.c:28:32: warning: product ID is blank" } */ +/* { dg-begin-multiline-output "" } + 28 | "productIds": [ "A-101", "", "A-223" ], + | ^~ + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } +In JSON property '/orders/0/total': + { dg-end-multiline-output "" } */ +/* { dg-regexp "\[^\n\r\]+test-nested-logical-locations-json.c:29:16: warning: value is negative" } */ +/* { dg-begin-multiline-output "" } + 29 | "total": "-3.25" + | ^~~~~~~ + { dg-end-multiline-output "" } */ + +/* Verify that some JSON was written to a file with the expected name: + { dg-final { verify-sarif-file } } */ + +/* Use a Python script to verify various properties about the generated + .sarif file: + { dg-final { run-sarif-pytest test-nested-logical-locations-json.c "test-nested-logical-locations-json-c.py" } } */ diff --git a/gcc/testsuite/libgdiagnostics.dg/test-warning-with-path-c.py b/gcc/testsuite/libgdiagnostics.dg/test-warning-with-path-c.py index 5d3bbc4..af1e7b9 100644 --- a/gcc/testsuite/libgdiagnostics.dg/test-warning-with-path-c.py +++ b/gcc/testsuite/libgdiagnostics.dg/test-warning-with-path-c.py @@ -51,10 +51,8 @@ def test_sarif_output_for_warning_with_path(sarif): assert len(location['logicalLocations']) == 1 logical_loc = location['logicalLocations'][0] - assert logical_loc['name'] == 'make_a_list_of_random_ints_badly' + assert logical_loc['index'] == 0 assert logical_loc['fullyQualifiedName'] == 'make_a_list_of_random_ints_badly' - assert logical_loc['decoratedName'] == 'make_a_list_of_random_ints_badly' - assert logical_loc['kind'] == 'function' assert len(result['codeFlows']) == 1 assert len(result['codeFlows'][0]['threadFlows']) == 1 @@ -106,3 +104,13 @@ def test_sarif_output_for_warning_with_path(sarif): == "when calling 'PyList_Append', passing NULL from (1) as argument 1" assert tfl_2['nestingLevel'] == 0 assert tfl_2['executionOrder'] == 3 + + # Check theRun.logicalLocations + assert 'logicalLocations' in run + assert len(run['logicalLocations']) == 1 + logical_loc = run['logicalLocations'][0] + assert logical_loc['name'] == 'make_a_list_of_random_ints_badly' + assert logical_loc['fullyQualifiedName'] == 'make_a_list_of_random_ints_badly' + assert logical_loc['decoratedName'] == 'make_a_list_of_random_ints_badly' + assert logical_loc['kind'] == 'function' + assert logical_loc['index'] == 0 diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif index 4743bad..9f0b87b 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.1-not-an-object.sarif @@ -1,6 +1,9 @@ [ null ] // { dg-error "expected a sarifLog object as the top-level value \\\[SARIF v2.1.0 §3.1\\\]" } /* { dg-begin-multiline-output "" } +In JSON array '': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 1 | [ null ] | ^~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif index c4354d4..be2316a 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-missing-arguments-for-placeholders.sarif @@ -9,6 +9,9 @@ } /* { dg-begin-multiline-output "" } +In JSON object '/runs/0/results/0/message': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 6 | { "message": { "text" : "the {0} {1} fox jumps over the {2} dog" } } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif index e3eb534..98c3dc9 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-not-enough-arguments-for-placeholders.sarif @@ -9,6 +9,9 @@ } /* { dg-begin-multiline-output "" } +In JSON object '/runs/0/results/0/message': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 6 | { "message": { "text" : "the {0} {1} fox jumps over the {2} dog", "arguments": ["quick", "brown"] } } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif index 29460e1..f816859 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif @@ -10,6 +10,9 @@ } /* { dg-begin-multiline-output "" } +In JSON property '/runs/0/results/0/message/text': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 6 | { "message": { "text" : "before {} after" }, | ^~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif index 771bd9c..d290604 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-no-version.sarif @@ -1,6 +1,9 @@ { } // { dg-error "expected sarifLog object to have a 'version' property \\\[SARIF v2.1.0 §3.13.2\\\]" } /* { dg-begin-multiline-output "" } +In JSON object '': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 1 | { } | ^~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif index 87bfd0d..c83be50 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.2-version-not-a-string.sarif @@ -1,6 +1,9 @@ { "version" : 42 } // { dg-error "15: expected sarifLog.version to be a JSON string; got JSON number \\\[SARIF v2.1.0 §3.13.2\\\]" } /* { dg-begin-multiline-output "" } +In JSON property '/version': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 1 | { "version" : 42 } | ^~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif index c5a26f0..202698e 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-bad-runs.sarif @@ -2,6 +2,9 @@ "runs": 42 } // { dg-error "expected sarifLog.runs to be 'null' or an array \\\[SARIF v2.1.0 §3.13.4\\\]" } /* { dg-begin-multiline-output "" } +In JSON property '/runs': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 2 | "runs": 42 } | ^~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif index f142321..a4870c1 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-no-runs.sarif @@ -1,6 +1,9 @@ { "version": "2.1.0" } // { dg-error "expected sarifLog object to have a 'runs' property \\\[SARIF v2.1.0 §3.13.4\\\]" } /* { dg-begin-multiline-output "" } +In JSON object '': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 1 | { "version": "2.1.0" } | ^~~~~~~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif index 4eeaaaa..b870959 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.13.4-non-object-in-runs.sarif @@ -2,6 +2,9 @@ "runs" : [42] } // { dg-error "expected element of sarifLog.runs array to be an object \\\[SARIF v2.1.0 §3.13.4\\\]" } /* { dg-begin-multiline-output "" } +In JSON property '/runs/0': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 2 | "runs" : [42] } | ^~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif index b5c3fbe..eb60b66 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.27.10-bad-level.sarif @@ -20,6 +20,9 @@ } /* { dg-begin-multiline-output "" } +In JSON property '/runs/0/results/0/level': + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 12 | "level": "mostly harmless", | ^~~~~~~~~~~~~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif index ef22614..d7baac9 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.33.3-index-out-of-range.sarif @@ -27,6 +27,9 @@ } /* { dg-begin-multiline-output "" } +In JSON property '/runs/0/results/0/locations/0/logicalLocations/0/index' + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 17 | "index": 42 | ^~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif index 7f58677..20552a3 100644 --- a/gcc/testsuite/sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-unhandled/3.27.10-none-level.sarif @@ -20,6 +20,9 @@ } /* { dg-begin-multiline-output "" } +In JSON property '/runs/0/results/0/level' + { dg-end-multiline-output "" } */ +/* { dg-begin-multiline-output "" } 12 | "level": "none", | ^~~~~~ { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-json-example.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-json-example.sarif new file mode 100644 index 0000000..6e4cf5b --- /dev/null +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-json-example.sarif @@ -0,0 +1,83 @@ +/* Adapted from the JSON example in SARIF v2.1.0, 3.33.7 "kind" property; + see https://github.com/oasis-tcs/sarif-spec/issues/670 */ +{ + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "example JSON scanner" + } + }, + "results": [ + { + "message": {"text": "product ID is blank"}, + "locations": [ + { + "logicalLocations": [ + { + "fullyQualifiedName": "/orders/0/productIds/1", + "index": 3 + } + ] + } + ] + }, + { + "message": {"text": "value is negative"}, + "locations": [ + { + "logicalLocations": [ + { + "fullyQualifiedName": "/orders/0/total", + "index": 4 + } + ] + } + ] + } + ], + "logicalLocations": [ + { + "name": "orders", + "fullyQualifiedName": "/orders", + "kind": "array" + }, + { + "name": "0", + "fullyQualifiedName": "/orders/0", + "kind": "object", + "parentIndex": 0 + }, + { + "name": "productIds", + "fullyQualifiedName": "/orders/0/productIds", + "kind": "array", + "parentIndex": 1 + }, + { + "name": "1", + "fullyQualifiedName": "/orders/0/productIds/1", + "kind": "value", + "parentIndex": 2 + }, + { + "name": "total", + "fullyQualifiedName": "/orders/0/total", + "kind": "property", + "parentIndex": 1 + } + ] + } + ] +} + +/* { dg-begin-multiline-output "" } +In JSON value '/orders/0/productIds/1': +example JSON scanner: warning: product ID is blank + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } +In JSON property '/orders/0/total': +example JSON scanner: warning: value is negative + { dg-end-multiline-output "" } */ diff --git a/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-xml-example.sarif b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-xml-example.sarif new file mode 100644 index 0000000..36afc65 --- /dev/null +++ b/gcc/testsuite/sarif-replay.dg/2.1.0-valid/3.33.7-xml-example.sarif @@ -0,0 +1,77 @@ +/* Adapted from the XML example in SARIF v2.1.0, 3.33.7 "kind" property; + see also https://github.com/oasis-tcs/sarif-spec/issues/669 */ +{ + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "example XML scanner" + } + }, + "results": [ + { + "message": {"text": "empty value"}, + "locations": [ + { + "logicalLocations": [ + { + "fullyQualifiedName": "/orders/order[1]/@number", + "index": 2 + } + ] + } + ] + }, + { + "message": {"text": "total is negative"}, + "locations": [ + { + "logicalLocations": [ + { + "fullyQualifiedName": "/orders/order[1]/total/text()", + "index": 3 + } + ] + } + ] + } + ], + "logicalLocations": [ + { + "name": "orders", + "fullyQualifiedName": "/orders", + "kind": "element" + }, + { + "name": "order[1]", + "fullyQualifiedName": "/orders/order[1]", + "kind": "element", + "parentIndex": 0 + }, + { + "name": "number", + "fullyQualifiedName": "/orders/order[1]/@number", + "kind": "attribute", + "parentIndex": 1 + }, + { + "name": "text", + "fullyQualifiedName": "/orders/order[1]/total/text()", + "kind": "text", + "parentIndex": 1 + } + ] + } + ] +} + +/* { dg-begin-multiline-output "" } +In attribute '/orders/order[1]/@number': +example XML scanner: warning: empty value + { dg-end-multiline-output "" } */ + +/* { dg-begin-multiline-output "" } +In text '/orders/order[1]/total/text()': +example XML scanner: warning: total is negative + { dg-end-multiline-output "" } */ |