Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify %s |
Daniel Dunbar | cb8845f | 2009-06-13 06:16:36 +0000 | [diff] [blame] | 2 | |
| 3 | class A { |
| 4 | public: |
| 5 | explicit A(); |
| 6 | |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 7 | explicit operator int(); // expected-warning {{explicit conversion functions are a C++11 extension}} |
Daniel Dunbar | cb8845f | 2009-06-13 06:16:36 +0000 | [diff] [blame] | 8 | |
Anders Carlsson | 0757c8c | 2010-01-24 16:49:46 +0000 | [diff] [blame] | 9 | explicit void f0(); // expected-error {{'explicit' can only be applied to a constructor or conversion function}} |
| 10 | |
| 11 | operator bool(); |
Daniel Dunbar | cb8845f | 2009-06-13 06:16:36 +0000 | [diff] [blame] | 12 | }; |
| 13 | |
Anders Carlsson | 0757c8c | 2010-01-24 16:49:46 +0000 | [diff] [blame] | 14 | explicit A::A() { } // expected-error {{'explicit' can only be specified inside the class definition}} |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 15 | explicit A::operator bool() { return false; } // expected-warning {{explicit conversion functions are a C++11 extension}}\ |
Anders Carlsson | 0757c8c | 2010-01-24 16:49:46 +0000 | [diff] [blame] | 16 | // expected-error {{'explicit' can only be specified inside the class definition}} |
Stephen Hines | 6bcf27b | 2014-05-29 04:14:42 -0700 | [diff] [blame^] | 17 | |
| 18 | class B { |
| 19 | friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}} |
| 20 | }; |