[llvm-bugs] [Bug 24945] New: "Unexpected Expression" improvement for if-else

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 25 23:27:06 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24945

            Bug ID: 24945
           Summary: "Unexpected Expression" improvement for if-else
           Product: clang
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rbarnes at umn.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

I have the following program:

    #include <iostream>

    int main(){
      int a;
      std::cin>>a;
      if(a>3){
        std::cerr<<"Here"<<std::endl;
      } else { //Line 8
        std::cerr<<"There"<<std::endl;
      } else { //Line 10
        std::cerr<<"Uh oh"<<std::endl;
      }
    }

clang doesn't want to compile it and complains:

    test.cpp:10:5: error: expected expression
      } else {
        ^
    1 error generated.

Of course, the problem here is that the if-else clause is actually an
if-else-else clause.

Not knowing much about how compilers are built, the error output here is a
little confusing to me: shouldn't an expression be expected on Line 8? Better
yet, perhaps the compiler could complain that an else-else is a no-no.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150926/27b2196e/attachment.html>


More information about the llvm-bugs mailing list