This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch / RFC] PR 45385


Hi,

this one is a bit subtler. It's actually a regression due to the fix for PR35602, which was about a bogus warning for:

struct c
{
  ~c();
  c();
};

int
main()
{
c x[0UL][0UL] = // { dg-bogus "warning: conversion to .long unsigned int. from .long int. may change the sign of the result" }
{
};
}


The way we did it, we added a check at the beginning of c-common.c:conversion_warning:

   /* If any operand is artificial, then this expression was generated
      by the compiler and we do not warn.  */
  for (i = 0; i < expr_num_operands; i++)
     {
       tree op = TREE_OPERAND (expr, i);
       if (op && DECL_P (op) && DECL_ARTIFICIAL (op))
     return;
     }

which catches the artificial (only) operand of the expr (expr is a BIT_NOT_EXPR and the operand a VAR_DECL).

Now, however, for testcases like PR45385, where member functions are involved, we easily fail to produce warnings, simply because the this pointer is artificial! Thus I had the idea of restricting the above check to the single operand case which matters for PR35602: for sure it's a safe change, and passes the testsuite, but I cannot exclude that more complex situations can occur for which the loop would avoid more bogus warnings... What do you think, is the change good enough for now?

Thanks,
Paolo.

////////////////////

Attachment: CL_45385
Description: Text document

Attachment: patch_45385
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]