r280309 - Fix all tests under test/CXX (and test/Analysis) to pass if clang's default

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 16:24:08 PDT 2016


Author: rsmith
Date: Wed Aug 31 18:24:08 2016
New Revision: 280309

URL: http://llvm.org/viewvc/llvm-project?rev=280309&view=rev
Log:
Fix all tests under test/CXX (and test/Analysis) to pass if clang's default
C++ language standard is not C++98.

Modified:
    cfe/trunk/test/Analysis/misc-ps-region-store.cpp
    cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
    cfe/trunk/test/CXX/class.access/p4.cpp
    cfe/trunk/test/CXX/class/class.union/p1.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
    cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp
    cfe/trunk/test/CXX/special/class.dtor/p9.cpp
    cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
    cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
    cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp

Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Wed Aug 31 18:24:08 2016
@@ -138,7 +138,7 @@ void pr7675_test() {
   pr7675(10.0);
   pr7675(10);
   pr7675('c');
-  pr7675_i(4.0i);
+  pr7675_i(4.0j);
 
   // Add check to ensure we are analyzing the code up to this point.
   clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}

Modified: cfe/trunk/test/CXX/class.access/class.friend/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.friend/p1.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.friend/p1.cpp Wed Aug 31 18:24:08 2016
@@ -1,3 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // C++'0x [class.friend] p1:
@@ -216,9 +219,17 @@ namespace test6 {
   struct A {};
 
   struct B {
-    friend A::A();
+    friend
+#if __cplusplus >= 201103L
+      constexpr
+#endif
+      A::A();
     friend A::~A();
-    friend A &A::operator=(const A&);
+    friend
+#if __cplusplus >= 201402L
+      constexpr
+#endif
+      A &A::operator=(const A&);
   };
 }
 
@@ -233,7 +244,11 @@ namespace test7 {
   class A {
     friend void X<int>::foo();
     friend X<int>::X();
-    friend X<int>::X(const X&);
+    friend
+#if __cplusplus >= 201103L
+      constexpr
+#endif
+      X<int>::X(const X&);
 
   private:
     A(); // expected-note 2 {{declared private here}}

Modified: cfe/trunk/test/CXX/class.access/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/p4.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class.access/p4.cpp (original)
+++ cfe/trunk/test/CXX/class.access/p4.cpp Wed Aug 31 18:24:08 2016
@@ -1,3 +1,5 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
 
 // C++0x [class.access]p4:
@@ -88,7 +90,7 @@ namespace test1 {
 namespace test2 {
   class A {
   private:
-    A(); // expected-note 3 {{declared private here}}
+    A(); // expected-note 1+{{declared private here}}
 
     static A foo;
   };
@@ -96,6 +98,7 @@ namespace test2 {
   A a; // expected-error {{calling a private constructor}}
   A A::foo; // okay
   
+#if __cplusplus < 201103L
   class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}}
   B b; // expected-note{{implicit default constructor}}
   
@@ -106,6 +109,19 @@ namespace test2 {
 
   class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}}
   D d; // expected-note{{implicit default constructor}}
+#else
+  class B : A { }; // expected-note {{base class 'test2::A' has an inaccessible default constructor}}
+  B b; // expected-error {{call to implicitly-deleted default constructor}}
+  
+  // FIXME: Do a better job of explaining how we get here from class D.
+  class C : virtual A { // expected-note {{default constructor of 'D' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor}}
+  public:
+    C();
+  };
+
+  class D : C { };
+  D d; // expected-error {{call to implicitly-deleted default constructor}}
+#endif
 }
 
 // Implicit destructor calls.
@@ -123,6 +139,7 @@ namespace test3 {
     A local; // expected-error {{variable of type 'test3::A' has private destructor}}
   }
 
+#if __cplusplus < 201103L
   template <unsigned N> class Base { ~Base(); }; // expected-note 14 {{declared private here}}
   class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 3 {{declared private here}} \
                                                // expected-error {{base class 'Base<2>' has private destructor}}
@@ -152,6 +169,33 @@ namespace test3 {
   {}; 
   Derived3 d3; // expected-note {{implicit default constructor}}\
                // expected-note{{implicit destructor}}}
+#else
+  template <unsigned N> class Base { ~Base(); }; // expected-note 4{{declared private here}}
+  class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 1{{declared private here}}
+  class Base3 : virtual Base<3> { public: ~Base3(); };
+
+  // These don't cause diagnostics because we don't need the destructor.
+  class Derived0 : Base<0> { ~Derived0(); };
+  class Derived1 : Base<1> { };
+
+  class Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}} \
+                   // expected-error {{inherited virtual base class 'Base<3>' has private destructor}}
+    Base<0>,  // expected-error {{base class 'Base<0>' has private destructor}}
+    virtual Base<1>, // expected-error {{base class 'Base<1>' has private destructor}}
+    Base2, // expected-error {{base class 'test3::Base2' has private destructor}}
+    virtual Base3
+  {
+    ~Derived2() {}
+  };
+
+  class Derived3 :
+    Base<0>, // expected-note {{deleted because base class 'Base<0>' has an inaccessible destructor}}
+    virtual Base<1>,
+    Base2,
+    virtual Base3
+  {}; 
+  Derived3 d3; // expected-error {{implicitly-deleted default constructor}}
+#endif
 }
 
 // Conversion functions.
