decl.c (grokdeclarator): constexpr only implies const in C++11.
2014-10-09 Marc Glisse <marc.glisse@inria.fr> gcc/cp/ * decl.c (grokdeclarator): constexpr only implies const in C++11. gcc/testsuite/ * 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. From-SVN: r216039
This commit is contained in:
parent
12d3031b2c
commit
d0ff1cb4d9
15 changed files with 41 additions and 21 deletions
|
@ -1,3 +1,7 @@
|
|||
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
|
||||
|
|
|
@ -10539,7 +10539,8 @@ grokdeclarator (const cp_declarator *declarator,
|
|||
&& !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);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
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
|
||||
|
|
|
@ -24,5 +24,5 @@ constexpr Defer<Function> make_deferred(const Function f) {
|
|||
|
||||
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 } }
|
||||
}
|
||||
|
|
|
@ -17,4 +17,4 @@ S::foo ()
|
|||
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 } }
|
||||
|
|
|
@ -5,7 +5,7 @@ template <class T>
|
|||
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(); };
|
||||
|
|
|
@ -16,7 +16,7 @@ int main()
|
|||
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:
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
// 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
|
||||
|
@ -44,8 +44,8 @@ const double* p = &x; // the &x forces x into memory
|
|||
// 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;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
// 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;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
struct A
|
||||
{
|
||||
constexpr A(int) { }
|
||||
constexpr operator int() { return 1; };
|
||||
constexpr operator int() const { return 1; };
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -23,11 +23,11 @@ public:
|
|||
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>
|
||||
|
|
|
@ -4,7 +4,7 @@ struct C { // literal type
|
|||
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
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
struct array
|
||||
{
|
||||
constexpr array() :x(0) {}
|
||||
constexpr int const* begin() { return &x; }
|
||||
constexpr int const* begin() const { return &x; }
|
||||
int x;
|
||||
};
|
||||
constexpr array aa;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
struct B
|
||||
{
|
||||
constexpr operator int() { return 4; }
|
||||
constexpr operator int() const { return 4; }
|
||||
};
|
||||
|
||||
template <int I>
|
||||
|
|
Loading…
Add table
Reference in a new issue