mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 01:26:05 +00:00
Slight refactoring; catch yet another case where we were missing an lvalue-to-rvalue conversion.
llvm-svn: 149003
This commit is contained in:
parent
9ec3c4f5a7
commit
1da70394f6
@ -995,12 +995,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
|
||||
// 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()) {
|
||||
ExprResult ConvertedSize = DefaultFunctionArrayLvalueConversion(ArraySize);
|
||||
if (ConvertedSize.isInvalid())
|
||||
return ExprError();
|
||||
ArraySize = ConvertedSize.take();
|
||||
|
||||
ConvertedSize = ConvertToIntegralOrEnumerationType(
|
||||
ExprResult ConvertedSize = ConvertToIntegralOrEnumerationType(
|
||||
StartLoc, ArraySize,
|
||||
PDiag(diag::err_array_size_not_integral),
|
||||
PDiag(diag::err_array_size_incomplete_type)
|
||||
|
@ -4801,10 +4801,17 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From,
|
||||
if (From->isTypeDependent())
|
||||
return Owned(From);
|
||||
|
||||
// Process placeholders immediately.
|
||||
if (From->hasPlaceholderType()) {
|
||||
ExprResult result = CheckPlaceholderExpr(From);
|
||||
if (result.isInvalid()) return result;
|
||||
From = result.take();
|
||||
}
|
||||
|
||||
// If the expression already has integral or enumeration type, we're golden.
|
||||
QualType T = From->getType();
|
||||
if (T->isIntegralOrEnumerationType())
|
||||
return Owned(From);
|
||||
return DefaultLvalueConversion(From);
|
||||
|
||||
// FIXME: Check for missing '()' if T is a function type?
|
||||
|
||||
@ -4933,7 +4940,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From,
|
||||
Diag(Loc, NotIntDiag)
|
||||
<< From->getType() << From->getSourceRange();
|
||||
|
||||
return Owned(From);
|
||||
return DefaultLvalueConversion(From);
|
||||
}
|
||||
|
||||
/// AddOverloadCandidate - Adds the given function to the set of
|
||||
|
@ -495,12 +495,8 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond,
|
||||
if (!Cond)
|
||||
return StmtError();
|
||||
|
||||
CondResult = DefaultFunctionArrayLvalueConversion(Cond);
|
||||
if (CondResult.isInvalid())
|
||||
return StmtError();
|
||||
|
||||
CondResult
|
||||
= ConvertToIntegralOrEnumerationType(SwitchLoc, CondResult.take(),
|
||||
= ConvertToIntegralOrEnumerationType(SwitchLoc, Cond,
|
||||
PDiag(diag::err_typecheck_statement_requires_integer),
|
||||
PDiag(diag::err_switch_incomplete_class_type)
|
||||
<< Cond->getSourceRange(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user