summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/default1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/default1.cpp')
-rw-r--r--test/SemaCXX/default1.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
new file mode 100644
index 0000000..be264ad
--- /dev/null
+++ b/test/SemaCXX/default1.cpp
@@ -0,0 +1,31 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+void f(int i);
+void f(int i = 0); // expected-note {{previous definition is here}}
+void f(int i = 17); // expected-error {{redefinition of default argument}}
+
+
+void g(int i, int j, int k = 3);
+void g(int i, int j = 2, int k);
+void g(int i = 1, int j, int k);
+
+void h(int i, int j = 2, int k = 3,
+ int l, // expected-error {{missing default argument on parameter 'l'}}
+ int, // expected-error {{missing default argument on parameter}}
+ int n);// expected-error {{missing default argument on parameter 'n'}}
+
+struct S { } s;
+void i(int = s) { } // expected-error {{incompatible type}}
+
+struct X {
+ X(int);
+};
+
+void j(X x = 17);
+
+struct Y {
+ explicit Y(int);
+};
+
+void k(Y y = 17); // expected-error{{cannot initialize 'y' with an rvalue of type 'int'}}
+
+void kk(Y = 17); // expected-error{{cannot initialize a value of type 'struct Y' with an rvalue of type 'int'}}
OpenPOWER on IntegriCloud