Subject: yacc and warnings
To: None <perry@NetBSD.ORG>
From: None <Anders.Hjalmarsson@economics.gu.se>
List: tech-userlevel
Date: 07/30/1997 18:42:13
I read your in commit-message on source-changes several days ago about the
problem with __dead not working. __dead expands to volatile when using gcc
but newer versions of gcc2 use __attribute__((noreturn)) (I seem to recall
that there was a problem with ansi compilance and using const or volatile
qualifiers for fuunctions). I was under the impression that __dead should
still work, but apparently it doesn't.
When I looked at the header files I found that exit and abort in <stdlib.h>
do not have __attribute_((noreturn)), probably gcc has builtin noreturn
declarations for them, since otherwise you should have got warnings about
their not returning. I think that those declarations should be added
anyway.
In some header files __noreturn__ is used while in others noreturn is used,
both are valid, but __noreturn__ is safer from redefinition, since it
is in the implementation namespace. Perhaps all uses on noreturn
should be changed to __noreturn__
Since __dead does not work should it be removed from the header files ?
With the following patches yacc still compiles cleanly:
--- defs.h.orig Sat Jul 26 04:08:10 1997
+++ defs.h Wed Jul 30 18:24:42 1997
@@ -324,14 +324,14 @@
extern void fatal __P((char *));
extern void reflexive_transitive_closure __P((unsigned *, int));
-extern void done __P((int));
+extern void done __P((int)) __attribute__((noreturn));
extern void fatal __P((char *));
extern void no_space __P((void));
extern void open_error(char *);
extern void unexpected_EOF __P((void));
extern void print_pos __P((char *, char *));
-extern __dead void syntax_error __P((int, char *, char *));
+extern void syntax_error __P((int, char *, char *)) __attribute__((noreturn));
extern void unterminated_comment __P((int, char *, char *));
extern void unterminated_string __P((int, char *, char *));
extern void unterminated_text __P((int, char *, char *));
--- reader.c.orig Sat Jul 26 04:08:12 1997
+++ reader.c Wed Jul 30 17:46:21 1997
@@ -355,7 +355,6 @@
}
syntax_error(lineno, line, t_cptr);
/*NOTREACHED*/
- exit(1);
}
--- main.c.orig Sat Jul 26 04:08:11 1997
+++ main.c Wed Jul 30 17:49:26 1997
@@ -116,7 +116,6 @@
int main __P((int, char *[]));
void onintr __P((int));
-__dead void done __P((int));
void set_signals __P((void));
void usage __P((void));
void getargs __P((int, char *[]));
@@ -124,7 +123,7 @@
void create_file_names __P((void));
void open_files __P((void));
-__dead void
+void
done(k)
int k;
{
@@ -467,5 +466,4 @@
output();
done(0);
/*NOTREACHED*/
- exit(0);
}