File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -892,11 +892,24 @@ bool Prescanner::HandleExponent(TokenSequence &tokens) {
892
892
}
893
893
894
894
bool Prescanner::HandleKindSuffix (TokenSequence &tokens) {
895
- if (*at_ == ' _' && IsLegalInIdentifier (*SkipWhiteSpace (at_ + 1 ))) {
896
- EmitCharAndAdvance (tokens, *at_);
897
- if (IsLegalIdentifierStart (*at_)) {
898
- // The kind specifier might be a macro, so put it into its own token.
895
+ if (*at_ == ' _' && IsLegalInIdentifier (at_[1 ])) {
896
+ // The kind specifier might be a macro (with or without its leading
897
+ // underscore); put it into its own token if it has been defined.
898
+ const char *p{at_ + 1 };
899
+ while (IsLegalInIdentifier (*++p)) {
900
+ }
901
+ if (CharBlock id{at_, static_cast <std::size_t >(p - at_)};
902
+ preprocessor_.IsNameDefined (id)) {
903
+ // In 1.0e0_foo, "_foo" is a defined name; retain the
904
+ // underscore
899
905
tokens.CloseToken ();
906
+ } else {
907
+ EmitCharAndAdvance (tokens, ' _' );
908
+ if (CharBlock id{at_, static_cast <std::size_t >(p - at_)};
909
+ preprocessor_.IsNameDefined (id)) {
910
+ // In 1.0e0_foo, "foo" is a defined name
911
+ tokens.CloseToken ();
912
+ }
900
913
}
901
914
while (IsLegalInIdentifier (*at_)) {
902
915
EmitCharAndAdvance (tokens, *at_);
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ TokenSequence &TokenSequence::ToLowerCase() {
187
187
} else if (*p == ' h' || *p == ' H' ) {
188
188
// Hollerith
189
189
*p = ' h' ;
190
- } else if (*p == ' _' ) {
190
+ } else if (*p == ' _' && p + 1 < limit && (p[ 1 ] == ' " ' || p[ 1 ] == ' \' ' ) ) {
191
191
// kind-prefixed character literal (e.g., 1_"ABC")
192
192
} else {
193
193
// exponent
Original file line number Diff line number Diff line change 1
1
! RUN: %flang -E %s 2>&1 | FileCheck %s
2
2
#define n k
3
+ #define _m _p
3
4
parameter (n= 4 )
4
5
! CHECK: print *,1_k
5
6
print * ,1_n
7
+ ! CHECK: print *,1_p
8
+ print * ,1_m
6
9
end
You can’t perform that action at this time.
0 commit comments