This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

20000313 cpp tries to stringify non-function macro on ppc


cpp in the snapshot stumbles on the linux include/asm-ppc/init.h statement:
#define __INIT		.section	".text.init",#alloc,#execinstr

A simple testcase:

> echo "#define _I #a" | ./cpp -v -nostdinc

GNU CPP version 2.96 20000313 (experimental) (cpplib)
 (PowerPC GNU/Linux)
#include "..." search starts here:
End of search list.
<stdin>:1:13: `#' is not followed by a macro argument name
# 1 ""

It looks like the #a is causing _cpp_lex_token to return CPP_STRINGSIZE

_cpp_lex_token (pfile)
    case '#':
...
      if (pfile->parsing_define_directive && ! CPP_TRADITIONAL (pfile))
	{
	  CPP_RESERVE (pfile, 3);
	  CPP_PUTC_Q (pfile, '#');
	  CPP_NUL_TERMINATE_Q (pfile);
    	  if (PEEKC () != '#')
	    return CPP_STRINGIZE;

(gdb) p *pfile.buffer
$93 = {cur = 0x1002ae94 "a\n", rlimit = 0x1002ae96 "", 
  buf = 0x1002ae88 "#define _I #a\n", alimit = 0x1002ae96 "", 
  line_base = 0x1002ae88 "#define _I #a\n", prev = 0x0, 

(gdb) bt
#0  _cpp_lex_token (pfile=0x100281fc) at ../../egcs/gcc/cpplex.c:722
#1  0x10006150 in cpp_get_token (pfile=0x100281fc)
    at ../../egcs/gcc/cpplex.c:1145
#2  0x1000b4c4 in collect_expansion (pfile=0x100281fc, arglist=0x0)
    at ../../egcs/gcc/cpphash.c:322
#3  0x1000c150 in _cpp_create_definition (pfile=0x100281fc, funlike=0x0)
    at ../../egcs/gcc/cpphash.c:736
#4  0x10007fd4 in do_define (pfile=0x100281fc, keyword=0x10015f30)
    at ../../egcs/gcc/cpplib.c:314
#5  0x10007cb4 in _cpp_handle_directive (pfile=0x100281fc)
    at ../../egcs/gcc/cpplib.c:215
#6  0x10006178 in cpp_get_token (pfile=0x100281fc)
    at ../../egcs/gcc/cpplex.c:1153

My novice guess would be that funlike could be passed down and checked...

Ed.Swarthout@motorola.com

My config.status:
#!/bin/sh
# This file was generated automatically by configure.  Do not edit.
# This directory was configured as follows:
../egcs/configure --with-gcc-version-trigger=/usr/src/els/egcs/gcc/version.c \
  --enable-languages=c,c++,proto,java --enable-shared --enable-threads=posix \
  --enable-haifa --host=ppc-redhat-linux --norecursion 
# using "mh-frag" and "mt-frag"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]