OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [lib/] [gcc-dg.exp] - Blame information for rev 779

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 306 jeremybenn
#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008, 2009
2
#   Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with GCC; see the file COPYING3.  If not see
16
# .
17
 
18
load_lib dg.exp
19
load_lib file-format.exp
20
load_lib target-supports.exp
21
load_lib target-supports-dg.exp
22
load_lib scanasm.exp
23
load_lib scanrtl.exp
24
load_lib scantree.exp
25
load_lib scanipa.exp
26
load_lib timeout.exp
27
load_lib timeout-dg.exp
28
load_lib prune.exp
29
load_lib libgloss.exp
30
load_lib target-libpath.exp
31
load_lib torture-options.exp
32
 
33
# We set LC_ALL and LANG to C so that we get the same error messages as expected.
34
setenv LC_ALL C
35
setenv LANG C
36
 
37
# Many hosts now default to a non-ASCII C locale, however, so
38
# they can set a charset encoding here if they need.
39
if { [ishost "*-*-cygwin*"] } {
40
  setenv LC_ALL C.ASCII
41
  setenv LANG C.ASCII
42
}
43
 
44
if [info exists TORTURE_OPTIONS] {
45
    set DG_TORTURE_OPTIONS $TORTURE_OPTIONS
46
} else {
47
    # It is theoretically beneficial to group all of the O2/O3 options together,
48
    # as in many cases the compiler will generate identical executables for
49
    # all of them--and the c-torture testsuite will skip testing identical
50
    # executables multiple times.
51
    # Also note that -finline-functions is explicitly included in one of the
52
    # items below, even though -O3 is also specified, because some ports may
53
    # choose to disable inlining functions by default, even when optimizing.
54
    set DG_TORTURE_OPTIONS [list \
55
        { -O0 } \
56
        { -O1 } \
57
        { -O2 } \
58
        { -O3 -fomit-frame-pointer } \
59
        { -O3 -fomit-frame-pointer -funroll-loops } \
60
        { -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
61
        { -O3 -g } \
62
        { -Os } ]
63
}
64
 
65
if [info exists ADDITIONAL_TORTURE_OPTIONS] {
66
    set DG_TORTURE_OPTIONS \
67
        [concat $DG_TORTURE_OPTIONS $ADDITIONAL_TORTURE_OPTIONS]
68
}
69
 
70
set LTO_TORTURE_OPTIONS ""
71
if [check_effective_target_lto] {
72
    set LTO_TORTURE_OPTIONS [list \
73
        { -O2 -flto } \
74
        { -O2 -fwhopr }
75
    ]
76
}
77
 
78
 
79
global GCC_UNDER_TEST
80
if ![info exists GCC_UNDER_TEST] {
81
    set GCC_UNDER_TEST "[find_gcc]"
82
}
83
 
84
global orig_environment_saved
85
 
86
# This file may be sourced, so don't override environment settings
87
# that have been previously setup.
88
if { $orig_environment_saved == 0 } {
89
    append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
90
    set_ld_library_path_env_vars
91
}
92
 
93
# Define gcc callbacks for dg.exp.
94
 
95
proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
96
    # Set up the compiler flags, based on what we're going to do.
97
 
98
    set options [list]
99
 
100
    # Tests should be able to use "dg-do repo".  However, the dg test
101
    # driver checks the argument to dg-do against a list of acceptable
102
    # options, and "repo" is not among them.  Therefore, we resort to
103
    # this ugly approach.
104
    if [string match "*-frepo*" $extra_tool_flags] then {
105
        set do_what "repo"
106
    }
107
 
108
    switch $do_what {
109
        "preprocess" {
110
            set compile_type "preprocess"
111
            set output_file "[file rootname [file tail $prog]].i"
112
        }
113
        "compile" {
114
            set compile_type "assembly"
115
            set output_file "[file rootname [file tail $prog]].s"
116
        }
117
        "assemble" {
118
            set compile_type "object"
119
            set output_file "[file rootname [file tail $prog]].o"
120
        }
121
        "precompile" {
122
            set compile_type "precompiled_header"
123
            set output_file "[file tail $prog].gch"
124
        }
125
        "link" {
126
            set compile_type "executable"
127
            set output_file "[file rootname [file tail $prog]].exe"
128
            # The following line is needed for targets like the i960 where
129
            # the default output file is b.out.  Sigh.
130
        }
131
        "repo" {
132
            set compile_type "object"
133
            set output_file "[file rootname [file tail $prog]].o"
134
        }
135
        "run" {
136
            set compile_type "executable"
137
            # FIXME: "./" is to cope with "." not being in $PATH.
138
            # Should this be handled elsewhere?
139
            # YES.
140
            set output_file "./[file rootname [file tail $prog]].exe"
141
            # This is the only place where we care if an executable was
142
            # created or not.  If it was, dg.exp will try to run it.
143
            catch { remote_file build delete $output_file }
144
        }
145
        default {
146
            perror "$do_what: not a valid dg-do keyword"
147
            return ""
148
        }
149
    }
150
 
151
    if { $extra_tool_flags != "" } {
152
        lappend options "additional_flags=$extra_tool_flags"
153
    }
154
 
155
    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options]
156
 
157
    # Look for an internal compiler error, which sometimes masks the fact
158
    # that we didn't get an expected error message.  XFAIL an ICE via
159
    # dg-xfail-if and use { dg-prune-output ".*internal compiler error.*" }
160
    # to avoid a second failure for excess errors.
161
    if [string match "*internal compiler error*" $comp_output] {
162
        upvar 2 name name
163
        fail "$name (internal compiler error)"
164
    }
165
 
166
    if { $do_what == "repo" } {
167
        set object_file "$output_file"
168
        set output_file "[file rootname [file tail $prog]].exe"
169
        set comp_output \
170
            [ concat $comp_output \
171
                  [$target_compile "$object_file" "$output_file" \
172
                       "executable" $options] ]
173
    }
174
 
175
    return [list $comp_output $output_file]
176
}
177
 
178
proc gcc-dg-test { prog do_what extra_tool_flags } {
179
    return [gcc-dg-test-1 gcc_target_compile $prog $do_what $extra_tool_flags]
180
}
181
 
182
proc gcc-dg-prune { system text } {
183
    global additional_prunes
184
 
185
    set text [prune_gcc_output $text]
186
 
187
    foreach p $additional_prunes {
188
        if { [string length $p] > 0 } {
189
            # Following regexp matches a complete line containing $p.
190
            regsub -all "(^|\n)\[^\n\]*$p\[^\n\]*" $text "" text
191
        }
192
    }
193
 
194
    # If we see "region xxx is full" then the testcase is too big for ram.
195
    # This is tricky to deal with in a large testsuite like c-torture so
196
    # deal with it here.  Just mark the testcase as unsupported.
197
    if [regexp "(^|\n)\[^\n\]*: region \[^\n\]* is full" $text] {
198
        # The format here is important.  See dg.exp.
199
        return "::unsupported::memory full"
200
    }
201
 
202
    # Likewise, if we see ".text exceeds local store range" or
203
    # similar.
204
    if {[string match "spu-*" $system] && \
205
            [string match "*exceeds local store*" $text]} {
206
        # The format here is important.  See dg.exp.
207
        return "::unsupported::memory full"
208
    }
209
 
210
    return $text
211
}
212
 
213
# Replace ${tool}_load with a wrapper to provide for an expected nonzero
214
# exit status.  Multiple languages include this file so this handles them
215
# all, not just gcc.
216
if { [info procs ${tool}_load] != [list] \
217
      && [info procs saved_${tool}_load] == [list] } {
218
    rename ${tool}_load saved_${tool}_load
219
 
220
    proc ${tool}_load { program args } {
221
        global tool
222
        global shouldfail
223
        set result [eval [list saved_${tool}_load $program] $args]
224
        if { $shouldfail != 0 } {
225
            switch [lindex $result 0] {
226
                "pass" { set status "fail" }
227
                "fail" { set status "pass" }
228
            }
229
            set result [list $status [lindex $result 1]]
230
        }
231
        return $result
232
    }
233
}
234
 
235
# Utility routines.
236
 
237
#
238
# search_for -- looks for a string match in a file
239
#
240
proc search_for { file pattern } {
241
    set fd [open $file r]
242
    while { [gets $fd cur_line]>=0 } {
243
        if [string match "*$pattern*" $cur_line] then {
244
            close $fd
245
            return 1
246
        }
247
    }
248
    close $fd
249
    return 0
250
}
251
 
