зеркало из https://github.com/microsoft/clang-1.git
Allow vectors to be constructed from constexpr function arguments in
constant expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152665 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
cf3a6c448c
Коммит
4b1f684416
|
@ -3743,7 +3743,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
|
|||
llvm::APSInt sInt(32);
|
||||
if (CountInits < NumInits) {
|
||||
if (!EvaluateInteger(E->getInit(CountInits), sInt, Info))
|
||||
return Error(E);
|
||||
return false;
|
||||
} else // trailing integer zero.
|
||||
sInt = Info.Ctx.MakeIntValue(0, EltTy);
|
||||
Elements.push_back(APValue(sInt));
|
||||
|
@ -3752,7 +3752,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
|
|||
llvm::APFloat f(0.0);
|
||||
if (CountInits < NumInits) {
|
||||
if (!EvaluateFloat(E->getInit(CountInits), f, Info))
|
||||
return Error(E);
|
||||
return false;
|
||||
} else // trailing float zero.
|
||||
f = APFloat::getZero(Info.Ctx.getFloatTypeSemantics(EltTy));
|
||||
Elements.push_back(APValue(f));
|
||||
|
|
|
@ -1230,3 +1230,17 @@ namespace CompoundLiteral {
|
|||
// in C++, and in C we model compound literals as lvalues.
|
||||
constexpr int *p = (int*)(int[1]){0}; // expected-warning {{C99}} expected-error {{constant expression}} expected-note 2{{temporary}}
|
||||
}
|
||||
|
||||
namespace Vector {
|
||||
typedef int __attribute__((vector_size(16))) VI4;
|
||||
constexpr VI4 f(int n) {
|
||||
return VI4 { n * 3, n + 4, n - 5, n / 6 };
|
||||
}
|
||||
constexpr auto v1 = f(10);
|
||||
|
||||
typedef double __attribute__((vector_size(32))) VD4;
|
||||
constexpr VD4 g(int n) {
|
||||
return (VD4) { n / 2.0, n + 1.5, n - 5.4, n * 0.9 }; // expected-warning {{C99}}
|
||||
}
|
||||
constexpr auto v2 = g(4);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче