Skip to content

Commit 1584c8a

Browse files
authored
Merge pull request #518 from ThePortlandGroup/nv_stage
Pull 2018-06-29T11-41 Recent NVIDIA Changes
2 parents 8d338d8 + 0ac92f4 commit 1584c8a

File tree

2 files changed

+219
-1
lines changed

2 files changed

+219
-1
lines changed

test/tools/check_compilation.py

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
#
2+
# Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
"""
18+
Helper for checking the output of deja-gnu style tests.
19+
20+
This script prints all non-error lines to allow external tools to find other
21+
problems. It then tries to match up lines with dg-type errors with the errors
22+
in the ouput file & prints any non-matching errors.
23+
24+
Script allows to match F90 (emited by flang) and PGF90 (emited by pgfortran)
25+
error prefixes. This functionality can be modified to disable checking error
26+
prefixes in the future.
27+
"""
28+
29+
import re
30+
import argparse
31+
from collections import namedtuple
32+
from os.path import basename
33+
34+
# Regex notes:
35+
# \S matches any non-whitespace character
36+
# \d matches [0-9]
37+
# \w matches [A-Za-z_0-9]
38+
# . matches any character except (possibly) line terminators
39+
# $ matches end-of-input
40+
# Parentheses define a capturing group
41+
# (?P<foo> ... ) defines a capturing group accessed with m.group("foo")
42+
43+
# an error listed in the source file:
44+
dgError = re.compile(r"""
45+
^(?P<stmt>.*?)\s*!\s*{\s* # fortran statement before error marker
46+
(?P<dg>dg-)? # dg- prefix means text need not match
47+
(?P<sev>(error|warning))\s* # severify
48+
\"(?P<prefix>(?:PG)?F\d\d) # error prefix
49+
-[WSF]-\d+- # PGI severity and error number
50+
(?P<text>.*)\" # text of message
51+
\s*(?P<lineno>\d*) # optional line number of message
52+
\s*}\s*$
53+
""", re.VERBOSE)
54+
55+
# an error output from the fortran compiler:
56+
pgfError = re.compile(r"""
57+
(?P<prefix>(?:PG)?F\d\d)- # error prefix
58+
(?P<sev>[WSF])-\d+-(?P<text>.+?)\s* # text & sev of error
59+
\((?P<file>\S+) # file name
60+
(:\s*(?P<lineno>\d+))?\)$ # optional line number
61+
""", re.VERBOSE)
62+
63+
# Compiler crash
64+
terminatedError = re.compile(r"TERMINATED by signal")
65+
66+
ErrorInfo = namedtuple("ErrorInfo", "file lineno sev prefix text")
67+
68+
def main():
69+
args = processArgs()
70+
terminated, logErrors = getLogErrors(args.log)
71+
sourceErrors = getSourceErrors(getFileSet(args.source, logErrors))
72+
if args.dump:
73+
dumpErrorSet(logErrors, title="Log Errors:")
74+
dumpErrorSet(sourceErrors, title="Source Errors:")
75+
checkErrorsMatch(terminated, logErrors, sourceErrors, basename(args.compiler))
76+
77+
def processArgs():
78+
""" Process command line arguments """
79+
80+
parser = argparse.ArgumentParser()
81+
parser.add_argument("source", help="source file")
82+
parser.add_argument("log", help="log file")
83+
parser.add_argument("compiler", nargs='?', help="Name of the compiler executable or path to it", default="pgf90")
84+
parser.add_argument("--dump", help="dump the error lists", action="store_true")
85+
return parser.parse_args()
86+
87+
def getLogErrors(log):
88+
"""
89+
Extract erros from the log file
90+
91+
:param log: log file path
92+
"""
93+
94+
terminated = False
95+
errorList = []
96+
with open(log, "r") as handle:
97+
for line in handle:
98+
m = pgfError.match(line)
99+
if m:
100+
text = m.group("text")
101+
prefix = m.group("prefix")
102+
sev = "warning" if m.group("sev") == "W" else "error"
103+
file = m.group("file")
104+
lineno = m.group("lineno") if m.group("lineno") else ""
105+
errorList.append(ErrorInfo(file, lineno, sev, prefix, text))
106+
elif terminatedError.search(line):
107+
terminated = True
108+
else:
109+
print line,
110+
return terminated, errorList
111+
112+
def getFileSet(source, logErrors):
113+
"""
114+
Get set of files to extract errors, containing original source file and
115+
any files mentioned in the errors
116+
117+
:param source: source file that was compiled
118+
:parma logErrors: list of error tuples from the log
119+
"""
120+
121+
fileSet = set([source])
122+
for e in logErrors:
123+
fileSet.add(e.file)
124+
return fileSet
125+
126+
def getSourceErrors(fileSet):
127+
"""
128+
Collect error messages from source files
129+
130+
:param fileSet: list of file names to process
131+
"""
132+
errorList = []
133+
saveList = [] # errors saved up for next line that isn't just dg-error
134+
for f in fileSet:
135+
with open(f, "r") as handle:
136+
lineno = 0
137+
for line in handle:
138+
lineno += 1
139+
m = dgError.search(line)
140+
if m:
141+
dg = m.group("dg") # dg-error vs. error
142+
stmt = m.group("stmt") # fortran stmt before dg-error
143+
text = m.group("text") if not dg else ""
144+
prefix = m.group("prefix") if not dg else ""
145+
sev = m.group("sev")
146+
l = m.group("lineno") # lineno specific in dg-error
147+
if l != "":
148+
errorList.append(ErrorInfo(f, l, sev, prefix, text))
149+
elif stmt != "" or dg:
150+
errorList.append(ErrorInfo(f, str(lineno), sev, prefix, text))
151+
else:
152+
saveList.append(ErrorInfo(f, "", sev, prefix, text))
153+
if len(saveList) > 0 and (not m or m.group("stmt")):
154+
# this was not a full-line dg-error, so saveList goes with this line
155+
for e in saveList:
156+
errorList.append(ErrorInfo(e.file, str(lineno), e.sev, e.prefix, e.text))
157+
saveList = []
158+
return errorList + saveList
159+
160+
def checkErrorsMatch(terminated, logErrors, sourceErrors, compiler):
161+
"""
162+
Report error mismatches
163+
164+
:param terminated: log indicates that compiler was terminated
165+
:param logErrors: error tuples from the compilation log
166+
:param sourceErrors: error tuples from the source file(s)
167+
:param compiler: compiler executable name
168+
"""
169+
170+
fail = None
171+
for e in logErrors:
172+
if not removeMatch(e, sourceErrors, (compiler == "flang")):
173+
fail = True
174+
print "Unexpected:", e.sev, e.file, e.lineno, e.text
175+
for e in sourceErrors:
176+
fail = True
177+
print "Missed:", e.sev, e.file, e.lineno, e.text
178+
if fail or terminated:
179+
print "FAIL"
180+
else:
181+
print "PASS"
182+
183+
def removeMatch(e, errors, matchF90):
184+
"""
185+
If e matches one of errors, remove it and return True
186+
187+
:param matchF90: match F90 prefix in error to PGF90 in entry in e
188+
"""
189+
for e2 in errors:
190+
if e.file != e2.file: continue
191+
if e.lineno != e2.lineno: continue
192+
if e.sev != e2.sev: continue
193+
if e2.text != "" and e.text != e2.text: continue
194+
if e2.prefix != "":
195+
if (not matchF90) and e.prefix != e2.prefix: continue
196+
if matchF90 and (e.prefix != "F90" or e2.prefix != "PGF90"): continue
197+
errors.remove(e2)
198+
return True
199+
return False
200+
201+
def dumpErrorSet(errors, title):
202+
"""
203+
Dump collected errors
204+
205+
:param erros: error list
206+
:param title: optional title
207+
"""
208+
if title:
209+
print title
210+
if len(errors) == 0:
211+
print " (none)"
212+
else:
213+
for e in errors:
214+
print " ", e.sev, e.file, e.lineno, e.prefix if e.prefix != None else "", e.text if e.text != None else ""
215+
216+
217+
if __name__=="__main__":
218+
main()

tools/flang1/flang1exe/semant3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ semant3(int rednum, SST *top)
531531
strcmp(SYMNAME(FVALG(sptr)), SYMNAME(gbl.currsub)) == 0 &&
532532
strcmp(SYMNAME(sptr), SYMNAME(gbl.currsub)) == 0 &&
533533
strcmp(SYMNAME(sptr), SYMNAME(FVALG(gbl.currsub))) == 0) {
534-
/* FS#20696: replace with correct LHS symbol */
534+
/* replace with correct LHS symbol */
535535
sptr = gbl.currsub;
536536
if (SST_IDG(RHS(2)) == S_LVALUE || SST_IDG(RHS(2)) == S_EXPR) {
537537
SST_LSYMP(RHS(2), sptr);

0 commit comments

Comments
 (0)