252
# Modified dg-runtest that can cycle through a list of optimization options
253
# as c-torture does.
254
proc gcc-dg-runtest { testcases default-extra-flags } {
255
    global runtests
256
 
257
    # Some callers set torture options themselves; don't override those.
258
    set existing_torture_options [torture-options-exist]
259
    if { $existing_torture_options == 0 } {
260
        global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
261
        torture-init
262
        set-torture-options $DG_TORTURE_OPTIONS [list {}] $LTO_TORTURE_OPTIONS
263
    }
264
    dump-torture-options
265
 
266
    foreach test $testcases {
267
        global torture_with_loops torture_without_loops
268
        # If we're only testing specific files and this isn't one of
269
        # them, skip it.
270
        if ![runtest_file_p $runtests $test] {
271
            continue
272
        }
273
 
274
        # Look for a loop within the source code - if we don't find one,
275
        # don't pass -funroll[-all]-loops.
276
        if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
277
            set option_list $torture_with_loops
278
        } else {
279
            set option_list $torture_without_loops
280
        }
281
 
282
        set nshort [file tail [file dirname $test]]/[file tail $test]
283
 
284
        foreach flags $option_list {
285
            verbose "Testing $nshort, $flags" 1
286
            dg-test $test $flags ${default-extra-flags}
287
        }
288
    }
289
 
290
    if { $existing_torture_options == 0 } {
291
        torture-finish
292
    }
293
}
294
 
295
proc gcc-dg-debug-runtest { target_compile trivial opt_opts testcases } {
296
    global srcdir subdir
297
 
298
    if ![info exists DEBUG_TORTURE_OPTIONS] {
299
        set DEBUG_TORTURE_OPTIONS ""
300
        foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} {
301
            set comp_output [$target_compile \
302
                    "$srcdir/$subdir/$trivial" "trivial.S" assembly \
303
                    "additional_flags=$type"]
304
            if { ! [string match "*: target system does not support the * debug format*" \
305
                    $comp_output] } {
306
                remove-build-file "trivial.S"
307
                foreach level {1 "" 3} {
308
                    if { ($type == "-gdwarf-2") && ($level != "") } {
309
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}" "-g${level}"]
310
                        foreach opt $opt_opts {
311
                            lappend DEBUG_TORTURE_OPTIONS \
312
                                    [list "${type}" "-g${level}" "$opt" ]
313
                        }
314
                    } else {
315
                        lappend DEBUG_TORTURE_OPTIONS [list "${type}${level}"]
316
                        foreach opt $opt_opts {
317
                            lappend DEBUG_TORTURE_OPTIONS \
318
                                    [list "${type}${level}" "$opt" ]
319
                        }
320
                    }
321
                }
322
            }
323
        }
324
    }
325
 
326
    verbose -log "Using options $DEBUG_TORTURE_OPTIONS"
327
 
328
    global runtests
329
 
330
    foreach test $testcases {
331
        # If we're only testing specific files and this isn't one of
332
        # them, skip it.
333
        if ![runtest_file_p $runtests $test] {
334
            continue
335
        }
336
 
337
        set nshort [file tail [file dirname $test]]/[file tail $test]
338
 
339
        foreach flags $DEBUG_TORTURE_OPTIONS {
340
            set doit 1
341
 
342
            # These tests check for information which may be deliberately
343
            # suppressed at -g1.
344
            if { ([string match {*/debug-[126].c} "$nshort"] \
345
                   || [string match {*/enum-1.c} "$nshort"] \
346
                   || [string match {*/enum-[12].C} "$nshort"]) \
347
                    && ([string match "*1" [lindex "$flags" 0] ]
348
                        || [lindex "$flags" 1] == "-g1") } {
349
                set doit 0
350
            }
351
 
352
    # High optimization can remove the variable whose existence is tested.
353
    # Dwarf debugging with commentary (-dA) preserves the symbol name in the
354
    # assembler output, but stabs debugging does not.
355
    # http://gcc.gnu.org/ml/gcc-regression/2003-04/msg00095.html
356
            if { [string match {*/debug-[12].c} "$nshort"] \
357
                    && [string match "*O*" "$flags"] \
358
                    && ( [string match "*coff*" "$flags"] \
359
                         || [string match "*stabs*" "$flags"] ) } {
360
                set doit 0
361
            }
362
 
363
            if { $doit } {
364
                verbose -log "Testing $nshort, $flags" 1
365
                dg-test $test $flags ""
366
            }
367
        }
368
    }
369
}
370
 
