On 09/18/2018 09:47 PM, Marek Polacek wrote:
As I mentioned in the PR, [class.conv.fct] says "A conversion function is never
used to convert a (possibly cv-qualified) object to the (possibly cv-qualified)
same object type (or a reference to it), to a (possibly cv-qualified) base class
of that type (or a reference to it), or to (possibly cv-qualified) void." but I
noticed we weren't warning about

struct X {
  operator X();
};

(and there are no tests for this case) because comparing types directly only
works for TYPE_CANONICAL, otherwise we have to use same_type_*.

I'm also changing the warning about 'void' since we can't form a reference to
void.

Since you're changing the text of the void warning it would also
be nice to add quoting around the type name if it doesn't involve
adjusting too many tests.  But...

...
+struct B { };
+
+struct X : public B {
+  operator X(); // { dg-warning "3:conversion to the same type will never use a 
type conversion operator" }

Is the operator function mentioned in the warning?

If not, mentioning it would make it clearer which of a set of
operators is not going to be used (when there are multiple like
in this test) and also make it easier to distinguish one from
the others if they're on the same line (e.g., if the class is
the result of macro expansion).

Martin

+  operator X&(); // { dg-warning "3:conversion to a reference to the same type will 
never use a type conversion operator" }
+  operator X() const; // { dg-warning "3:conversion to the same type will never use 
a type conversion operator" }
+  operator const X(); // { dg-warning "3:conversion to the same type will never use 
a type conversion operator" }
+
+  operator B(); // { dg-warning "3:conversion to a base class will never use a type 
conversion operator" }
+  operator B&(); // { dg-warning "3:conversion to a reference to a base class will 
never use a type conversion operator" }
+  operator B() const; // { dg-warning "3:conversion to a base class will never use 
a type conversion operator" }
+  operator const B(); // { dg-warning "3:conversion to a base class will never use 
a type conversion operator" }
+
+  operator void(); // { dg-warning "3:conversion to void will never use a type 
conversion operator" }
+  operator void() const; // { dg-warning "3:conversion to void will never use a 
type conversion operator" }
+};


Reply via email to