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 270231 - typeof keyword not recognized by C++ parser
Summary: typeof keyword not recognized by C++ parser
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: petrk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-28 14:10 UTC by michaelkourlas
Modified: 2017-04-20 10:06 UTC (History)
0 users

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 michaelkourlas 2017-03-28 14:10:09 UTC
"typeof" is a GCC extension that is equivalent to "decltype" from C++11. It appears that the NetBeans C++ parser doesn't properly recognize this keyword.

For example, GCC 4.6.4 successfully complies the following code when using the default standard "gnu++98":

<code>
#include <iostream>

int main()
{
    int x = 3;
    typeof(x) y = 2;
    std::cout << (x + y);
}
</code>

However, NetBeans reports a syntax error on line 6: "Unable to resolve identifier x".

***

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 1
Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13
Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13
System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
Comment 1 petrk 2017-03-30 18:47:23 UTC
Can you, please, provide a compilation command? As far as I know GCC doesn't support typeof extension in C++, only in C. Therefore I'm confused because your test case uses iostream. However, there is a keyword __typeof__ which works both in C and C++. So, I think that we need to add support for typeof into C language and for __typeof__ into both languages. Do you agree?
Comment 2 michaelkourlas 2017-03-30 21:21:50 UTC
The commands I'm using to compile and execute are nothing special:

g++ main.cpp -o main
./main

However, this is on GCC 4.6.4, which is pretty old.

I believe "__typeof__" must be used if you're compiling in standards mode, but by default GCC accepts "typeof" as a non-standard extension.
Comment 3 michaelkourlas 2017-03-30 21:22:55 UTC
To be clear, though, I believe that GCC indeed supports the "typeof" keyword in C++, not just C.
Comment 4 petrk 2017-03-31 18:02:18 UTC
Fixed at enum: 315028:4b94e16d83c2
Comment 5 Quality Engineering 2017-04-11 01:51:37 UTC
Integrated into 'main-silver', will be available in build *201704110002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3b32f280b5fe
User: Petr Kudryavtsev <petrk@netbeans.org>
Log: Fixed #270231 - typeof keyword not recognized by C++ parser
(transplanted from e238ee10b99de88e3e79086cb9d7d8acd2ec82c7)
(transplanted from 4b94e16d83c2d117d977b7b3155ebadacfdf7a98)
Comment 6 ilia 2017-04-13 10:47:36 UTC
https://netbeans.org/bugzilla/show_bug.cgi?id=270231 Changesets:
    http://hg.netbeans.org/releases/rev/4b94e16d83c2 # Fixed #270231 - typeof keyword not recognized by C++ parser
    http://hg.netbeans.org/releases/rev/090487d610f8 # Additional fix for bug #270231 - typeof keyword not recognized by C++ parser
Comment 7 soldatov 2017-04-20 10:06:17 UTC
Verified in NetBeans IDE 8.2 (Build 201704181436)