view gcc/testsuite/g++.dg/conversion/op4.C @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 84e7813d76e9
children
line wrap: on
line source

/* PR c++/26698 */
/* { dg-do compile } */

struct X {
  int x;
  X (int i = 0) : x (i) {}
  operator X& (void) const { // { dg-warning "will never use" }
    return *(new X);
  }
};

void add_one (X & ref) { /* { dg-message "argument" } */
  ++ ref.x;
}

void foo() {
  X const a (2);
  add_one(a); /* { dg-error "discards qualifiers" } */
}