Do placeholder conversions on array bounds in both declarators and
new-expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147900 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 5e7fb33..d4efa78 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1010,10 +1010,13 @@
// C++ 5.3.4p6: "The expression in a direct-new-declarator shall have integral
// or enumeration type with a non-negative value."
if (ArraySize && !ArraySize->isTypeDependent()) {
+ // Eliminate placeholders.
+ ExprResult ConvertedSize = CheckPlaceholderExpr(ArraySize);
+ if (ConvertedSize.isInvalid())
+ return ExprError();
+ ArraySize = ConvertedSize.take();
- QualType SizeType = ArraySize->getType();
-
- ExprResult ConvertedSize = ConvertToIntegralOrEnumerationType(
+ ConvertedSize = ConvertToIntegralOrEnumerationType(
StartLoc, ArraySize,
PDiag(diag::err_array_size_not_integral),
PDiag(diag::err_array_size_incomplete_type)
@@ -1029,7 +1032,7 @@
return ExprError();
ArraySize = ConvertedSize.take();
- SizeType = ArraySize->getType();
+ QualType SizeType = ArraySize->getType();
if (!SizeType->isIntegralOrUnscopedEnumerationType())
return ExprError();