reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s

namespace test0 {
  struct A { // expected-note {{candidate function (the implicit copy assignment operator) not viable: 'this' argument has type 'const test0::A', but method is not marked const}}
#if __cplusplus >= 201103L
  // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable: 'this' argument has type 'const test0::A', but method is not marked const}}
#endif
    A &operator=(void*); // expected-note {{candidate function not viable: 'this' argument has type 'const test0::A', but method is not marked const}}
  };

  void test(const A &a) {
    a = "help"; // expected-error {{no viable overloaded '='}}
  }
}

namespace PR16314 {
  void f(char*);
  int &f(...);
  void x()
  {
    int &n = f("foo");
#if __cplusplus < 201103L
    // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
    // expected-error@-3 {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'void'}}
#endif
  }
}

namespace warn_if_best {
  int f(char *);
  void f(double);
  void x()
  {
    int n = f("foo");
#if __cplusplus < 201103L
    // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
#else
    // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#endif
  }
}

namespace userdefined_vs_illformed {
  struct X { X(const char *); };

  void *f(char *p); // best for C++03
  double f(X x);  // best for C++11
  void g()
  {
    double d = f("foo");
#if __cplusplus < 201103L
    // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
    // expected-error@-3 {{cannot initialize a variable of type 'double' with an rvalue of type 'void *'}}
#endif
  }
}

namespace sfinae_test {
  int f(int, char*);

  template<int T>
  struct S { typedef int type; };

  template<>
  struct S<sizeof(int)> { typedef void type; };

  // C++11: SFINAE failure
  // C++03: ok
  template<typename T> int cxx11_ignored(T, typename S<sizeof(f(T(), "foo"))>::type *);
#if __cplusplus < 201103L
  // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
#else
  // expected-note@-4 {{candidate template ignored: substitution failure}}
#endif

  // C++11: better than latter
  // C++03: worse than latter
  template<typename T> void g(T, ...);
  template<typename T> int g(T, typename S<sizeof(f(T(), "foo"))>::type *);
#if __cplusplus < 201103L
  // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
#endif

  int a = cxx11_ignored(0, 0);
  int b = g(0, 0);
#if __cplusplus >= 201103L
  // expected-error@-3 {{no matching function for call to 'cxx11_ignored'}}
  // expected-error@-3 {{cannot initialize a variable of type 'int' with an rvalue of type 'void'}}
#endif
}