[LLVMbugs] [Bug 11297] New: Bad diagnostic for range for loop with non-declaration

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 2 10:19:56 PDT 2011


             Bug #: 11297
           Summary: Bad diagnostic for range for loop with non-declaration
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat test.cc
#include <map>
#include <tuple>
#include <string>
int foo(const std::map<std::string, int>& foo) {
    std::string key;
    int value = 0;

    for ( std::tie(key, value) : foo ) {
    return value;
$ clang++ -stdlib=libc++ -std=c++0x -c test.cc
test.cc:8:32: error: expected ';' in 'for' statement specifier
    for ( std::tie(key, value) : foo ) {
test.cc:8:32: error: expected expression
2 errors generated.

This should say something like "for-range-declaration must be a declaration",
with the whole non-declaration underlined. Complaining about the missing
semicolon is particularly strange since valid range-based for loops don't need
a semicolon.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list