diff options
author | Andrew Pinski <apinski@marvell.com> | 2023-07-11 22:14:18 -0700 |
---|---|---|
committer | Andrew Pinski <apinski@marvell.com> | 2023-09-14 07:29:43 -0700 |
commit | 4241415b8817d505e92144175c040a48b1cf2b9f (patch) | |
tree | 6691be9f6d271d143c54cc3bad0e08e365955b16 | |
parent | 8ebb02dd6c9d190c84bf40259201e8e7327291f8 (diff) | |
download | gcc-4241415b8817d505e92144175c040a48b1cf2b9f.zip gcc-4241415b8817d505e92144175c040a48b1cf2b9f.tar.gz gcc-4241415b8817d505e92144175c040a48b1cf2b9f.tar.bz2 |
Improve error message for if with an else part while in switch
While writing some match.pd code, I was trying to figure
out why I was getting an `expected ), got (` error message
while writing an if statement with an else clause. For switch
statements, the if statements cannot have an else clause so
it would be better to have a decent error message saying that
explictly.
OK? Bootstrapped and tested on x86_64-linux-gnu.
gcc/ChangeLog:
* genmatch.cc (parser::parse_result): For an else clause
of an if statement inside a switch, error out explictly.
-rw-r--r-- | gcc/genmatch.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc index a1925a7..03d325e 100644 --- a/gcc/genmatch.cc +++ b/gcc/genmatch.cc @@ -4891,6 +4891,8 @@ parser::parse_result (operand *result, predicate_id *matcher) ife->trueexpr = parse_result (result, matcher); else ife->trueexpr = parse_op (); + if (peek ()->type == CPP_OPEN_PAREN) + fatal_at (peek(), "if inside switch cannot have an else"); eat_token (CPP_CLOSE_PAREN); } else |