Anonymous | Login | 2021-01-16 20:42 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | Category | Severity | Type | Date Submitted | Last Update | |||||||
0001388 | [1003.1(2016/18)/Issue7+TC2] Shell and Utilities | Objection | Omission | 2020-08-11 14:17 | 2020-08-19 16:42 | |||||||
Reporter | geoffclare | View Status | public | |||||||||
Assigned To | ||||||||||||
Priority | normal | Resolution | Open | |||||||||
Status | New | |||||||||||
Name | Geoff Clare | |||||||||||
Organization | The Open Group | |||||||||||
User Reference | ||||||||||||
Section | yacc | |||||||||||
Page Number | 3456 | |||||||||||
Line Number | 116732 | |||||||||||
Interp Status | --- | |||||||||||
Final Accepted Text | ||||||||||||
Summary | 0001388: yacc description does not say who declares yyerror() and yylex() | |||||||||||
Description |
The description of yacc talks about the functions yyerror() and yylex() in various places, but nowhere does it state who is responsible for declaring them. This means that, in practice, a portable application has to declare them in the .y file (if it does not define them) in case yacc does not provide declarations of them in the code file and the compiler that will be used treats calls to undeclared functions as an error. It doesn't take much thought about the reasons why prototypes were added to the C language to come to the conclusion that the greatly preferable solution is for yacc to be required to supply prototypes for yyerror() and yylex() that match the yyerror() definition in its library and the yylex() definition produced by lex, even (some might say especially) if the .y file includes definitions of those functions to be used instead of the library version of yyerror() and a lex-generated yylex(). There is also no statement about a declaration of main(), but the situation for main() is quite different from the above two functions. Although in theory an application could call yacc's library version of main() from code in a .y file, it is questionable why any application (other than a test suite) would do so, in particular because that version of main() does not accept any arguments and it calls exit() -- it does not return -- and therefore is of little use recursively. An application that provides its own main() could call it recursively, but can reasonably be expected to ensure it does not call main() without previously defining or declaring it. In addition, since main() has multiple different allowed prototypes, if yacc were to output a declaration it would have to be a non-prototype one: int main(); so that there is no risk of a clash with a definition of main() that has a different prototype, but there does not seem much point in it producing such a declaration. (Or it could check whether the .y file contains a definition of main() and output a prototype declaration if it does not contain one, but that seems impractical.) The simplest solution is just not to allow yacc to provide a declaration of main(). |
|||||||||||
Desired Action |
On page 3456 line 116732 section yacc (Code File), change:It also shall contain a copy of the #define statements in the header file.to: It also shall contain prototype declarations of the yyerror() and yylex() functions, and a copy of the #define statements in the header file, prior to any code copied from within <tt>%{</tt> and <tt>%}</tt> in the declarations section in grammar. On page 3456 line 116734 section yacc (Code File), add a new paragraph: The code file shall not contain a declaration of the main() function, unless one is present within <tt>%{</tt> and <tt>%}</tt> in the declarations section in grammar. On page 3469 line 117335 section yacc (RATIONALE), add new paragraphs: Earlier versions of this standard did not require the code file created by yacc to contain declarations of yyerror() and yylex(). This meant that portable applications that did not define them had to declare them in the grammar file, to ensure they would not be diagnosed by the compiler as being called without being declared, but this was not stated in those versions of the standard either. The standard developers decided it was preferable for yacc to include the declarations in the code file and this is now a requirement. |
|||||||||||
Tags | No tags attached. | |||||||||||
Attached Files | ||||||||||||
|
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |