diff options
| author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 | 
|---|---|---|
| committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 | 
| commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
| tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/qual-id-test.cpp | |
| parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
| parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) | |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/qual-id-test.cpp')
| -rw-r--r-- | clang/test/SemaCXX/qual-id-test.cpp | 149 | 
1 files changed, 149 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/qual-id-test.cpp b/clang/test/SemaCXX/qual-id-test.cpp new file mode 100644 index 0000000..9994d75 --- /dev/null +++ b/clang/test/SemaCXX/qual-id-test.cpp @@ -0,0 +1,149 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s  +namespace A +{ +    namespace B +    { +        struct base // expected-note{{object type}} +        { +            void x() {} +            void y() {} +        }; +    } + +    struct member +    { +        void foo(); +    }; + +    struct middleman +    { +        member * operator->() { return 0; } +    }; + +    struct sub : B::base +    { +        void x() {} +        middleman operator->() { return middleman(); } +    }; +} + +struct bad +{ +  int x(); +}; + +namespace C +{ +    void fun() +    { +        A::sub a; + +        a.x(); +     +        a.sub::x(); +        a.base::x(); + +        a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}} + +        a.A::sub::x(); +        a.A::B::base::x(); + +        a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} + +        a->foo(); +        a->member::foo(); +        a->A::member::foo(); +    } + +    void fun2() +    { +        A::sub *a; + +        a->x(); + +        a->sub::x(); +        a->base::x(); + +        a->B::base::x(); // expected-error{{use of undeclared identifier 'B'}} + +        a->A::sub::x(); +        a->A::B::base::x(); + +        a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} + +        (*a)->foo(); +        (*a)->member::foo(); +        (*a)->A::member::foo(); +    } + +    void fun3() +    { +        int i; +        i.foo(); // expected-error{{member reference base type 'int' is not a structure or union}} +    } + +    void fun4a() { +      A::sub *a; +       +      typedef A::member base; // expected-note{{current scope}} +      a->base::x(); // expected-error{{ambiguous}}       +    } + +    void fun4b() { +      A::sub *a; +       +      typedef A::B::base base; +      a->base::x(); +    } +   +    template<typename T> +    void fun5() +    { +        T a; +        a.x(); +        a->foo(); + +        a.A::sub::x(); +        a.A::B::base::x(); +        a->A::member::foo(); + +        a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}} +    } + +  void test_fun5() { +    fun5<A::sub>(); // expected-note{{instantiation}} +  } +   +  template<typename T> +  void fun6() { +    T a; +    a.sub::x(); +    a.base::x(); +    a->member::foo(); +    a.B::base::x(); // expected-error{{use of undeclared identifier 'B'}} +   } +   +  void test_fun6() { +    fun6<A::sub>(); // expected-note{{instantiation}} +  } +   +} + +// PR4703 +struct a { +  int a; +  static int sa; +}; + +a a; + +int a::sa = a.a; // expected-error {{invalid use of non-static data member 'a'}} + + +namespace PR6645 { +  typedef int foo; +  namespace Inner { +    typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \ +    // expected-error{{cannot define or redeclare 'foo' here because namespace 'Inner' does not enclose namespace 'PR6645'}} +  } +}  | 
