[gnu.gcc] Patches to GCC for shared and private storage class modifiers

brooks@maddog.llnl.gov (09/20/89)

Here is a revised set of patches to GCC 1.35 for shared and private
keyword support.  Error checking for the use of the keywords is
included.  If anyone tries these out and finds problems with
them I would like to hear about it.

These patches are hereby placed in the public domain.

*** /tmp/,RCSt1a05659	Tue Sep 19 19:32:52 1989
--- c-decl.c	Mon Sep 18 12:50:35 1989
***************
*** 2204,2210
      if (specbits & 1 << (int) RID_STATIC) nclasses++;
      if (specbits & 1 << (int) RID_EXTERN) nclasses++;
      if (specbits & 1 << (int) RID_REGISTER) nclasses++;
!     if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
  
      /* Warn about storage classes that are invalid for certain
         kinds of declarations (parameters, typenames, etc.).  */

--- 2204,2210 -----
      if (specbits & 1 << (int) RID_STATIC) nclasses++;
      if (specbits & 1 << (int) RID_EXTERN) nclasses++;
      if (specbits & 1 << (int) RID_REGISTER) nclasses++;
!     if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;    
  
      if ( (specbits & 1<< (int) RID_AUTO) && (specbits & 1 << (int) RID_SHARED))
        {
***************
*** 2206,2211
      if (specbits & 1 << (int) RID_REGISTER) nclasses++;
      if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
  
      /* Warn about storage classes that are invalid for certain
         kinds of declarations (parameters, typenames, etc.).  */
  

--- 2206,2241 -----
      if (specbits & 1 << (int) RID_REGISTER) nclasses++;
      if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;    
  
+     if ( (specbits & 1<< (int) RID_AUTO) && (specbits & 1 << (int) RID_SHARED))
+       {
+       error("cannot share automatic variable '%s'",name);
+       specbits &= ~(1 << (int) RID_SHARED);
+       }
+ 
+     if((specbits & 1<<(int)RID_REGISTER) && (specbits & 1<<(int)RID_SHARED))
+       {
+       error("cannot share register variable '%s'",name);
+       specbits &= ~(1 << (int) RID_SHARED);
+       }
+ 
+     if((specbits & 1<<(int)RID_PRIVATE) && (specbits & 1<<(int)RID_SHARED))
+       {
+       error("cannot share private variable '%s'",name);
+       specbits &= ~(1 << (int) RID_SHARED);
+       }
+ 
+     if((specbits & 1<<(int)RID_EXTERN) && (specbits & 1<<(int)RID_SHARED))
+       {
+       error("cannot declare external variable '%s' as shared",name);
+       specbits &= ~(1 << (int) RID_SHARED);
+       }
+ 
+     if((specbits & 1<<(int)RID_TYPEDEF) && (specbits & 1<<(int)RID_SHARED))
+       {
+       error("cannot declare typedef '%s' as shared",name);
+       specbits &= ~(1 << (int) RID_SHARED);
+       }
+ 
      /* Warn about storage classes that are invalid for certain
         kinds of declarations (parameters, typenames, etc.).  */
  
***************
*** 2508,2514
  	  type = build_pointer_type (type);
  
  	decl = build_decl (PARM_DECL, declarator, type);
! 
  	/* Compute the type actually passed in the parmlist,
  	   for the case where there is no prototype.
  	   (For example, shorts and chars are passed as ints.)

--- 2538,2545 -----
  	  type = build_pointer_type (type);
  
  	decl = build_decl (PARM_DECL, declarator, type);
! 	if(specbits & (1<<(int) RID_SHARED))
! 	  error("cannot declare function parameter '%s' as shared",name);
  	/* Compute the type actually passed in the parmlist,
  	   for the case where there is no prototype.
  	   (For example, shorts and chars are passed as ints.)
***************
*** 2580,2585
  	if (inlinep)
  	  warning_with_decl (decl, "variable `%s' declared `inline'");
  
  	/* An uninitialized decl with `extern' is a reference.  */
  	TREE_EXTERNAL (decl)
  	  = !initialized && (specbits & (1 << (int) RID_EXTERN));

--- 2611,2618 -----
  	if (inlinep)
  	  warning_with_decl (decl, "variable `%s' declared `inline'");
  
+ 
+ 
  	/* An uninitialized decl with `extern' is a reference.  */
  	TREE_EXTERNAL (decl)
  	  = !initialized && (specbits & (1 << (int) RID_EXTERN));
***************
*** 2586,2592
  	/* At top level, either `static' or no s.c. makes a definition
  	   (perhaps tentative), and absence of `static' makes it public.  */
  	if (current_binding_level == global_binding_level)
! 	  {
  	    TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC));
  	    TREE_STATIC (decl) = ! TREE_EXTERNAL (decl);
  	  }

