From: Chandler Carruth Date: Sun, 24 Apr 2011 02:49:28 +0000 (+0000) Subject: Add support for '__is_literal_type' spelling of the existing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3840281126e7d10552c55f6fd8b1ec9483898906;p=clang Add support for '__is_literal_type' spelling of the existing '__is_literal' type trait for GCC compatibility. At least one relased version if libstdc++ uses this name for the trait despite it not being documented anywhere. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130078 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index 96f5aa9cad..ac8e694337 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -338,6 +338,9 @@ KEYWORD(__is_empty , KEYCXX) KEYWORD(__is_enum , KEYCXX) // Tentative name - there's no implementation of std::is_literal_type yet. KEYWORD(__is_literal , KEYCXX) +// Name for GCC 4.6 compatibility - people have already written libraries using +// this name unfortunately. +KEYWORD(__is_literal_type , KEYCXX) KEYWORD(__is_pod , KEYCXX) KEYWORD(__is_polymorphic , KEYCXX) KEYWORD(__is_trivial , KEYCXX) diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index d218c79736..0ad153fc57 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -989,6 +989,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw___is_empty: case tok::kw___is_enum: case tok::kw___is_literal: + case tok::kw___is_literal_type: case tok::kw___is_pod: case tok::kw___is_polymorphic: case tok::kw___is_trivial: diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 38c074d1de..1165ff0978 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -1927,6 +1927,7 @@ static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) { case tok::kw___is_empty: return UTT_IsEmpty; case tok::kw___is_enum: return UTT_IsEnum; case tok::kw___is_literal: return UTT_IsLiteral; + case tok::kw___is_literal_type: return UTT_IsLiteral; case tok::kw___is_pod: return UTT_IsPOD; case tok::kw___is_polymorphic: return UTT_IsPolymorphic; case tok::kw___is_trivial: return UTT_IsTrivial; diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 3e00a8c0db..618c3e2bd4 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -660,6 +660,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw___is_empty: case tok::kw___is_enum: case tok::kw___is_literal: + case tok::kw___is_literal_type: case tok::kw___is_pod: case tok::kw___is_polymorphic: case tok::kw___is_trivial: diff --git a/test/SemaCXX/literal-type.cpp b/test/SemaCXX/literal-type.cpp index 142dd756e5..8eff677a0f 100644 --- a/test/SemaCXX/literal-type.cpp +++ b/test/SemaCXX/literal-type.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s static_assert(__is_literal(int), "fail"); +static_assert(__is_literal_type(int), "fail"); // alternate spelling for GCC static_assert(__is_literal(void*), "fail"); enum E { E1 }; static_assert(__is_literal(E), "fail");