From: Jean Perier Date: Thu, 24 Jan 2019 17:49:00 +0000 (-0800) Subject: [flang] Add test related to issue flang-compiler/f18#267 X-Git-Tag: llvmorg-12-init~9537^2~1837 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd8e7081083afe18e582a8ae66a540f3e5f172dc;p=platform%2Fupstream%2Fllvm.git [flang] Add test related to issue flang-compiler/f18#267 Original-commit: flang-compiler/f18@a9b2a05f7533546d5f791d5558017c45430e1077 Tree-same-pre-rewrite: false --- diff --git a/flang/test/evaluate/CMakeLists.txt b/flang/test/evaluate/CMakeLists.txt index d255e26..3fd9f0d 100644 --- a/flang/test/evaluate/CMakeLists.txt +++ b/flang/test/evaluate/CMakeLists.txt @@ -107,6 +107,15 @@ target_link_libraries(ISO-Fortran-binding-test FortranRuntime ) +add_executable(folding-test + folding.cc +) + +target_link_libraries(folding-test + FortranEvaluateTesting + FortranEvaluate +) + add_test(Expression expression-test) add_test(Leadz leading-zero-bit-count-test) add_test(PopPar bit-population-count-test) @@ -116,3 +125,4 @@ add_test(Logical logical-test) add_test(Real real-test) add_test(RESHAPE reshape-test) add_test(ISO-binding ISO-Fortran-binding-test) +add_test(folding folding-test) diff --git a/flang/test/evaluate/folding.cc b/flang/test/evaluate/folding.cc new file mode 100644 index 0000000..4ec630a --- /dev/null +++ b/flang/test/evaluate/folding.cc @@ -0,0 +1,49 @@ +// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "testing.h" +#include "../../lib/evaluate/expression.h" +#include "../../lib/evaluate/fold.h" +#include "../../lib/evaluate/type.h" +#include + +using namespace Fortran::evaluate; + +// helpers to call functions on all types from tuple +template static void VariadicCallHelper(const T... args) { + return; +} + +template +static void VariadicCallHelper(const std::tuple dummy) { + VariadicCallHelper(Test::template Run()...); + return; +} + +struct TestGetScalarConstantValue { + template static bool Run() { + Expr exprFullyTyped{Constant{Scalar{}}}; + Expr> exprSomeKind{exprFullyTyped}; + Expr exprSomeType{exprSomeKind}; + TEST(GetScalarConstantValue(exprFullyTyped) != nullptr); + TEST(GetScalarConstantValue(exprSomeKind) != nullptr); + TEST(GetScalarConstantValue(exprSomeType) != nullptr); + return true; + } +}; + +int main() { + VariadicCallHelper(AllIntrinsicTypes{}); + return testing::Complete(); +}