aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/scng.adb
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2015-10-23 10:41:13 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2015-10-23 12:41:13 +0200
commitc79f6efda3d3ebae36ecd7beab058684d2790903 (patch)
tree0ed8b11b3c01df9037e5e1900516917ec38ab9ab /gcc/ada/scng.adb
parent10158317660dcb6db1913913ce99073078314b4f (diff)
downloadgcc-c79f6efda3d3ebae36ecd7beab058684d2790903.zip
gcc-c79f6efda3d3ebae36ecd7beab058684d2790903.tar.gz
gcc-c79f6efda3d3ebae36ecd7beab058684d2790903.tar.bz2
exp_ch6.adb (Expand_N_Extended_Return_Statement): Do not call SS_Release for a block statement enclosing the return statement in...
2015-10-23 Bob Duff <duff@adacore.com> * exp_ch6.adb (Expand_N_Extended_Return_Statement): Do not call SS_Release for a block statement enclosing the return statement in the case where a build-in-place function return is returning the result on the secondary stack. This is accomplished by setting the Sec_Stack_Needed_For_Return flag on such blocks. It was already being set for the function itself, and it was already set correctly for blocks in the non-build-in-place case (in Expand_Simple_Function_Return). (Set_Enclosing_Sec_Stack_Return): New procedure to perform the Set_Sec_Stack_Needed_For_Return calls. Called in the build-in-place and non-build-in-place cases. (Expand_Simple_Function_Return): Call Set_Enclosing_Sec_Stack_Return instead of performing the loop in line. 2015-10-23 Bob Duff <duff@adacore.com> * scng.adb (Char_Literal_Case): If an apostrophe follows a reserved word, treat it as a lone apostrophe, rather than the start of a character literal. This was already done for "all", but it needs to be done also for (e.g.) "Delta". From-SVN: r229226
Diffstat (limited to 'gcc/ada/scng.adb')
-rw-r--r--gcc/ada/scng.adb30
1 files changed, 18 insertions, 12 deletions
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
index 0216ddf..f0a9013 100644
--- a/gcc/ada/scng.adb
+++ b/gcc/ada/scng.adb
@@ -1834,14 +1834,19 @@ package body Scng is
-- Apostrophe. This can either be the start of a character literal,
-- or an isolated apostrophe used in a qualified expression or an
- -- attribute. We treat it as a character literal if it does not
- -- follow a right parenthesis, identifier, the keyword ALL or
- -- a literal. This means that we correctly treat constructs like:
+ -- attribute. In the following:
-- A := CHARACTER'('A');
- -- Note that RM-2.2(7) does not require a separator between
- -- "CHARACTER" and "'" in the above.
+ -- the first apostrophe is treated as an isolated apostrophe, and the
+ -- second one is treated as the start of the character literal 'A'.
+ -- Note that RM-2.2(7) does not require a separator between "'" and
+ -- "(" in the above, so we cannot use lookahead to distinguish the
+ -- cases; we use look-back instead. Analysis of the grammar shows
+ -- that some tokens can be followed by an apostrophe, and some by a
+ -- character literal, but none by both. Some cannot be followed by
+ -- either, so it doesn't matter what we do in those cases, except to
+ -- get good error behavior.
when ''' => Char_Literal_Case : declare
Code : Char_Code;
@@ -1851,17 +1856,18 @@ package body Scng is
Accumulate_Checksum (''');
Scan_Ptr := Scan_Ptr + 1;
- -- Here is where we make the test to distinguish the cases. Treat
- -- as apostrophe if previous token is an identifier, right paren
- -- or the reserved word "all" (latter case as in A.all'Address)
- -- (or the reserved word "project" in project files). Also treat
- -- it as apostrophe after a literal (this catches some legitimate
- -- cases, like A."abs"'Address, and also gives better error
- -- behavior for impossible cases like 123'xxx).
+ -- Distinguish between apostrophe and character literal. It's an
+ -- apostrophe if the previous token is one of the following.
+ -- Reserved words are included for things like A.all'Address and
+ -- T'Digits'Img. Strings literals are included for things like
+ -- "abs"'Address. Other literals are included to give better error
+ -- behavior for illegal cases like 123'Img.
if Prev_Token = Tok_Identifier
or else Prev_Token = Tok_Right_Paren
or else Prev_Token = Tok_All
+ or else Prev_Token = Tok_Delta
+ or else Prev_Token = Tok_Digits
or else Prev_Token = Tok_Project
or else Prev_Token in Token_Class_Literal
then