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
This commit is contained in:
Marek Polacek 2014-12-01 15:26:10 +00:00 committed by Marek Polacek
parent 7a1811342e
commit e42c407c8a
6 changed files with 27 additions and 3 deletions

View File

@ -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

View File

@ -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))
{

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,13 @@
// { dg-do compile { target c++14 } }
struct S
{
int i = 20;
constexpr void
foo (void)
{
if (i > 20)
__builtin_abort ();
}
};