This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Two small fixes for C/C++ lexer
- To: gcc-patches at gcc dot gnu dot org
- Subject: Two small fixes for C/C++ lexer
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Fri, 8 Sep 2000 15:16:24 -0700
1) As previously discussed, adjust the #ifdefs so C++ specific pragmas
still work on targets that don't want #pragma pack, #pragma weak, etc.
This has been bootstrapped on i386-linux and I built cc1 and cc1plus in a
i386-linux->hppa-hpux10 cross configuration.
2) One line hopeful fix for bootstrap failures on targets that do not
define NO_IMPLICIT_EXTERN_C. I tested this to the best of my
abilities by building a "native i386-sysv4" compiler on my linux box.
This is not the world's greatest test, but (a) the patch is Obviously
Correct, or at least can't make the situation worse; (b) if it's
wrong, the autobuilder will let me know about it in short order. :)
zw
* c-pragma.c: Don't elide entire file if !HANDLE_GENERIC_PRAGMAS.
(init_pragma): Avoid warning if pfile happens to be unused.
* c-pragma.h: Never define HANDLE_GENERIC_PRAGMAS. Never
define init_pragma to nothing. Always prototype
init_pragma. Prototype dispatch_pragma if !USE_CPPLIB.
* c-lex.c (process_directive): Always call dispatch_pragma.
Initialize entering_c_header to 0.
===================================================================
Index: c-pragma.c
--- c-pragma.c 2000/09/07 22:24:31 1.35
+++ c-pragma.c 2000/09/08 22:11:01
@@ -32,8 +32,6 @@ Boston, MA 02111-1307, USA. */
#include "c-lex.h"
#include "tm_p.h"
-#ifdef HANDLE_GENERIC_PRAGMAS
-
#if USE_CPPLIB
extern cpp_reader parse_in;
#else
@@ -438,10 +436,11 @@ dispatch_pragma ()
void
init_pragma ()
{
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
#if !USE_CPPLIB
- cpp_reader *pfile = 0;
+ pfile = 0;
#else
- cpp_reader *pfile = &parse_in;
+ pfile = &parse_in;
#endif
#ifdef HANDLE_PRAGMA_PACK
@@ -450,7 +449,6 @@ init_pragma ()
#ifdef HANDLE_PRAGMA_WEAK
cpp_register_pragma (pfile, 0, "weak", handle_pragma_weak);
#endif
-
#ifdef REGISTER_TARGET_PRAGMAS
REGISTER_TARGET_PRAGMAS (pfile);
#endif
@@ -460,5 +458,3 @@ init_pragma ()
mark_align_stack);
#endif
}
-
-#endif /* HANDLE_GENERIC_PRAGMAS */
===================================================================
Index: c-pragma.h
--- c-pragma.h 2000/09/07 22:24:31 1.16
+++ c-pragma.h 2000/09/08 22:11:01
@@ -57,25 +57,11 @@ extern struct weak_syms * weak_decls;
extern int add_weak PARAMS ((const char *, const char *));
#endif /* HANDLE_PRAGMA_WEAK */
-
-/* Define HANDLE_GENERIC_PRAGMAS if any kind of front-end pragma
- parsing is to be done. The code in GCC's generic C source files
- will only look for the definition of this constant. They will
- ignore definitions of HANDLE_PRAGMA_PACK and so on. */
-#if defined HANDLE_PRAGMA_PACK || defined HANDLE_PRAGMA_WEAK \
- || defined REGISTER_TARGET_PRAGMAS
-#define HANDLE_GENERIC_PRAGMAS
-#endif
-
-#ifdef HANDLE_GENERIC_PRAGMAS
extern void init_pragma PARAMS ((void));
-# if !USE_CPPLIB
+/* If cpplib is in use, it handles dispatch. */
+#if !USE_CPPLIB
extern void dispatch_pragma PARAMS ((void));
-# endif
-
-#else
-# define init_pragma()
#endif
/* Duplicate prototypes for the register_pragma stuff and the typedef for
===================================================================
Index: c-lex.c
--- c-lex.c 2000/09/08 01:38:08 1.99
+++ c-lex.c 2000/09/08 22:11:02
@@ -438,7 +438,7 @@ process_directive ()
int action_number, l;
char *new_file;
#ifndef NO_IMPLICIT_EXTERN_C
- int entering_c_header;
+ int entering_c_header = 0;
#endif
/* Don't read beyond this line. */
@@ -457,9 +457,7 @@ process_directive ()
if (!strcmp (name, "pragma"))
{
-#ifdef HANDLE_GENERIC_PRAGMAS
dispatch_pragma ();
-#endif
goto skipline;
}
else if (!strcmp (name, "define"))