Bug 264482

Summary: kdevelop enforces usage of {braces} around switch cases
Product: [Applications] kdevelop Reporter: Émeric Dupont <emeric.dupont>
Component: Language Support: CPP (old)Assignee: kdevelop-bugs-null
Status: RESOLVED DUPLICATE    
Severity: normal CC: sebastian
Priority: NOR    
Version: 4.1.60   
Target Milestone: 4.2.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:

Description Émeric Dupont 2011-01-27 14:44:46 UTC
Version:           4.1.60 (using KDE 4.6.0) 
OS:                Linux

Google test (http://code.google.com/p/googletest/) uses macros in the form "switch (0) case 0: if (true) ; else ;" for its ASSERT_* macros. Since there is only one case in the switch, curly braces should not be required around it.

However, when parsing such a line, kdevelop displays an error "Unexpected token 'case'".



Reproducible: Always

Steps to Reproduce:
$ cat << EOF > main.cpp
int main()
{
    switch (0) case 0: if (true) ; else return 1;
    return 0;
}
EOF

# Make sure the code is legit:
$ g++ --version
g++ (GCC) 4.5.2
$ g++ -ansi -Wall -pedantic main.cpp

# Open main.cpp in kdevelop
# Toggle 'Problems' tool view open

Actual Results:  
The "switch" line is highlighted, and the problem "Unexpected token 'case'" appears line 3 column 16.

Expected Results:  
There should be no problem shown on this line.

"switch (0) { case 0: if (true) ; else return 1; }" is a syntax accepted by kdevelop.
Comment 1 Sebastian Dörner 2011-01-27 21:44:40 UTC

*** This bug has been marked as a duplicate of bug 204665 ***
Comment 2 Aleix Pol 2013-03-31 00:48:30 UTC
Moving all the bugs from the CPP Parser. It was not well defined the difference between it and C++ Language Support and people kept reporting in both places indistinctively