summaryrefslogtreecommitdiff
path: root/test/cedet/tests/teststruct.cpp
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2009-09-28 23:23:31 +0000
committerChong Yidong <cyd@stupidchicken.com>2009-09-28 23:23:31 +0000
commit74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a (patch)
treed895d7e93cf93022f48bd6d173f616f1bb4b99fc /test/cedet/tests/teststruct.cpp
parentb9de0a4665563f847bc7c94f8c89180bf2a9f6bd (diff)
downloademacs-74ea13c1a8d63e4f4015e2b9e7e4336e546e7e4a.tar.gz
Add CEDET tests.
Diffstat (limited to 'test/cedet/tests/teststruct.cpp')
-rw-r--r--test/cedet/tests/teststruct.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/cedet/tests/teststruct.cpp b/test/cedet/tests/teststruct.cpp
new file mode 100644
index 00000000000..6bc27b97208
--- /dev/null
+++ b/test/cedet/tests/teststruct.cpp
@@ -0,0 +1,66 @@
+// Combinations of templates and structure inheritance.
+//
+// Created by Alex Ott.
+
+template <typename DerivedT>
+struct grammar {
+public:
+ typedef grammar<DerivedT> self_t;
+ typedef DerivedT const& embed_t;
+ grammar() {}
+ ~grammar() { }
+ void use_parser() const { }
+ void test1() { }
+};
+
+struct PDFbool_parser : public grammar<PDFbool_parser> {
+ PDFbool_parser() {}
+ template <typename scannerT> struct definition {
+ typedef typename scannerT::iterator_t iterator_t;
+ int top;
+ definition(const PDFbool_parser& /*self*/) {
+ return ;
+ }
+ const int start() const {
+ return top;
+ }
+ };
+};
+
+int main(void) {
+ PDFbool_parser PDFbool_p = PDFbool_parser();
+ PDFbool_p.//-1-
+ ;
+ // #1# ("definition" "embed_t" "self_t" "test1" "use_parser")
+}
+
+// ----------------------------------------------------------------------
+
+template <class Derived> struct Base {
+public:
+ void interface()
+ {
+ // ...
+ static_cast<Derived*>(this)->implementation();
+ // ...
+ }
+
+ static void static_func()
+ {
+ // ...
+ Derived::static_sub_func();
+ // ...
+ }
+};
+
+struct Derived : Base<Derived> {
+ void implementation() { }
+ static void static_sub_func() { }
+};
+
+int foo () {
+ Derived d;
+ d.//-2-
+ ;
+ // #2# ("implementation" "interface" "static_func" "static_sub_func")
+}