[flang] Changes per the review comments. The majority of the changes are simply

to rename identifiers to meet the project (not LLVM) coding standard.
Includes a home brew of FileCheck for testing.

Original-commit: flang-compiler/f18@bb15490cc0
Reviewed-on: https://github.com/flang-compiler/f18/pull/170
Tree-same-pre-rewrite: false
This commit is contained in:
Eric Schweitz 2018-08-31 10:26:19 -07:00 committed by GitHub
parent 7bdf04b695
commit 715a1ed493
16 changed files with 764 additions and 560 deletions

View file

@ -35,19 +35,6 @@ std::ostream &operator<<(std::ostream &o, const MessageFixedText &t) {
MessageFormattedText::MessageFormattedText(MessageFixedText text, ...)
: isFatal_{text.isFatal()} {
va_list ap;
va_start(ap, text);
SetMessageFormattedText(text, ap);
va_end(ap);
}
MessageFormattedText::MessageFormattedText(MessageFixedText text, va_list ap)
: isFatal_{text.isFatal()} {
SetMessageFormattedText(text, ap);
}
void MessageFormattedText::SetMessageFormattedText(MessageFixedText text,
va_list ap) {
const char *p{text.text().begin()};
std::string asString;
if (*text.text().end() != '\0') {
@ -56,7 +43,10 @@ void MessageFormattedText::SetMessageFormattedText(MessageFixedText text,
p = asString.data();
}
char buffer[256];
va_list ap;
va_start(ap, text);
vsnprintf(buffer, sizeof buffer, p, ap);
va_end(ap);
string_ = buffer;
}

View file

@ -68,7 +68,6 @@ constexpr MessageFixedText operator""_err_en_US(
class MessageFormattedText {
public:
MessageFormattedText(MessageFixedText, ...);
MessageFormattedText(MessageFixedText, va_list);
MessageFormattedText(const MessageFormattedText &) = default;
MessageFormattedText(MessageFormattedText &&) = default;
MessageFormattedText &operator=(const MessageFormattedText &) = default;
@ -78,7 +77,6 @@ public:
std::string MoveString() { return std::move(string_); }
private:
void SetMessageFormattedText(MessageFixedText, va_list);
std::string string_;
bool isFatal_{false};
};

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,4 @@
/* -*- mode: c++; c-basic-offset: 2 -*- */
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -15,26 +16,19 @@
#ifndef FORTRAN_SEMANTICS_RESOLVE_LABELS_H_
#define FORTRAN_SEMANTICS_RESOLVE_LABELS_H_
namespace Fortran {
namespace parser {
namespace Fortran::parser {
struct Program;
class CookedSource;
} // parser
} // namespace Fortran::parser
namespace semantics {
namespace Fortran::semantics {
/// \brief Validate the labels in the program
/// \param ParseTree the parse tree
/// \param Source the cooked source
/// \return true, iff the program's labels pass semantics checks
bool ValidateLabels(const parser::Program &ParseTree,
const parser::CookedSource &Source);
} // semantics
} // Fortran
bool ValidateLabels(
const parser::Program &ParseTree, const parser::CookedSource &Source);
} // namespace Fortran::semantics
#endif // FORTRAN_SEMANTICS_RESOLVE_LABELS_H_
// Local Variables:
// mode: C++
// c-basic-offset: 2
// End:
#endif // FORTRAN_SEMANTICS_RESOLVE_LABELS_H_

View file

@ -84,6 +84,10 @@ set(MODFILE_TESTS
modfile11.f90
)
set(LABEL_TESTS
label*.[Ff]90
)
foreach(test ${ERROR_TESTS})
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_errors.sh ${test})
endforeach()
@ -95,3 +99,7 @@ endforeach()
foreach(test ${MODFILE_TESTS})
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_modfile.sh ${test})
endforeach()
foreach(test ${LABEL_TESTS})
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test_any.sh ${test})
endforeach()

View file

@ -12,13 +12,17 @@
! See the License for the specific language governing permissions and
! limitations under the License.
! RUN: f18 < %s | FileCheck %s
! CHECK-NOT:
! RUN: ${F18} -funparse-with-symbols %s -o /dev/null 2>&1 | grep -v 'procedure conflicts' | ${FileCheck} %s
! CHECK-NOT: error:[[:space:]]
! FIXME: filter out the array/function syntax issues (procedure conflicts)
! for now...
! these are the conformance tests
! define STRICT_F18 to eliminate tests of features not in F18
! define ARCHAIC_FORTRAN to add test of feature found in Fortran before F95
subroutine sub00(a,b,n,m)
real a(n)
real :: b(m)

