diff --git a/flang/lib/Parser/preprocessor.h b/flang/lib/Parser/preprocessor.h --- a/flang/lib/Parser/preprocessor.h +++ b/flang/lib/Parser/preprocessor.h @@ -67,6 +67,7 @@ void Define(std::string macro, std::string value); void Undefine(std::string macro); + bool IsNameDefined(const CharBlock &); std::optional MacroReplacement( const TokenSequence &, const Prescanner &); @@ -79,7 +80,6 @@ enum class CanDeadElseAppear { No, Yes }; CharBlock SaveTokenAsName(const CharBlock &); - bool IsNameDefined(const CharBlock &); TokenSequence ReplaceMacros(const TokenSequence &, const Prescanner &); void SkipDisabledConditionalCode( const std::string &, IsElseActive, Prescanner *, ProvenanceRange); diff --git a/flang/lib/Parser/preprocessor.cpp b/flang/lib/Parser/preprocessor.cpp --- a/flang/lib/Parser/preprocessor.cpp +++ b/flang/lib/Parser/preprocessor.cpp @@ -212,7 +212,7 @@ } void Preprocessor::Define(std::string macro, std::string value) { - definitions_.emplace(SaveTokenAsName(macro), Definition{value, allSources_}); + definitions_.emplace(macro, Definition{value, allSources_}); } void Preprocessor::Undefine(std::string macro) { definitions_.erase(macro); } diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp --- a/flang/lib/Parser/prescan.cpp +++ b/flang/lib/Parser/prescan.cpp @@ -246,7 +246,7 @@ } void Prescanner::LabelField(TokenSequence &token, int outCol) { - bool badLabel{false}; + const char *bad{nullptr}; for (; *at_ != '\n' && column_ <= 6; ++at_) { if (*at_ == '\t') { ++at_; @@ -256,16 +256,18 @@ if (*at_ != ' ' && !(*at_ == '0' && column_ == 6)) { // '0' in column 6 becomes space EmitChar(token, *at_); - if (!IsDecimalDigit(*at_) && !badLabel) { - Say(GetProvenance(at_), - "Character in fixed-form label field must be a digit"_en_US); - badLabel = true; + if (!bad && !IsDecimalDigit(*at_)) { + bad = at_; } ++outCol; } ++column_; } if (outCol > 1) { + if (bad && !preprocessor_.IsNameDefined(token.CurrentOpenToken())) { + Say(GetProvenance(bad), + "Character in fixed-form label field must be a digit"_en_US); + } token.CloseToken(); } SkipToNextSignificantCharacter(); @@ -1098,6 +1100,15 @@ return iter == compilerDirectiveSentinels_.end() ? nullptr : iter->c_str(); } +constexpr bool IsDirective(const char *match, const char *dir) { + for (; *match; ++match) { + if (*match != ToLowerCaseLetter(*dir++)) { + return false; + } + } + return true; +} + Prescanner::LineClassification Prescanner::ClassifyLine( const char *start) const { if (inFixedForm_) { @@ -1122,13 +1133,12 @@ return {LineClassification::Kind::IncludeLine, *quoteOffset}; } if (const char *dir{IsPreprocessorDirectiveLine(start)}) { - if (std::memcmp(dir, "if", 2) == 0 || std::memcmp(dir, "elif", 4) == 0 || - std::memcmp(dir, "else", 4) == 0 || std::memcmp(dir, "endif", 5) == 0) { + if (IsDirective("if", dir) || IsDirective("elif", dir) || + IsDirective("else", dir) || IsDirective("endif", dir)) { return {LineClassification::Kind::ConditionalCompilationDirective}; - } else if (std::memcmp(dir, "include", 7) == 0) { + } else if (IsDirective("include", dir)) { return {LineClassification::Kind::IncludeDirective}; - } else if (std::memcmp(dir, "define", 6) == 0 || - std::memcmp(dir, "undef", 5) == 0) { + } else if (IsDirective("define", dir) || IsDirective("undef", dir)) { return {LineClassification::Kind::DefinitionDirective}; } else { return {LineClassification::Kind::PreprocessorDirective}; diff --git a/flang/test/Preprocessing/lit.local.cfg.py b/flang/test/Preprocessing/lit.local.cfg.py deleted file mode 100644 --- a/flang/test/Preprocessing/lit.local.cfg.py +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Python -*- - -from lit.llvm import llvm_config - -# Added this line file to prevent lit from discovering these tests -# See Issue #1052 -config.suffixes = [] diff --git a/flang/test/Preprocessing/pp001.F b/flang/test/Preprocessing/pp001.F --- a/flang/test/Preprocessing/pp001.F +++ b/flang/test/Preprocessing/pp001.F @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then * keyword macros integer, parameter :: KWM = 666 #define KWM 777 if (KWM .eq. 777) then - print *, 'pp001.F pass' + print *, 'pp001.F yes' else - print *, 'pp001.F FAIL: ', KWM + print *, 'pp001.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp002.F b/flang/test/Preprocessing/pp002.F --- a/flang/test/Preprocessing/pp002.F +++ b/flang/test/Preprocessing/pp002.F @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm.eq.777)then * #undef integer, parameter :: KWM = 777 #define KWM 666 #undef KWM if (KWM .eq. 777) then - print *, 'pp002.F pass' + print *, 'pp002.F yes' else - print *, 'pp002.F FAIL: ', KWM + print *, 'pp002.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp003.F b/flang/test/Preprocessing/pp003.F --- a/flang/test/Preprocessing/pp003.F +++ b/flang/test/Preprocessing/pp003.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * function-like macros integer function IFLM(x) integer :: x @@ -8,8 +10,8 @@ integer :: res res = IFLM(666) if (res .eq. 777) then - print *, 'pp003.F pass' + print *, 'pp003.F yes' else - print *, 'pp003.F FAIL: ', res + print *, 'pp003.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp004.F b/flang/test/Preprocessing/pp004.F --- a/flang/test/Preprocessing/pp004.F +++ b/flang/test/Preprocessing/pp004.F @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm.eq.777)then * KWMs case-sensitive integer, parameter :: KWM = 777 #define KWM 666 if (kwm .eq. 777) then - print *, 'pp004.F pass' + print *, 'pp004.F yes' else - print *, 'pp004.F FAIL: ', kwm + print *, 'pp004.F no: ', kwm end if end diff --git a/flang/test/Preprocessing/pp005.F b/flang/test/Preprocessing/pp005.F --- a/flang/test/Preprocessing/pp005.F +++ b/flang/test/Preprocessing/pp005.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=777 * KWM split across continuation, implicit padding integer, parameter :: KWM = 666 #define KWM 777 @@ -5,8 +7,8 @@ res = KW +M if (res .eq. 777) then - print *, 'pp005.F pass' + print *, 'pp005.F yes' else - print *, 'pp005.F FAIL: ', res + print *, 'pp005.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp006.F b/flang/test/Preprocessing/pp006.F --- a/flang/test/Preprocessing/pp006.F +++ b/flang/test/Preprocessing/pp006.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=777 * ditto, but with intervening *comment line integer, parameter :: KWM = 666 #define KWM 777 @@ -6,8 +8,8 @@ *comment +M if (res .eq. 777) then - print *, 'pp006.F pass' + print *, 'pp006.F yes' else - print *, 'pp006.F FAIL: ', res + print *, 'pp006.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp007.F b/flang/test/Preprocessing/pp007.F --- a/flang/test/Preprocessing/pp007.F +++ b/flang/test/Preprocessing/pp007.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=kwm * KWM split across continuation, clipped after column 72 integer, parameter :: KWM = 666 #define KWM 777 @@ -8,8 +10,8 @@ res = KW comment +M if (res .eq. 777) then - print *, 'pp007.F pass' + print *, 'pp007.F yes' else - print *, 'pp007.F FAIL: ', res + print *, 'pp007.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp008.F b/flang/test/Preprocessing/pp008.F --- a/flang/test/Preprocessing/pp008.F +++ b/flang/test/Preprocessing/pp008.F @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=kwm * KWM with spaces in name at invocation NOT replaced integer, parameter :: KWM = 777 #define KWM 666 integer :: res res = K W M if (res .eq. 777) then - print *, 'pp008.F pass' + print *, 'pp008.F yes' else - print *, 'pp008.F FAIL: ', res + print *, 'pp008.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp009.F b/flang/test/Preprocessing/pp009.F --- a/flang/test/Preprocessing/pp009.F +++ b/flang/test/Preprocessing/pp009.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call split across continuation, implicit padding integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL +M(666) if (res .eq. 777) then - print *, 'pp009.F pass' + print *, 'pp009.F yes' else - print *, 'pp009.F FAIL: ', res + print *, 'pp009.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp010.F b/flang/test/Preprocessing/pp010.F --- a/flang/test/Preprocessing/pp010.F +++ b/flang/test/Preprocessing/pp010.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * ditto, but with intervening *comment line integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ *comment +M(666) if (res .eq. 777) then - print *, 'pp010.F pass' + print *, 'pp010.F yes' else - print *, 'pp010.F FAIL: ', res + print *, 'pp010.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp011.F b/flang/test/Preprocessing/pp011.F --- a/flang/test/Preprocessing/pp011.F +++ b/flang/test/Preprocessing/pp011.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=iflm(666) * FLM call name split across continuation, clipped integer function IFLM(x) integer :: x @@ -12,8 +14,8 @@ res = IFL comment +M(666) if (res .eq. 777) then - print *, 'pp011.F pass' + print *, 'pp011.F yes' else - print *, 'pp011.F FAIL: ', res + print *, 'pp011.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp012.F b/flang/test/Preprocessing/pp012.F --- a/flang/test/Preprocessing/pp012.F +++ b/flang/test/Preprocessing/pp012.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call name split across continuation integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL +M(666) if (res .eq. 777) then - print *, 'pp012.F pass' + print *, 'pp012.F yes' else - print *, 'pp012.F FAIL: ', res + print *, 'pp012.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp013.F b/flang/test/Preprocessing/pp013.F --- a/flang/test/Preprocessing/pp013.F +++ b/flang/test/Preprocessing/pp013.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call split between name and ( integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM +(666) if (res .eq. 777) then - print *, 'pp013.F pass' + print *, 'pp013.F yes' else - print *, 'pp013.F FAIL: ', res + print *, 'pp013.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp014.F b/flang/test/Preprocessing/pp014.F --- a/flang/test/Preprocessing/pp014.F +++ b/flang/test/Preprocessing/pp014.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call split between name and (, with intervening *comment integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ *comment +(666) if (res .eq. 777) then - print *, 'pp014.F pass' + print *, 'pp014.F yes' else - print *, 'pp014.F FAIL: ', res + print *, 'pp014.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp015.F b/flang/test/Preprocessing/pp015.F --- a/flang/test/Preprocessing/pp015.F +++ b/flang/test/Preprocessing/pp015.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call split between name and (, clipped integer function IFLM(x) integer :: x @@ -12,8 +14,8 @@ res = IFLM comment +(666) if (res .eq. 777) then - print *, 'pp015.F pass' + print *, 'pp015.F yes' else - print *, 'pp015.F FAIL: ', res + print *, 'pp015.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp016.F b/flang/test/Preprocessing/pp016.F --- a/flang/test/Preprocessing/pp016.F +++ b/flang/test/Preprocessing/pp016.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call split between name and ( and in argument integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ +(66 +6) if (res .eq. 777) then - print *, 'pp016.F pass' + print *, 'pp016.F yes' else - print *, 'pp016.F FAIL: ', res + print *, 'pp016.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp017.F b/flang/test/Preprocessing/pp017.F --- a/flang/test/Preprocessing/pp017.F +++ b/flang/test/Preprocessing/pp017.F @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then * KLM rescan integer, parameter :: KWM = 666, KWM2 = 667 #define KWM2 777 #define KWM KWM2 if (KWM .eq. 777) then - print *, 'pp017.F pass' + print *, 'pp017.F yes' else - print *, 'pp017.F FAIL: ', KWM + print *, 'pp017.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp018.F b/flang/test/Preprocessing/pp018.F --- a/flang/test/Preprocessing/pp018.F +++ b/flang/test/Preprocessing/pp018.F @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm2.eq.777)then * KLM rescan with #undef (so rescan is after expansion) integer, parameter :: KWM2 = 777, KWM = 667 #define KWM2 666 #define KWM KWM2 #undef KWM2 if (KWM .eq. 777) then - print *, 'pp018.F pass' + print *, 'pp018.F yes' else - print *, 'pp018.F FAIL: ', KWM + print *, 'pp018.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp019.F b/flang/test/Preprocessing/pp019.F --- a/flang/test/Preprocessing/pp019.F +++ b/flang/test/Preprocessing/pp019.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM rescan integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ integer :: res res = IFLM(666) if (res .eq. 777) then - print *, 'pp019.F pass' + print *, 'pp019.F yes' else - print *, 'pp019.F FAIL: ', res + print *, 'pp019.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp020.F b/flang/test/Preprocessing/pp020.F --- a/flang/test/Preprocessing/pp020.F +++ b/flang/test/Preprocessing/pp020.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((111)+666) * FLM expansion of argument integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ integer :: res res = IFLM(KWM) if (res .eq. 777) then - print *, 'pp020.F pass' + print *, 'pp020.F yes' else - print *, 'pp020.F FAIL: ', res + print *, 'pp020.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp021.F b/flang/test/Preprocessing/pp021.F --- a/flang/test/Preprocessing/pp021.F +++ b/flang/test/Preprocessing/pp021.F @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch='KWM' +! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in 'literal' #define KWM 666 character(len=3) :: ch ch = 'KWM' if (ch .eq. 'KWM') then - print *, 'pp021.F pass' + print *, 'pp021.F yes' else - print *, 'pp021.F FAIL: ', ch + print *, 'pp021.F no: ', ch end if end diff --git a/flang/test/Preprocessing/pp022.F b/flang/test/Preprocessing/pp022.F --- a/flang/test/Preprocessing/pp022.F +++ b/flang/test/Preprocessing/pp022.F @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch="KWM" +! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in "literal" #define KWM 666 character(len=3) :: ch ch = "KWM" if (ch .eq. 'KWM') then - print *, 'pp022.F pass' + print *, 'pp022.F yes' else - print *, 'pp022.F FAIL: ', ch + print *, 'pp022.F no: ', ch end if end diff --git a/flang/test/Preprocessing/pp023.F b/flang/test/Preprocessing/pp023.F --- a/flang/test/Preprocessing/pp023.F +++ b/flang/test/Preprocessing/pp023.F @@ -1,11 +1,14 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch=3hKWM +! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in 9HHOLLERITH literal #define KWM 666 #define HKWM 667 character(len=3) :: ch ch = 3HKWM if (ch .eq. 'KWM') then - print *, 'pp023.F pass' + print *, 'pp023.F yes' else - print *, 'pp023.F FAIL: ', ch + print *, 'pp023.F no: ', ch end if end diff --git a/flang/test/Preprocessing/pp024.F b/flang/test/Preprocessing/pp024.F --- a/flang/test/Preprocessing/pp024.F +++ b/flang/test/Preprocessing/pp024.F @@ -1,3 +1,6 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: 100format(3hKWM) +! CHECK: if(ch.eq.'KWM')then * KWM NOT expanded in Hollerith in FORMAT #define KWM 666 #define HKWM 667 @@ -5,8 +8,8 @@ 100 format(3HKWM) write(ch, 100) if (ch .eq. 'KWM') then - print *, 'pp024.F pass' + print *, 'pp024.F yes' else - print *, 'pp024.F FAIL: ', ch + print *, 'pp024.F no: ', ch end if end diff --git a/flang/test/Preprocessing/pp025.F b/flang/test/Preprocessing/pp025.F --- a/flang/test/Preprocessing/pp025.F +++ b/flang/test/Preprocessing/pp025.F @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=ikwm2z * KWM expansion is before token pasting due to fixed-form space removal integer, parameter :: IKWM2Z = 777 #define KWM KWM2 integer :: res res = I KWM Z if (res .eq. 777) then - print *, 'pp025.F pass' + print *, 'pp025.F yes' else - print *, 'pp025.F FAIL: ', res + print *, 'pp025.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp026.F b/flang/test/Preprocessing/pp026.F --- a/flang/test/Preprocessing/pp026.F +++ b/flang/test/Preprocessing/pp026.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((111)+666) * ## token pasting works in FLM integer function IFLM(x) integer :: x @@ -12,8 +14,8 @@ integer :: res res = IFLM(KWM) if (res .eq. 777) then - print *, 'pp026.F pass' + print *, 'pp026.F yes' else - print *, 'pp026.F FAIL: ', res + print *, 'pp026.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp027.F b/flang/test/Preprocessing/pp027.F --- a/flang/test/Preprocessing/pp027.F +++ b/flang/test/Preprocessing/pp027.F @@ -1,9 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: kwm=666 +! CHECK: if(777.eq.777)then * #DEFINE works in fixed form integer, parameter :: KWM = 666 #DEFINE KWM 777 if (KWM .eq. 777) then - print *, 'pp027.F pass' + print *, 'pp027.F yes' else - print *, 'pp027.F FAIL: ', KWM + print *, 'pp027.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp028.F b/flang/test/Preprocessing/pp028.F --- a/flang/test/Preprocessing/pp028.F +++ b/flang/test/Preprocessing/pp028.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=kw * fixed-form clipping done before KWM expansion on source line integer, parameter :: KW = 777 #define KWM 666 @@ -7,8 +9,8 @@ *234567890123456789012345678901234567890123456789012345678901234567890123 res = KWM if (res .eq. 777) then - print *, 'pp028.F pass' + print *, 'pp028.F yes' else - print *, 'pp028.F FAIL: ', res + print *, 'pp028.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp029.F b/flang/test/Preprocessing/pp029.F --- a/flang/test/Preprocessing/pp029.F +++ b/flang/test/Preprocessing/pp029.F @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(77 7.eq.777)then * \ newline allowed in #define integer, parameter :: KWM = 666 #define KWM 77\ 7 if (KWM .eq. 777) then - print *, 'pp029.F pass' + print *, 'pp029.F yes' else - print *, 'pp029.F FAIL: ', KWM + print *, 'pp029.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp030.F b/flang/test/Preprocessing/pp030.F --- a/flang/test/Preprocessing/pp030.F +++ b/flang/test/Preprocessing/pp030.F @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then * /* C comment */ erased from #define integer, parameter :: KWM = 666 #define KWM 777 /* C comment */ if (KWM .eq. 777) then - print *, 'pp030.F pass' + print *, 'pp030.F yes' else - print *, 'pp030.F FAIL: ', KWM + print *, 'pp030.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp031.F b/flang/test/Preprocessing/pp031.F --- a/flang/test/Preprocessing/pp031.F +++ b/flang/test/Preprocessing/pp031.F @@ -1,9 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777//ccomment.eq.777)then +! CHECK: print*,'pp031.F no: ',777//ccomment * // C++ comment NOT erased from #define integer, parameter :: KWM = 666 #define KWM 777 // C comment if (KWM .eq. 777) then print *, 'pp031.F FAIL (should not have compiled)' else - print *, 'pp031.F FAIL: ', KWM + print *, 'pp031.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp032.F b/flang/test/Preprocessing/pp032.F --- a/flang/test/Preprocessing/pp032.F +++ b/flang/test/Preprocessing/pp032.F @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then +! CHECK: print*,'pp032.F no: ',777 * /* C comment */ \ newline erased from #define integer, parameter :: KWM = 666 #define KWM 77/* C comment */\ 7 if (KWM .eq. 777) then - print *, 'pp032.F pass' + print *, 'pp032.F yes' else - print *, 'pp032.F FAIL: ', KWM + print *, 'pp032.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp033.F b/flang/test/Preprocessing/pp033.F --- a/flang/test/Preprocessing/pp033.F +++ b/flang/test/Preprocessing/pp033.F @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then +! CHECK: print*,'pp033.F no: ',777 * /* C comment \ newline */ erased from #define integer, parameter :: KWM = 666 #define KWM 77/* C comment \ */7 if (KWM .eq. 777) then - print *, 'pp033.F pass' + print *, 'pp033.F yes' else - print *, 'pp033.F FAIL: ', KWM + print *, 'pp033.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp034.F b/flang/test/Preprocessing/pp034.F --- a/flang/test/Preprocessing/pp034.F +++ b/flang/test/Preprocessing/pp034.F @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then +! CHECK: print*,'pp034.F no: ',777 * \ newline allowed in name on KWM definition integer, parameter :: KWMC = 666 #define KWM\ C 777 if (KWMC .eq. 777) then - print *, 'pp034.F pass' + print *, 'pp034.F yes' else - print *, 'pp034.F FAIL: ', KWMC + print *, 'pp034.F no: ', KWMC end if end diff --git a/flang/test/Preprocessing/pp035.F b/flang/test/Preprocessing/pp035.F --- a/flang/test/Preprocessing/pp035.F +++ b/flang/test/Preprocessing/pp035.F @@ -1,3 +1,6 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777.eq.777)then +! CHECK: print*,'pp035.F no: ',777 * #if 2 .LT. 3 works integer, parameter :: KWM = 666 #if 2 .LT. 3 @@ -6,8 +9,8 @@ #define KWM 667 #endif if (KWM .eq. 777) then - print *, 'pp035.F pass' + print *, 'pp035.F yes' else - print *, 'pp035.F FAIL: ', KWM + print *, 'pp035.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp036.F b/flang/test/Preprocessing/pp036.F --- a/flang/test/Preprocessing/pp036.F +++ b/flang/test/Preprocessing/pp036.F @@ -1,8 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(.true.)then +! CHECK: print*,'pp036.F no: ',.true. * #define FALSE TRUE ... .FALSE. -> .TRUE. #define FALSE TRUE if (.FALSE.) then - print *, 'pp036.F pass' + print *, 'pp036.F yes' else - print *, 'pp036.F FAIL: ', .FALSE. + print *, 'pp036.F no: ', .FALSE. end if end diff --git a/flang/test/Preprocessing/pp037.F b/flang/test/Preprocessing/pp037.F --- a/flang/test/Preprocessing/pp037.F +++ b/flang/test/Preprocessing/pp037.F @@ -1,11 +1,14 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(7777.eq.777)then +! CHECK: print*,'pp037.F no: ',7777 * fixed-form clipping NOT applied to #define integer, parameter :: KWM = 666 * 1 2 3 4 5 6 7 *234567890123456789012345678901234567890123456789012345678901234567890123 #define KWM 7777 if (KWM .eq. 777) then - print *, 'pp037.F pass' + print *, 'pp037.F yes' else - print *, 'pp037.F FAIL: ', KWM + print *, 'pp037.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp038.F b/flang/test/Preprocessing/pp038.F --- a/flang/test/Preprocessing/pp038.F +++ b/flang/test/Preprocessing/pp038.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=((666)+111) * FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM(666 ) if (res .eq. 777) then - print *, 'pp038.F pass' + print *, 'pp038.F yes' else - print *, 'pp038.F FAIL: ', res + print *, 'pp038.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp039.F b/flang/test/Preprocessing/pp039.F --- a/flang/test/Preprocessing/pp039.F +++ b/flang/test/Preprocessing/pp039.F @@ -1,3 +1,7 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res=iflm +! CHECK: (666) +! CHECK-NOT: res=((666)+111) * FLM call with '(' on next line (not a continuation) integer function IFLM(x) integer :: x @@ -9,8 +13,8 @@ res = IFLM (666) if (res .eq. 777) then - print *, 'pp039.F pass' + print *, 'pp039.F yes' else - print *, 'pp039.F FAIL: ', res + print *, 'pp039.F no: ', res end if end diff --git a/flang/test/Preprocessing/pp040.F b/flang/test/Preprocessing/pp040.F --- a/flang/test/Preprocessing/pp040.F +++ b/flang/test/Preprocessing/pp040.F @@ -1,5 +1,7 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK-NOT: FAIL HARD! * #define KWM c, then KWM works as comment line initiator #define KWM c KWM print *, 'pp040.F FAIL HARD!'; stop - print *, 'pp040.F pass' + print *, 'pp040.F yes' end diff --git a/flang/test/Preprocessing/pp041.F b/flang/test/Preprocessing/pp041.F --- a/flang/test/Preprocessing/pp041.F +++ b/flang/test/Preprocessing/pp041.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: j=666wmj=j+1wm211 * use KWM expansion as continuation indicators #define KWM 0 #define KWM2 1 @@ -6,8 +8,8 @@ KWM j = j + 1 KWM2 11 if (j .eq. 777) then - print *, 'pp041.F pass' + print *, 'pp041.F yes' else - print *, 'pp041.F FAIL', j + print *, 'pp041.F no', j end if end diff --git a/flang/test/Preprocessing/pp042.F b/flang/test/Preprocessing/pp042.F --- a/flang/test/Preprocessing/pp042.F +++ b/flang/test/Preprocessing/pp042.F @@ -1,6 +1,8 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK-NOT: goto 2 * #define c 1, then use c as label in fixed-form #define c 1 -c print *, 'pp042.F pass'; goto 2 - print *, 'pp042.F FAIL' +c print *, 'pp042.F yes'; goto 2 + print *, 'pp042.F no' 2 continue end diff --git a/flang/test/Preprocessing/pp043.F b/flang/test/Preprocessing/pp043.F --- a/flang/test/Preprocessing/pp043.F +++ b/flang/test/Preprocessing/pp043.F @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm.eq.777)then * #define with # in column 6 is a continuation line in fixed-form integer, parameter :: defineKWM666 = 555 integer, parameter :: KWM = #define KWM 666 ++222 if (KWM .eq. 777) then - print *, 'pp043.F pass' + print *, 'pp043.F yes' else - print *, 'pp043.F FAIL: ', KWM + print *, 'pp043.F no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp044.F b/flang/test/Preprocessing/pp044.F --- a/flang/test/Preprocessing/pp044.F +++ b/flang/test/Preprocessing/pp044.F @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK-NOT:z=111 * #define directive amid continuations integer, parameter :: KWM = 222, KWM111 = 333, KWM222 = 555 integer, parameter :: KWMKWM = 333 @@ -5,8 +7,8 @@ #define KWM 111 +KWM+444 if (z .EQ. 777) then - print *, 'pass' + print *, 'yes' else - print *, 'FAIL', z + print *, 'no', z end if end diff --git a/flang/test/Preprocessing/pp101.F90 b/flang/test/Preprocessing/pp101.F90 --- a/flang/test/Preprocessing/pp101.F90 +++ b/flang/test/Preprocessing/pp101.F90 @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777 .eq. 777) then ! keyword macros integer, parameter :: KWM = 666 #define KWM 777 if (KWM .eq. 777) then - print *, 'pp101.F90 pass' + print *, 'pp101.F90 yes' else - print *, 'pp101.F90 FAIL: ', KWM + print *, 'pp101.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp102.F90 b/flang/test/Preprocessing/pp102.F90 --- a/flang/test/Preprocessing/pp102.F90 +++ b/flang/test/Preprocessing/pp102.F90 @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm .eq. 777) then ! #undef integer, parameter :: KWM = 777 #define KWM 666 #undef KWM if (KWM .eq. 777) then - print *, 'pp102.F90 pass' + print *, 'pp102.F90 yes' else - print *, 'pp102.F90 FAIL: ', KWM + print *, 'pp102.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp103.F90 b/flang/test/Preprocessing/pp103.F90 --- a/flang/test/Preprocessing/pp103.F90 +++ b/flang/test/Preprocessing/pp103.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! function-like macros integer function IFLM(x) integer :: x @@ -8,8 +10,8 @@ integer :: res res = IFLM(666) if (res .eq. 777) then - print *, 'pp103.F90 pass' + print *, 'pp103.F90 yes' else - print *, 'pp103.F90 FAIL: ', res + print *, 'pp103.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp104.F90 b/flang/test/Preprocessing/pp104.F90 --- a/flang/test/Preprocessing/pp104.F90 +++ b/flang/test/Preprocessing/pp104.F90 @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm .eq. 777) then ! KWMs case-sensitive integer, parameter :: KWM = 777 #define KWM 666 if (kwm .eq. 777) then - print *, 'pp104.F90 pass' + print *, 'pp104.F90 yes' else - print *, 'pp104.F90 FAIL: ', kwm + print *, 'pp104.F90 no: ', kwm end if end diff --git a/flang/test/Preprocessing/pp105.F90 b/flang/test/Preprocessing/pp105.F90 --- a/flang/test/Preprocessing/pp105.F90 +++ b/flang/test/Preprocessing/pp105.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = 777 ! KWM call name split across continuation, with leading & integer, parameter :: KWM = 666 #define KWM 777 @@ -5,8 +7,8 @@ res = KW& &M if (res .eq. 777) then - print *, 'pp105.F90 pass' + print *, 'pp105.F90 yes' else - print *, 'pp105.F90 FAIL: ', res + print *, 'pp105.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp106.F90 b/flang/test/Preprocessing/pp106.F90 --- a/flang/test/Preprocessing/pp106.F90 +++ b/flang/test/Preprocessing/pp106.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = 777 ! ditto, with & ! comment integer, parameter :: KWM = 666 #define KWM 777 @@ -5,8 +7,8 @@ res = KW& ! comment &M if (res .eq. 777) then - print *, 'pp106.F90 pass' + print *, 'pp106.F90 yes' else - print *, 'pp106.F90 FAIL: ', res + print *, 'pp106.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp107.F90 b/flang/test/Preprocessing/pp107.F90 --- a/flang/test/Preprocessing/pp107.F90 +++ b/flang/test/Preprocessing/pp107.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = kwm ! KWM call name split across continuation, no leading &, with & ! comment integer, parameter :: KWM = 666 #define KWM 777 @@ -5,8 +7,8 @@ res = KW& ! comment M if (res .eq. 777) then - print *, 'pp107.F90 pass' + print *, 'pp107.F90 yes' else - print *, 'pp107.F90 FAIL: ', res + print *, 'pp107.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp108.F90 b/flang/test/Preprocessing/pp108.F90 --- a/flang/test/Preprocessing/pp108.F90 +++ b/flang/test/Preprocessing/pp108.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = kwm ! ditto, but without & ! comment integer, parameter :: KWM = 666 #define KWM 777 @@ -5,8 +7,8 @@ res = KW& M if (res .eq. 777) then - print *, 'pp108.F90 pass' + print *, 'pp108.F90 yes' else - print *, 'pp108.F90 FAIL: ', res + print *, 'pp108.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp109.F90 b/flang/test/Preprocessing/pp109.F90 --- a/flang/test/Preprocessing/pp109.F90 +++ b/flang/test/Preprocessing/pp109.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! FLM call name split with leading & integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL& &M(666) if (res .eq. 777) then - print *, 'pp109.F90 pass' + print *, 'pp109.F90 yes' else - print *, 'pp109.F90 FAIL: ', res + print *, 'pp109.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp110.F90 b/flang/test/Preprocessing/pp110.F90 --- a/flang/test/Preprocessing/pp110.F90 +++ b/flang/test/Preprocessing/pp110.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! ditto, with & ! comment integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL& ! comment &M(666) if (res .eq. 777) then - print *, 'pp110.F90 pass' + print *, 'pp110.F90 yes' else - print *, 'pp110.F90 FAIL: ', res + print *, 'pp110.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp111.F90 b/flang/test/Preprocessing/pp111.F90 --- a/flang/test/Preprocessing/pp111.F90 +++ b/flang/test/Preprocessing/pp111.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm (666) ! FLM call name split across continuation, no leading &, with & ! comment integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL& ! comment M(666) if (res .eq. 777) then - print *, 'pp111.F90 pass' + print *, 'pp111.F90 yes' else - print *, 'pp111.F90 FAIL: ', res + print *, 'pp111.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp112.F90 b/flang/test/Preprocessing/pp112.F90 --- a/flang/test/Preprocessing/pp112.F90 +++ b/flang/test/Preprocessing/pp112.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm (666) ! ditto, but without & ! comment integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFL& M(666) if (res .eq. 777) then - print *, 'pp112.F90 pass' + print *, 'pp112.F90 yes' else - print *, 'pp112.F90 FAIL: ', res + print *, 'pp112.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp113.F90 b/flang/test/Preprocessing/pp113.F90 --- a/flang/test/Preprocessing/pp113.F90 +++ b/flang/test/Preprocessing/pp113.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! FLM call split across continuation between name and (, leading & integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM& &(666) if (res .eq. 777) then - print *, 'pp113.F90 pass' + print *, 'pp113.F90 yes' else - print *, 'pp113.F90 FAIL: ', res + print *, 'pp113.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp114.F90 b/flang/test/Preprocessing/pp114.F90 --- a/flang/test/Preprocessing/pp114.F90 +++ b/flang/test/Preprocessing/pp114.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! ditto, with & ! comment, leading & integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM& ! comment &(666) if (res .eq. 777) then - print *, 'pp114.F90 pass' + print *, 'pp114.F90 yes' else - print *, 'pp114.F90 FAIL: ', res + print *, 'pp114.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp115.F90 b/flang/test/Preprocessing/pp115.F90 --- a/flang/test/Preprocessing/pp115.F90 +++ b/flang/test/Preprocessing/pp115.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm (666) ! ditto, with & ! comment, no leading & integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM& ! comment (666) if (res .eq. 777) then - print *, 'pp115.F90 pass' + print *, 'pp115.F90 yes' else - print *, 'pp115.F90 FAIL: ', res + print *, 'pp115.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp116.F90 b/flang/test/Preprocessing/pp116.F90 --- a/flang/test/Preprocessing/pp116.F90 +++ b/flang/test/Preprocessing/pp116.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm (666) ! FLM call split between name and (, no leading & integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM& (666) if (res .eq. 777) then - print *, 'pp116.F90 pass' + print *, 'pp116.F90 yes' else - print *, 'pp116.F90 FAIL: ', res + print *, 'pp116.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp117.F90 b/flang/test/Preprocessing/pp117.F90 --- a/flang/test/Preprocessing/pp117.F90 +++ b/flang/test/Preprocessing/pp117.F90 @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777 .eq. 777) then ! KWM rescan integer, parameter :: KWM = 666, KWM2 = 667 #define KWM2 777 #define KWM KWM2 if (KWM .eq. 777) then - print *, 'pp117.F90 pass' + print *, 'pp117.F90 yes' else - print *, 'pp117.F90 FAIL: ', KWM + print *, 'pp117.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp118.F90 b/flang/test/Preprocessing/pp118.F90 --- a/flang/test/Preprocessing/pp118.F90 +++ b/flang/test/Preprocessing/pp118.F90 @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(kwm2 .eq. 777) then ! KWM rescan with #undef, proving rescan after expansion integer, parameter :: KWM2 = 777, KWM = 667 #define KWM2 666 #define KWM KWM2 #undef KWM2 if (KWM .eq. 777) then - print *, 'pp118.F90 pass' + print *, 'pp118.F90 yes' else - print *, 'pp118.F90 FAIL: ', KWM + print *, 'pp118.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp119.F90 b/flang/test/Preprocessing/pp119.F90 --- a/flang/test/Preprocessing/pp119.F90 +++ b/flang/test/Preprocessing/pp119.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((666)+111) ! FLM rescan integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ integer :: res res = IFLM(666) if (res .eq. 777) then - print *, 'pp119.F90 pass' + print *, 'pp119.F90 yes' else - print *, 'pp119.F90 FAIL: ', res + print *, 'pp119.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp120.F90 b/flang/test/Preprocessing/pp120.F90 --- a/flang/test/Preprocessing/pp120.F90 +++ b/flang/test/Preprocessing/pp120.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = ((111)+666) ! FLM expansion of argument integer function IFLM(x) integer :: x @@ -10,8 +12,8 @@ integer :: res res = IFLM(KWM) if (res .eq. 777) then - print *, 'pp120.F90 pass' + print *, 'pp120.F90 yes' else - print *, 'pp120.F90 FAIL: ', res + print *, 'pp120.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp121.F90 b/flang/test/Preprocessing/pp121.F90 --- a/flang/test/Preprocessing/pp121.F90 +++ b/flang/test/Preprocessing/pp121.F90 @@ -1,10 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch = 'KWM' +! CHECK: if(ch .eq. 'KWM') then ! KWM NOT expanded in 'literal' #define KWM 666 character(len=3) :: ch ch = 'KWM' if (ch .eq. 'KWM') then - print *, 'pp121.F90 pass' + print *, 'pp121.F90 yes' else - print *, 'pp121.F90 FAIL: ', ch + print *, 'pp121.F90 no: ', ch end if end diff --git a/flang/test/Preprocessing/pp122.F90 b/flang/test/Preprocessing/pp122.F90 --- a/flang/test/Preprocessing/pp122.F90 +++ b/flang/test/Preprocessing/pp122.F90 @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch = "KWM" ! KWM NOT expanded in "literal" #define KWM 666 character(len=3) :: ch ch = "KWM" if (ch .eq. 'KWM') then - print *, 'pp122.F90 pass' + print *, 'pp122.F90 yes' else - print *, 'pp122.F90 FAIL: ', ch + print *, 'pp122.F90 no: ', ch end if end diff --git a/flang/test/Preprocessing/pp123.F90 b/flang/test/Preprocessing/pp123.F90 --- a/flang/test/Preprocessing/pp123.F90 +++ b/flang/test/Preprocessing/pp123.F90 @@ -1,11 +1,13 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: ch = 3hKWM ! KWM NOT expanded in Hollerith literal #define KWM 666 #define HKWM 667 character(len=3) :: ch ch = 3HKWM if (ch .eq. 'KWM') then - print *, 'pp123.F90 pass' + print *, 'pp123.F90 yes' else - print *, 'pp123.F90 FAIL: ', ch + print *, 'pp123.F90 no: ', ch end if end diff --git a/flang/test/Preprocessing/pp124.F90 b/flang/test/Preprocessing/pp124.F90 --- a/flang/test/Preprocessing/pp124.F90 +++ b/flang/test/Preprocessing/pp124.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: 100 format(3hKWM) ! KWM NOT expanded in Hollerith in FORMAT #define KWM 666 #define HKWM 667 @@ -5,8 +7,8 @@ 100 format(3HKWM) write(ch, 100) if (ch .eq. 'KWM') then - print *, 'pp124.F90 pass' + print *, 'pp124.F90 yes' else - print *, 'pp124.F90 FAIL: ', ch + print *, 'pp124.F90 no: ', ch end if end diff --git a/flang/test/Preprocessing/pp125.F90 b/flang/test/Preprocessing/pp125.F90 --- a/flang/test/Preprocessing/pp125.F90 +++ b/flang/test/Preprocessing/pp125.F90 @@ -1,9 +1,11 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777 .eq. 777) then ! #DEFINE works in free form integer, parameter :: KWM = 666 #DEFINE KWM 777 if (KWM .eq. 777) then - print *, 'pp125.F90 pass' + print *, 'pp125.F90 yes' else - print *, 'pp125.F90 FAIL: ', KWM + print *, 'pp125.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp126.F90 b/flang/test/Preprocessing/pp126.F90 --- a/flang/test/Preprocessing/pp126.F90 +++ b/flang/test/Preprocessing/pp126.F90 @@ -1,10 +1,12 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: if(777 .eq. 777) then ! \ newline works in #define integer, parameter :: KWM = 666 #define KWM 77\ 7 if (KWM .eq. 777) then - print *, 'pp126.F90 pass' + print *, 'pp126.F90 yes' else - print *, 'pp126.F90 FAIL: ', KWM + print *, 'pp126.F90 no: ', KWM end if end diff --git a/flang/test/Preprocessing/pp127.F90 b/flang/test/Preprocessing/pp127.F90 --- a/flang/test/Preprocessing/pp127.F90 +++ b/flang/test/Preprocessing/pp127.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm(666 ) ! FLM call with closing ')' on next line (not a continuation) integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM(666 ) if (res .eq. 777) then - print *, 'pp127.F90 pass' + print *, 'pp127.F90 yes' else - print *, 'pp127.F90 FAIL: ', res + print *, 'pp127.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp128.F90 b/flang/test/Preprocessing/pp128.F90 --- a/flang/test/Preprocessing/pp128.F90 +++ b/flang/test/Preprocessing/pp128.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: res = iflm ! FLM call with '(' on next line (not a continuation) integer function IFLM(x) integer :: x @@ -9,8 +11,8 @@ res = IFLM (666) if (res .eq. 777) then - print *, 'pp128.F90 pass' + print *, 'pp128.F90 yes' else - print *, 'pp128.F90 FAIL: ', res + print *, 'pp128.F90 no: ', res end if end diff --git a/flang/test/Preprocessing/pp129.F90 b/flang/test/Preprocessing/pp129.F90 --- a/flang/test/Preprocessing/pp129.F90 +++ b/flang/test/Preprocessing/pp129.F90 @@ -1,5 +1,7 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK-NOT: stop ! #define KWM !, then KWM works as comment line initiator #define KWM ! KWM print *, 'pp129.F90 FAIL HARD!'; stop - print *, 'pp129.F90 pass' + print *, 'pp129.F90 yes' end diff --git a/flang/test/Preprocessing/pp130.F90 b/flang/test/Preprocessing/pp130.F90 --- a/flang/test/Preprocessing/pp130.F90 +++ b/flang/test/Preprocessing/pp130.F90 @@ -1,3 +1,5 @@ +! RUN: %f18 -E %s 2>&1 | FileCheck %s +! CHECK: j = j + & ! #define KWM &, use for continuation w/o pasting (ifort and nag seem to continue #define) #define KWM & @@ -6,8 +8,8 @@ j = j + KWM 111 if (j .eq. 777) then - print *, 'pp130.F90 pass' + print *, 'pp130.F90 yes' else - print *, 'pp130.F90 FAIL', j + print *, 'pp130.F90 no', j end if end