brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.7 KiB · 41c30ff Raw
242 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5template<typename _Alloc> class allocator;6template<class _CharT> struct char_traits;7template<typename _CharT, typename _Traits = char_traits<_CharT>,8         typename _Alloc = allocator<_CharT> >9class basic_string;10template<typename _CharT, typename _Traits, typename _Alloc>11const typename basic_string<_CharT, _Traits, _Alloc>::size_type12basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}}13  = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;14 15// PR711816template<typename T>17class Foo {18  class Bar;19  void f() {20    Bar i;21  }22};23 24// PR762525template<typename T> struct a : T {26 struct x : T {27   int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}28 };29};30 31namespace rdar8605381 {32struct X {};33 34struct Y { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}35#if __cplusplus >= 201103L // C++11 or later36// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}37#endif38 39  Y();40};41 42struct {43  Y obj;44} objs[] = {45  new Y // expected-error{{no viable conversion}}46};47}48 49// http://llvm.org/PR823450namespace PR8234 {51template<typename Signature>52class callback53{54};55 56template<typename R , typename ARG_TYPE0>57class callback<R( ARG_TYPE0)>58{59    public:60        callback() {}61};62 63template< typename ARG_TYPE0>64class callback<void( ARG_TYPE0)>65{66    public:67        callback() {}68};69 70void f()71{72    callback<void(const int&)> op;73}74}75 76namespace PR9007 {77  struct bar {78    enum xxx {79      yyy = sizeof(struct foo*)80    };81    foo *xxx();82  };83}84 85namespace PR9026 {86  class InfallibleTArray {87  };88  class Variant;89  class CompVariant {90    operator const InfallibleTArray&() const;91  };92  class Variant {93    operator const CompVariant&() const;94  };95  void     Write(const Variant& __v);96  void     Write(const InfallibleTArray& __v);97  Variant x;98  void Write2() {99    Write(x);100  }101}102 103namespace PR10270 {104  template<typename T> class C;105  template<typename T> void f() {106    if (C<T> == 1) // expected-error{{expected unqualified-id}}107      return;108  }109}110 111namespace rdar11806334 {112 113class cc_YCbCr;114 115class cc_rgb116{117 public:118  cc_rgb( uint p ); // expected-error {{unknown type name}}119  cc_rgb( cc_YCbCr v_in );120};121 122class cc_hsl123{124 public:125  cc_rgb rgb();126  cc_YCbCr YCbCr();127};128 129class cc_YCbCr130{131 public:132  cc_YCbCr( const cc_rgb v_in );133};134 135cc_YCbCr cc_hsl::YCbCr()136{137 cc_YCbCr v_out = cc_YCbCr( rgb());138 return v_out;139}140 141}142 143namespace test1 {144  int getString(const int*);145  template<int a> class ELFObjectFile  {146    const int* sh;147    ELFObjectFile() {148      switch (*sh) {149      }150      int SectionName(getString(sh));151    }152  };153}154 155namespace test2 {156  struct fltSemantics ;157  const fltSemantics &foobar();158  void VisitCastExpr(int x) {159    switch (x) {160    case 42:161      const fltSemantics &Sem = foobar();162    }163  }164}165 166namespace test3 {167  struct nsCSSRect {168  };169  static int nsCSSRect::* sides;170  nsCSSRect dimenX;171  void ParseBoxCornerRadii(int y) {172    switch (y) {173    }174    int& x = dimenX.*sides;175  }176}177 178namespace pr16964 {179  template<typename> struct bs {180    bs();181    static int* member(); // expected-note{{possible target}}182    member();  // expected-error{{a type specifier is required for all declarations}}183    static member();  // expected-error{{a type specifier is required for all declarations}}184    static int* member(int); // expected-note{{possible target}}185  };186 187  template<typename T> bs<T>::bs() { member; }  // expected-error{{did you mean to call it}}188 189  bs<int> test() {190    return bs<int>(); // expected-note{{in instantiation}}191  }192}193 194namespace pr12791 {195  template<class _Alloc> class allocator {};196  template<class _CharT> struct char_traits;197  struct input_iterator_tag {};198  struct forward_iterator_tag : public input_iterator_tag {};199 200  template<typename _CharT, typename _Traits, typename _Alloc> struct basic_string {201    struct _Alloc_hider : _Alloc { _Alloc_hider(_CharT*, const _Alloc&); };202    mutable _Alloc_hider _M_dataplus;203    template<class _InputIterator> basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc());204    template<class _InIterator> static _CharT* _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, input_iterator_tag);205    template<class _FwdIterator> static _CharT* _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, forward_iterator_tag);206    static _CharT* _S_construct(size_type __req, _CharT __c, const _Alloc& __a); // expected-error{{unknown type name 'size_type'}}207  };208 209  template<typename _CharT, typename _Traits, typename _Alloc>210  template<typename _InputIterator>211  basic_string<_CharT, _Traits, _Alloc>:: basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)212  : _M_dataplus(_S_construct(__beg, __end, __a, input_iterator_tag()), __a) {}213 214  template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > struct basic_stringbuf {215    typedef _CharT char_type;216    typedef basic_string<char_type, _Traits, _Alloc> __string_type;217    __string_type str() const {__string_type((char_type*)0,(char_type*)0);}218  };219 220  template class basic_stringbuf<char>;221}222 223namespace pr16989 {224  class C {225    template <class T>226    C tpl_mem(T *) { return }    // expected-error{{expected expression}}227    void mem(int *p) {228      tpl_mem(p);229    }230  };231  class C2 {232    void f();233  };234  void C2::f() {}235}236 237namespace pr20660 {238 appendList(int[]...);     // expected-error {{a type specifier is required for all declarations}}239 appendList(int[]...) { }  // expected-error {{a type specifier is required for all declarations}}240}241 242