Bug 60512 - Syntax parser can be fooled by #defines
Summary: Syntax parser can be fooled by #defines
Status: RESOLVED DUPLICATE of bug 132643
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 60766 101179 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-30 07:07 UTC by Jon Smirl
Modified: 2013-03-31 00:51 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Smirl 2003-06-30 07:07:08 UTC
Version:           CVS (using KDE KDE 3.1)
Installed from:    RedHat RPMs

Editor flags a syntax error on 'foreach_s' in C code. List macros like this are all over the kernel source.

#define foreach_s(ptr, t, list)   \
        for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next)


static void free_funcs( struct dynfn *l )
{
   struct dynfn *f, *tmp;
   foreach_s (f, tmp, l) {
      remove_from_list( f );
      ALIGN_FREE( f->code );
      FREE( f );
   }
}
Comment 1 Thiago Macieira 2003-06-30 13:17:04 UTC
Note that you added a space between the macro and the parenthesis. It might be 
the cause. 
Comment 2 Amilcar do Carmo Lucas 2003-06-30 14:20:47 UTC
This was tested in three diferent machines: 
Mine, Roberto's and Jens's 
 
It worked fine in all of them, with or without the space. 
 
Please provide some more info! 
Comment 3 Jon Smirl 2003-06-30 18:18:06 UTC
I should have added the the #define is in an include file. Adding it to the C
file clears the error.

The project is makefile based without automake.

Does the problem reporter parse include files? 
How does it find the path to them on a makefile project?
Should the problem report flag include files that it's can't locate?
Comment 4 Jesse 2004-04-12 03:35:28 UTC
*** Bug 60766 has been marked as a duplicate of this bug. ***
Comment 5 Daniel Franke 2005-02-08 16:36:31 UTC
here's another example (removed safeguards for simplicity):

-- bug.h --
#define BUG_ATTRIBUTES __attribute__ ((noreturn, format (printf, 1, 2)))
void bug(const char *fmt, ...) BUG_ATTRIBUTES;
--

-- bug.c --
#include "bug.h"
void bug(const char *fmt, ...) BUG_ATTRIBUTES {    // <-- Syntax Error reported
}
--
Comment 6 Daniel Franke 2005-02-08 16:37:51 UTC
Another try ... 

> bug.h
#define BUG_ATTRIBUTES __attribute__ ((noreturn, format (printf, 1, 2)))
void bug(const char *fmt, ...) BUG_ATTRIBUTES;


> bug.c
#include "bug.h"
void bug(const char *fmt, ...) BUG_ATTRIBUTES {    // <-- Syntax Error reported
}
Comment 7 Dominik Haumann 2005-02-08 17:01:16 UTC
Another example is wxWidgets. It heavily uses macros, for instance to declare the event table, or the app etc. (very MFCish way). KDevelop even has wxWidgets templates, but isn't able to parse them correctly.

<Example: dlg.h>
// include wxWidgets includes
class DlgAbout : public wxDialog
{
public:
    CDlgAbout( wxWindow *pParent );
    ~CDlgAbout();
private:
    DECLARE_EVENT_TABLE() // XXX
};
</Example>

The line marked with XXX always gives an error with the result, that the whole class does not appear in the class view, which makes KDevelop almost unusable with wxWidgets. It seems KDevelop wants a semi-colon ';', but if I add it I cannot compile anymore.
Comment 8 Jens Dagerbo 2005-03-11 13:00:07 UTC
*** Bug 101179 has been marked as a duplicate of this bug. ***
Comment 9 Tommy Li 2005-09-04 09:55:30 UTC
This still occurs in version 3.2.2 and renders WxWidgets unusable with Kdevelop.
Comment 10 Jens Dagerbo 2006-12-29 09:50:29 UTC
Problem is with the parser, not the Problems display widget.
Comment 11 Jens Dagerbo 2007-01-07 04:36:08 UTC
I believe we've delt with this problem as much as we reasonably can in KDevelop3. See comment #3 in bug #132643.

*** This bug has been marked as a duplicate of 132643 ***
Comment 12 Aleix Pol 2013-03-31 00:51:54 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