the code with the following options:
@example
-$ gm2 -g -fsoft-check-all -O2 -c assignvalue.mod
+$ gm2 -g -fsoft-check-all -O2 -fm2-plugin -c assignvalue.mod
assignvalue.mod:16:0:inevitable that this error will occur at run time,
assignment will result in an overflow
@end example
--- /dev/null
+(* { dg-do compile } *)
+(* { dg-options "-fsoft-check-all -fm2-plugin" } *)
+(* { dg-skip-if "" { *-*-* } { "*" } { "-O2" } } *)
+
+MODULE assignvalue ; (*!m2iso+gm2*)
+
+PROCEDURE bad () : INTEGER ;
+VAR
+ i: INTEGER ;
+BEGIN
+ i := -1 ;
+ RETURN i
+END bad ;
+
+VAR
+ foo: CARDINAL ;
+BEGIN
+ (* The m2rte plugin will detect this as an error, post
+ optimization. *)
+ foo := bad () (* { dg-error "error: In program module assignvalue" } *)
+ (* { dg-begin-multiline-output "" }
+runtime error will occur, assignment will cause a range error, as the runtime instance value of 'CARDINAL' does not overlap with the type 'INTEGER'
+ { dg-end-multiline-output "" } *)
+
+END assignvalue.
--- /dev/null
+# Compile tests, no torture testing.
+#
+# These tests should all generate errors if the plugin is available.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir
+
+# Initialize `dg'.
+dg-init
+
+# If the --enable-plugin has not been enabled during configure, bail.
+if { ![gm2-dg-frontend-configure-check "enable-plugin" ] } {
+ return
+}
+
+# Main loop.
+
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.mod]]
+
+gm2-dg-runtest $tests "" ""
+
+# All done.
+dg-finish
if [expr [search_for $test "dg-do run"]] {
set option_list $TORTURE_OPTIONS
} else {
- set option_list [list { -O } ]
+ set option_list [list { -O -O2 } ]
}
set nshort [file tail [file dirname $test]]/[file tail $test]
}
}
+
+# Check if frontend has been configured with option.
+# This checks a configure build option was used and not
+# the availability of a compiler command line option.
+
+proc gm2-dg-frontend-configure-check { option } {
+ global GCC_UNDER_TEST
+
+ # ignore any arguments after the command
+ set compiler [lindex $GCC_UNDER_TEST 0]
+
+ if ![is_remote host] {
+ set compiler_name [which $compiler]
+ } else {
+ set compiler_name $compiler
+ }
+
+ # verify that the compiler exists
+ if { $compiler_name != 0 } then {
+ set tmp [remote_exec host "$compiler -v"]
+ set status [lindex $tmp 0]
+ set output [lindex $tmp 1]
+ regexp "Configured with.*\[\n\r\]" $output config
+ set option "*${option}*"
+ if { [string match $option $config] } {
+ return 1
+ } else {
+ return 0
+ }
+ } else {
+ # compiler does not exist (this should have already been detected)
+ warning "$compiler does not exist"
+ return 0
+ }
+}