@@ -201,9 +245,13 @@ namespace test4 {
 // Implicit copy assignment operator uses.
 namespace test5 {
   class A {
-    void operator=(const A &); // expected-note 2 {{implicitly declared private here}}
+    void operator=(const A &);
+#if __cplusplus < 201103L
+    // expected-note at -2 2{{implicitly declared private here}}
+#endif
   };
 
+#if __cplusplus < 201103L
   class Test1 { A a; }; // expected-error {{private member}}
   void test1() {
     Test1 a; 
@@ -215,15 +263,32 @@ namespace test5 {
     Test2 a;
     a = Test2(); // expected-note{{implicit copy}}
   }
+#else
+  class Test1 { A a; }; // expected-note {{because field 'a' has an inaccessible copy assignment operator}}
+  void test1() {
+    Test1 a; 
+    a = Test1(); // expected-error {{copy assignment operator is implicitly deleted}}
+  }
+
+  class Test2 : A {}; // expected-note {{because base class 'test5::A' has an inaccessible copy assignment operator}}
+  void test2() {
+    Test2 a;
+    a = Test2(); // expected-error {{copy assignment operator is implicitly deleted}}
+  }
+#endif
 }
 
 // Implicit copy constructor uses.
 namespace test6 {
   class A {
     public: A();
-    private: A(const A &); // expected-note 2 {{declared private here}}
+    private: A(const A &);
+#if __cplusplus < 201103L
+    // expected-note at -2 2{{declared private here}}
+#endif
   };
 
+#if __cplusplus < 201103L
   class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}}
   void test1(const Test1 &t) {
     Test1 a = t; // expected-note{{implicit copy}}
@@ -233,6 +298,17 @@ namespace test6 {
   void test2(const Test2 &t) {
     Test2 a = t; // expected-note{{implicit copy}}
   }
+#else
+  class Test1 { A a; }; // expected-note {{field 'a' has an inaccessible copy constructor}}
+  void test1(const Test1 &t) {
+    Test1 a = t; // expected-error{{implicitly-deleted}}
+  }
+
+  class Test2 : A {}; // expected-note {{base class 'test6::A' has an inaccessible copy constructor}}
+  void test2(const Test2 &t) {
+    Test2 a = t; // expected-error{{implicitly-deleted}}
+  }
+#endif
 }
 
 // Redeclaration lookups are not accesses.

Modified: cfe/trunk/test/CXX/class/class.union/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.union/p1.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.union/p1.cpp (original)
+++ cfe/trunk/test/CXX/class/class.union/p1.cpp Wed Aug 31 18:24:08 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s 
 
 void abort() __attribute__((noreturn));
 

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp Wed Aug 31 18:24:08 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // Verify that the appropriate fixits are emitted for narrowing conversions in
 // initializer lists.

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp Wed Aug 31 18:24:08 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++03 -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s
 
 // C++03 requires that we check for a copy constructor when binding a
 // reference to a temporary, since we are allowed to make a copy, Even

Modified: cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp Wed Aug 31 18:24:08 2016
@@ -1,3 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 //   A program that calls for default-initialization or value-initialization of
@@ -5,6 +7,11 @@
 //   cv-unqualified version of T is used for these definitions of
 //   zero-initialization, default-initialization, and value-initialization.
 
+typedef int &IR;
+IR r; // expected-error {{declaration of reference variable 'r' requires an initializer}}
+int n = IR(); // expected-error {{reference to type 'int' requires an initializer}}
+
+#if __cplusplus < 201103L
 struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}}
   int &x; // expected-note {{declared here}} expected-error 3{{reference to type 'int' requires an initializer}}
 };
