Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-26146

Code model doesn't respect c++ standard in cmake project

    XMLWordPrintable

Details

    • Windows
    • 54c53223228539e3ca4126657ae52bc2fc705c71 (qt-creator/qt-creator/5.0)

    Description

      This bug is only reproducible on Windows MSVC, I tried it now on Linux and there it works like expected.

      I have created New Project - Library - C++ library ( shared ), it is practically the default library cmake project.

      I have changed the standard to 20:

      set(CMAKE_CXX_STANDARD 20)

      I pasted this code to the cpp file: 

      #include <type_traits>
      namespace Orm::Query
      {}
      template<typename T>
      concept Queryable = std::convertible_to<T, int> ||
                          std::invocable<T, int>;
      

       And I get errors and warnings from the code model.

      If the code model doesn't respect the selected c++ standard then it can be assumed that it doesn't respect CMAKE_CXX_EXTENSIONS too.

      Used example project:

      library_cmake.zip

      Main CMakeLists.txt file:

      cpp file content:

       

      And errors and warnings views:

      As another proof the same works in the qmake project, here is the same example as the qmake project:

      library_qmake.zip

      Open library_qmake.pro and uncomment CONFIG += c++11 and also comment #CONFIG += c++2a, by this you select c++11 standard and you get exactly the same errors and warnings as I have reported above. So it is absolutely clear that QtCreator doesn't set up the underlying library correctly. ( I don't know what is used to obtain warnings and errors by the Code Model, I'm guessing libclang? )

      Attachments

        1. qtcreator-codemodel.png
          qtcreator-codemodel.png
          37 kB
        2. library_qmake.zip
          4 kB
        3. library_cmake.zip
          8 kB
        4. image-2021-08-19-12-27-17-252.png
          image-2021-08-19-12-27-17-252.png
          280 kB
        5. image-2021-08-19-12-27-07-624.png
          image-2021-08-19-12-27-07-624.png
          220 kB
        6. image-2021-08-19-12-11-55-325.png
          image-2021-08-19-12-11-55-325.png
          254 kB

        Activity

          People

            cadam Cristian Adam
            silverq Silver Zachara
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: