name: UnusedMissingReturn
# this workflow checks for
# * unused input arguments
# * missing return values
# * strict prototypes
# some users have default configs that will needlessly fail Meson self-tests due to these syntax.
env:
  CFLAGS: "-Werror=unused-parameter -Werror=return-type -Werror=strict-prototypes"
  CPPFLAGS: "-Werror=unused-parameter -Werror=return-type"
  FFLAGS: "-fimplicit-none"

concurrency:
  group: unusedargs-${{ github.head_ref || github.ref }}
  cancel-in-progress: true

on:
  push:
    paths:
    - ".github/workflows/unusedargs_missingreturn.yml"
    - "test cases/cmake/**"
    - "test cases/common/**"
    - "test cases/fortran/**"
    - "test cases/linuxlike/**"
    - "test cases/objc/**"
    - "test cases/objcpp/**"
    - "test cases/windows/**"

  pull_request:
    paths:
    - ".github/workflows/unusedargs_missingreturn.yml"
    - "test cases/cmake/**"
    - "test cases/common/**"
    - "test cases/fortran/**"
    - "test cases/linuxlike/**"
    - "test cases/objc/**"
    - "test cases/objcpp/**"
    - "test cases/windows/**"

permissions:
  contents: read

jobs:

  linux:
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: '3.x'
    - name: Install Compilers
      run: |
        sudo apt update -yq
        sudo apt install -yq --no-install-recommends g++ gfortran ninja-build gobjc gobjc++
    - run: ./run_project_tests.py --only cmake common fortran platform-linux "objective c" "objective c++"
      env:
        MESON_CI_JOBNAME: linux-ubuntu-gcc-werror

  windows:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: '3.x'

    - run: pip install ninja pefile

    - run: python ./run_project_tests.py --only platform-windows
      env:
        CC: gcc
        CXX: g++
        FC: gfortran
        MESON_CI_JOBNAME: msys2-gcc-werror
