1 # Executing Actions. -*- Autotest -*-
2 # Copyright (C) 2002 Free Software Foundation, Inc.
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 2, or (at your option)
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 AT_BANNER([[User Actions.]])
22 # AT_SYNCLINES_COMPILE(FILE)
23 # --------------------------
24 # Compile FILE expecting an error, and save in the file stdout the normalized
26 m4_define([AT_SYNCLINES_COMPILE],
27 [AT_CHECK([$CC $CFLAGS $CPPFLAGS $1 -c], 1, [], [stderr])
28 # In case GCC displays column information, strip it down.
30 # input.y:4:2: #error "4" or input.y:4.2: #error "4"
32 # input.y:4: #error "4"
34 AT_CHECK([[sed 's/^\([^:]*:[^:.]*\)[.:][^:]*:\(.*\)$/\1:\2/' stderr]], 0, [stdout])
37 # AT_TEST_SYNCLINE(TITLE, INPUT, ERROR-MSG)
38 # -----------------------------------------
39 # Check that compiling the parser produced from INPUT cause GCC
41 m4_define([AT_TEST_SYNCLINE],
44 # It seems impossible to find a generic scheme to check the location
45 # of an error. Even requiring GCC is not sufficient, since for instance
46 # the version modified by Apple:
48 # | Reading specs from /usr/libexec/gcc/darwin/ppc/2.95.2/specs
49 # | Apple Computer, Inc. version gcc-934.3, based on gcc version 2.95.2
50 # | 19991024 (release) configure:2124: $? = 0
54 # | input.y:2: #error "2"
59 # | cpp-precomp: warning: errors during smart preprocessing, retrying in basic mode
65 AT_SYNCLINES_COMPILE([syncline.c])
66 AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
68 AT_DATA([[input.y]], [$2])
69 AT_CHECK([bison input.y -o input.c])
70 AT_SYNCLINES_COMPILE([input.c])
71 AT_CHECK([cat stdout], 0, [$3])
76 ## --------------------- ##
77 ## Prologue synch line. ##
78 ## --------------------- ##
81 AT_TEST_SYNCLINE([Prologue synch line],
84 void yyerror (const char *s);
90 [input.y:2: #error "2"
94 ## ------------------- ##
95 ## %union synch line. ##
96 ## ------------------- ##
98 AT_TEST_SYNCLINE([%union synch line],
103 void yyerror (const char *s);
109 [input.y:2: #error "2"
113 ## ------------------------- ##
114 ## Postprologue synch line. ##
115 ## ------------------------- ##
117 AT_TEST_SYNCLINE([Postprologue synch line],
119 void yyerror (const char *s);
132 [input.y:10: #error "10"
136 ## ------------------- ##
137 ## Action synch line. ##
138 ## ------------------- ##
140 AT_TEST_SYNCLINE([Action synch line],
142 void yyerror (const char *s);
151 [input.y:8: #error "8"
155 ## --------------------- ##
156 ## Epilogue synch line. ##
157 ## --------------------- ##
159 AT_TEST_SYNCLINE([Epilogue synch line],
161 void yyerror (const char *s);
169 [input.y:8: #error "8"