Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

declaration conflicts for extern "C" function #12874

Closed Quuxplusone closed 10 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR12770
Status RESOLVED FIXED
Importance P enhancement
Reported by Dmitri Shubin (sbn@tbricks.com)
Reported on 2012-05-09 01:47:07 -0700
Last modified on 2014-02-05 19:31:49 -0800
Version 3.0
Hardware Macintosh MacOS X
CC basv@odd-e.com, dgregor@apple.com, efriedma@quicinc.com, gribozavr@gmail.com, joakim@tbricks.com, llvm-bugs@lists.llvm.org, rafael@espindo.la, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The following code is accepted by g++ (4.2.1 on MacOSX, 4.5.1, 4.7.0 on
Solaris, 4.1.2, 3.4.6, 4.4.4 on Linux) and Sun C++ 5.11 on Solaris, but
rejected by clang (3.0 on MacOSX and TOT on Solaris):

$ cat -n b.cpp
     1  extern "C" {
     2
     3  namespace std {
     4  int rename(const char *, const char *);
     5  }
     6
     7  }
     8
     9  using std::rename;
    10
    11  extern "C" int rename(const char *, const char *);
$ clang++ -c b.cpp
b.cpp:11:16: error: declaration conflicts with target of using declaration
already in scope
extern "C" int rename(const char *, const char *);
               ^
b.cpp:4:5: note: target of using declaration
int rename(const char *, const char *);
    ^
b.cpp:9:12: note: using declaration
using std::rename;
           ^
1 error generated.
$ clang++ -v
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
Quuxplusone commented 12 years ago
This currently breaks build on Solaris 10 with TOT of clang: the following 2
lines are rejected:

$ cat -n a.cpp
     1  #include <unistd.h>
     2  #include <stdio.h>
$ ./build-clang/Release/bin/clang++ -c a.cpp
In file included from a.cpp:2:
/usr/include/stdio.h:85:12: error: target of using declaration conflicts with
declaration already in scope
using std::rename;
           ^
/usr/include/iso/stdio_iso.h:190:12: note: target of using declaration
extern int      rename(const char *, const char *);
                ^
/usr/include/unistd.h:449:12: note: conflicting declaration
extern int rename(const char *, const char *);
           ^
1 error generated.
$ ./build-clang/Release/bin/clang++ -v
clang version 3.2 (trunk 156374)
Target: i386-pc-solaris2.10
Thread model: posix

This started to happen after default value of __cpusplus macro was changed from
1 to std conforming 199711L
Quuxplusone commented 11 years ago

_Bug 14619 has been marked as a duplicate of this bug._

Quuxplusone commented 10 years ago
We don't consider the case where a using shadow declaration declares the same
entity that we're declaring. Another rejects-valid:

  namespace A { void f(); }
  namespace B { using A::f; }
  namespace A { using B::f; void f(); }
Quuxplusone commented 10 years ago

Fixed in r200897.