View file

@ -14,7 +14,7 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: label '0' is out of range
! CHECK: label '100000' is out of range
! CHECK: label '123456' is out of range

View file

@ -14,7 +14,7 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: 'do 10 i = 1, m' doesn't properly nest
! CHECK: label '30' cannot be found
! CHECK: label '40' cannot be found

View file

@ -14,7 +14,7 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: branch into 'do 10 i = 1, m' from another scope
! CHECK: branch into 'do 20 j = 1, n' from another scope

View file

@ -14,10 +14,10 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: label '50' was not found
! CHECK: label '55' is not in scope
! CHECK: label '70' is not an action stmt
! CHECK: '70' not a branch target
subroutine sub00(a,b,n,m)
real a(n,m)

View file

@ -14,11 +14,11 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: label '10' is not in scope
! CHECK: label '20' was not found
! CHECK: label '40' is not in scope
! CHECK: label '50' is not in scope (FIXME is that correct?)
! CHECK: label '50' is not in scope
subroutine sub00(n)
GOTO (10,20,30) n

View file

@ -14,10 +14,10 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: label '10' is not in scope
! CHECK: label '20' was not found
! CHECK: label '30' is not an action stmt
! CHECK: '30' not a branch target
! CHECK: label '60' was not found
subroutine sub00(n,m)

View file

@ -14,10 +14,10 @@
! negative test -- invalid labels, out of range
! RUN: f18 < %s | FileCheck %s
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: IF construct name mismatch
! CHECK: DO construct name mismatch
! CHECK: CYCLE construct name mismatch
! CHECK: CYCLE construct-name 'label3' is not in scope
subroutine sub00(a,b,n,m)
real a(n,m)

View file

@ -12,8 +12,8 @@
! See the License for the specific language governing permissions and
! limitations under the License.
! RUN: f18 < %s | FileCheck %s
! CHECK:
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: label '60' was not found
subroutine s(a)
real a(10)

View file

@ -12,8 +12,8 @@
! See the License for the specific language governing permissions and
! limitations under the License.
! RUN: f18 < %s | FileCheck %s
! CHECK:
! RUN: ${F18} -funparse-with-symbols %s 2>&1 | ${FileCheck} %s
! CHECK: '60' not a FORMAT
subroutine s(a)
real a(10)

View file

@ -0,0 +1,58 @@
#!/usr/bin/env bash
# Copyright (c) 2018, 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.
# Compile a source file with '-funparse-with-symbols' and verify
# we get the right symbols in the output, i.e. the output should be
# the same as the input, except for the copyright comment.
# Change the compiler by setting the F18 environment variable.
PATH=/usr/bin:/bin
srcdir=$(dirname $0)
F18=${F18:=../../tools/f18/f18}
FileCheck=${FileCheck:=internal_check}
function internal_check() {
r=true
linput="$1"
lstdin=`mktemp`
lcheck=`mktemp`
cat - > ${lstdin}
egrep '^[[:space:]]*![[:space:]]*CHECK:[[:space:]]*' ${linput} | sed -e 's/^[[:space:]]*![[:space:]]*CHECK:[[:space:]]*//' > ${lcheck} 2>/dev/null
while read p; do
if egrep "${p}" ${lstdin} >/dev/null 2>&1; then
true
else
echo "Not found: ${p}" >&2
r=false
fi
done < ${lcheck}
egrep '^[[:space:]]*![[:space:]]*CHECK-NOT:[[:space:]]*' ${linput} | sed -e 's/^[[:space:]]*![[:space:]]*CHECK-NOT:[[:space:]]*//' > ${lcheck} 2>/dev/null
while read p; do
if egrep ${p} ${lstdin} >/dev/null 2>&1; then
echo "Found: ${p}" >&2
r=false
fi
done < ${lcheck}
rm -f ${lstdin} ${lcheck}
${r}
}
r=0
for input in $*; do
CMD=$(cat ${input} | egrep '^[[:space:]]*![[:space:]]*RUN:[[:space:]]*' | sed -e 's/^[[:space:]]*![[:space:]]*RUN:[[:space:]]*//')
CMD=$(echo ${CMD} | sed -e "s:%s:${input}:g")
eval "( ${CMD} )" || (echo "test ${input} failed"; r=1)
done
exit $r