require that operands to __real/__imag are complex or arithmetic.  This
fixes GCC PR33193




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41428 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index e4dd9bb..a859fe8 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -283,9 +283,17 @@
 QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc) {
   DefaultFunctionArrayConversion(V);
   
+  // These operators return the element type of a complex type.
   if (const ComplexType *CT = V->getType()->getAsComplexType())
     return CT->getElementType();
-  return V->getType();
+  
+  // Otherwise they pass through real integer and floating point types here.
+  if (V->getType()->isArithmeticType())
+    return V->getType();
+  
+  // Reject anything else.
+  Diag(Loc, diag::err_realimag_invalid_type, V->getType().getAsString());
+  return QualType();
 }