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]
Other format: [Raw text]

[Bug c/14265] New: variable name si_value causes strange errors; sivalue and ui_value not


In the following module i used the variable name "si_value" but this produces 
these errors:

bsp0.c:110: warning: no semicolon at end of struct or union
bsp0.c:110: error: parse error before '.' token
bsp0.c:111: warning: unused variable `ui_value'
...
 
With "sivalue" instead of "si_value" it's no problem.

I tried it with 
gcc version 3.3.1 (SuSE Linux)
and command line
gcc -O2 -Wall -DLINUX -I /lib/modules/`uname -r`/build/include -c bsp0.c
on 
Linux version 2.4.21-144-smp (root@i386.suse.de) (gcc version 3.3.1 (SuSE Linux)
) #1 SMP Fri Nov 14 00:08:31 UTC 2003
but the bug also occures during cross-compiling for ARM.

It seems that gcc can't confine the variable namespace.

/*

bsp0.c: Demonstates a gcc bug: si_value is used from the gcc and cannot be used 
as variable (see si_value below).

compile with
gcc -O6 -Wall -DLINUX -I /lib/modules/`uname -r`/build/include -c bsp0.c

*/



#ifndef __KERNEL__
#   define __KERNEL__
#endif
#ifndef MODULE
#   define MODULE
#endif

#include <linux/module.h>
#include <linux/kernel.h>       /* Fuer z.B. printk */
#include <linux/sched.h>        /* Fuer z.B. free_irq */
#include <linux/init.h>         /* Fuer z.B. __init */
#include <linux/signal.h>
#include <linux/errno.h>        /* Fuer z.B. EINVAL */
#include <linux/mm.h>           /* Fuer z.B. GFP_xxx-Makros */
#include <linux/poll.h>
#include <linux/miscdevice.h>
#include <linux/random.h>
#include <linux/delay.h>        /* Fuer z.B. udelay */
#include <linux/ioport.h>       /* Fuer z.B. request_mem_region        */
#include <linux/smbno.h>        /* Fuer z.B. SUCCESS */
#include <linux/major.h>        /* Fuer  */
#include <linux/fs.h>           /* Fuer z.B. struct file_operation */
#include <linux/types.h>        /* u16, u32 and such */
// #include <linux/slab.h>              /* Fuer z.B. kmalloc, kfree */





/* Lokale Funtionen */
static loff_t bsp0_llseek (struct file *filp, loff_t ppos, int origin);
static ssize_t bsp0_read (struct file *filp, char *buf, size_t count, loff_t * 
ppos);
static ssize_t bsp0_write (struct file *filp, const char *buf, size_t count, 
loff_t * ppos);
static int bsp0_ioctl (struct inode *inode, struct file *filp, unsigned int 
iocmd, unsigned long ioarg);
static int bsp0_open (struct inode *inode, struct file *filp);
static int bsp0_close (struct inode *inode, struct file *filp);





// macro for resetting the grey decoder variables (above) in a stationary 
position




struct file_operations bsp0_fops = {
llseek:bsp0_llseek,
read:bsp0_read,
write:bsp0_write,
open:bsp0_open,
release:bsp0_close,
ioctl:bsp0_ioctl,
};




/*
 * close access to the bsp0
  */
static int
bsp0_close (struct inode *inode, struct file *filp)
{


  MOD_DEC_USE_COUNT;

  return (0);
}



void
cleanup_module (void)
{


  return;
}



        // init static int __init
int
init_module (void)
{
  return 0;
}


          // read access from user space
static ssize_t
bsp0_read (struct file *filp, char *buf, size_t count, loff_t * ppos)
{
  //  unsigned long flags;


  union u_tag
  {
    s32 si_value;               // caution with the member name si_value: gcc 
warns with no semicolon at end of struct or union
    u32 ui_value;
  } *u_value =
  {
  (void *) buf};                // correct cast

  return (count);
}                               /* ..end of bsp0_read.    */


                              // write: >=1 int: reset grey decoder, >=2: set 
position to zero
static ssize_t
bsp0_write (struct file *filp, const char *buf, size_t count, loff_t * ppos)
{

  return (0);
}                               /* ..end of bsp0_write.   */


static loff_t
bsp0_llseek (struct file *filp, loff_t ppos, int origin)
{

  return (-EINVAL);             /* Fehler -> zurueck.           */
}                               /* ..end of bsp0_lseek.   */


static int
bsp0_ioctl (struct inode *inode, struct file *filp, unsigned int iocmd, unsigned 
long ioarg)
{

  return (-EINVAL);             /* Fehler -> zurueck.           */
}                               /* ..end of bsp0_ioctl.   */


static int
bsp0_open (struct inode *inode, struct file *filp)
{

  return (0);
}                               /* ..end of bsp0_open.    */

-- 
           Summary: variable name si_value causes strange errors; sivalue
                    and ui_value not
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nobodyo at web dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.3.1
  GCC host triplet: 3.3.1
GCC target triplet: 3.3.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14265


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