From de180f4ed0626a42925854ed8ac299264033a1dc Mon Sep 17 00:00:00 2001 From: peter klausler Date: Fri, 6 Apr 2018 17:04:18 -0700 Subject: [PATCH] [flang] Prevent misrecognition of a digit string that is the kind parameter of a character literal from being misrecognized as an integer literal. Original-commit: flang-compiler/f18@bd7ed0b162b7cc4e89e0d08e22e8676d59261931 Reviewed-on: https://github.com/flang-compiler/f18/pull/48 Tree-same-pre-rewrite: false --- flang/lib/parser/grammar.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flang/lib/parser/grammar.h b/flang/lib/parser/grammar.h index dcab4fb..07803f4 100644 --- a/flang/lib/parser/grammar.h +++ b/flang/lib/parser/grammar.h @@ -713,8 +713,10 @@ TYPE_PARSER(space >> sourced(construct{}( signedDigitString, maybe(underscore >> kindParam)))) // R708 int-literal-constant -> digit-string [_ kind-param] +// The negated look-ahead for a trailing underscore prevents misrecognition +// when the digit string is a numeric kind parameter of a character literal. TYPE_PARSER(construct{}( - space >> digitString, maybe(underscore >> kindParam))) + space >> digitString, maybe(underscore >> kindParam) / !underscore)) // R709 kind-param -> digit-string | scalar-int-constant-name TYPE_PARSER(construct{}(digitString) || -- 2.7.4