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) {
892892}
893893
894894bool 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
899905 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+ }
900913 }
901914 while (IsLegalInIdentifier (*at_)) {
902915 EmitCharAndAdvance (tokens, *at_);
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ TokenSequence &TokenSequence::ToLowerCase() {
187187 } else if (*p == ' h' || *p == ' H' ) {
188188 // Hollerith
189189 *p = ' h' ;
190- } else if (*p == ' _' ) {
190+ } else if (*p == ' _' && p + 1 < limit && (p[ 1 ] == ' " ' || p[ 1 ] == ' \' ' ) ) {
191191 // kind-prefixed character literal (e.g., 1_"ABC")
192192 } else {
193193 // exponent
Original file line number Diff line number Diff line change 11! RUN: %flang -E %s 2>&1 | FileCheck %s
22#define n k
3+ #define _m _p
34parameter (n= 4 )
45! CHECK: print *,1_k
56print * ,1_n
7+ ! CHECK: print *,1_p
8+ print * ,1_m
69end
You can’t perform that action at this time.
0 commit comments