diff options
author | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-04-08 18:45:10 +0000 |
commit | c72c57c9e9b69944e3e009cd5e209634839581d3 (patch) | |
tree | 4fc2f184c499d106f29a386c452b49e5197bf63d /test/SemaCXX/function-extern-c.cpp | |
parent | 5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff) | |
download | FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz |
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'test/SemaCXX/function-extern-c.cpp')
-rw-r--r-- | test/SemaCXX/function-extern-c.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/SemaCXX/function-extern-c.cpp b/test/SemaCXX/function-extern-c.cpp index 16dbbb2..6ab9657 100644 --- a/test/SemaCXX/function-extern-c.cpp +++ b/test/SemaCXX/function-extern-c.cpp @@ -38,3 +38,61 @@ extern "C" long long f11( void ); extern "C" A *f10( void ); extern "C" struct mypodstruct f12(); // expected-warning {{'f12' has C-linkage specified, but returns incomplete type 'struct mypodstruct' which could be incompatible with C}} + +namespace test2 { + // FIXME: we should probably suppress the first warning as the second one + // is more precise. + // For now this tests that a second 'extern "C"' is not necessary to trigger + // the warning. + struct A; + extern "C" A f(void); // expected-warning {{'f' has C-linkage specified, but returns incomplete type 'test2::A' which could be incompatible with C}} + struct A { + A(const A&); + }; + A f(void); // no warning. warning is already issued on first declaration. +} + +namespace test3 { + struct A { + A(const A&); + }; + extern "C" { + // Don't warn for static functions. + 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(); +} |