<html>
    <head>
      <base href="https://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 --- - __attribute__((deprecated)) doesn't appear for implicit construction of rvalues [-Wdeprecated-declarations]"
   href="https://llvm.org/bugs/show_bug.cgi?id=25472">25472</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((deprecated)) doesn't appear for implicit construction of rvalues [-Wdeprecated-declarations]
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>olegat@feralinteractive.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When the __attribute__((deprecated)) attribute is added to an implicit
constructor, the -Wdeprecated-declarations warning will not always appear.

It seems to appear in the following cases:
 - constructing an lvalue.
 - explicitly constructing an rvalue.

It doeesn't seem to appear in the following cases:
 - implicitly constructing an rvalue.


Example "test.cpp":
class X
{
public:
    X() { }
    X(char d) __attribute__((deprecated("no no no."))) { }
    const X operator+(const X&) const {return X();}
};
void doesntwarn_fn(const X&) { }

int main()
{
    X warns0 ('0');
    X warns1 = '1';
    X warns2 = '1' + '1';
    X warns3 = X() + X('9');
    X doesntwarn = X() + '2' + '3';
    doesntwarn_fn( '6' );

    // mute unused warnings.
    (void) (warns0 + warns1 + warns2 + warns3 + doesntwarn);
}


Result:
clang -Wall -o test test.cpp
test.cpp:12:4: warning: 'X' is deprecated: no no no.
[-Wdeprecated-declarations]
        X warns0 ('0');
          ^
test.cpp:5:2: note: 'X' has been explicitly marked deprecated here
        X(char d) __attribute__((deprecated("no no no."))) { }
        ^
test.cpp:13:4: warning: 'X' is deprecated: no no no.
[-Wdeprecated-declarations]
        X warns1 = '1';
          ^
test.cpp:5:2: note: 'X' has been explicitly marked deprecated here
        X(char d) __attribute__((deprecated("no no no."))) { }
        ^
test.cpp:14:4: warning: 'X' is deprecated: no no no.
[-Wdeprecated-declarations]
        X warns2 = '1' + '1';
          ^
test.cpp:5:2: note: 'X' has been explicitly marked deprecated here
        X(char d) __attribute__((deprecated("no no no."))) { }
        ^
test.cpp:15:19: warning: 'X' is deprecated: no no no.
[-Wdeprecated-declarations]
        X warns3 = X() + X('9');
                         ^
test.cpp:5:2: note: 'X' has been explicitly marked deprecated here
        X(char d) __attribute__((deprecated("no no no."))) { }
        ^
4 warnings generated.


Tested on the two following clang versions with identical results:
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
Thread model: posix

clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix


Result in GCC:
gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcc -Wall -o test test.cpp
test.cpp: In function ‘int main()’:
test.cpp:12:15: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X warns0 ('0');
               ^
test.cpp:13:13: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X warns1 = '1';
             ^
test.cpp:14:19: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X warns2 = '1' + '1';
                   ^
test.cpp:15:24: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X warns3 = X() + X('9');
                        ^
test.cpp:16:23: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X doesntwarn = X() + '2' + '3';
                       ^
test.cpp:16:29: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  X doesntwarn = X() + '2' + '3';
                             ^
test.cpp:17:21: warning: ‘X::X(char)’ is deprecated (declared at test.cpp:5):
no no no. [-Wdeprecated-declarations]
  doesntwarn_fn( '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>