summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2013-06-22 00:20:41 +0000
committerRichard Trieu <rtrieu@google.com>2013-06-22 00:20:41 +0000
commit41bc0994c3446249236499395b002f7fad5d752d (patch)
tree1528d23acb5505f268f18e7ed65d394b9f985bbc /clang/test
parent091dd7be12f5131267b2dd8eaedc76ad09d76dd0 (diff)
downloadbcm5719-llvm-41bc0994c3446249236499395b002f7fad5d752d.tar.gz
bcm5719-llvm-41bc0994c3446249236499395b002f7fad5d752d.zip
Extend -Wnon-pod-varargs to more cases, such as function pointers as return
types and function pointer arrays. llvm-svn: 184616
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/vararg-non-pod.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/vararg-non-pod.cpp b/clang/test/SemaCXX/vararg-non-pod.cpp
index f1ab9b162ce..056d23fe332 100644
--- a/clang/test/SemaCXX/vararg-non-pod.cpp
+++ b/clang/test/SemaCXX/vararg-non-pod.cpp
@@ -153,3 +153,39 @@ namespace t10 {
s(f);
}
}
+
+namespace t11 {
+ typedef void(*function_ptr)(int, ...);
+ typedef void(C::*member_ptr)(int, ...);
+ typedef void(^block_ptr)(int, ...);
+
+ function_ptr get_f_ptr();
+ member_ptr get_m_ptr();
+ block_ptr get_b_ptr();
+
+ function_ptr arr_f_ptr[5];
+ member_ptr arr_m_ptr[5];
+ block_ptr arr_b_ptr[5];
+
+ void test() {
+ C c(10);
+
+ (get_f_ptr())(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
+ (get_f_ptr())(10, version);
+
+ (c.*get_m_ptr())(10, c); // TODO: This should also warn.
+ (c.*get_m_ptr())(10, version);
+
+ (get_b_ptr())(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime}}
+ (get_b_ptr())(10, version);
+
+ (arr_f_ptr[3])(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
+ (arr_f_ptr[3])(10, version);
+
+ (c.*arr_m_ptr[3])(10, c); // TODO: This should also warn.
+ (c.*arr_m_ptr[3])(10, version);
+
+ (arr_b_ptr[3])(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime}}
+ (arr_b_ptr[3])(10, version);
+ }
+}
OpenPOWER on IntegriCloud