[cfe-commits] r103253 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/init.c

Eli Friedman eli.friedman at gmail.com
Fri May 7 12:48:16 PDT 2010


On Fri, May 7, 2010 at 8:18 AM, Rafael Espindola
<rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Fri May  7 10:18:43 2010
> New Revision: 103253
>
> URL: http://llvm.org/viewvc/llvm-project?rev=103253&view=rev
> Log:
> Fix PR4386 by implementing gcc's old behaviour (4.2) when initializing
> variables with a comparison of a function pointer with 0.
>
>
> Modified:
>    cfe/trunk/lib/AST/ExprConstant.cpp
>    cfe/trunk/test/Sema/init.c
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=103253&r1=103252&r2=103253&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May  7 10:18:43 2010
> @@ -70,9 +70,20 @@
>  //===----------------------------------------------------------------------===//
>
>  static bool EvalPointerValueAsBool(APValue& Value, bool& Result) {
> -  // FIXME: Is this accurate for all kinds of bases?  If not, what would
> -  // the check look like?
> -  Result = Value.getLValueBase() || !Value.getLValueOffset().isZero();
> +  const Expr* Base = Value.getLValueBase();
> +
> +  Result = Base || !Value.getLValueOffset().isZero();
> +
> +  const DeclRefExpr* DeclRef = dyn_cast<DeclRefExpr>(Base);
> +  if (!DeclRef)
> +    return true;

Is it possible for Base to be null?

-Eli




More information about the cfe-commits mailing list