brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ac040cc Raw
71 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s3// RUN: %clang_cc1 -fsyntax-only -verify %s4 5struct IntHolder { // expected-note 0-1{{here}} expected-note 2-4{{candidate constructor (the implicit}}6  IntHolder(int); // expected-note 2{{candidate constructor}}7};8 9template<typename T, typename U>10struct X { // expected-note{{here}}11  void f() { 12    T t; // expected-error{{no matching}}13  }14 15  void g() { }16  17  struct Inner {18#if __cplusplus >= 201103L19    T value; 	// expected-note {{has no default constructor}}20#else21    // expected-error@-4 {{implicit default}}22    T value; 	// expected-note {{member is declared here}}23#endif24  };25  26  static T value;27};28 29template<typename T, typename U>30T X<T, U>::value; // expected-error{{no matching constructor}}31 32IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) {33  xih.g(); // okay34  xih.f(); // expected-note{{instantiation}}35  36  X<IntHolder, int>::Inner inner;37#if __cplusplus >= 201103L38  // expected-error@-2 {{call to implicitly-deleted}}39#else40  // expected-note@-4 {{first required here}}41#endif42  43  return X<IntHolder, int>::value; // expected-note{{instantiation}}44}45 46// Explicitly specialize the members of X<IntHolder, long> to not cause47// problems with instantiation.48template<>49void X<IntHolder, long>::f() { }50 51template<>52struct X<IntHolder, long>::Inner {53  Inner() : value(17) { }54  IntHolder value;55};56 57template<>58IntHolder X<IntHolder, long>::value = 17;59 60IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) {61  xih.g(); // okay62  xih.f(); // okay, uses specialization63  64  X<IntHolder, long>::Inner inner; // okay, uses specialization65  66  return X<IntHolder, long>::value; // okay, uses specialization67}68 69template<>70X<IntHolder, long>::X() { } // expected-error{{instantiated member}}71