Fix the EntityKind order so that all entity kinds that can be copied (using copy constructors) come first. Also, fix a bug where EK_New was left out of the err_init_conversion_failed diagnostic (It is now reported as 'new value'). Please review Doug :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94289 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 4cfe94e..df0f7f7 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -546,8 +546,9 @@
// C++ initialization
def err_init_conversion_failed : Error<
"cannot initialize %select{a variable|a parameter|return object|an "
- "exception object|a value|a base class|a member subobject|an array element}0"
- " of type %1 with an %select{rvalue|lvalue}2 of type %3">;
+ "exception object|a member subobject|an array element|a new value|a value|a "
+ "base class|an array element}0 of type %1 with an %select{rvalue|lvalue}2 of "
+ "type %3">;
def err_lvalue_to_rvalue_ref : Error<"rvalue reference cannot bind to lvalue">;
def err_invalid_initialization : Error<
diff --git a/lib/Sema/SemaInit.h b/lib/Sema/SemaInit.h
index 5c30554..d7d3756 100644
--- a/lib/Sema/SemaInit.h
+++ b/lib/Sema/SemaInit.h
@@ -47,6 +47,11 @@
/// \brief The entity being initialized is an exception object that
/// is being thrown.
EK_Exception,
+ /// \brief The entity being initialized is a non-static data member
+ /// subobject.
+ EK_Member,
+ /// \brief The entity being initialized is an element of an array.
+ EK_ArrayElement,
/// \brief The entity being initialized is an object (or array of
/// objects) allocated via new.
EK_New,
@@ -54,11 +59,6 @@
EK_Temporary,
/// \brief The entity being initialized is a base member subobject.
EK_Base,
- /// \brief The entity being initialized is a non-static data member
- /// subobject.
- EK_Member,
- /// \brief The entity being initialized is an element of an array.
- EK_ArrayElement,
/// \brief The entity being initialized is an element of a vector.
/// or vector.
EK_VectorElement
diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp
index 0e0f630..b058fc1 100644
--- a/test/SemaCXX/new-delete.cpp
+++ b/test/SemaCXX/new-delete.cpp
@@ -65,7 +65,7 @@
(void)new S(1); // expected-error {{no matching constructor}}
(void)new S(1, 1); // expected-error {{call to constructor of 'struct S' is ambiguous}}
(void)new const int; // expected-error {{default initialization of an object of const type 'int const'}}
- (void)new float*(ip); // expected-error {{cannot initialize a value of type 'float *' with an lvalue of type 'int *'}}
+ (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
// Undefined, but clang should reject it directly.
(void)new int[-1]; // expected-error {{array size is negative}}
(void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'struct S'}}