diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-22 15:31:51 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-04-22 15:31:51 +0000 |
commit | a10b97898ee6339c3110e6ca33f178ff52f05238 (patch) | |
tree | f9d49e4f10fe8063997db53fd0611a0b6b0d7c27 /lib/AST/Type.cpp | |
parent | 19258e8ba5904a04eaa09b7559206e87dccf07a2 (diff) |
C++1y constexpr extensions, round 1: Allow most forms of declaration and
statement in constexpr functions. Everything which doesn't require variable
mutation is also allowed as an extension in C++11. 'void' becomes a literal
type to support constexpr functions which return 'void'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Type.cpp')
-rw-r--r-- | lib/AST/Type.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 0c5636d840..7922c33d75 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -1142,16 +1142,20 @@ bool QualType::isTriviallyCopyableType(ASTContext &Context) const { -bool Type::isLiteralType() const { +bool Type::isLiteralType(ASTContext &Ctx) const { if (isDependentType()) return false; - // C++0x [basic.types]p10: + // C++1y [basic.types]p10: + // A type is a literal type if it is: + // -- cv void; or + if (Ctx.getLangOpts().CPlusPlus1y && isVoidType()) + return true; + + // C++11 [basic.types]p10: // A type is a literal type if it is: // [...] - // -- an array of literal type. - // Extension: variable arrays cannot be literal types, since they're - // runtime-sized. + // -- an array of literal type other than an array of runtime bound; or if (isVariableArrayType()) return false; const Type *BaseTy = getBaseElementTypeUnsafe(); @@ -1162,7 +1166,7 @@ bool Type::isLiteralType() const { if (BaseTy->isIncompleteType()) return false; - // C++0x [basic.types]p10: + // C++11 [basic.types]p10: // A type is a literal type if it is: // -- a scalar type; or // As an extension, Clang treats vector types and complex types as |