@@ -22,6 +29,25 @@ struct U {
   T t[3]; // expected-note {{in value-initialization of type 'T' here}}
 };
 U u = U(); // expected-note {{in value-initialization of type 'U' here}}
+#else
+struct S {
+  int &x; // expected-note 4{{because field 'x' of reference type 'int &' would not be initialized}}
+};
+S s; // expected-error {{deleted default constructor}}
+S f() {
+  return S(); // expected-error {{deleted default constructor}}
+}
+
+struct T
+  : S { // expected-note 2{{because base class 'S' has a deleted default constructor}}
+};
+T t = T(); // expected-error {{deleted default constructor}}
+
+struct U {
+  T t[3]; // expected-note {{because field 't' has a deleted default constructor}}
+};
+U u = U(); // expected-error {{deleted default constructor}}
+#endif
 
 // Ensure that we handle C++11 in-class initializers properly as an extension.
 // In this case, there is no user-declared default constructor, so we
@@ -29,20 +55,19 @@ U u = U(); // expected-note {{in value-i
 // constructor call anyway, because the default constructor is not trivial.
 struct V {
   int n;
-  int &r = n; // expected-warning {{C++11}}
+  int &r = n; // expected-warning 0-1{{C++11}}
 };
 V v = V(); // ok
 struct W {
   int n;
-  S s = { n }; // expected-warning {{C++11}}
+  S s = { n }; // expected-warning 0-1{{C++11}}
 };
 W w = W(); // ok
 
 // Ensure we're not faking this up by making the default constructor
 // non-trivial.
-#define static_assert(B, S) typedef int assert_failed[(B) ? 1 : -1];
-static_assert(__has_trivial_constructor(S), "");
-static_assert(__has_trivial_constructor(T), "");
-static_assert(__has_trivial_constructor(U), "");
-static_assert(!__has_trivial_constructor(V), "");
-static_assert(!__has_trivial_constructor(W), "");
+_Static_assert(__has_trivial_constructor(S), "");
+_Static_assert(__has_trivial_constructor(T), "");
+_Static_assert(__has_trivial_constructor(U), "");
+_Static_assert(!__has_trivial_constructor(V), "");
+_Static_assert(!__has_trivial_constructor(W), "");

Modified: cfe/trunk/test/CXX/special/class.dtor/p9.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/special/class.dtor/p9.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/special/class.dtor/p9.cpp (original)
+++ cfe/trunk/test/CXX/special/class.dtor/p9.cpp Wed Aug 31 18:24:08 2016
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
-// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s
 
-typedef typeof(sizeof(int)) size_t;
+typedef __typeof(sizeof(int)) size_t;
 
 // PR7803
 namespace test0 {
@@ -63,6 +65,7 @@ namespace test2 {
   };
   B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}}
 
+#if __cplusplus < 201103L
   struct CBase { virtual ~CBase(); };
   struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}}
     static void operator delete(void*, const int &); // expected-note {{declared here}}
@@ -70,6 +73,15 @@ namespace test2 {
   void test() {
     C c; // expected-note {{first required here}}
   }
+#else
+  struct CBase { virtual ~CBase(); }; // expected-note {{overridden virtual function is here}}
+  struct C : CBase { // expected-error {{deleted function '~C' cannot override a non-deleted function}} expected-note {{requires an unambiguous, accessible 'operator delete'}}
+    static void operator delete(void*, const int &);
+  };
+  void test() {
+    C c; // expected-error {{attempt to use a deleted function}}
+  }
+#endif
 }
 
 // PR7346

Modified: cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp Wed Aug 31 18:24:08 2016
@@ -1,3 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // C++0x [temp.arg.nontype] p5:
@@ -45,15 +49,23 @@ namespace pointer_to_object_parameters {
     operator int() const;
   };
   
