diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-03-14 23:09:00 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-03-14 23:09:00 +0000 |
commit | 96db329b3a982ac83c700c4469a3f618dc53cb42 (patch) | |
tree | 15f75569dcd53e02f6e499ec55ec02dd496ea6f4 /test/SemaCXX/function-extern-c.cpp | |
parent | 57f8da506a0db208a936e26a8cb77267f638b26b (diff) |
Diagnose about extern "C" functions returning c++ objects
on first declaration only. // rdar://13364028
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177127 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/function-extern-c.cpp')
-rw-r--r-- | test/SemaCXX/function-extern-c.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/test/SemaCXX/function-extern-c.cpp b/test/SemaCXX/function-extern-c.cpp index a4b8400abc..6ab9657350 100644 --- a/test/SemaCXX/function-extern-c.cpp +++ b/test/SemaCXX/function-extern-c.cpp @@ -49,7 +49,7 @@ namespace test2 { struct A { A(const A&); }; - A f(void); // expected-warning {{'f' has C-linkage specified, but returns user-defined type 'test2::A' which is incompatible with C}} + A f(void); // no warning. warning is already issued on first declaration. } namespace test3 { @@ -61,3 +61,38 @@ namespace test3 { static A f(void); } } + +// rdar://13364028 +namespace rdar13364028 { +class A { +public: + virtual int x(); +}; + +extern "C" { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type-c-linkage" +A xyzzy(); +#pragma clang diagnostic pop +A bbb(); // expected-warning {{'bbb' has C-linkage specified, but returns user-defined type 'rdar13364028::A' which is incompatible with C}} +A ccc() { // expected-warning {{'ccc' has C-linkage specified, but returns user-defined type 'rdar13364028::A' which is incompatible with C}} + return A(); +}; +} + +A xyzzy(); + +A xyzzy() +{ + return A(); +} + +A bbb() +{ + return A(); +} + +A bbb(); + +A ccc(); +} |