371
# Prune any messages matching ARGS[1] (a regexp) from test output.
372
proc dg-prune-output { args } {
373
    global additional_prunes
374
 
375
    if { [llength $args] != 2 } {
376
        error "[lindex $args 1]: need one argument"
377
        return
378
    }
379
 
380
    lappend additional_prunes [lindex $args 1]
381
}
382
 
383
# Remove files matching the pattern from the build machine.
384
proc remove-build-file { pat } {
385
    verbose "remove-build-file `$pat'" 2
386
    set file_list "[glob -nocomplain $pat]"
387
    verbose "remove-build-file `$file_list'" 2
388
    foreach output_file $file_list {
389
        if [is_remote host] {
390
            # Ensure the host knows the file is gone by deleting there
391
            # first.
392
            remote_file host delete $output_file
393
        }
394
        remote_file build delete $output_file
395
    }
396
}
397
 
398
# Remove runtime-generated profile file for the current test.
399
proc cleanup-profile-file { } {
400
    remove-build-file "mon.out"
401
    remove-build-file "gmon.out"
402
}
403
 
404
# Remove compiler-generated coverage files for the current test.
405
proc cleanup-coverage-files { } {
406
    # This assumes that we are two frames down from dg-test or some other proc
407
    # that stores the filename of the testcase in a local variable "name".
408
    # A cleaner solution would require a new DejaGnu release.
409
    upvar 2 name testcase
410
    remove-build-file "[file rootname [file tail $testcase]].gc??"
411
 
412
    # Clean up coverage files for additional source files.
413
    if [info exists additional_sources] {
414
        foreach srcfile $additional_sources {
415
            remove-build-file "[file rootname [file tail $srcfile]].gc??"
416
        }
417
    }
418
}
419
 
420
# Remove compiler-generated files from -repo for the current test.
421
proc cleanup-repo-files { } {
422
    # This assumes that we are two frames down from dg-test or some other proc
423
    # that stores the filename of the testcase in a local variable "name".
424
    # A cleaner solution would require a new DejaGnu release.
425
    upvar 2 name testcase
426
    remove-build-file "[file rootname [file tail $testcase]].o"
427
    remove-build-file "[file rootname [file tail $testcase]].rpo"
428
 
429
    # Clean up files for additional source files.
430
    if [info exists additional_sources] {
431
        foreach srcfile $additional_sources {
432
            remove-build-file "[file rootname [file tail $srcfile]].o"
433
            remove-build-file "[file rootname [file tail $srcfile]].rpo"
434
        }
435
    }
436
}
437
 
438
# Remove compiler-generated RTL dump files for the current test.
439
#
440
# SUFFIX is the filename suffix pattern.
441
proc cleanup-rtl-dump { suffix } {
442
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]r.$suffix"
443
}
444
 
445
# Remove a specific tree dump file for the current test.
446
#
447
# SUFFIX is the tree dump file suffix pattern.
448
proc cleanup-tree-dump { suffix } {
449
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]t.$suffix"
450
}
451
 
452
# Remove a specific ipa dump file for the current test.
453
#
454
# SUFFIX is the ipa dump file suffix pattern.
455
proc cleanup-ipa-dump { suffix } {
456
  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]i.$suffix"
457
}
458
 
459
# Remove all dump files with the provided suffix.
460
proc cleanup-dump { suffix } {
461
    # This assumes that we are three frames down from dg-test or some other
462
    # proc that stores the filename of the testcase in a local variable
463
    # "name".  A cleaner solution would require a new DejaGnu release.
464
    upvar 3 name testcase
465
    # The name might include a list of options; extract the file name.
466
    set src [file tail [lindex $testcase 0]]
467
    remove-build-file "[file tail $src].$suffix"
468
    # -fcompare-debug dumps
469
    remove-build-file "[file tail $src].gk.$suffix"
470
 
471
    # Clean up dump files for additional source files.
472
    if [info exists additional_sources] {
473
        foreach srcfile $additional_sources {
474
            remove-build-file "[file tail $srcfile].$suffix"
475
            # -fcompare-debug dumps
476
            remove-build-file "[file tail $srcfile].gk.$suffix"
477
        }
478
    }
479
}
480
 