-  template<X const *Ptr> struct A2; // expected-note{{template parameter is declared here}}
+  template<X const *Ptr> struct A2; // expected-note 0-1{{template parameter is declared here}}
   
-  X *X_ptr;
+  X *X_ptr; // expected-note 0-1{{declared here}}
   X an_X;
   X array_of_Xs[10];
-  A2<X_ptr> *a12; // expected-error{{must have its address taken}}
+  A2<X_ptr> *a12;
+#if __cplusplus < 201103L
+  // expected-error at -2 {{must have its address taken}}
+#else
+  // expected-error at -4 {{not a constant expression}} expected-note at -4 {{read of non-constexpr variable}}
+#endif
   A2<array_of_Xs> *a13;
   A2<&an_X> *a13_2;
-  A2<(&an_X)> *a13_3; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}}
+  A2<(&an_X)> *a13_3;
+#if __cplusplus < 201103L
+  // expected-warning at -2 {{address non-type template argument cannot be surrounded by parentheses}}
+#endif
 
   // PR6244
   struct X1 {} X1v;
@@ -62,12 +74,24 @@ namespace pointer_to_object_parameters {
   struct X4 : X3<&X1v> { };
 
   // PR6563
-  int *bar;
-  template <int *> struct zed {}; // expected-note 2{{template parameter is declared here}}
-  void g(zed<bar>*); // expected-error{{must have its address taken}}
-
-  int baz;
-  void g2(zed<baz>*); // expected-error{{must have its address taken}}
+  int *bar; // expected-note 0-1{{declared here}}
+  template <int *> struct zed {}; // expected-note 0-2{{template parameter is declared here}}
+  void g(zed<bar>*);
+#if __cplusplus < 201103L
+  // expected-error at -2 {{must have its address taken}}
+#else
+  // expected-error at -4 {{not a constant expression}} expected-note at -4 {{read of non-constexpr variable}}
+#endif
+
+  int baz; // expected-note 0-1{{declared here}}
+  void g2(zed<baz>*);
+#if __cplusplus < 201103L
+  // expected-error at -2 {{must have its address taken}}
+#elif __cplusplus <= 201402L
+  // expected-error at -4 {{not a constant expression}} expected-note at -4 {{read of non-const variable}}
+#else
+  // expected-error at -6 {{not implicitly convertible to 'int *'}}
+#endif
 
   void g3(zed<&baz>*); // okay
 }
@@ -78,9 +102,9 @@ namespace pointer_to_object_parameters {
 //        template-argument. The template-parameter is bound directly to the
 //        template-argument, which shall be an lvalue.
 namespace reference_parameters {
-  template <int& N> struct S0 { }; // expected-note 3 {{template parameter is declared here}}
-  template <const int& N> struct S1 { }; // expected-note 2 {{template parameter is declared here}}
-  template <volatile int& N> struct S2 { }; // expected-note 2 {{template parameter is declared here}}
+  template <int& N> struct S0 { }; // expected-note 0-3{{template parameter is declared here}}
+  template <const int& N> struct S1 { }; // expected-note 0-2{{template parameter is declared here}}
+  template <volatile int& N> struct S2 { }; // expected-note 0-2{{template parameter is declared here}}
   template <const volatile int& N> struct S3 { };
   int i;
   extern const int ci;
@@ -88,19 +112,19 @@ namespace reference_parameters {
   extern const volatile int cvi;
   void test() {
     S0<i> s0;
-    S0<ci> s0c; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const int' ignores qualifiers}}
-    S0<vi> s0v; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'volatile int' ignores qualifiers}}
-    S0<cvi> s0cv; // expected-error{{reference binding of non-type template parameter of type 'int &' to template argument of type 'const volatile int' ignores qualifiers}}
+    S0<ci> s0c; // expected-error{{type 'const int'}}
+    S0<vi> s0v; // expected-error{{type 'volatile int'}}
+    S0<cvi> s0cv; // expected-error{{type 'const volatile int'}}
 
     S1<i> s1;
     S1<ci> s1c;
-    S1<vi> s1v; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'volatile int' ignores qualifiers}}
-    S1<cvi> s1cv; // expected-error{{reference binding of non-type template parameter of type 'const int &' to template argument of type 'const volatile int' ignores qualifiers}}
+    S1<vi> s1v; // expected-error{{type 'volatile int'}}
+    S1<cvi> s1cv; // expected-error{{type 'const volatile int'}}
 
     S2<i> s2;
