diff mbox series

[arm] PR target/85658 Fix operator precedence errors in parsecpu.awk

Message ID ab008436-05b5-5d72-9302-a698e1c6db1e@arm.com
State New
Headers show
Series [arm] PR target/85658 Fix operator precedence errors in parsecpu.awk | expand

Commit Message

Richard Earnshaw (lists) May 8, 2018, 10:35 a.m. UTC
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.

Committed to trunk and gcc-8 branch.
diff mbox series

Patch

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 <name>")
     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)
 }