Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when including boost headers [clang-diagnostic-missing-template-arg-list-after-template-kw] #101079

Closed
FoxLightning opened this issue Jul 29, 2024 · 6 comments
Labels
c++ clang-tidy question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@FoxLightning
Copy link

FoxLightning commented Jul 29, 2024

boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
82 | quat_traits::template write_element_idx(i, q) = s;
(I don't include this header)

appear if use in cmake project with
boost built from source v1.85
tried c++ standard 17 20 23 - same result

LLVM version 20.0.0git
Optimized build. (on 18 was crash)

latest Mac OS
cpu m1pro

file(GLOB_RECURSE CPP_FILES *.cpp)
include_directories(${PROJECT_SOURCE_DIR}/src/include)
add_executable(${PROJECT_NAME} ${CPP_FILES})

if (WIN32)
    target_link_libraries(
        ${PROJECT_NAME} PRIVATE SDL3main
    )
endif()

# third party libs
target_link_libraries(${PROJECT_NAME} PRIVATE
    SDL3::SDL3
    SDL3_image::SDL3_image
    SDL3_ttf::SDL3_ttf
    Boost::geometry
)
# clang-tidy setup
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
    set(CLANG_TIDY_CONFIG_FILE ${PROJECT_SOURCE_DIR}/.clang-tidy)
    set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-config-file=${CLANG_TIDY_CONFIG_FILE}")
    message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
    message(STATUS "Using clang-tidy configuration: ${CLANG_TIDY_CONFIG_FILE}")
else()
    message(WARNING "clang-tidy not found!")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
cmake_minimum_required(VERSION 3.16)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# clang-tidy crashes on C++20 during linting boost/geometry headers
# even if headers dont include in HeaderFilterRegex
set(CMAKE_CXX_STANDARD 17)

project(GameOne VERSION 0.1)

# Black magic from one internet guy, need for run SDL3_image 
# (Probably usefull only for MacOS)
enable_language(OBJC)

add_subdirectory(lib/SDL)
add_subdirectory(lib/SDL_image)
add_subdirectory(lib/SDL_ttf)
add_subdirectory(lib/boost)
add_subdirectory(src)
image
/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   82 |     quat_traits<Q>::template write_element_idx(i, q) = s;
      |                              ^
/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:92:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   92 |     quat_traits<Q>::template write_element_idx(i, q, s);
      |                              ^
4 warnings and 2 errors generated.
Error while processing /Users/bohdanlysychenko/GameOne/src/cpp/GameBase/BaseController.cpp.
Suppressed 4 warnings (4 with check filters).
Found compiler error(s).
make[2]: *** [src/CMakeFiles/GameOne.dir/cpp/GameBase/BaseController.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/GameOne.dir/all] Error 2
make: *** [all] Error 2
@FoxLightning FoxLightning changed the title Error when including boost headersc[clang-diagnostic-missing-template-arg-list-after-template-kw] Error when including boost headers [clang-diagnostic-missing-template-arg-list-after-template-kw] Jul 29, 2024
@keinflue
Copy link

keinflue commented Jul 30, 2024

Clang is correctly rejecting the boost code. The template keyword must be followed by a template-id (i.e. a name followed by template argument list), except when the name refers to a class or alias template (and this use is deprecated).

From a quick look at the code, the template keyword simply should be removed.

I would suggest reporting the issue to boost/qvm.

See also #94194.

@FoxLightning
Copy link
Author

FoxLightning commented Jul 30, 2024

Clang is correctly rejecting the boost code. The template keyword must be followed by a template-id (i.e. a name followed by template argument list), except when the name refers to a class or alias template (and this use is deprecated).

From a quick look at the code, the template keyword simply should be removed.

I would suggest reporting the issue to boost/qvm.

See also #94194.

If this is a normal situation, then why does clang compiler not produce this error?
Why params -clang-diagnostic-missing-template-arg-list-after-template-kw and -Wno-missing-template-arg-list-after-template-kw in .clang-tidy dont work?

@AaronBallman
Copy link
Collaborator

Perhaps you've configured clang-tidy incorrectly?

https://godbolt.org/z/vv5GY7qY4

@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2024

@llvm/issue-subscribers-c-1

Author: Bogdan (FoxLightning)

boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw] 82 | quat_traits<Q>::template write_element_idx(i, q) = s; (I don't include this header)

appear if use in cmake project with
boost built from source v1.85
tried c++ standard 17 20 23 - same result

LLVM version 20.0.0git
Optimized build. (on 18 was crash)

latest Mac OS
cpu m1pro

file(GLOB_RECURSE CPP_FILES *.cpp)
include_directories(${PROJECT_SOURCE_DIR}/src/include)
add_executable(${PROJECT_NAME} ${CPP_FILES})

if (WIN32)
    target_link_libraries(
        ${PROJECT_NAME} PRIVATE SDL3main
    )
endif()

# third party libs
target_link_libraries(${PROJECT_NAME} PRIVATE
    SDL3::SDL3
    SDL3_image::SDL3_image
    SDL3_ttf::SDL3_ttf
    Boost::geometry
)
# clang-tidy setup
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
    set(CLANG_TIDY_CONFIG_FILE ${PROJECT_SOURCE_DIR}/.clang-tidy)
    set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-config-file=${CLANG_TIDY_CONFIG_FILE}")
    message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
    message(STATUS "Using clang-tidy configuration: ${CLANG_TIDY_CONFIG_FILE}")
else()
    message(WARNING "clang-tidy not found!")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
cmake_minimum_required(VERSION 3.16)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# clang-tidy crashes on C++20 during linting boost/geometry headers
# even if headers dont include in HeaderFilterRegex
set(CMAKE_CXX_STANDARD 17)

project(GameOne VERSION 0.1)

# Black magic from one internet guy, need for run SDL3_image 
# (Probably usefull only for MacOS)
enable_language(OBJC)

add_subdirectory(lib/SDL)
add_subdirectory(lib/SDL_image)
add_subdirectory(lib/SDL_ttf)
add_subdirectory(lib/boost)
add_subdirectory(src)

<img width="461" alt="image" src="https://github.com/user-attachments/assets/c409be76-f5bb-477b-9fc1-fee7b421a7c0">

/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   82 |     quat_traits&lt;Q&gt;::template write_element_idx(i, q) = s;
      |                              ^
/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:92:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   92 |     quat_traits&lt;Q&gt;::template write_element_idx(i, q, s);
      |                              ^
4 warnings and 2 errors generated.
Error while processing /Users/bohdanlysychenko/GameOne/src/cpp/GameBase/BaseController.cpp.
Suppressed 4 warnings (4 with check filters).
Found compiler error(s).
make[2]: *** [src/CMakeFiles/GameOne.dir/cpp/GameBase/BaseController.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/GameOne.dir/all] Error 2
make: *** [all] Error 2

@llvmbot
Copy link
Member

llvmbot commented Jul 30, 2024

@llvm/issue-subscribers-clang-tidy

Author: Bogdan (FoxLightning)

boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw] 82 | quat_traits<Q>::template write_element_idx(i, q) = s; (I don't include this header)

appear if use in cmake project with
boost built from source v1.85
tried c++ standard 17 20 23 - same result

LLVM version 20.0.0git
Optimized build. (on 18 was crash)

latest Mac OS
cpu m1pro

file(GLOB_RECURSE CPP_FILES *.cpp)
include_directories(${PROJECT_SOURCE_DIR}/src/include)
add_executable(${PROJECT_NAME} ${CPP_FILES})

if (WIN32)
    target_link_libraries(
        ${PROJECT_NAME} PRIVATE SDL3main
    )
endif()

# third party libs
target_link_libraries(${PROJECT_NAME} PRIVATE
    SDL3::SDL3
    SDL3_image::SDL3_image
    SDL3_ttf::SDL3_ttf
    Boost::geometry
)
# clang-tidy setup
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
    set(CLANG_TIDY_CONFIG_FILE ${PROJECT_SOURCE_DIR}/.clang-tidy)
    set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-config-file=${CLANG_TIDY_CONFIG_FILE}")
    message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
    message(STATUS "Using clang-tidy configuration: ${CLANG_TIDY_CONFIG_FILE}")
else()
    message(WARNING "clang-tidy not found!")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CMAKE_CXX_CLANG_TIDY}")