-    S2<ci> s2c; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const int' ignores qualifiers}}
+    S2<ci> s2c; // expected-error{{type 'const int'}}
     S2<vi> s2v;
-    S2<cvi> s2cv; // expected-error{{reference binding of non-type template parameter of type 'volatile int &' to template argument of type 'const volatile int' ignores qualifiers}}
+    S2<cvi> s2cv; // expected-error{{type 'const volatile int'}}
 
     S3<i> s3;
     S3<ci> s3c;
@@ -125,9 +149,12 @@ namespace reference_parameters {
   }
 
   namespace PR6749 {
-    template <int& i> struct foo {}; // expected-note{{template parameter is declared here}}
+    template <int& i> struct foo {}; // expected-note 0-1{{template parameter is declared here}}
     int x, &y = x;
-    foo<y> f; // expected-error{{is not an object}}
+    foo<y> f;
+#if __cplusplus <= 201402L
+    // expected-error at -2 {{is not an object}}
+#endif
   }
 }
 
@@ -138,16 +165,21 @@ namespace reference_parameters {
 //        a set of overloaded functions (or a pointer to such), the matching
 //        function is selected from the set (13.4).
 namespace pointer_to_function {
-  template<int (*)(int)> struct X0 { }; // expected-note 3{{template parameter is declared here}}
+  template<int (*)(int)> struct X0 { }; // expected-note 0-3{{template parameter is declared here}}
   int f(int);
   int f(float);
   int g(float);
-  int (*funcptr)(int);
+  int (*funcptr)(int); // expected-note 0-1{{declared here}}
   void x0a(X0<f>);
   void x0b(X0<&f>);
-  void x0c(X0<g>); // expected-error{{non-type template argument of type 'int (float)' cannot be converted to a value of type 'int (*)(int)'}}
-  void x0d(X0<&g>); // expected-error{{non-type template argument of type 'int (*)(float)' cannot be converted to a value of type 'int (*)(int)'}}
-  void x0e(X0<funcptr>); // expected-error{{must have its address taken}}
+  void x0c(X0<g>); // expected-error-re{{type 'int (float)' {{.*}}convert{{.*}} 'int (*)(int)'}}
+  void x0d(X0<&g>); // expected-error-re{{type 'int (*)(float)' {{.*}}convert{{.*}} 'int (*)(int)'}}
+  void x0e(X0<funcptr>);
+#if __cplusplus < 201103L
+  // expected-error at -2 {{must have its address taken}}
+#else
+  // expected-error at -4 {{not a constant expression}} expected-note at -4 {{read of non-constexpr variable}}
+#endif
 }
 
 //     -- For a non-type template-parameter of type reference to function, no
@@ -155,16 +187,23 @@ namespace pointer_to_function {
 //        overloaded functions, the matching function is selected from the set
 //        (13.4).
 namespace reference_to_function {
-  template<int (&)(int)> struct X0 { }; // expected-note 4{{template parameter is declared here}}
+  template<int (&)(int)> struct X0 { }; // expected-note 0-4{{template parameter is declared here}}
   int f(int);
   int f(float);
   int g(float);
   int (*funcptr)(int);
   void x0a(X0<f>);
+#if __cplusplus <= 201402L
   void x0b(X0<&f>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
   void x0c(X0<g>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (float)'}}
   void x0d(X0<&g>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}}
   void x0e(X0<funcptr>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (*)(int)'}}
+#else
+  void x0b(X0<&f>); // expected-error{{value of type '<overloaded function type>' is not implicitly convertible to 'int (&)(int)'}}
+  void x0c(X0<g>); // expected-error{{value of type 'int (float)' is not implicitly convertible to 'int (&)(int)'}}
+  void x0d(X0<&g>); // expected-error{{value of type 'int (*)(float)' is not implicitly convertible to 'int (&)(int)'}}
+  void x0e(X0<funcptr>); // expected-error{{value of type 'int (*)(int)' is not implicitly convertible to 'int (&)(int)'}}
+#endif
 }
 //     -- For a non-type template-parameter of type pointer to member function,
 //        if the template-argument is of type std::nullptr_t, the null member
@@ -181,10 +220,10 @@ namespace pointer_to_member_function {
     float h(float);
   };
 
-  template<int (Y::*)(int)> struct X0 {}; // expected-note{{template parameter is declared here}}
+  template<int (Y::*)(int)> struct X0 {}; // expected-note 0-1{{template parameter is declared here}}
   X0<&Y::f> x0a;
   X0<&Y::g> x0b;
-  X0<&Y::h> x0c; // expected-error-re{{non-type template argument of type 'float (pointer_to_member_function::Y::*)(float){{( __attribute__\(\(thiscall\)\))?}}' cannot be converted to a value of type 'int (pointer_to_member_function::Y::*)(int){{( __attribute__\(\(thiscall\)\))?}}'}}
+  X0<&Y::h> x0c; // expected-error-re{{type 'float (pointer_to_member_function::Y::*)(float){{( __attribute__\(\(thiscall\)\))?}}' {{.*}} convert{{.*}} 'int (pointer_to_member_function::Y::*)(int){{( __attribute__\(\(thiscall\)\))?}}'}}
 }
 
 //     -- For a non-type template-parameter of type pointer to data member,
@@ -195,9 +234,14 @@ namespace pointer_to_member_data {
   struct X { int x; };
   struct Y : X { int y; };
 
-  template<int Y::*> struct X0 {}; // expected-note{{template parameter is declared here}}
+  template<int Y::*> struct X0 {}; // expected-note 0-1{{template parameter is declared here}}
   X0<&Y::y> x0a;
-  X0<&Y::x> x0b;  // expected-error{{non-type template argument of type 'int pointer_to_member_data::X::*' cannot be converted to a value of type 'int pointer_to_member_data::Y::*'}}
+  X0<&Y::x> x0b;
+#if __cplusplus <= 201402L
+  // expected-error at -2 {{non-type template argument of type 'int pointer_to_member_data::X::*' cannot be converted to a value of type 'int pointer_to_member_data::Y::*'}}
+#else
+  // expected-error at -4 {{conversion from 'int pointer_to_member_data::X::*' to 'int pointer_to_member_data::Y::*' is not allowed in a converted constant expression}}
+#endif
 
   // Test qualification conversions
   template<const int Y::*> struct X1 {};

Modified: cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp Wed Aug 31 18:24:08 2016
@@ -28,4 +28,4 @@ X2& get_X2() {
   return X0<X2>::value; // expected-note{{instantiation}}
 }
 
-template<typename T> T x; // expected-warning{{variable templates are a C++14 extension}}
+template<typename T> T x; // expected-warning 0-1{{variable templates are a C++14 extension}}

Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp?rev=280309&r1=280308&r2=280309&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp Wed Aug 31 18:24:08 2016
@@ -1,6 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-struct IntHolder { // expected-note{{here}} // expected-note 2{{candidate constructor (the implicit copy constructor)}}
+struct IntHolder { // expected-note 0-1{{here}} expected-note 2-4{{candidate constructor (the implicit}}
   IntHolder(int); // expected-note 2{{candidate constructor}}
 };
 
@@ -12,8 +14,13 @@ struct X { // expected-note{{here}}
 
   void g() { }
   
-  struct Inner {  // expected-error{{implicit default}}
+  struct Inner {
+#if __cplusplus >= 201103L
+    T value; 	// expected-note {{has no default constructor}}
+#else
+    // expected-error at -4 {{implicit default}}
     T value; 	// expected-note {{member is declared here}}
+#endif
   };
   
   static T value;
@@ -26,7 +33,12 @@ IntHolder &test_X_IntHolderInt(X<IntHold
   xih.g(); // okay
   xih.f(); // expected-note{{instantiation}}
   
-  X<IntHolder, int>::Inner inner; // expected-note {{first required here}}
+  X<IntHolder, int>::Inner inner;
+#if __cplusplus >= 201103L
+  // expected-error at -2 {{call to implicitly-deleted}}
+#else
+  // expected-note at -4 {{first required here}}
+#endif
   
   return X<IntHolder, int>::value; // expected-note{{instantiation}}
 }




More information about the cfe-commits mailing list