[cfe-commits] r149469 - in /cfe/trunk: lib/Sema/SemaType.cpp test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Tue Jan 31 20:40:03 PST 2012
Author: rsmith
Date: Tue Jan 31 22:40:02 2012
New Revision: 149469
URL: http://llvm.org/viewvc/llvm-project?rev=149469&view=rev
Log:
constexpr: Unlike other incomplete types, 'void' cannot possibly be completed as
a literal type. Disallow it as the return type of a constexpr function
declaration.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=149469&r1=149468&r2=149469&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jan 31 22:40:02 2012
@@ -4212,7 +4212,8 @@
assert(!T->isDependentType() && "type should not be dependent");
bool Incomplete = RequireCompleteType(Loc, T, 0);
- if (T->isLiteralType() || (AllowIncompleteType && Incomplete))
+ if (T->isLiteralType() ||
+ (AllowIncompleteType && Incomplete && !T->isVoidType()))
return false;
if (PD.getDiagID() == 0)
Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp?rev=149469&r1=149468&r2=149469&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp Tue Jan 31 22:40:02 2012
@@ -40,6 +40,7 @@
// - its return type shall be a literal type;
constexpr NonLiteral NonLiteralReturn(); // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
+ constexpr void VoidReturn(); // 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();
constexpr F NonLiteralReturn2; // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
More information about the cfe-commits
mailing list