2008/6/12 Jonathan Wakely:
> 2008/6/11 Volker Reichelt:
>> * Scopes in for-loops:
>>
>>  void foo()
>>  {
>>    for (int i=0; i<10; ++i) {}
>>    i = 0;
>>  }
>>
>>  warn.cc: In function 'void foo()':
>>  warn.cc:4: warning: name lookup of 'i' changed for new ISO 'for' scoping
>>  warn.cc:3: warning:   using obsolete binding at 'i'
>
> I suggest making this a permerror and changing the text slightly, see
> http://gcc.gnu.org/ml/gcc/2008-01/msg00192.html
>
>> * Declaration with no type:
>>
>>  foo() {}
>>
>>  warn.cc:1: warning: ISO C++ forbids declaration of 'foo' with no type
>
> See the part about special handling of 'main' in
> http://gcc.gnu.org/ml/gcc/2008-01/msg00189.html
>
>
>> * Invalid use of 'template':
>> * Using 'struct' for a union:
>
> These two can both be fixed by changes in cp/parser.c - all cases of
> pedwarn that are not guarded by testing 'pedantic' should be
> permerrors.

Could a C++ maintainer please review this patch to turn most pedwarns
into permerrors.

This restores the previous behaviour without any switches: most
diagnostics are errors. The permerrors can be relaxed with
-fpermissive.  When a warning was guarded by a test for the 'pedantic'
flag I left it as a pedwarn.

The interesting cases are:
* when 'main' is declared without a return type. I split one case into
a permerror and pedwarn.
* 'for' scoping.   I removed the "new" from "new ISO 'for' scoping"
since the ISO standard is not new, and when C++0x arrives it would be
misleading.
* Should it really be a hard error for a class to declare itself as a
friend? I don't think it's expressly forbidden
e.g. class A { friend class A; };
I changed this to a permerror, restoring the old  behaviour.
* I don't think the pedwarn in joust() in cp/call.c should be a
permerror, is this a GNU extension?
          if (warn)
            {
              pedwarn ("\
ISO C++ says that these are ambiguous, even \
though the worst conversion for the first is better than \
the worst conversion for the second:");
              print_z_candidate (_("candidate 1:"), w);
              print_z_candidate (_("candidate 2:"), l);
            }

* I don't know if these in cp/typeck.c should be permerrors, DTRT
implies not, but should tf_error be changed to tf_warning?

  /* DTRT if one side is an overloaded function, but complain about it.  */
  if (type_unknown_p (op0))
    {
      tree t = instantiate_type (TREE_TYPE (op1), op0, tf_none);
      if (t != error_mark_node)
        {
          if (complain & tf_error)
            pedwarn ("assuming cast to type %qT from overloaded function",
                     TREE_TYPE (t));
          op0 = t;
        }
    }
  if (type_unknown_p (op1))
    {
      tree t = instantiate_type (TREE_TYPE (op0), op1, tf_none);
      if (t != error_mark_node)
        {
          if (complain & tf_error)
            pedwarn ("assuming cast to type %qT from overloaded function",
                     TREE_TYPE (t));
          op1 = t;
        }
    }

tested linux/x86-64

Jon

Attachment: permerrors.patch
Description: Binary data

Reply via email to