+2014-10-09 Marc Glisse <marc.glisse@inria.fr>
+
+ * decl.c (grokdeclarator): constexpr only implies const in C++11.
+
2014-10-08 Jason Merrill <jason@redhat.com>
PR c++/63405
&& !NEW_DELETE_OPNAME_P (unqualified_id))
{
cp_cv_quals real_quals = memfn_quals;
- if (constexpr_p && sfk != sfk_constructor && sfk != sfk_destructor)
+ if (cxx_dialect < cxx14 && constexpr_p
+ && sfk != sfk_constructor && sfk != sfk_destructor)
real_quals |= TYPE_QUAL_CONST;
type = build_memfn_type (type, ctype, real_quals, rqual);
}
+2014-10-09 Marc Glisse <marc.glisse@inria.fr>
+
+ * g++.dg/cpp0x/constexpr-52892-1.C: Error on missing const in C++14.
+ * g++.dg/cpp0x/constexpr-array-ptr7.C: Likewise.
+ * g++.dg/cpp0x/constexpr-diag1.C: Add const.
+ * g++.dg/cpp0x/constexpr-diag3.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ex1.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ex2.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ex4.C: Likewise.
+ * g++.dg/cpp0x/constexpr-initlist.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ptrmem.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ptrsub.C: Likewise.
+ * g++.dg/cpp0x/constexpr-ref4.C: Likewise.
+ * g++.dg/cpp0x/constexpr-static6.C: Likewise.
+
2014-10-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/63380
int main() {
constexpr auto deferred = make_deferred(&fibonacci);
- static_assert(deferred(25) == 75025, "Static fibonacci call failed");
+ static_assert(deferred(25) == 75025, "Static fibonacci call failed"); // { dg-error "no match for call" "" { target c++14 } }
}
constexpr S s = { 0,1,2,3,4,5,6,7,8,9,10 };
#define SA(X) static_assert ((X), #X)
-SA(s.foo() == 10);
+SA(s.foo() == 10); // { dg-error "discards qualifiers" "" { target c++14 } }
struct A
{
T t;
- constexpr int f() { return 42; } // { dg-error "enclosing class" }
+ constexpr int f() const { return 42; } // { dg-error "enclosing class" }
};
struct B { B(); operator int(); };
struct complex // { dg-message "no constexpr constructor" }
{
complex(double r, double i) : re(r), im(i) { }
- constexpr double real() { return re; } // { dg-error "not a literal type" }
+ constexpr double real() const { return re; } // { dg-error "not a literal type" }
double imag() const { return im; }
private:
// 2 defined before first use
// NOTE: this is only needed in contexts that require a constant-expression
struct S {
- constexpr int twice();
- constexpr int t(); // { dg-message "used but never defined" }
+ constexpr int twice() const;
+ constexpr int t() const; // { dg-message "used but never defined" }
private:
static constexpr int val = 7; // constexpr variable
};
-constexpr int S::twice() { return val + val; }
+constexpr int S::twice() const { return val + val; }
constexpr S s = { };
int x1 = s.twice(); // ok
int x2 = s.t(); // error: S::t() not defined
// 1
struct complex {
constexpr complex(double r, double i) : re(r), im(i) { }
- constexpr double real() { return re; }
- constexpr double imag() { return im; }
+ constexpr double real() const { return re; }
+ constexpr double imag() const { return im; }
private:
double re;
double im;
// p 4
struct A {
constexpr A(int i) : val(i) { }
- constexpr operator int() { return val; }
- constexpr operator long() { return -1; }
+ constexpr operator int() const { return val; }
+ constexpr operator long() const { return -1; }
private:
int val;
};
struct A
{
constexpr A(int) { }
- constexpr operator int() { return 1; };
+ constexpr operator int() const { return 1; };
};
template <class T>
template<size_t N>
constexpr initializer_list(const E(&array)[N]) : sz(N), start(array) {}
- constexpr size_t size() { return sz; }
+ constexpr size_t size() const { return sz; }
- constexpr const E* begin() { return start; }
+ constexpr const E* begin() const { return start; }
- constexpr const E* end() { return start + sz; }
+ constexpr const E* end() const { return start + sz; }
};
template<class E, size_t N>
int m;
int n;
constexpr C(int m) : m(m), n(-m) {}
- constexpr bool is_neg() { return m < 0; }
+ constexpr bool is_neg() const { return m < 0; }
};
constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1
struct array
{
constexpr array() :x(0) {}
- constexpr int const* begin() { return &x; }
+ constexpr int const* begin() const { return &x; }
int x;
};
constexpr array aa;
struct S
{
int s[1];
- constexpr const int &foo (unsigned i) { return (i < 1 ? 0 : throw 1), s[i]; }
- constexpr const int &bar (unsigned i) { return i < 1 ? s[i] : (throw 0, s[i]); }
+ constexpr const int &foo (unsigned i) const { return (i < 1 ? 0 : throw 1), s[i]; }
+ constexpr const int &bar (unsigned i) const { return i < 1 ? s[i] : (throw 0, s[i]); }
};
int
struct B
{
- constexpr operator int() { return 4; }
+ constexpr operator int() const { return 4; }
};
template <int I>