aboutsummaryrefslogtreecommitdiff
path: root/test/CXX
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-04-21 01:08:50 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-04-21 01:08:50 +0000
commit840462670ba7a6bc26265a2306b35f2f0f01f51c (patch)
tree83c14a10bce99e57a7064e3edb4a50d3c8b300af /test/CXX
parent39b0e269dc8895ecc0f92f08126d3082b2a837a8 (diff)
The 'constexpr implies const' rule for non-static member functions is gone in
C++1y, so stop adding the 'const' there. Provide a compatibility warning for code relying on this in C++11, with a fix-it hint. Update our lazily-written tests to add the const, except for those ones which were testing our implementation of this rule. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX')
-rw-r--r--test/CXX/basic/basic.types/p10.cpp10
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp4
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp26
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp2
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp4
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp14
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp2
-rw-r--r--test/CXX/dcl.dcl/p4-0x.cpp8
-rw-r--r--test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp4
-rw-r--r--test/CXX/expr/expr.ass/p9-cxx11.cpp4
-rw-r--r--test/CXX/expr/expr.const/p2-0x.cpp8
-rw-r--r--test/CXX/expr/expr.const/p3-0x.cpp2
-rw-r--r--test/CXX/expr/expr.const/p5-0x.cpp12
-rw-r--r--test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp4
-rw-r--r--test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp10
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp2
16 files changed, 58 insertions, 58 deletions
diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp
index 6401c29dcf..690538d053 100644
--- a/test/CXX/basic/basic.types/p10.cpp
+++ b/test/CXX/basic/basic.types/p10.cpp
@@ -32,13 +32,13 @@ constexpr ClassTemp<int> classtemplate2[] = {};
// - it has a trivial destructor
struct UserProvDtor {
- constexpr int f(); // expected-error {{non-literal type 'UserProvDtor' cannot have constexpr members}}
+ constexpr int f() const; // expected-error {{non-literal type 'UserProvDtor' cannot have constexpr members}}
~UserProvDtor(); // expected-note {{has a user-provided destructor}}
};
struct NonTrivDtor {
constexpr NonTrivDtor();
- constexpr int f(); // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
+ constexpr int f() const; // expected-error {{non-literal type 'NonTrivDtor' cannot have constexpr members}}
virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}} expected-note {{because it is virtual}}
};
struct NonTrivDtorBase {
@@ -71,11 +71,11 @@ struct CtorTemplate {
};
struct CopyCtorOnly { // expected-note {{'CopyCtorOnly' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}}
constexpr CopyCtorOnly(CopyCtorOnly&);
- constexpr int f(); // expected-error {{non-literal type 'CopyCtorOnly' cannot have constexpr members}}
+ constexpr int f() const; // expected-error {{non-literal type 'CopyCtorOnly' cannot have constexpr members}}
};
struct MoveCtorOnly { // expected-note {{no constexpr constructors other than copy or move constructors}}
constexpr MoveCtorOnly(MoveCtorOnly&&);
- constexpr int f(); // expected-error {{non-literal type 'MoveCtorOnly' cannot have constexpr members}}
+ constexpr int f() const; // expected-error {{non-literal type 'MoveCtorOnly' cannot have constexpr members}}
};
template<typename T>
struct CtorArg {
@@ -104,7 +104,7 @@ constexpr int f(NonLitMember) {} // expected-error {{1st parameter type 'NonLitM
struct NonLitBase :
S { // expected-note {{base class 'S' of non-literal type}}
constexpr NonLitBase();
- constexpr int f() { return 0; } // expected-error {{non-literal type 'NonLitBase' cannot have constexpr members}}
+ constexpr int f() const { return 0; } // expected-error {{non-literal type 'NonLitBase' cannot have constexpr members}}
};
struct LitMemBase : Agg {
Agg agg;
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
index a3a964a1ca..122a400d9b 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp
@@ -71,7 +71,7 @@ struct ConstexprDtor {
template <typename T> constexpr T ft(T t) { return t; }
template <typename T> T gt(T t) { return t; }
struct S {
- template<typename T> constexpr T f();
+ template<typename T> constexpr T f(); // expected-warning {{C++1y}}
template<typename T> T g() const;
};
@@ -81,7 +81,7 @@ template <> char ft(char c) { return c; } // expected-note {{previous}}
template <> constexpr char ft(char nl); // expected-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}}
template <> constexpr int gt(int nl) { return nl; }
template <> notlit S::f() const { return notlit(); }
-template <> constexpr int S::g() { return 0; } // expected-note {{previous}}
+template <> constexpr int S::g() { return 0; } // expected-note {{previous}} expected-warning {{C++1y}}
template <> int S::g() const; // expected-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}}
// specializations can drop the 'constexpr' but not the implied 'const'.
template <> char S::g() { return 0; } // expected-error {{no function template matches}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 0cef31b6c8..06993c225e 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -28,41 +28,41 @@ struct SS : S {
// constraints:
struct T : SS, NonLiteral { // expected-note {{base class 'NonLiteral' of non-literal type}}
constexpr T();
- constexpr int f(); // expected-error {{non-literal type 'T' cannot have constexpr members}}
+ constexpr int f() const; // expected-error {{non-literal type 'T' cannot have constexpr members}}
// - it shall not be virtual;
- virtual constexpr int ExplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
+ virtual constexpr int ExplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
- constexpr int ImplicitlyVirtual() { return 0; } // expected-error {{virtual function cannot be constexpr}}
+ constexpr int ImplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}}
// - its return type shall be a literal type;
- constexpr NonLiteral NonLiteralReturn() { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
- constexpr void VoidReturn() { return; } // expected-error {{constexpr function's return type 'void' is not a literal type}}
+ constexpr NonLiteral NonLiteralReturn() const { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr void VoidReturn() const { return; } // expected-error {{constexpr function's return type 'void' is not a literal type}}
constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}}
- typedef NonLiteral F();
+ typedef NonLiteral F() const;
constexpr F NonLiteralReturn2; // ok until definition
// - each of its parameter types shall be a literal type;
- constexpr int NonLiteralParam(NonLiteral) { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
- typedef int G(NonLiteral);
+ constexpr int NonLiteralParam(NonLiteral) const { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
+ typedef int G(NonLiteral) const;
constexpr G NonLiteralParam2; // ok until definition
// - its function-body shall be = delete, = default,
- constexpr int Deleted() = delete;
+ constexpr int Deleted() const = delete;
// It's not possible for the function-body to legally be "= default" here.
// Other than constructors, only the copy- and move-assignment operators and
// destructor can be defaulted. Destructors can't be constexpr since they
// don't have a literal return type. Defaulted assignment operators can't be
// constexpr since they can't be const.
- constexpr T &operator=(const T&) = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
+ constexpr T &operator=(const T&) = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} expected-warning {{C++1y}}
};
struct U {
- constexpr U SelfReturn();
- constexpr int SelfParam(U);
+ constexpr U SelfReturn() const;
+ constexpr int SelfParam(U) const;
};
struct V : virtual U { // expected-note {{here}}
- constexpr int F() { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}}
+ constexpr int F() const { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}}
};
// or a compound-statememt that contains only
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
index bca73ee85f..5e40f69d77 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
@@ -102,7 +102,7 @@ X x = cmin(X(), X()); // ok, not constexpr
template<typename T>
struct Y {
constexpr Y() {}
- constexpr int get() { return T(); }
+ constexpr int get() { return T(); } // expected-warning {{C++1y}}
};
struct Z { operator int(); };
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
index 1a6dc9ecfb..bb7f7ac326 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
@@ -24,7 +24,7 @@ struct S {
struct T {};
template<typename T> struct ImplicitVirtualFromDependentBase : T {
- constexpr int ImplicitlyVirtual() { return 0; }
+ constexpr int ImplicitlyVirtual() const { return 0; }
};
constexpr int a = ImplicitVirtualFromDependentBase<S>().ImplicitlyVirtual(); // expected-error {{constant expression}} expected-note {{cannot evaluate virtual function call}}
@@ -32,7 +32,7 @@ constexpr int b = ImplicitVirtualFromDependentBase<T>().ImplicitlyVirtual(); //
constexpr int c = ImplicitVirtualFromDependentBase<S>().ImplicitVirtualFromDependentBase<S>::ImplicitlyVirtual();
template<typename R> struct ConstexprMember {
- constexpr R F() { return 0; }
+ constexpr R F() const { return 0; }
};
constexpr int d = ConstexprMember<int>().F(); // ok
constexpr int e = ConstexprMember<NonLiteral>().F(); // expected-error {{constant expression}}
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
index 344f8ce8c4..40aa600ba1 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp
@@ -3,13 +3,13 @@
using size_t = decltype(sizeof(int));
struct S {
- constexpr int f();
+ constexpr int f(); // expected-warning {{C++1y}}
constexpr int g() const;
- constexpr int h();
+ constexpr int h(); // expected-warning {{C++1y}}
int h();
static constexpr int Sf();
/*static*/ constexpr void *operator new(size_t) noexcept;
- template<typename T> constexpr T tm();
+ template<typename T> constexpr T tm(); // expected-warning {{C++1y}}
template<typename T> static constexpr T ts();
};
@@ -26,12 +26,12 @@ void f(const S &s) {
}
constexpr int S::f() const { return 0; }
-constexpr int S::g() { return 1; }
-constexpr int S::h() { return 0; }
+constexpr int S::g() { return 1; } // expected-warning {{C++1y}}
+constexpr int S::h() { return 0; } // expected-warning {{C++1y}}
int S::h() { return 0; }
constexpr int S::Sf() { return 2; }
constexpr void *S::operator new(size_t) noexcept { return 0; }
-template<typename T> constexpr T S::tm() { return T(); }
+template<typename T> constexpr T S::tm() { return T(); } // expected-warning {{C++1y}}
template<typename T> constexpr T S::ts() { return T(); }
namespace std_example {
@@ -39,7 +39,7 @@ namespace std_example {
class debug_flag { // expected-note {{not an aggregate and has no constexpr constructors}}
public:
explicit debug_flag(bool);
- constexpr bool is_on(); // expected-error {{non-literal type 'std_example::debug_flag' cannot have constexpr members}}
+ constexpr bool is_on() const; // expected-error {{non-literal type 'std_example::debug_flag' cannot have constexpr members}}
private:
bool flag;
};
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
index 093bc14d47..d55de08144 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp
@@ -76,7 +76,7 @@ namespace libcxx_example {
template<typename T> struct swappable {
typedef decltype(swap(declval<T&>(), declval<T&>())) type;
static const bool value = !is_same<type, nat>::value;
- constexpr operator bool() { return value; }
+ constexpr operator bool() const { return value; }
};
static_assert(swappable<int>(), "");
diff --git a/test/CXX/dcl.dcl/p4-0x.cpp b/test/CXX/dcl.dcl/p4-0x.cpp
index 31d49127e7..1f4cdda1a1 100644
--- a/test/CXX/dcl.dcl/p4-0x.cpp
+++ b/test/CXX/dcl.dcl/p4-0x.cpp
@@ -2,15 +2,15 @@
struct S {
constexpr S(bool b) : b(b) {}
- constexpr explicit operator bool() { return b; }
+ constexpr explicit operator bool() const { return b; }
bool b;
};
struct T {
- constexpr operator int() { return 1; }
+ constexpr operator int() const { return 1; }
};
struct U {
- constexpr operator int() { return 1; } // expected-note {{candidate}}
- constexpr operator long() { return 0; } // expected-note {{candidate}}
+ constexpr operator int() const { return 1; } // expected-note {{candidate}}
+ constexpr operator long() const { return 0; } // expected-note {{candidate}}
};
static_assert(S(true), "");
diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
index 783aba1823..b9a1bc5288 100644
--- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
+++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
@@ -6,8 +6,8 @@ struct S1 {
constexpr S1() = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
constexpr S1(const S1&) = default;
constexpr S1(S1&&) = default;
- constexpr S1 &operator=(const S1&) = default; // expected-error {{explicitly-defaulted copy assignment operator may not have}}
- constexpr S1 &operator=(S1&&) = default; // expected-error {{explicitly-defaulted move assignment operator may not have}}
+ constexpr S1 &operator=(const S1&) const = default; // expected-error {{explicitly-defaulted copy assignment operator may not have}}
+ constexpr S1 &operator=(S1&&) const = default; // expected-error {{explicitly-defaulted move assignment operator may not have}}
constexpr ~S1() = default; // expected-error {{destructor cannot be marked constexpr}}
int n;
};
diff --git a/test/CXX/expr/expr.ass/p9-cxx11.cpp b/test/CXX/expr/expr.ass/p9-cxx11.cpp
index 206c82c985..ecc6d2c3d5 100644
--- a/test/CXX/expr/expr.ass/p9-cxx11.cpp
+++ b/test/CXX/expr/expr.ass/p9-cxx11.cpp
@@ -24,8 +24,8 @@ struct S {
int a, b;
};
struct T {
- constexpr int operator=(S s) { return s.a; }
- constexpr int operator+=(S s) { return s.b; }
+ constexpr int operator=(S s) const { return s.a; }
+ constexpr int operator+=(S s) const { return s.b; }
};
static_assert((T() = {4, 9}) == 4, "");
static_assert((T() += {4, 9}) == 9, "");
diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp
index 065a12b3f2..634dee3782 100644
--- a/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/test/CXX/expr/expr.const/p2-0x.cpp
@@ -118,7 +118,7 @@ namespace IncompleteClassTypeAddr {
constexpr S (*p2)[] = &sArr; // ok
struct S {
- constexpr S *operator&() { return nullptr; }
+ constexpr S *operator&() const { return nullptr; }
};
constexpr S *q = &s; // ok
static_assert(!q, "");
@@ -205,7 +205,7 @@ namespace UndefinedBehavior {
constexpr const int &np = (*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot access array element of null pointer}}
struct C {
- constexpr int f() { return 0; }
+ constexpr int f() const { return 0; }
} constexpr c = C();
constexpr int k1 = c.f(); // ok
constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}}
@@ -481,14 +481,14 @@ namespace UnspecifiedRelations {
public:
constexpr A() : a(0), b(0) {}
int a;
- constexpr bool cmp() { return &a < &b; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}}
+ constexpr bool cmp() const { return &a < &b; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}}
private:
int b;
};
class B {
public:
A a;
- constexpr bool cmp() { return &a.a < &b.a; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}}
+ constexpr bool cmp() const { return &a.a < &b.a; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}}
protected:
A b;
};
diff --git a/test/CXX/expr/expr.const/p3-0x.cpp b/test/CXX/expr/expr.const/p3-0x.cpp
index 6ddd11bcee..047e238190 100644
--- a/test/CXX/expr/expr.const/p3-0x.cpp
+++ b/test/CXX/expr/expr.const/p3-0x.cpp
@@ -101,7 +101,7 @@ int n = Val<bool, &S::operator int>::value; // expected-error {{conversion from
namespace NonConstLValue {
struct S {
- constexpr operator int() { return 10; }
+ constexpr operator int() const { return 10; }
};
S s; // not constexpr
// Under the FDIS, this is not a converted constant expression.
diff --git a/test/CXX/expr/expr.const/p5-0x.cpp b/test/CXX/expr/expr.const/p5-0x.cpp
index bdb2b23ec7..0a4ac22d06 100644
--- a/test/CXX/expr/expr.const/p5-0x.cpp
+++ b/test/CXX/expr/expr.const/p5-0x.cpp
@@ -7,8 +7,8 @@ namespace std_example {
struct A {
constexpr A(int i) : val(i) { }
- constexpr operator int() { return val; }
- constexpr operator long() { return 43; }
+ constexpr operator int() const { return val; }
+ constexpr operator long() const { return 43; }
private:
int val;
};
@@ -21,17 +21,17 @@ int ary[a]; // expected-error {{size of array has non-integer type 'const std_ex
struct OK {
constexpr OK() {}
- constexpr operator int() { return 8; }
+ constexpr operator int() const { return 8; }
} constexpr ok;
extern struct Incomplete incomplete; // expected-note 4{{forward decl}}
struct Explicit {
constexpr Explicit() {}
- constexpr explicit operator int() { return 4; } // expected-note 4{{here}}
+ constexpr explicit operator int() const { return 4; } // expected-note 4{{here}}
} constexpr expl;
struct Ambiguous {
constexpr Ambiguous() {}
- constexpr operator int() { return 2; } // expected-note 4{{here}}
- constexpr operator long() { return 1; } // expected-note 4{{here}}
+ constexpr operator int() const { return 2; } // expected-note 4{{here}}
+ constexpr operator long() const { return 1; } // expected-note 4{{here}}
} constexpr ambig;
constexpr int test_ok = ok; // ok
diff --git a/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp b/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
index d0f15d4d3d..fda0c5cff1 100644
--- a/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
+++ b/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp
@@ -3,12 +3,12 @@
struct Value {
constexpr Value(int n) : n(n) {}
- constexpr operator short() { return n; }
+ constexpr operator short() const { return n; }
int n;
};
enum E { E0, E1 };
struct Alt {
- constexpr operator E() { return E0; }
+ constexpr operator E() const { return E0; }
};
constexpr short s = Alt();
diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
index e0ffef5007..82114cfa9d 100644
--- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
+++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp
@@ -193,18 +193,18 @@ namespace PacksAtDifferentLevels {
template<typename...A>
struct X6 {
template<typename...B>
- constexpr auto f1(A ...a) -> decltype(g(A(a + B())...)) { return g(A(a + B())...); }
+ constexpr auto f1(A ...a) const -> decltype(g(A(a + B())...)) { return g(A(a + B())...); }
template<typename...B>
- constexpr auto f2(A ...a, B ...b) -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}}
+ constexpr auto f2(A ...a, B ...b) const -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}}
template<typename...B> struct Inner {
template<typename...C>
- constexpr auto f(A ...a, B ...b, C ...c) -> decltype(g(a+b+c...)) { return g(a+b+c...); }
+ constexpr auto f(A ...a, B ...b, C ...c) const -> decltype(g(a+b+c...)) { return g(a+b+c...); }
};
};
- struct A { constexpr operator int() { return 2; } };
- struct B { constexpr operator int() { return 1; } };
+ struct A { constexpr operator int() const { return 2; } };
+ struct B { constexpr operator int() const { return 1; } };
static_assert(X6<unsigned char, int>().f1<A, B>(255, 1) == 12, "");
static_assert(X6<int, int>().f2(3, 4, 0, 0) == 34, "");
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
index e0c7b35a79..f804d4db12 100644
--- a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -9,7 +9,7 @@ template inline void X<int>::f(); // expected-error{{explicit instantiation cann
template<typename T>
struct Y {
- constexpr int f() { return 0; }
+ constexpr int f() { return 0; } // expected-warning{{C++1y}}
};
template constexpr int Y<int>::f() const; // expected-error{{explicit instantiation cannot be 'constexpr'}}