--- 2619,2625 -----
  	/* At top level, either `static' or no s.c. makes a definition
  	   (perhaps tentative), and absence of `static' makes it public.  */
  	if (current_binding_level == global_binding_level)
! 	    {
  	    TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC));
  	    TREE_STATIC (decl) = ! TREE_EXTERNAL (decl);
  	    }
***************
*** 2589,2595
  	  {
  	    TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC));
  	    TREE_STATIC (decl) = ! TREE_EXTERNAL (decl);
! 	  }
  	/* Not at top level, only `static' makes a static definition.  */
  	else
  	  {

--- 2622,2628 -----
  	    {
  	    TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC));
  	    TREE_STATIC (decl) = ! TREE_EXTERNAL (decl);
! 	    }
  	/* Not at top level, only `static' makes a static definition.  */
  	else
              {
***************
*** 2592,2598
  	  }
  	/* Not at top level, only `static' makes a static definition.  */
  	else
! 	  {
  	    TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
  	    TREE_PUBLIC (decl) = TREE_EXTERNAL (decl);
  	    /* `extern' with initialization is invalid if not at top level.  */

--- 2625,2631 -----
  	    }
  	/* Not at top level, only `static' makes a static definition.  */
  	else
!             {
  	    TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
  	    TREE_PUBLIC (decl) = TREE_EXTERNAL (decl);
  	    /* `extern' with initialization is invalid if not at top level.  */
***************
*** 2598,2605
  	    /* `extern' with initialization is invalid if not at top level.  */
  	    if ((specbits & (1 << (int) RID_EXTERN)) && initialized)
  	      error ("`%s' has both `extern' and initializer", name);
! 	  }
!       }
  
      /* Record `register' declaration for warnings on &
         and in case doing stupid register allocation.  */

--- 2631,2646 -----
  	    /* `extern' with initialization is invalid if not at top level.  */
  	    if ((specbits & (1 << (int) RID_EXTERN)) && initialized)
  	      error ("`%s' has both `extern' and initializer", name);
! 	    /* give error if attempt is made to share non-static variable. */
! 	    if( (specbits & 1 << (int) RID_SHARED) && !(TREE_STATIC (decl)) )
! 	      error ("cannot share non-static variable '%s'", name);
! 	    }
! 	/* determine whether the variable should be tagged 'shared' */
! 	TREE_SHARED (decl) = flag_shared_data && TREE_STATIC (decl);
! 	if( specbits & (1 << (int) RID_SHARED)) TREE_SHARED (decl) = 1; 
!         if( specbits & (1 << (int) RID_PRIVATE)) TREE_SHARED (decl) = 0;
! 	}
! 
  
      /* Record `register' declaration for warnings on &
         and in case doing stupid register allocation.  */
*** /tmp/,RCSt1a05664	Tue Sep 19 19:33:03 1989
--- c-parse.h	Mon Sep 18 12:51:40 1989
***************
*** 42,47
    RID_VOLATILE,
    RID_INLINE,
    RID_NOALIAS,
  
    RID_MAX,
  };

--- 42,49 -----
    RID_VOLATILE,
    RID_INLINE,
    RID_NOALIAS,
+   RID_PRIVATE,
+   RID_SHARED,
  
    RID_MAX,
  };
*** /tmp/,RCSt1a05669	Tue Sep 19 19:33:11 1989
--- c-parse.y	Mon Sep 18 12:51:56 1989
***************
*** 1318,1327
  /* Data type that represents the GNU C reserved words. */
  struct resword { char *name; short token; enum rid rid; };
  