cmake_minimum_required(VERSION 3.16)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# clang-tidy crashes on C++20 during linting boost/geometry headers
# even if headers dont include in HeaderFilterRegex
set(CMAKE_CXX_STANDARD 17)

project(GameOne VERSION 0.1)

# Black magic from one internet guy, need for run SDL3_image 
# (Probably usefull only for MacOS)
enable_language(OBJC)

add_subdirectory(lib/SDL)
add_subdirectory(lib/SDL_image)
add_subdirectory(lib/SDL_ttf)
add_subdirectory(lib/boost)
add_subdirectory(src)

<img width="461" alt="image" src="https://github.com/user-attachments/assets/c409be76-f5bb-477b-9fc1-fee7b421a7c0">

/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:82:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   82 |     quat_traits&lt;Q&gt;::template write_element_idx(i, q) = s;
      |                              ^
/Users/bohdanlysychenko/GameOne/lib/boost/libs/qvm/include/boost/qvm/quat_traits.hpp:92:30: error: a template argument list is expected after a name prefixed by the template keyword [clang-diagnostic-missing-template-arg-list-after-template-kw]
   92 |     quat_traits&lt;Q&gt;::template write_element_idx(i, q, s);
      |                              ^
4 warnings and 2 errors generated.
Error while processing /Users/bohdanlysychenko/GameOne/src/cpp/GameBase/BaseController.cpp.
Suppressed 4 warnings (4 with check filters).
Found compiler error(s).
make[2]: *** [src/CMakeFiles/GameOne.dir/cpp/GameBase/BaseController.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/GameOne.dir/all] Error 2
make: *** [all] Error 2

@FoxLightning
Copy link
Author

Yes, indeed the problem was in the wrong arguments for the linter. I missed --extra-arg-before
This helps me

--extra-arg-before=-Wno-missing-template-arg-list-after-template-kw

Thanks everyone for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang-tidy question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

5 participants