From 0513e3d517795ce27335c60af6289f27c1328fb3 Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Tue, 8 May 2018 10:21:34 +0000 Subject: [PATCH] [arm] PR target/85658 Fix operator precedence errors in parsecpu.awk There are a number of places in parsecpu.awk where I've managed to get the operator precedence between ! and 'in' incorrect (! binds more tightly). In most cases this just makes a consistency test ineffective, but in a few cases it means we fail to correctly diagnose errors by the user (for example, when passing an invalid cpu or architecture name to configure. This patch fixes all the cases I could find, based on searching for all uses of the two operators in the same expression. The tweak to the API of check_fpu is to bring it into line with the other check functions - it now returns the result rather than printing it directly. The caller now does the printing, in the same way that the chkarch and chkcpu commands do. PR target/85658 * config/arm/parsecpu.awk (check_cpu): Fix operator precedence. (check_arch): Likewise. (check_fpu): Return the result rather than printing it. (end arch): Fix operator precedence. (end cpu): Likewise. (END): Print the result from check_fpu. From-SVN: r260032 --- gcc/ChangeLog | 10 ++++++++++ gcc/config/arm/parsecpu.awk | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 748cf93..924a033 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2018-05-08 Richard Earnshaw + + PR target/85658 + * config/arm/parsecpu.awk (check_cpu): Fix operator precedence. + (check_arch): Likewise. + (check_fpu): Return the result rather than printing it. + (end arch): Fix operator precedence. + (end cpu): Likewise. + (END): Print the result from check_fpu. + 2018-05-08 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/config/arm/parsecpu.awk b/gcc/config/arm/parsecpu.awk index 56c762b..4d234c3 100644 --- a/gcc/config/arm/parsecpu.awk +++ b/gcc/config/arm/parsecpu.awk @@ -463,7 +463,7 @@ function gen_opt () { function check_cpu (name) { exts = split (name, extensions, "+") - if (! extensions[1] in cpu_cnames) { + if (! (extensions[1] in cpu_cnames)) { return "error" } @@ -477,15 +477,16 @@ function check_cpu (name) { } function check_fpu (name) { - if (name in fpu_cnames) { - print fpu_cnames[name] - } else print "error" + if (! (name in fpu_cnames)) { + return "error" + } + return fpu_cnames[name] } function check_arch (name) { exts = split (name, extensions, "+") - if (! extensions[1] in arch_isa) { + if (! (extensions[1] in arch_isa)) { return "error" } @@ -600,10 +601,10 @@ BEGIN { /^end arch / { if (NF != 3) fatal("syntax: end arch ") if (arch_name != $3) fatal("mimatched end arch") - if (! arch_name in arch_tune_for) { + if (! (arch_name in arch_tune_for)) { fatal("arch definition lacks a \"tune for\" statement") } - if (! arch_name in arch_isa) { + if (! (arch_name in arch_isa)) { fatal("arch definition lacks an \"isa\" statement") } arch_list = arch_list " " arch_name @@ -742,7 +743,7 @@ BEGIN { cpu_cnames[cpu_name] = cpu_name gsub(/[-+.]/, "_", cpu_cnames[cpu_name]) } - if (! cpu_name in cpu_arch) fatal("cpu definition lacks an architecture") + if (! (cpu_name in cpu_arch)) fatal("cpu definition lacks an architecture") cpu_list = cpu_list " " cpu_name cpu_name = "" parse_ok = 1 @@ -776,6 +777,6 @@ END { print check_arch(target[2]) } else if (cmd ~ /^chkfpu /) { split (cmd, target) - check_fpu(target[2]) + print check_fpu(target[2]) } else fatal("unrecognized command: "cmd) } -- 2.7.4