[llvm-bugs] [Bug 25472] New: __attribute__((deprecated)) doesn't appear for implicit construction of rvalues [-Wdeprecated-declarations]

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 10 04:19:58 PST 2015


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

            Bug ID: 25472
           Summary: __attribute__((deprecated)) doesn't appear for
                    implicit construction of rvalues
                    [-Wdeprecated-declarations]
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: olegat at feralinteractive.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

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' );
                     ^

-- 
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/20151110/ef968bc2/attachment.html>


More information about the llvm-bugs mailing list