481
# Remove files kept by --save-temps for the current test.
482
#
483
# Currently this is only .i, .ii, .s and .o files, but more can be added
484
# if there are tests generating them.
485
# ARGS is a list of suffixes to NOT delete.
486
proc cleanup-saved-temps { args } {
487
    global additional_sources
488
    set suffixes {}
489
 
490
    # add the to-be-kept suffixes
491
    foreach suffix {".ii" ".i" ".s" ".o" ".gkd"} {
492
        if {[lsearch $args $suffix] < 0} {
493
            lappend suffixes $suffix
494
        }
495
    }
496
 
497
    # This assumes that we are two frames down from dg-test or some other proc
498
    # that stores the filename of the testcase in a local variable "name".
499
    # A cleaner solution would require a new DejaGnu release.
500
    upvar 2 name testcase
501
    foreach suffix $suffixes {
502
        remove-build-file "[file rootname [file tail $testcase]]$suffix"
503
        # -fcompare-debug dumps
504
        remove-build-file "[file rootname [file tail $testcase]].gk$suffix"
505
    }
506
 
507
    # Clean up saved temp files for additional source files.
508
    if [info exists additional_sources] {
509
        foreach srcfile $additional_sources {
510
            foreach suffix $suffixes {
511
                remove-build-file "[file rootname [file tail $srcfile]]$suffix"
512
                # -fcompare-debug dumps
513
                remove-build-file "[file rootname [file tail $srcfile]].gk$suffix"
514
            }
515
        }
516
    }
517
}
518
 
519
# Remove files for specified Fortran modules.
520
proc cleanup-modules { modlist } {
521
    foreach modname $modlist {
522
        remove-build-file [string tolower $modname].mod
523
    }
524
}
525
 
526
# Scan Fortran modules for a given regexp.
527
#
528
# Argument 0 is the module name
529
# Argument 1 is the regexp to match
530
proc scan-module { args } {
531
    set modfilename [string tolower [lindex $args 0]].mod
532
    set fd [open $modfilename r]
533
    set text [read $fd]
534
    close $fd
535
 
536
    upvar 2 name testcase
537
    if [regexp -- [lindex $args 1] $text] {
538
      pass "$testcase scan-module [lindex $args 1]"
539
    } else {
540
      fail "$testcase scan-module [lindex $args 1]"
541
    }
542
}
543
 
544
# Verify that the compiler output file exists, invoked via dg-final.
545
proc output-exists { args } {
546
    # Process an optional target or xfail list.
547
    if { [llength $args] >= 1 } {
548
        switch [dg-process-target [lindex $args 0]] {
549
            "S" { }
550
            "N" { return }
551
            "F" { setup_xfail "*-*-*" }
552
            "P" { }
553
        }
554
    }
555
 
556
    # Access variables from gcc-dg-test-1.
557
    upvar 2 name testcase
558
    upvar 2 output_file output_file
559
 
560
    if [file exists $output_file] {
561
        pass "$testcase output-exists $output_file"
562
    } else {
563
        fail "$testcase output-exists $output_file"
564
    }
565
}
566
 
567
# Verify that the compiler output file does not exist, invoked via dg-final.
568
proc output-exists-not { args } {
569
    # Process an optional target or xfail list.
570
    if { [llength $args] >= 1 } {
571
        switch [dg-process-target [lindex $args 0]] {
572
            "S" { }
573
            "N" { return }
574
            "F" { setup_xfail "*-*-*" }
575
            "P" { }
576
        }
577
    }
578
 
579
    # Access variables from gcc-dg-test-1.
580
    upvar 2 name testcase
581
    upvar 2 output_file output_file
582
 
583
    if [file exists $output_file] {
584
        fail "$testcase output-exists-not $output_file"
585
    } else {
586
        pass "$testcase output-exists-not $output_file"
587
    }
588
}
589
 
590
# We need to make sure that additional_* are cleared out after every
591
# test.  It is not enough to clear them out *before* the next test run
592
# because gcc-target-compile gets run directly from some .exp files
593
# (outside of any test).  (Those uses should eventually be eliminated.)
594
 
595
# Because the DG framework doesn't provide a hook that is run at the
596
# end of a test, we must replace dg-test with a wrapper.
597
 
