diff options
author | Marek Polacek <polacek@redhat.com> | 2014-12-01 15:26:10 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2014-12-01 15:26:10 +0000 |
commit | e42c407c8ad2b2bf30fdfab1f7cb6948f1949f38 (patch) | |
tree | 0cafcc47e67ab0a33504262784e400ad017401b1 /gcc | |
parent | 7a1811342e2bf412fa3ad4c023342d4aca47cb54 (diff) | |
download | gcc-e42c407c8ad2b2bf30fdfab1f7cb6948f1949f38.zip gcc-e42c407c8ad2b2bf30fdfab1f7cb6948f1949f38.tar.gz gcc-e42c407c8ad2b2bf30fdfab1f7cb6948f1949f38.tar.bz2 |
constexpr.c (literal_type_p): Return true for void type in C++14.
* constexpr.c (literal_type_p): Return true for void type in C++14.
* g++.dg/cpp0x/constexpr-function2.C: Limit dg-error to C++11.
* g++.dg/cpp0x/constexpr-neg1.C: Likewise.
* g++.dg/cpp1y/constexpr-void1.C: New test.
From-SVN: r218220
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/constexpr.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C | 13 |
6 files changed, 27 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c804761..77b2b1e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2014-12-01 Marek Polacek <polacek@redhat.com> + + * constexpr.c (literal_type_p): Return true for void type in C++14. + 2014-12-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60845 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f4aca4b..6fdb9f3 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -59,7 +59,8 @@ literal_type_p (tree t) { if (SCALAR_TYPE_P (t) || TREE_CODE (t) == VECTOR_TYPE - || TREE_CODE (t) == REFERENCE_TYPE) + || TREE_CODE (t) == REFERENCE_TYPE + || (VOID_TYPE_P (t) && cxx_dialect >= cxx14)) return true; if (CLASS_TYPE_P (t)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0655cdf..715ea97 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-12-01 Marek Polacek <polacek@redhat.com> + + * g++.dg/cpp0x/constexpr-function2.C: Limit dg-error to C++11. + * g++.dg/cpp0x/constexpr-neg1.C: Likewise. + * g++.dg/cpp1y/constexpr-void1.C: New test. + 2014-12-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60845 diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C index 8c51c9d..95ee244 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-function2.C @@ -23,7 +23,7 @@ constexpr int area = squarei(side); // { dg-error "side|argument" } int next(constexpr int x) // { dg-error "parameter" } { return x + 1; } -constexpr void f(int x) // { dg-error "return type .void" } +constexpr void f(int x) // { dg-error "return type .void" "" { target c++11_only } } { /* ... */ } constexpr int prev(int x) diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C index 35f5e8e..dfa1d6b 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-neg1.C @@ -29,7 +29,7 @@ int next(constexpr int x) { // { dg-error "parameter" } extern constexpr int memsz; // { dg-error "definition" } // error: return type is void -constexpr void f(int x) // { dg-error "void" } +constexpr void f(int x) // { dg-error "void" "" { target c++11_only } } { /* ... */ } // error: use of decrement constexpr int prev(int x) diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C new file mode 100644 index 0000000..10ef5bc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-void1.C @@ -0,0 +1,13 @@ +// { dg-do compile { target c++14 } } + +struct S +{ + int i = 20; + + constexpr void + foo (void) + { + if (i > 20) + __builtin_abort (); + } +}; |