xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class.derived/p1.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // base-clause:
4*f4a2713aSLionel Sambuc //         : base-specifier-list
5*f4a2713aSLionel Sambuc // base-specifier-list:
6*f4a2713aSLionel Sambuc //         base-specifier ...[opt]
7*f4a2713aSLionel Sambuc //         base-specifier-list , base-specifier ...[opt]
8*f4a2713aSLionel Sambuc // base-specifier:
9*f4a2713aSLionel Sambuc //         attribute-specifier-seq[opt] base-type-specifier
10*f4a2713aSLionel Sambuc //         attribute-specifier-seq[opt] virtual access-specifier[opt] base-type-specifier
11*f4a2713aSLionel Sambuc //         attribute-specifier-seq[opt] access-specifier virtual[opt] base-type-specifier
12*f4a2713aSLionel Sambuc // class-or-decltype:
13*f4a2713aSLionel Sambuc //         nested-name-specifier[opt] class-name
14*f4a2713aSLionel Sambuc //         decltype-specifier
15*f4a2713aSLionel Sambuc // base-type-specifier:
16*f4a2713aSLionel Sambuc //         class-or-decltype
17*f4a2713aSLionel Sambuc // access-specifier:
18*f4a2713aSLionel Sambuc //         private
19*f4a2713aSLionel Sambuc //         protected
20*f4a2713aSLionel Sambuc //         public
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc namespace PR11216 {
23*f4a2713aSLionel Sambuc   struct Base { };
24*f4a2713aSLionel Sambuc   struct Derived : decltype(Base()) { };
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc   int func();
27*f4a2713aSLionel Sambuc   struct Derived2 : decltype(func()) { }; // expected-error {{base specifier must name a class}}
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc   template<typename T>
30*f4a2713aSLionel Sambuc   struct Derived3 : decltype(T().foo()) { };
31*f4a2713aSLionel Sambuc   struct Foo { Base foo(); };
32*f4a2713aSLionel Sambuc   Derived3<Foo> d;
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc   struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}}
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc   template<typename T>
39*f4a2713aSLionel Sambuc   struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}}
40*f4a2713aSLionel Sambuc }
41