Bug 534913 - Adding the possibility to suppress a "Syntax Error" due to missing lot of C++17 features
Summary: Adding the possibility to suppress a "Syntax Error" due to missing lot of C++...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: Next   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-21 07:47 EDT by Peter VARGA CLA
Modified: 2020-09-04 15:25 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter VARGA CLA 2018-05-21 07:47:07 EDT
I refer to this SO thread:
https://stackoverflow.com/questions/50435974/how-to-suppress-syntax-error-in-eclipse-4-7-3a

This very simple C++17 example generates 2 Syntax Errors and they cannot be suppressed as other errors:
http://en.cppreference.com/w/cpp/utility/variant/visit

The fact is that lot of C++17 features are still not implemented and I guess it won't be better with other/following standards.
E.q. the implementation will took longer than the standard becomes active.

I consider it as a good feature, especially also for the future.

Just adding the error type "Syntax Error" in "Preferences | C/C++ | Code Analysis"
Comment 1 Nathan Ridge CLA 2018-05-22 01:50:52 EDT
I agree, this would be a useful feature to have.

It's not very trivial to implement, because the current @suppress feature is a Codan feature, and syntax errors are not created by Codan. (They don't even use IMarkers the way Codan errors do. They create IAnnotations directly, which happens in TranslationUnitAnnotationModel, CDT's customized version of ResourceMarkerAnnotationModel).

Possible implementation strategies are:

  - Get syntax errors to be reported by Codan, by writing
    a new checker like SyntaxErrorChecker. The checker can
    query the problems directly from the AST, similar to
    how CModelBuilder2.buildModel() currently does. The
    code in TranslationUnitAnnotationModel to create
    IAnnotations for syntax problems can be removed.

    If we go this route, the support for @suppress will
    come automatically.

  - Factor out the relevant code for supporting @supress
    from Codan, and use it when creating IAnnotations
    for syntax problems in TranslationUnitAnnotationModel.

I don't expect to have time to work on this, but if someone would like to tackle it, I'm happy to provide guidance.
Comment 2 Nathan Ridge CLA 2018-05-22 01:55:59 EDT
The first option would require some extra plumbing if we want to syntax errors to continue to have their own icon and underline style (distinct from other Codan errors). There may also be some differences in how soon the syntax errors show up (i.e. we might currently do the model building, which produces the syntax errors, more often than we run the Codan checkers; I'm not actually sure, that's just my impression based on how quickly the two kinds of errors show up).
Comment 3 Marco Stornelli CLA 2019-08-05 05:12:41 EDT
I tried to add a new checker moving the code from CModelBuilder2 as Nathan said. It works quite well but there are some problems from UI point of view in my opinion. At the moment we have a unique annotation "Index Marker" with specific symbol. Codan problems have three level of severity: error, warning and info. At the moment I created a specific marker codanSyntaxProblem (child of codanProblem) and I linked it to the current Index annotation for all severity levels. It works but if you open the codan ui what's the point to set the severity if everything points to the same value? I mean to keep consistent behavior we should use the same approach, so three level of severity as other codan problems, maybe keeping error as default in this case. Another option would be to use three new icons for this specific problems, but honestly I'm not a UI designer so I don't know what's the best option.
Comment 4 Eclipse Genie CLA 2020-01-03 04:05:37 EST
New Gerrit change created: https://git.eclipse.org/r/155155