From 7e1848ddba7b2a5f73a17387de7078bf8de7a646 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 11 Dec 2009 01:52:50 +0000 Subject: [PATCH] Give the "cannot pass object of non-POD type 'class C' through variadic constructor; call will abort at runtime" warning a -W flag (non-pod-varargs) and default it being an error by default. There is no good reason to allow users to get bitten by this sort of thing by default. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91094 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 3 ++- test/SemaCXX/overload-call-copycon.cpp | 10 +++++----- test/SemaCXX/vararg-non-pod.cpp | 2 +- test/SemaObjCXX/vararg-non-pod.mm | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 8739890c9a..ef7b0ded16 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2009,7 +2009,8 @@ def err_cannot_pass_objc_interface_to_vararg : Error< def warn_cannot_pass_non_pod_arg_to_vararg : Warning< "cannot pass object of non-POD type %0 through variadic " - "%select{function|block|method|constructor}1; call will abort at runtime">; + "%select{function|block|method|constructor}1; call will abort at runtime">, + InGroup>, DefaultError; def err_typecheck_call_invalid_ordered_compare : Error< "ordered compare requires two args of floating point type (%0 and %1)">; diff --git a/test/SemaCXX/overload-call-copycon.cpp b/test/SemaCXX/overload-call-copycon.cpp index 755e27adba..6436236b81 100644 --- a/test/SemaCXX/overload-call-copycon.cpp +++ b/test/SemaCXX/overload-call-copycon.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only %s +// RUN: clang-cc -fsyntax-only %s -Wnon-pod-varargs class X { }; int& copycon(X x); @@ -23,10 +23,10 @@ float& copycon2(...); void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) { int& i1 = copycon2(b); - float& f1 = copycon2(bc); - float& f2 = copycon2(bv); + float& f1 = copycon2(bc); // expected-warning {{cannot pass object of non-POD type}} + float& f2 = copycon2(bv); // expected-warning {{cannot pass object of non-POD type}} short& s1 = copycon2(a); - float& f3 = copycon2(ac); + float& f3 = copycon2(ac); // expected-warning {{cannot pass object of non-POD type}} } int& copycon3(A a); @@ -34,7 +34,7 @@ float& copycon3(...); void test_copycon3(B b, const B bc) { int& i1 = copycon3(b); - float& f1 = copycon3(bc); + float& f1 = copycon3(bc); // expected-warning {{cannot pass object of non-POD type}} } diff --git a/test/SemaCXX/vararg-non-pod.cpp b/test/SemaCXX/vararg-non-pod.cpp index 977df144fa..c34f8d0b8f 100644 --- a/test/SemaCXX/vararg-non-pod.cpp +++ b/test/SemaCXX/vararg-non-pod.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify -fblocks %s +// RUN: clang-cc -fsyntax-only -verify -fblocks %s -Wnon-pod-varargs extern char version[]; diff --git a/test/SemaObjCXX/vararg-non-pod.mm b/test/SemaObjCXX/vararg-non-pod.mm index eeed09e616..83cbaf8071 100644 --- a/test/SemaObjCXX/vararg-non-pod.mm +++ b/test/SemaObjCXX/vararg-non-pod.mm @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify %s +// RUN: clang-cc -fsyntax-only -verify %s -Wnon-pod-varargs extern char version[]; -- 2.40.0