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

            Bug ID: 39502
           Summary: Erroneous fix-it in for-range loop over values when
                    given a collection of pointers
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

// RUN: clang++ -std=c++11 -fsyntax-only -fdiagnostics-parseable-fixits

#include <vector>
struct Foo {};
void test(std::vector<Foo *> &v) {
  for (Foo x : v)
    ;
}

---

% clang++ -std=c++11 -fsyntax-only -fdiagnostics-parseable-fixits test.cpp
test.cpp:4:12: error: no viable conversion from 'Foo *' to 'Foo'
  for (Foo x : v)
           ^ ~
test.cpp:2:8: note: candidate constructor (the implicit copy constructor) not
      viable: no known conversion from 'Foo *' to 'const Foo &' for 1st
      argument; dereference the argument with *
struct Foo {};
       ^
fix-it:"test.cpp":{4:14-4:14}:"*"
test.cpp:2:8: note: candidate constructor (the implicit move constructor) not
      viable: no known conversion from 'Foo *' to 'Foo &&' for 1st argument
struct Foo {};
       ^

---

Bad: inserting a fix-it before the ":" (current behavior)
Good: no fix-it, no custom message
Better: new message with a fix-it to turn the element type declaration into a
pointer when possible

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to