- #define MIN_WORD_LENGTH     2      /* minimum size for C keyword */
- #define MAX_WORD_LENGTH     9      /* maximum size for C keyword */
- #define MIN_HASH_VALUE      4      /* range of the hash keys values  */
- #define MAX_HASH_VALUE      52     /* for the perfect hash generator */
  #define NORID RID_UNUSED
  
  /* This function performs the minimum-perfect hash mapping from input

--- 1318,1323 -----
  /* Data type that represents the GNU C reserved words. */
  struct resword { char *name; short token; enum rid rid; };
  
  #define NORID RID_UNUSED
  #define MIN_WORD_LENGTH 2
  #define MAX_WORD_LENGTH 10
***************
*** 1323,1329
  #define MIN_HASH_VALUE      4      /* range of the hash keys values  */
  #define MAX_HASH_VALUE      52     /* for the perfect hash generator */
  #define NORID RID_UNUSED
! 
  /* This function performs the minimum-perfect hash mapping from input
     string to reswords table index.  It only looks at the first and 
     last characters in the string, thus assuring the O(1) lookup time 

--- 1319,1332 -----
  struct resword { char *name; short token; enum rid rid; };
  
  #define NORID RID_UNUSED
! #define MIN_WORD_LENGTH 2
! #define MAX_WORD_LENGTH 10
! #define MIN_HASH_VALUE 6
! #define MAX_HASH_VALUE 63
! /*
!    43 keywords
!    58 is the maximum key range
! */
  /* This function performs the minimum-perfect hash mapping from input
     string to reswords table index.  It only looks at the first and 
     last characters in the string, thus assuring the O(1) lookup time 
***************
*** 1351,1369
  
    static int hash_table[] = 
      {
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,  52,  52,  52,  52,  52,
!       52,  52,  52,  52,  52,   7,  52,  12,   0,  18,
!        5,   0,  13,   2,   2,  29,  52,   0,   7,  37,
!       25,   0,  52,  52,  17,  19,   0,  21,   1,   3,
!       52,  52,  52,  52,  52,  52,  52,  52,
      };
  
    /* The hash function is very simple: add the length of STR

--- 1354,1372 -----
  
    static int hash_table[] = 
      {
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
!      63, 63, 63, 63, 63,  0, 63, 31, 23, 10,
!      30,  0,  3, 16,  4, 15, 63,  0, 18, 29,
!      10,  0,  3, 63, 11,  0,  0,  0, 25,  4,
!       3, 32, 63, 63, 63, 63, 63, 63,
      };
  
    /* The hash function is very simple: add the length of STR
***************
*** 1371,1377
       Putting LEN near LEN - 1 generates slightly better 
       code... */
  
!   return len + hash_table[str[len - 1]] + hash_table[str[0]];
  }
  
  /* This routine attempts to match the string found in the reswords table

--- 1374,1380 -----
       Putting LEN near LEN - 1 generates slightly better 
       code... */
  
