[cfe-commits] r149003 - in /cfe/trunk/lib/Sema: SemaExprCXX.cpp SemaOverload.cpp SemaStmt.cpp

Eli Friedman eli.friedman at gmail.com
Wed Jan 25 16:26:19 PST 2012


Author: efriedma
Date: Wed Jan 25 18:26:18 2012
New Revision: 149003

URL: http://llvm.org/viewvc/llvm-project?rev=149003&view=rev
Log:
Slight refactoring; catch yet another case where we were missing an lvalue-to-rvalue conversion.


Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=149003&r1=149002&r2=149003&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Jan 25 18:26:18 2012
@@ -995,12 +995,7 @@
   // 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)

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=149003&r1=149002&r2=149003&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 25 18:26:18 2012
@@ -4801,10 +4801,17 @@
   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 @@
     Diag(Loc, NotIntDiag)
       << From->getType() << From->getSourceRange();
 
-  return Owned(From);
+  return DefaultLvalueConversion(From);
 }
 
 /// AddOverloadCandidate - Adds the given function to the set of

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=149003&r1=149002&r2=149003&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Jan 25 18:26:18 2012
@@ -495,12 +495,8 @@
   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(),





More information about the cfe-commits mailing list