[cfe-commits] r81808 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/conditional-expr.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 15 07:58:44 PDT 2009


On Sep 14, 2009, at 4:15 PM, Anders Carlsson wrote:

> Author: andersca
> Date: Mon Sep 14 18:15:26 2009
> New Revision: 81808
>
> URL: http://llvm.org/viewvc/llvm-project?rev=81808&view=rev
> Log:
> Diagnose taking the address of a bit-field inside a conditional  
> operator.

Looks good, with one tiny comment below.

> Modified:
>    cfe/trunk/lib/Sema/SemaExpr.cpp
>    cfe/trunk/test/SemaCXX/conditional-expr.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=81808&r1=81807&r2=81808&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Sep 14 18:15:26 2009
> @@ -5062,6 +5062,10 @@
>     Diag(OpLoc, diag::err_typecheck_address_of)
>       << "property expression" << op->getSourceRange();
>     return QualType();
> +  } else if (ConditionalOperator *CO = dyn_cast<ConditionalOperator> 
> (op)) {
> +    // FIXME: Can LHS ever be null here?
> +    if (!CheckAddressOfOperand(CO->getLHS(), OpLoc).isNull())
> +      return CheckAddressOfOperand(CO->getRHS(), OpLoc);

LHS can be NULL, due to a GCC extension that allows one to omit the  
middle operand:

	http://gcc.gnu.org/onlinedocs/gcc-4.4.1/gcc/Conditionals.html#Conditionals

Use CO->getTrueExpr() instead

	- Doug



More information about the cfe-commits mailing list