Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/explicit2.C

raw
1 // { dg-do assemble }
2
3 class string {
4 public:
5 string(const char*) { }
6 explicit string(int size) { }
7 };
8
9 void foo(string) { }
10
11 string bar() {
12 foo("hello"); // ok
13 foo(string(2)); // ok
14 foo(2); // { dg-error "" } no implicit conversion from int to string
15 string x = 2; // { dg-error "" } no implicit conversion from int to string
16 string y(2); // ok
17 foo((string)2); // ok
18 return 2; // { dg-error "" } no implicit conversion from int to string
19 }
20
21 class A : string {
22 public:
23 A() : string(2) { } // ok
24 };