https://bugs.kde.org/show_bug.cgi?id=443315

            Bug ID: 443315
           Summary: "Expected expression" error declaring a variable
                    immediately after a case label
           Product: kdevelop
           Version: 5.6.2
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Language Support: CPP (Clang-based)
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: m...@dblsaiko.net
  Target Milestone: ---

SUMMARY

KDevelop analyzes a variable declaration right at the beginning of a case block
incorrectly, leading to an error while the code still compiles.

Minimal reproducible case:

    // test.c
    int main()
    {
        switch (0) {
        case 0:
            int i;  // error: Expected expression
        }

        return 0;
    }

After changing this code to the following, the error goes away:

    // test.c
    int main()
    {
        switch (0) {
        case 0:
            0;        // <- inserted line, any statement will do
            int i;
        }

        return 0;
    }

STEPS TO REPRODUCE
1. Declare a variable immediately after a case label in a switch statement

OBSERVED RESULT
KDevelop will show an "Expected expression" error after the variable
declaration

EXPECTED RESULT
KDevelop parses the code correctly as a variable declaration

SOFTWARE/OS VERSIONS
Operating System: Gentoo 2.8
KDE Plasma Version: 5.22.90
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2
Kernel Version: 5.14.8-gentoo-dist (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 23.4 GiB of RAM
Graphics Processor: Radeon RX Vega

ADDITIONAL INFORMATION

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to