aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/cxx-class.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-07-01 10:37:29 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-07-01 10:37:29 +0000
commit07952324dda0e758c17f8bc3015793c65c51c48c (patch)
treedf23760bd379514f0adb730fe44cb2642df6d58c /test/Sema/cxx-class.cpp
parentaae2d7418b7004fde1ba08fe60db219d0c95ff30 (diff)
Add Sema support for C++ classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/cxx-class.cpp')
-rw-r--r--test/Sema/cxx-class.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/test/Sema/cxx-class.cpp b/test/Sema/cxx-class.cpp
new file mode 100644
index 0000000000..b7702dd24a
--- /dev/null
+++ b/test/Sema/cxx-class.cpp
@@ -0,0 +1,70 @@
+// RUN: clang -fsyntax-only -verify %s
+class C {
+public:
+ auto int errx; // expected-error {{error: storage class specified for a member declaration}}
+ register int erry; // expected-error {{error: storage class specified for a member declaration}}
+ extern int errz; // expected-error {{error: storage class specified for a member declaration}}
+
+ static void sm() {
+ sx = 0;
+ this->x = 0; // expected-error {{error: invalid use of 'this' outside of a nonstatic member function}}
+ x = 0; // expected-error {{error: invalid use of member 'x' in static member function}}
+ }
+
+ class NestedC {
+ void m() {
+ sx = 0;
+ x = 0; // expected-error {{error: invalid use of nonstatic data member 'x'}}
+ }
+ };
+
+ int b : 1, w : 2;
+ int : 1, : 2;
+ typedef int E : 1; // expected-error {{error: cannot declare 'E' to be a bit-field type}}
+ static int sb : 1; // expected-error {{error: static member 'sb' cannot be a bit-field}}
+ static int vs;
+
+ typedef int func();
+ func tm;
+ func btm : 1; // expected-error {{error: bit-field 'btm' with non-integral type}}
+ NestedC bc : 1; // expected-error {{error: bit-field 'bc' with non-integral type}}
+
+ enum E { en1, en2 };
+
+ int i = 0; // expected-error {{error: 'i' can only be initialized if it is a static const integral data member}}
+ static int si = 0; // expected-error {{error: 'si' can only be initialized if it is a static const integral data member}}
+ static const NestedC ci = 0; // expected-error {{error: 'ci' can only be initialized if it is a static const integral data member}}
+ static const int nci = vs; // expected-error {{error: initializer element is not constant}}
+ static const int vi = 0;
+ static const E evi = 0;
+
+ void m() {
+ sx = 0;
+ this->x = 0;
+ y = 0;
+ this = 0; // expected-error {{error: expression is not assignable}}
+ }
+
+ int f1(int p) {
+ A z = 6;
+ return p + x + this->y + z;
+ }
+
+ typedef int A;
+
+private:
+ int x,y;
+ static int sx;
+};
+
+class C2 {
+ void f() {
+ static int lx;
+ class LC1 {
+ int m() { return lx; }
+ };
+ class LC2 {
+ int m() { return lx; }
+ };
+ }
+};