Bug 57156

Summary: Language support for plain C files
Product: [Applications] kdevelop Reporter: andreaswuest
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: wishlist CC: esigra, gpiez, jed, jonsmirl, kde, leandrosansilva, maciek2w, michalsrb, rad.n, rmoats-web, robinpeder, truedfx
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: a c++ code where the bug apears

Description andreaswuest 2003-04-12 11:46:02 UTC
Version:           Current CVS version (using KDE KDE 3.1.1)
Installed from:    Gentoo Packages
Compiler:          gcc 3.2.2 
OS:          Linux

hi,

the gideon problem reporter shows correct as problematic.
however the line is perfectly ok and compiles fine. To
reproduce the bug add the following structure to a class header file :

  struct NEXT_MOVE
  {
    int orientation; // TOP, RIGHT, BOTTOM, LEFT
    int srcX;
    int srcY;
    int destX;
    int destY;
    bool movePossible;
    bool fromOutside;
  } nextMove;

now add the following line somewhere in the class implementation :

   nextMove = (NEXT_MOVE) { 0, 0, 0, 0, 0, true, true };

The reporter shows the line as bad and gives the following reason :
';' expected found '{'
';' expected found '}'

the bug is present in the current cvs version.

bye,

 Andreas
Comment 1 Sascha Cunz 2004-06-04 02:23:19 UTC
I can confirm this behaviour - and also that it is bad. Though, this is a problem in the underlying parser (which thinks there is an error ), not in the problem reporter (which would be the case, if it reported i.e. "FooBar is undefined" when FooBar is actually defined and parsed)
Comment 2 Becheru Petru-Ioan 2004-12-23 15:17:07 UTC
yes the bug is simple:it interprets "{" as a start of a composed instruction( begin-end from pascal).I have vers 3.1.2 of KDevelop 
Comment 3 Becheru Petru-Ioan 2004-12-23 15:24:49 UTC
Created attachment 8783 [details]
a c++ code where the bug apears

if u define a struct
struct STR
  {
   int/*any type*/ member1,member2;
  };

a use like
STR str={1,2};//here there is no problem  
str=(STR){5,6};//the problem is here :)
Comment 4 Jens Dagerbo 2006-04-18 22:17:09 UTC
Changing description to make the report more general.

See the dupes for more examples.
Comment 5 Jens Dagerbo 2006-04-18 22:17:19 UTC
*** Bug 60763 has been marked as a duplicate of this bug. ***
Comment 6 Jens Dagerbo 2006-04-18 22:17:28 UTC
*** Bug 60774 has been marked as a duplicate of this bug. ***
Comment 7 Jens Dagerbo 2006-04-18 22:18:28 UTC
*** Bug 60262 has been marked as a duplicate of this bug. ***
Comment 8 Jens Dagerbo 2006-04-18 22:35:37 UTC
*** Bug 71536 has been marked as a duplicate of this bug. ***
Comment 9 Jens Dagerbo 2006-12-19 20:02:44 UTC
*** Bug 108215 has been marked as a duplicate of this bug. ***
Comment 10 Jens Dagerbo 2007-01-09 17:53:01 UTC
*** Bug 136464 has been marked as a duplicate of this bug. ***
Comment 11 Andreas Pakulat 2007-11-30 16:37:12 UTC
*** Bug 63216 has been marked as a duplicate of this bug. ***
Comment 12 Andreas Pakulat 2007-12-01 00:47:50 UTC
*** Bug 108667 has been marked as a duplicate of this bug. ***
Comment 13 Pablo Diaz-Gutierrez 2007-12-27 04:04:43 UTC
A simple yet important example that I haven't seen in the dupes is the following:

if (a*b < c) foo();

If it helps as a hint, only the * operator signals the problem (not +, - or /).
Comment 14 Andreas Pakulat 2008-06-29 15:01:03 UTC
I'm tempted to close this as wontfix, KDevelop is a C++ IDE first and foremost and thus you can expect problems when using C syntax thats not part of the C-subset of C++.

