[PATCH] C++11: Reject string literal to non-const char * conversion
Richard Smith
richard at metafoo.co.uk
Thu Jan 16 15:04:12 PST 2014
Sorry, forgot to Clowncopterize =(
I think this is basically ready to commit, just a couple of tiny comments.
================
Comment at: lib/Sema/SemaOverload.cpp:3294-3303
@@ +3293,12 @@
+ const ImplicitConversionSequence &ICS) {
+ if (ICS.isStandard() && ICS.Standard.First == ICK_Array_To_Pointer &&
+ ICS.Standard.Second == ICK_Identity &&
+ ICS.Standard.Third == ICK_Qualification)
+ return ICS.Standard.DeprecatedStringLiteralToCharPtr;
+ if (ICS.isUserDefined() &&
+ ICS.UserDefined.Before.First == ICK_Array_To_Pointer &&
+ ICS.UserDefined.Before.Second == ICK_Identity &&
+ ICS.UserDefined.Before.Third == ICK_Qualification)
+ return ICS.UserDefined.Before.DeprecatedStringLiteralToCharPtr;
+ return false;
+}
----------------
Now `DeprecatedStringLiteralToCharPtr` is always initialized, do you need this complexity? Would this work:
return (ICS.isStandard() && ICS.Standard.DeprecatedStringLiteralToCharPtr) ||
(ICS.isUserDefined() && ICS.UserDefined.Before.DeprecatedStringLiteralToCharPtr);
================
Comment at: test/SemaCXX/overload-0x.cpp:1-5
@@ -1,3 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -DCHECK_BEST -std=c++11 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DCHECK_BEST -fsyntax-only -verify %s
+#ifndef CHECK_BEST
namespace test0 {
----------------
Do you really need all three of these and the macro? Since you're not testing the generated IR any more, I think you can drop the #ifndef and go down to two RUN: lines (one for c++11 and one for c++98).
http://llvm-reviews.chandlerc.com/D1965
More information about the cfe-commits
mailing list