summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/constructor-initializer.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-05 04:29:56 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-05 04:29:56 +0000
commite8381c00eb6c753c6100b968d16c829933e743e2 (patch)
tree1fed91840bcb8c2d5cb5083c5f01a945c6536145 /clang/test/SemaCXX/constructor-initializer.cpp
parentf14b77ebf12ee2e1bc21145c3947dd30c9d2b988 (diff)
downloadbcm5719-llvm-e8381c00eb6c753c6100b968d16c829933e743e2.tar.gz
bcm5719-llvm-e8381c00eb6c753c6100b968d16c829933e743e2.zip
Initial implementation of parsing, semantic analysis, and AST-building
for constructor initializations, e.g., class A { }; class B : public A { int m; public: B() : A(), m(17) { }; }; llvm-svn: 58749
Diffstat (limited to 'clang/test/SemaCXX/constructor-initializer.cpp')
-rw-r--r--clang/test/SemaCXX/constructor-initializer.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/constructor-initializer.cpp b/clang/test/SemaCXX/constructor-initializer.cpp
new file mode 100644
index 00000000000..6b450b097ac
--- /dev/null
+++ b/clang/test/SemaCXX/constructor-initializer.cpp
@@ -0,0 +1,43 @@
+// RUN: clang -fsyntax-only -verify %s
+class A {
+ int m;
+};
+
+class B : public A {
+public:
+ B() : A(), m(1), n(3.14) { }
+
+private:
+ int m;
+ float n;
+};
+
+
+class C : public virtual B {
+public:
+ C() : B() { }
+};
+
+class D : public C {
+public:
+ D() : B(), C() { }
+};
+
+class E : public D, public B {
+public:
+ E() : B(), D() { } // expected-error{{base class initializer 'B' names both a direct base class and an inherited virtual base class}}
+};
+
+
+typedef int INT;
+
+class F : public B {
+public:
+ int B;
+
+ F() : B(17),
+ m(17), // expected-error{{member initializer 'm' does not name a non-static data member or base class}}
+ INT(17) // expected-error{{constructor initializer 'INT' does not name a class}}
+ {
+ }
+};
OpenPOWER on IntegriCloud