Implement parsing and semantic checking of the 'mutable' keyword.
Thanks to Doug for the review. Actual effects of mutable to follow.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59331 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index ef0c901..5afa8d6 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -21,6 +21,7 @@
int x,f(),y,g();
inline int h();
static const int sci = 10;
+ mutable int mi;
};
void glo()
{
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 7eeecdc..ada508a 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -61,6 +61,11 @@
int x,y;
static int sx;
+ mutable int mi;
+ mutable int &mir; // expected-error {{error: 'mutable' cannot be applied to references}}
+ mutable void mfn(); // expected-error {{error: 'mutable' cannot be applied to functions}}
+ mutable const int mci; // expected-error {{error: 'mutable' and 'const' cannot be mixed}}
+
static const int number = 50;
static int arr[number];
};
@@ -76,3 +81,11 @@
};
}
};
+
+// Play with mutable a bit more, to make sure it doesn't crash anything.
+mutable int gi; // expected-error {{error: 'mutable' can only be applied to member variables}}
+mutable void gfn(); // expected-error {{illegal storage class on function}}
+void ogfn()
+{
+ mutable int ml; // expected-error {{error: 'mutable' can only be applied to member variables}}
+}