]> granicus.if.org Git - clang/commitdiff
Slight refactoring; catch yet another case where we were missing an lvalue-to-rvalue...
authorEli Friedman <eli.friedman@gmail.com>
Thu, 26 Jan 2012 00:26:18 +0000 (00:26 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 26 Jan 2012 00:26:18 +0000 (00:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149003 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaStmt.cpp

index 2f8bf7743130d28be317ad296dc028fbd4c573d1..ae0c2c58c1902c90e82b1cd22f941bc29ccb949a 100644 (file)
@@ -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)
index 36b6946a031d66284048fdb5752fb3e60633c493..1aa59446697c250a4c257fa527b10c98fdfad9f2 100644 (file)
@@ -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
index 0eb8d2863cf9d423a37f8f96687f6d835ec7ee56..fdcad08b5e3b58d05b46eb0831ddfb7c62eea98c 100644 (file)
@@ -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(),