598
if { [info procs saved-dg-test] == [list] } {
599
    rename dg-test saved-dg-test
600
 
601
    proc dg-test { args } {
602
        global additional_files
603
        global additional_sources
604
        global additional_prunes
605
        global errorInfo
606
        global compiler_conditional_xfail_data
607
        global shouldfail
608
 
609
        if { [ catch { eval saved-dg-test $args } errmsg ] } {
610
            set saved_info $errorInfo
611
            set additional_files ""
612
            set additional_sources ""
613
            set additional_prunes ""
614
            set shouldfail 0
615
            if [info exists compiler_conditional_xfail_data] {
616
                unset compiler_conditional_xfail_data
617
            }
618
            unset_timeout_vars
619
            error $errmsg $saved_info
620
        }
621
        set additional_files ""
622
        set additional_sources ""
623
        set additional_prunes ""
624
        set shouldfail 0
625
        unset_timeout_vars
626
        if [info exists compiler_conditional_xfail_data] {
627
            unset compiler_conditional_xfail_data
628
        }
629
    }
630
}
631
 
632
if { [info procs saved-dg-warning] == [list] \
633
     && [info exists gcc_warning_prefix] } {
634
    rename dg-warning saved-dg-warning
635
 
636
    proc dg-warning { args } {
637
        # Make this variable available here and to the saved proc.
638
        upvar dg-messages dg-messages
639
        global gcc_warning_prefix
640
 
641
        process-message saved-dg-warning "$gcc_warning_prefix" "$args"
642
    }
643
}
644
 
645
if { [info procs saved-dg-error] == [list] \
646
     && [info exists gcc_error_prefix] } {
647
    rename dg-error saved-dg-error
648
 
649
    proc dg-error { args } {
650
        # Make this variable available here and to the saved proc.
651
        upvar dg-messages dg-messages
652
        global gcc_error_prefix
653
 
654
        process-message saved-dg-error "$gcc_error_prefix" "$args"
655
    }
656
 
657
    # Override dg-bogus at the same time.  It doesn't handle a prefix
658
    # but its expression should include a column number.  Otherwise the
659
    # line number can match the column number for other messages, leading
660
    # to insanity.
661
    rename dg-bogus saved-dg-bogus
662
 
663
    proc dg-bogus { args } {
664
        upvar dg-messages dg-messages
665
        process-message saved-dg-bogus "" $args
666
    }
667
}
668
 
669
# Modify the regular expression saved by a DejaGnu message directive to
670
# include a prefix and to force the expression to match a single line.
671
# MSGPROC is the procedure to call.
672
# MSGPREFIX is the prefix to prepend.
673
# DGARGS is the original argument list.
674
 
675
proc process-message { msgproc msgprefix dgargs } {
676
    upvar dg-messages dg-messages
677
 
678
    # Process the dg- directive, including adding the regular expression
679
    # to the new message entry in dg-messages.
680
    set msgcnt [llength ${dg-messages}]
681
    catch { eval $msgproc $dgargs }
682
 
683
    # If the target expression wasn't satisfied there is no new message.
684
    if { [llength ${dg-messages}] == $msgcnt } {
685
        return;
686
    }
687
 
688
    # Get the entry for the new message.  Prepend the message prefix to
689
    # the regular expression and make it match a single line.
690
    set newentry [lindex ${dg-messages} end]
691
    set expmsg [lindex $newentry 2]
692
 
693
    # Handle column numbers from the specified expression (if there is
694
    # one) and set up the search expression that will be used by DejaGnu.
695
    if [regexp "^(\[0-9\]+):" $expmsg "" column] {
696
        # The expression in the directive included a column number.
697
        # Remove "COLUMN:" from the original expression and move it
698
        # to the proper place in the search expression.
699
        regsub "^\[0-9\]+:" $expmsg "" expmsg
700
        set expmsg "$column: $msgprefix\[^\n\]*$expmsg"
701
    } elseif [string match "" [lindex $newentry 0]] {
702
        # The specified line number is 0; don't expect a column number.
703
        set expmsg "$msgprefix\[^\n\]*$expmsg"
704
    } else {
705
        # There is no column number in the search expression, but we
706
        # should expect one in the message itself.
707
        set expmsg "\[0-9\]+: $msgprefix\[^\n\]*$expmsg"
708
    }
709
 
710
    set newentry [lreplace $newentry 2 2 $expmsg]
711
    set dg-messages [lreplace ${dg-messages} end end $newentry]
712
    verbose "process-message:\n${dg-messages}" 2
713
}
714
 
715
# Look for messages that don't have standard prefixes.
716
 
717
proc dg-message { args } {
718
    upvar dg-messages dg-messages
719
    process-message saved-dg-warning "" $args
720
}
721
 
722
set additional_prunes ""

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.