But I'm just changing it to a wishlist item for a C language plugin.
Comment 15 David Nolden 2008-06-29 15:17:36 UTC
Note however that simple C should be quite usable with our C++ support, and I think it's ok improving kdevelop a bit more so it works good with C, once C++ is "ready".
Comment 16 Andreas Pakulat 2009-03-21 13:02:01 UTC
*** Bug 187783 has been marked as a duplicate of this bug. ***
Comment 17 Robin Pedersen 2009-03-21 13:31:25 UTC
C99 designated initializers.

Because bug 187783 was closed, I'm putting this example here:

 struct foobar { int foo; int bar; };
 struct foobar fb = { .bar = 10, .foo = 20 };
Comment 18 Jed Brown 2010-06-07 16:39:33 UTC
The SSE intrinsics headers distributed with GCC use compound literals, so including xmmintrin.h, even from standards-conforming C++, produces spurious "Problems".
Comment 19 Gunther Piez 2010-06-07 19:53:54 UTC
It may not be standard, but compound literals in C++ are supported by g++, Intels icpc, MS and IBM compilers. And I use this kind of construct rather often, as it is extremly handy when writing SSE code :-)
Comment 20 Milian Wolff 2011-04-08 13:47:43 UTC
*** Bug 270319 has been marked as a duplicate of this bug. ***
Comment 21 Kevin Funk 2012-12-02 23:16:00 UTC
*** Bug 246026 has been marked as a duplicate of this bug. ***
Comment 22 Aleix Pol 2013-03-31 00:56:38 UTC
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively
Comment 23 Kevin Funk 2016-01-04 23:37:49 UTC
*** Bug 302589 has been marked as a duplicate of this bug. ***
Comment 24 Sergey Kalinichev 2016-03-08 06:21:20 UTC
Git commit 70834035889654703d9b3eca2c4951a03a0eda53 by Sergey Kalinichev.
Committed on 08/03/2016 at 06:05.
Pushed by skalinichev into branch '5.0'.

Parse C files in C mode

Now there are 2 language profiles: one for C++, another one for C.
The language type is determined by mime type.
Since *.h files used in C and C++, by default they are parsed
in C++ mode, to change that behavior there is a "Parse *.h headers
in plain C" check-box.
Related: bug 357774, bug 357615

Differential revision: https://phabricator.kde.org/D1047

M  +1    -1    languages/clang/clangparsejob.cpp
M  +5    -0    languages/clang/clangsettings/clangsettingsmanager.cpp
M  +2    -0    languages/clang/clangsettings/clangsettingsmanager.h
M  +1    -1    languages/clang/duchain/parsesession.cpp
M  +2    -1    languages/clang/tests/test_duchain.cpp
M  +0    -1    languages/clang/tests/test_files.cpp
M  +12   -2    languages/plugins/custom-definesandincludes/compilerprovider/compilerprovider.cpp
M  +64   -9    languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.cpp
M  +33   -2    languages/plugins/custom-definesandincludes/compilerprovider/settingsmanager.h
M  +15   -6    languages/plugins/custom-definesandincludes/definesandincludesmanager.cpp
M  +1    -0    languages/plugins/custom-definesandincludes/definesandincludesmanager.h
M  +2    -2    languages/plugins/custom-definesandincludes/idefinesandincludesmanager.h
M  +57   -24   languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.cpp
M  +6    -3    languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.h
M  +120  -8    languages/plugins/custom-definesandincludes/kcm_widget/parserwidget.ui
M  +4    -3    languages/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp
M  +1    -1    languages/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.h
M  +3    -2    languages/plugins/custom-definesandincludes/kcm_widget/projectpathswidget.cpp
M  +1    -1    languages/plugins/custom-definesandincludes/tests/test_definesandincludes.cpp

http://commits.kde.org/kdevelop/70834035889654703d9b3eca2c4951a03a0eda53