]> granicus.if.org Git - clang/commitdiff
Test explicit constructor
authorDouglas Gregor <dgregor@apple.com>
Wed, 14 Jan 2009 18:02:48 +0000 (18:02 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 14 Jan 2009 18:02:48 +0000 (18:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62237 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/converting-constructor.cpp

index b99a134328efcda565487ddc531a7b26372169f2..0ab8d93137795f04f03378ba0ae6d4002e1b80c0 100644 (file)
@@ -21,3 +21,20 @@ void g(short s, Y y, Z z) {
   f(z); // expected-error{{incompatible type passing 'class Z', expected 'class X'}}
 }
 
+
+class FromShort {
+public:
+  FromShort(short s);
+};
+
+class FromShortExplicitly {
+public:
+  explicit FromShortExplicitly(short s);
+};
+
+void explicit_constructor(short s) {
+  FromShort fs1(s);
+  FromShort fs2 = s;
+  FromShortExplicitly fse1(s);
+  FromShortExplicitly fse2 = s; // expected-error{{error: cannot initialize 'fse2' with an lvalue of type 'short'}}
+}