!   return len + hash_table[str[1]] + hash_table[str[0]] + hash_table[str[len - 1]];
  }
  
  /* This routine attempts to match the string found in the reswords table
***************
*** 1397,1449
  
    static struct resword reswords[] = 
      {
!       { "",},{ "",},{ "",},{ "",},
!       { "else", ELSE, NORID },
!       { "break", BREAK, NORID },
!       { "goto", GOTO, NORID },
!       { "do", DO, NORID },
!       { "while", WHILE, NORID },
!       { "volatile", TYPE_QUAL, RID_VOLATILE },
!       { "void", TYPESPEC, RID_VOID },
!       { "double", TYPESPEC, RID_DOUBLE },
!       { "default", DEFAULT, NORID },
!       { "long", TYPESPEC, RID_LONG },
!       { "__const", TYPE_QUAL, RID_CONST },
!       { "__inline", SCSPEC, RID_INLINE },
!       { "auto", SCSPEC, RID_AUTO },
!       { "__volatile", TYPE_QUAL, RID_VOLATILE },
!       { "float", TYPESPEC, RID_FLOAT },
!       { "typeof", TYPEOF, NORID },
!       { "typedef", SCSPEC, RID_TYPEDEF },
!       { "",},
!       { "case", CASE, NORID },
!       { "const", TYPE_QUAL, RID_CONST },
!       { "short", TYPESPEC, RID_SHORT },
!       { "struct", STRUCT, NORID },
!       { "continue", CONTINUE, NORID },
!       { "switch", SWITCH, NORID },
!       { "__typeof", TYPEOF, NORID },
!       { "__alignof", ALIGNOF, NORID },
!       { "signed", TYPESPEC, RID_SIGNED },
!       { "extern", SCSPEC, RID_EXTERN },
!       { "int", TYPESPEC, RID_INT },
!       { "for", FOR, NORID },
!       { "unsigned", TYPESPEC, RID_UNSIGNED },
!       { "inline", SCSPEC, RID_INLINE },
!       { "",},{ "",},
!       { "sizeof", SIZEOF, NORID },
!       { "char", TYPESPEC, RID_CHAR },
!       { "",},
!       { "enum", ENUM, NORID },
!       { "register", SCSPEC, RID_REGISTER },
!       { "static", SCSPEC, RID_STATIC },
!       { "if", IF, NORID },
!       { "",},{ "",},{ "",},
!       { "return", RETURN, NORID },
!       { "__asm", ASM, NORID },
!       { "",},
!       { "union", UNION, NORID },
!       { "asm", ASM, NORID },
      };
  
    if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 

--- 1400,1454 -----
  
    static struct resword reswords[] = 
      {
!       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
!       {"struct",  STRUCT, NORID ,},
!       {"__const",  TYPE_QUAL, RID_CONST ,},
!       {"__inline",  SCSPEC, RID_INLINE ,},
!       {"short",  TYPESPEC, RID_SHORT ,},
!       {"__volatile",  TYPE_QUAL, RID_VOLATILE ,},
!       {"__typeof",  TYPEOF, NORID ,},
!       {"__alignof",  ALIGNOF, NORID ,},
!       {"while",  WHILE, NORID ,},
!       {"switch",  SWITCH, NORID ,},
!       {"const",  TYPE_QUAL, RID_CONST ,},
!       {"static",  SCSPEC, RID_STATIC ,},
!       {"for",  FOR, NORID ,},
!       {"continue",  CONTINUE, NORID ,},
!       {"extern",  SCSPEC, RID_EXTERN ,},
!       {"goto",  GOTO, NORID ,},
!       {"private",  SCSPEC, RID_PRIVATE,},
!       {"else",  ELSE, NORID ,},
!       {"if",  IF, NORID ,},
!       {"sizeof",  SIZEOF, NORID ,},
!       {"union",  UNION, NORID ,},
!       {"float",  TYPESPEC, RID_FLOAT ,},
!       {"return",  RETURN, NORID ,},
!       {"int",  TYPESPEC, RID_INT ,},
!       {"char",  TYPESPEC, RID_CHAR ,},
!       {"register",  SCSPEC, RID_REGISTER ,},
!       {"inline",  SCSPEC, RID_INLINE ,},
!       {"do",  DO, NORID ,},
!       {"volatile",  TYPE_QUAL, RID_VOLATILE ,},
!       {"__asm",  ASM, NORID ,},
!       {"auto",  SCSPEC, RID_AUTO ,},
!       {"double",  TYPESPEC, RID_DOUBLE ,},
!       {"default",  DEFAULT, NORID ,},
!       {"long",  TYPESPEC, RID_LONG ,},
!       {"break",  BREAK, NORID ,},
!       {"shared",  SCSPEC, RID_SHARED,},
!       {"typeof",  TYPEOF, NORID ,},
!       {"typedef",  SCSPEC, RID_TYPEDEF ,},
!       {"enum",  ENUM, NORID ,},
!       {"",}, 
!       {"case",  CASE, NORID ,},
!       {"",}, {"",}, 
!       {"unsigned",  TYPESPEC, RID_UNSIGNED ,},
!       {"",}, {"",}, 
!       {"signed",  TYPESPEC, RID_SIGNED ,},
!       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
!       {"void",  TYPESPEC, RID_VOID ,},
!       {"",}, {"",}, {"",}, 
!       {"asm",  ASM, NORID ,},
      };
  
    if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 
***************
*** 1498,1503
    ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
    ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
    ridpointers[(int) RID_REGISTER] = get_identifier ("register");
  }
  
  static void

--- 1503,1510 -----
    ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
    ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
    ridpointers[(int) RID_REGISTER] = get_identifier ("register");
+   ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
+   ridpointers[(int) RID_SHARED] = get_identifier ("shared");
  }
  
  static void
*** /tmp/,RCSt1a05674	Tue Sep 19 19:33:20 1989
--- print-tree.c	Mon Sep 18 12:48:14 1989
***************
*** 270,275
        fputs ("lang_flag_4", outfile);
        first = 0;
      }
    fputs ("] ", outfile);
  }
  

--- 270,281 -----
        fputs ("lang_flag_4", outfile);
        first = 0;
      }
+   if (TREE_SHARED (node))
+     {
+       if (!first) putc (' ', outfile);
+       fputs ("shared", outfile);
+       first = 0;
+     }
    fputs ("] ", outfile);
  }
  
*** /tmp/,RCSt1a05679	Tue Sep 19 19:33:25 1989
--- tree.h	Mon Sep 18 12:51:22 1989
***************
*** 146,151
    unsigned asm_written_attr: 1;
    unsigned inline_attr : 1;
    unsigned used_attr : 1;
    unsigned lang_flag_1 : 1;
    unsigned lang_flag_2 : 1;
    unsigned lang_flag_3 : 1;

--- 146,152 -----
    unsigned asm_written_attr: 1;
    unsigned inline_attr : 1;
    unsigned used_attr : 1;
+   unsigned shared_attr : 1;
    unsigned lang_flag_1 : 1;
    unsigned lang_flag_2 : 1;
    unsigned lang_flag_3 : 1;
***************
*** 150,156
    unsigned lang_flag_2 : 1;
    unsigned lang_flag_3 : 1;
    unsigned lang_flag_4 : 1;
!   /* There is room for four more attributes.  */
  };
  
  /* Define accessors for the fields that all tree nodes have

--- 151,157 -----
    unsigned lang_flag_2 : 1;
    unsigned lang_flag_3 : 1;
    unsigned lang_flag_4 : 1;
!   /* There is room for three more attributes.  */
  };
  
  /* Define accessors for the fields that all tree nodes have
***************
*** 272,277
  
  /* Nonzero in a _DECL if the name is used in its scope.  */
  #define TREE_USED(NODE) ((NODE)->common.used_attr)
  
  #define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1)
  #define TREE_LANG_FLAG_2(NODE) ((NODE)->common.lang_flag_2)

