]> granicus.if.org Git - clang/commitdiff
Add a CK_ArrayToPointerDecay cast kind.
authorAnders Carlsson <andersca@mac.com>
Fri, 7 Aug 2009 23:48:20 +0000 (23:48 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 7 Aug 2009 23:48:20 +0000 (23:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78434 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/CodeGen/CGExprScalar.cpp
lib/Sema/SemaExpr.cpp

index 0c884d88b7efc0f018314008d00eb43fe543e470..fed58ba22bd82b611be2b7bbf5d6b32ea9d7e3db 100644 (file)
@@ -1181,7 +1181,10 @@ public:
     CK_Dynamic,
     
     /// CK_ToUnion - Cast to union (GCC extension).
-    CK_ToUnion
+    CK_ToUnion,
+    
+    /// CK_ArrayToPointerDecay - Array to pointer decay.
+    CK_ArrayToPointerDecay
   };
   
 private:
index 0f8d38e6d27a412f960b14224db6d5b167db62e1..3a9ec7ef6f95ba0558feef5eb6e7930d9746a830 100644 (file)
@@ -595,6 +595,7 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) {
   // If this is due to array->pointer conversion, emit the array expression as
   // an l-value.
   if (Op->getType()->isArrayType()) {
+    assert(E->getCastKind() == CastExpr::CK_ArrayToPointerDecay);
     Value *V = EmitLValue(Op).getAddress();  // Bitfields can't be arrays.
 
     // Note that VLA pointers are always decayed, so we don't need to do
index 6f75b59c30513af4309d53871357f59f0d02edfd..5d9b69c844874d5f821c96b76e301883a16034ae 100644 (file)
@@ -209,7 +209,8 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) {
     //
     if (getLangOptions().C99 || getLangOptions().CPlusPlus ||
         E->isLvalue(Context) == Expr::LV_Valid)
-      ImpCastExprToType(E, Context.getArrayDecayedType(Ty));
+      ImpCastExprToType(E, Context.getArrayDecayedType(Ty),
+                        CastExpr::CK_ArrayToPointerDecay);
   }
 }