<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Bogus message regarding use of "this" in friend declaration"
   href="http://llvm.org/bugs/show_bug.cgi?id=18475">18475</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bogus message regarding use of "this" in friend declaration
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hstong@ca.ibm.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The use of "this" in trailing-return-types and exception-specifications does
not work in friend declarations in Clang.

## SMALL SOURCE:
struct Other {
   int p();
   auto q() -> decltype(p()) *;
};

class Friendly {
   // according to 5.1.1 [expr.prim.general] paragraph 3 the expression "this"
   // below is a prvalue of type "pointer to Other".
   friend auto Other::q() -> decltype(this->p()) *;
      // GCC and ICC accepts, Clang rejects
};

## COMPILER INVOCATION:
clang++ -std=c++11 friendThis.cc 

## ACTUAL OUTPUT:
friendThis.cc:9:39: error: invalid use of 'this' outside of a non-static member
function
   friend auto Other::q() -> decltype(this->p()) *;
                                      ^
1 error generated.

## EXPECTED OUTPUT:
Clean compile.

## clang++ -v:
clang version 3.5 
Target: powerpc64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/3.4.6
Found candidate GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6
Selected GCC installation: /usr/lib/gcc/ppc64-redhat-linux/4.4.6</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>