diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 173a4f43a911175643bda81ee675e8d9269056ea (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /test/SemaCXX/vararg-class.cpp | |
parent | 88f7a7d5251a2d813460274c92decc143a11569b (diff) | |
download | FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz |
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'test/SemaCXX/vararg-class.cpp')
-rw-r--r-- | test/SemaCXX/vararg-class.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/SemaCXX/vararg-class.cpp b/test/SemaCXX/vararg-class.cpp new file mode 100644 index 0000000..08f521c --- /dev/null +++ b/test/SemaCXX/vararg-class.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -verify -Wclass-varargs -std=c++98 %s +// RUN: %clang_cc1 -verify -Wclass-varargs -std=c++11 %s + +struct A {}; +struct B { ~B(); }; +class C { char *c_str(); }; +struct D { char *c_str(); }; +struct E { E(); }; +struct F { F(); char *c_str(); }; + +void v(...); +void w(const char*, ...) __attribute__((format(printf, 1, 2))); + +void test(A a, B b, C c, D d, E e, F f) { + v(a); // expected-warning-re {{passing object of class type 'A' through variadic function{{$}}}} + v(b); // expected-error-re {{cannot pass object of non-{{POD|trivial}} type 'B' through variadic function; call will abort at runtime}} + v(c); // expected-warning {{passing object of class type 'C' through variadic function; did you mean to call '.c_str()'?}} + v(d); // expected-warning {{passing object of class type 'D' through variadic function; did you mean to call '.c_str()'?}} + v(e); + v(f); +#if __cplusplus < 201103L + // expected-error@-3 {{cannot pass object of non-POD type 'E' through variadic function; call will abort at runtime}} + // expected-error@-3 {{cannot pass object of non-POD type 'F' through variadic function; call will abort at runtime}} +#else + // expected-warning-re@-6 {{passing object of class type 'E' through variadic function{{$}}}} + // expected-warning@-6 {{passing object of class type 'F' through variadic function; did you mean to call '.c_str()'?}} +#endif + + v(d.c_str()); + v(f.c_str()); + v(0); + v('x'); + + w("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'A'}} + w("%s", b); // expected-error-re {{cannot pass non-{{POD|trivial}} object of type 'B' to variadic function; expected type from format string was 'char *'}} + w("%s", c); // expected-warning {{format specifies type 'char *' but the argument has type 'C'}} + w("%s", d); // expected-warning {{format specifies type 'char *' but the argument has type 'D'}} + w("%s", e); + w("%s", f); +#if __cplusplus < 201103L + // expected-error@-3 {{cannot pass non-POD object of type 'E' to variadic function; expected type from format string was 'char *'}} + // expected-error@-3 {{cannot pass non-POD object of type 'F' to variadic function; expected type from format string was 'char *'}} + // expected-note@-4 {{did you mean to call the c_str() method?}} +#else + // expected-warning@-7 {{format specifies type 'char *' but the argument has type 'E'}} + // expected-warning@-7 {{format specifies type 'char *' but the argument has type 'F'}} +#endif +} |