--- 273,281 -----
  
  /* Nonzero in a _DECL if the name is used in its scope.  */
  #define TREE_USED(NODE) ((NODE)->common.used_attr)
+ 
+ /* Nonzero in a _DECL if it is to be SHARED data. */
+ #define TREE_SHARED(NODE) ((NODE)->common.shared_attr)
  
  #define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1)
  #define TREE_LANG_FLAG_2(NODE) ((NODE)->common.lang_flag_2)
*** /tmp/,RCSt1a05684	Tue Sep 19 19:33:34 1989
--- varasm.c	Mon Sep 18 12:49:21 1989
***************
*** 38,43
  
  #define MIN(a, b) ((a) < (b) ? (a) : (b))
  
  /* File in which assembler code is being written.  */
  
  extern FILE *asm_out_file;

--- 38,44 -----
  
  #define MIN(a, b) ((a) < (b) ? (a) : (b))
  
+ 
  /* File in which assembler code is being written.  */
  
  extern FILE *asm_out_file;
***************
*** 70,76
  void output_constant ();
  void output_constructor ();
  
! static enum in_section {no_section, in_text, in_data} in_section = no_section;
  
  /* Tell assembler to switch to text section.  */
  

--- 71,77 -----
  void output_constant ();
  void output_constructor ();
  
! static enum in_section {no_section, in_text, in_data, in_shared_data} in_section = no_section;
  
  /* Tell assembler to switch to text section.  */
  
