[cfe-commits] r82129 - in /cfe/trunk: lib/AST/Expr.cpp lib/Sema/SemaExpr.cpp test/SemaCXX/value-dependent-exprs.cpp

Douglas Gregor dgregor at apple.com
Fri Sep 18 07:29:08 PDT 2009


On Sep 18, 2009, at 1:43 AM, Daniel Dunbar wrote:

> On Wed, Sep 16, 2009 at 11:42 PM, Eli Friedman  
> <eli.friedman at gmail.com> wrote:
>> On Wed, Sep 16, 2009 at 11:31 PM, Daniel Dunbar <daniel at zuster.org>  
>> wrote:
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>>> +++ cfe/trunk/lib/AST/Expr.cpp Thu Sep 17 01:31:27 2009
>>> @@ -1626,6 +1626,9 @@
>>>  /// integer constant expression with the value zero, or if this  
>>> is one that is
>>>  /// cast to void*.
>>>  bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
>>> +  // Ignore value dependent expressions.
>>> +  if (isValueDependent())
>>> +    return true;
>>>   // Strip off a cast to void*, if it exists. Except in C++.
>>>   if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr> 
>>> (this)) {
>>>     if (!Ctx.getLangOptions().CPlusPlus) {
>>
>> It's kind of confusing to claim that something which may not be a  
>> null
>> pointer constant is a null pointer constant.  It would be clearer for
>> the callers to explicitly deal with this case.
>
> Yes, I wasn't sure about this part. My logic was that assuming it was
> a null pointer constant would be conservatively safe, but I can't
> convince myself of this so I change it to an assert and FIXME that
> part of the test for now.

In some places, we'll pretend that a value-dependent expression is the  
null pointer constant; in others, we'll pretend that it can't be the  
null pointer constant. There's a little discussion of the issue here:

	http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#903

I think that means we should fix all of the callers of  
isNullPointerConstant, rather than giving it a default behavior.

	- Doug



More information about the cfe-commits mailing list