This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 238041 - Function inside a function (in C) breaks parser
Summary: Function inside a function (in C) breaks parser
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: petrk
URL:
Keywords:
: 147758 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-11-06 11:47 UTC by Vladimir Kvashin
Modified: 2013-12-16 08:54 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Kvashin 2013-11-06 11:47:59 UTC
Function inside a function (in C) breaks parser.
A lot of red underlines with "unexpected token" message appears.
Fortunately, parser recovers after "}" that closes outer function.

Code example is:

#include <stdio.h>
#include <stdlib.h>

#define assert_true(condition) _assert_true(condition, #condition)

typedef struct {
    int size;
    int capacity;
    void** data;
} array;

void* array_get(array *a, int index);
void array_qsort(array *a, int (*comparator)(const void *element1, const void *element2));

int main(int argc, char** argv) {

    array a;
    
   int string_comparator (const void *element1, const void *element2) {
       const char *str1 = *((char**)element1);
       const char *str2 = *((char**)element2);
       int res = strcmp(str1, str2);
       return res;
   }
   array_qsort(&a, string_comparator);
   
    assert_true(strcmp(array_get(&a, 0), "1") == 0);
    assert_true(strcmp(array_get(&a, 1), "2") == 0);
    assert_true(strcmp(array_get(&a, 2), "3") == 0);
    assert_true(strcmp(array_get(&a, 3), "4") == 0);
    
    return (EXIT_SUCCESS);
}
Comment 1 petrk 2013-12-13 17:14:40 UTC
Fixed in http://hg.netbeans.org/cnd-main/rev/909bfffff63b
Comment 2 soldatov 2013-12-13 17:38:54 UTC
Bug 147758 should be checked too.
Comment 3 petrk 2013-12-16 08:54:56 UTC
*** Bug 147758 has been marked as a duplicate of this bug. ***