Bug 223596 - KDevelop doesn't properly parse va_arg
Summary: KDevelop doesn't properly parse va_arg
Alias: None
Product: kdevelop
Classification: Unclassified
Component: Language Support: CPP (old) (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal with 21 votes (vote)
Target Milestone: ---
Assignee: kdevelop-bugs-null
: 200289 (view as bug list)
Depends on:
Reported: 2010-01-20 17:39 UTC by Marat Radchenko
Modified: 2012-12-08 18:18 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Marat Radchenko 2010-01-20 17:39:28 UTC
Version:           3.9.97 (using KDevPlatform 0.9.97) (using 4.3.3 (KDE 4.3.3), Gentoo)
Compiler:          x86_64-pc-linux-gnu-gcc
OS:                Linux (x86_64) release 2.6.31-gentoo

1. Create .c file with following contents (it's valid C, yep):
#include <stdarg.h>

static void foo(va_list ap) {
  const char * bar = va_arg(ap, char *);

int main(void) {}

2. Open in in KDevelop

Expected: file is parsed properly, no errors.
Actual: line from foo function is marked as invalid and several "unexpected token" problems are reported.
Comment 1 Nicolás Alvarez 2010-07-22 21:18:18 UTC
On my system, va_arg is defined as:

#define va_arg(v,l)     __builtin_va_arg(v,l)

__builtin_va_arg is a gcc builtin, not declared in any header, so KDevelop doesn't know about it.

How to solve this? Add support for __builtin_va_arg, or override va_arg? Or maybe both; add our own set of __builtin*s, like a compiler would, and override the macros to ensure they are defined to point at the builtins, like a compiler's bundled headers would?
Comment 2 Marat Radchenko 2010-10-30 18:50:27 UTC
I'd say KDevelop should explicitely 'know' how va_arg works since it is a builtin (and special) thing in C.
Comment 3 Olivier.jg 2010-12-17 13:11:07 UTC
*** Bug 200289 has been marked as a duplicate of this bug. ***
Comment 4 Olivier.jg 2012-12-08 18:18:03 UTC
Git commit 6f54bcb4da0fd2911a0ee909b75ef6b42c6a7cd9 by Olivier JG.
Committed on 08/12/2012 at 19:16.
Pushed by olivierjg into branch 'master'.

Add simple definition for __builtin_va_arg to allow the declaration
builder to get the correct types and create declarations.
Add tests.

M  +11   -0    languages/cpp/setuphelpers.cpp
A  +40   -0    languages/cpp/tests/cpptestfiles/va_arg.cpp     [License: LGPL (v2)]