***************
*** 87,93
  /* Tell assembler to switch to data section.  */
  
  void
! data_section ()
  {
    if (in_section != in_data)
      {

--- 88,94 -----
  /* Tell assembler to switch to data section.  */
  
  void
! shared_data_section()
  {
     if(in_section != in_shared_data) {
  #ifdef SHARED_SECTION_ASM_OP
***************
*** 89,98
  void
  data_section ()
  {
!   if (in_section != in_data)
!     {
!       if (flag_shared_data)
! 	{
  #ifdef SHARED_SECTION_ASM_OP
  	  fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else

--- 90,96 -----
  void
  shared_data_section()
  {
!    if(in_section != in_shared_data) {
  #ifdef SHARED_SECTION_ASM_OP
        fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else
***************
*** 94,100
        if (flag_shared_data)
  	{
  #ifdef SHARED_SECTION_ASM_OP
! 	  fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else
  	  fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif

--- 92,98 -----
  {
     if(in_section != in_shared_data) {
  #ifdef SHARED_SECTION_ASM_OP
!       fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else
        fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif
***************
*** 96,102
  #ifdef SHARED_SECTION_ASM_OP
  	  fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else
! 	  fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif
  	}
        else

--- 94,100 -----
  #ifdef SHARED_SECTION_ASM_OP
        fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  #else
!       fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif
        in_section = in_shared_data;
     }
***************
*** 98,106
  #else
  	  fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif
! 	}
!       else
! 	fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  
        in_section = in_data;
      }

--- 96,104 -----
  #else
        fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  #endif
!       in_section = in_shared_data;
!    }
! }
  
  void
  data_section ()
***************
*** 102,107
        else
  	fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  
        in_section = in_data;
      }
  }

--- 100,111 -----
     }
  }
  
+ void
+ data_section ()
+ {
+   if (in_section != in_data)
+     {
+       fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
        in_section = in_data;
      }
  }
***************
*** 472,483
        rounded = ((rounded + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  		 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  		 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
!       if (flag_shared_data)
! 	data_section ();
!       if (TREE_PUBLIC (decl))
! 	ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
!       else
! 	ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
        return;
      }
  

--- 476,505 -----
        rounded = ((rounded + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  		 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  		 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
!       if (TREE_PUBLIC (decl)) {
!            if (TREE_SHARED (decl)) {
! #ifdef SHARED_ASM_OUTPUT_COMMON
!                 SHARED_ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
! #else
! 	                ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);          
! #endif
!                 }
!            else {
!                 ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
!                 }
! 	   }
!       else {
!             if (TREE_SHARED (decl)) {
! #ifdef SHARED_ASM_OUTPUT_LOCAL
!                  SHARED_ASM_OUTPUT_LOCAL(asm_out_file, name, size, rounded);
! #else
!                  ASM_OUTPUT_LOCAL(asm_out_file, name, size, rounded);           
! #endif
!                  }
!             else {
!                  ASM_OUTPUT_LOCAL(asm_out_file, name, size, rounded);
!                  }
!             }
        return;
      }
  
***************
*** 503,510
    /* Switch to the proper section for this data.  */
    if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl))
      text_section ();
!   else
!     data_section ();
  
    /* Output the alignment of this data.  */
    for (i = 0; DECL_ALIGN (decl) >= BITS_PER_UNIT << (i + 1); i++);

--- 525,534 -----
    /* Switch to the proper section for this data.  */
    if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl))
      text_section ();
!   else {
!      if (TREE_SHARED (decl)) shared_data_section();
!      else data_section ();
!      }
  
    /* Output the alignment of this data.  */
    for (i = 0; DECL_ALIGN (decl) >= BITS_PER_UNIT << (i + 1); i++);
***************
*** 579,586
  		 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  		 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  
!   if (flag_shared_data)
!     data_section ();
    ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
    ++const_labelno;
  

--- 603,610 -----
  		 / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  		 * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  
!   /* if (flag_shared_data)
!     data_section (); */
    ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
    ++const_labelno;
  
brooks@maddog.llnl.gov, brooks@maddog.uucp