[cfe-commits] r41428 - in /cfe/trunk: Sema/SemaExpr.cpp include/clang/Basic/DiagnosticKinds.def

Chris Lattner sabre at nondot.org
Sat Aug 25 22:39:27 PDT 2007


Author: lattner
Date: Sun Aug 26 00:39:26 2007
New Revision: 41428

URL: http://llvm.org/viewvc/llvm-project?rev=41428&view=rev
Log:
require that operands to __real/__imag are complex or arithmetic.  This
fixes GCC PR33193



Modified:
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=41428&r1=41427&r2=41428&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Sun Aug 26 00:39:26 2007
@@ -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();
 }
 
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=41428&r1=41427&r2=41428&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Sun Aug 26 00:39:26 2007
@@ -610,6 +610,8 @@
      "arithmetic on pointer to incomplete type '%0'")
 DIAG(err_typecheck_decl_incomplete_type, ERROR,
      "variable has incomplete type '%0'")
+DIAG(err_realimag_invalid_type, ERROR,
+     "invalid type '%0' to __real or __imag operator")
 DIAG(err_typecheck_sclass_fscope, ERROR,
      "illegal storage class on file-scoped variable")
 DIAG(err_typecheck_sclass_func, ERROR,





More information about the cfe-commits mailing list