Implement sema support for __real/__imag nodes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41375 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 1026424..ea2ec4a 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -271,6 +271,15 @@
   return new SizeOfAlignOfTypeExpr(isSizeof, ArgTy, resultType, OpLoc, RPLoc);
 }
 
+QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isImag) {
+  DefaultFunctionArrayConversion(V);
+  
+  if (const ComplexType *CT = V->getType()->getAsComplexType())
+    return CT->getElementType();
+  return V->getType();
+}
+
+
 
 Action::ExprResult Sema::ParsePostfixUnaryOp(SourceLocation OpLoc, 
                                              tok::TokenKind Kind,
@@ -1586,8 +1595,13 @@
   case UnaryOperator::AlignOf:
     resultType = CheckSizeOfAlignOfOperand(Input->getType(), OpLoc, false);
     break;
+  case UnaryOperator::Real:
+    resultType = CheckRealImagOperand(Input, OpLoc, false);
+    break;
+  case UnaryOperator::Imag:
+    resultType = CheckRealImagOperand(Input, OpLoc, true);
+    break;
   case UnaryOperator::Extension:
-    // FIXME: does __extension__ cause any promotions? I would think not.
     resultType = Input->getType();
     break;
   }