https://bugs.kde.org/show_bug.cgi?id=469079

Igor Kushnir <igor...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Version Fixed In|                            |5.13.231200
             Status|ASSIGNED                    |RESOLVED
      Latest Commit|                            |https://invent.kde.org/kdev
                   |                            |elop/kdevelop/-/commit/6c44
                   |                            |e08795219bf14e30d2384d6ac06
                   |                            |aa3b59517

--- Comment #16 from Igor Kushnir <igor...@gmail.com> ---
Git commit 6c44e08795219bf14e30d2384d6ac06aa3b59517 by Igor Kushnir.
Committed on 15/09/2023 at 10:55.
Pushed by igorkushnir into branch 'master'.

Improve GCC compatibility by including floating typedefs

The included _FloatX typedefs eliminate the following parse errors when
GCC 13 is selected as "Compiler for path":
    /usr/include/stdlib.h:141:8: error: unknown type name '_Float32'
    /usr/include/stdlib.h:147:8: error: unknown type name '_Float64'
    /usr/include/stdlib.h:153:8: error: unknown type name '_Float128'
    /usr/include/stdlib.h:159:8: error: unknown type name '_Float32x'
    /usr/include/stdlib.h:165:8: error: unknown type name '_Float64x'

There are so many such errors that parsing sometimes fails altogether:
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
This fatal error can be reproduced by including <bits/stdc++.h> in
main.cpp and inserting `set(CMAKE_CXX_STANDARD 20)` in CMakeLists.txt of
a single-file hello-world C++ project; selecting "c++2a" C++ profile and
"GCC" as Compiler for path on the project's Language Support
configuration page and restarting KDevelop as
    KDEV_CLANG_DISPLAY_DIAGS=1 CLEAR_DUCHAIN_DIR=1 kdevelop

This change also fixes the testGccCompatibility test (both data rows) in
test_duchain-clang.

The included _FloatX typedefs introduce type aliases instead of GCC's
separate types. This causes the following parse errors:
    /usr/include/math.h:1396:19: error: redefinition of '__iseqsig_type<float>'
    /usr/include/math.h:1406:19: error: redefinition of
'__iseqsig_type<double>'
    /usr/include/math.h:1432:19: error: redefinition of
'__iseqsig_type<double>'
    /usr/include/math.h:1442:19: error: redefinition of '__iseqsig_type<long
double>'
because of template specializations like this:
    template<> struct __iseqsig_type<_Float32>
Fortunately, these new redefinition errors are much fewer and don't
cause the "too many errors" fatal error.

The _FloatX typedefs are included in C programs only when GCC version is
7 or later and in C++ programs only when GCC version is 13 or later,
because earlier GCC versions don't provide these types and glibc
provides their substitutes for earlier GCC versions in its
bits/floatn-common.h header:
    #  if !__GNUC_PREREQ (7, 0) || (defined __cplusplus && !__GNUC_PREREQ (13,
0))
    typedef float _Float32;
    #  endif

Include also a __float80 typedef to eliminate the following parse error:
    /usr/include/c++/13.2.1/compare:715:33: error: unknown type name
'__float80'
According to the documentation, GCC provides __float80 since at least
version 7:
https://gcc.gnu.org/onlinedocs/gcc-7.5.0/gcc/Floating-Types.html#Floating-Types

The changes in ClangCodeCompletionContext::completionItems() prevent
unwanted _FloatX TypedefDecl completions, which would otherwise make
TestCodeCompletion::testIgnoreGccBuiltins() fail.

Note: c791359763cd862f93ad9f91fa628d20e1e630f2 removed a similarly
included workaround header gcc_compat.h.
FIXED-IN: 5.13.231200

M  +2    -1    plugins/clang/CMakeLists.txt
M  +49   -3    plugins/clang/codecompletion/context.cpp
A  +35   -0   
plugins/clang/duchain/gccCompatibility/additional_floating_types.h    
[License: LGPL(v2.0+)]
M  +18   -1    plugins/clang/duchain/parsesession.cpp

https://invent.kde.org/kdevelop/kdevelop/-/commit/6c44e08795219bf14e30d2384d6ac06aa3b59517

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to