| Summary: | add checker for digraphs and trigraphs. | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Vasiliy Dybala <dibalavs> | ||||
| Component: | cdt-codan | Assignee: | CDT Codan Inbox <cdt-codan-inbox> | ||||
| Status: | RESOLVED INVALID | QA Contact: | Elena Laskavaia <elaskavaia.cdt> | ||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | cdtdoug, yevshif, zeratul976 | ||||
| Version: | 8.0 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Let's think for a second here. The "Syntax error" marker comes from the parser, since the parser understands digraphs / trigraphs correctly and is unable to parse the code. The parser has to support digraphs and trigraphs, because it needs to be able to handle any legacy code which has them in. It is indeed possible to have a checker which would look for digraphs/trigraphs- but what then? We can't always warn about them since I they might be desired in some code. Some compilers (like GCC on default settings) ignore di/trigraphs, but I believe there's no accessible project-specific setting for that, so that we could set the parser in the right mode automatically. What I'd actually like to see is separate syntax coloring for di/trigraphs. Created attachment 201608 [details]
Checker + fixes
Actually I have serious second thoughts about them being "desired in some code"... Anyway- here's the checker + two quick fixes:
- replace the sequence by "normal" token
- escape the sequence
Trigraphs are checked before tokenisation, digraphs - after.
The patch also does a little cleanup w/r/t localisation in a couple of other quick fixes (there were two Messages.properties when there should've been one).
Do we need junits for this checker?
According to the standard, the code in comment 0 is valid. We no longer give a syntax error for it (see bug 398254). Do we still need this checker? |
Build Identifier: 201010290004 1. write code: const int var = 1; namespace { const int var = 2; template<int c> void f(){} void test() { f<::var>(); } } 2. at line "f<::var>();" eclipse shows uninformative error "syntax error.". But a few people use di and trigraphs (I don't know anyone who uses them) and they are may don't know that symbols <: has another meaning. The idea is add checker that can say user friendly message, for example: "Syntax error. Found '<:' digraph. Please fix to '< :'" Reproducible: Always