Attachment 'C11atomic3.patch'

Download

   1 Index: gcc/c-family/c-common.h
   2 ===================================================================
   3 *** gcc/c-family/c-common.h	(revision 202709)
   4 --- gcc/c-family/c-common.h	(working copy)
   5 *************** enum rid
   6 *** 66,72 ****
   7     RID_UNSIGNED, RID_LONG,    RID_CONST, RID_EXTERN,
   8     RID_REGISTER, RID_TYPEDEF, RID_SHORT, RID_INLINE,
   9     RID_VOLATILE, RID_SIGNED,  RID_AUTO,  RID_RESTRICT,
  10 !   RID_NORETURN,
  11   
  12     /* C extensions */
  13     RID_COMPLEX, RID_THREAD, RID_SAT,
  14 --- 66,72 ----
  15     RID_UNSIGNED, RID_LONG,    RID_CONST, RID_EXTERN,
  16     RID_REGISTER, RID_TYPEDEF, RID_SHORT, RID_INLINE,
  17     RID_VOLATILE, RID_SIGNED,  RID_AUTO,  RID_RESTRICT,
  18 !   RID_NORETURN, RID_ATOMIC,
  19   
  20     /* C extensions */
  21     RID_COMPLEX, RID_THREAD, RID_SAT,
  22 Index: gcc/c-family/c-common.c
  23 ===================================================================
  24 *** gcc/c-family/c-common.c	(revision 202709)
  25 --- gcc/c-family/c-common.c	(working copy)
  26 *************** static tree handle_unused_attribute (tre
  27 *** 327,332 ****
  28 --- 327,333 ----
  29   static tree handle_externally_visible_attribute (tree *, tree, tree, int,
  30   						 bool *);
  31   static tree handle_const_attribute (tree *, tree, tree, int, bool *);
  32 + static tree handle_atomic_attribute (tree *, tree, tree, int, bool *);
  33   static tree handle_transparent_union_attribute (tree *, tree, tree,
  34   						int, bool *);
  35   static tree handle_constructor_attribute (tree *, tree, tree, int, bool *);
  36 *************** const struct c_common_resword c_common_r
  37 *** 403,408 ****
  38 --- 404,410 ----
  39   {
  40     { "_Alignas",		RID_ALIGNAS,   D_CONLY },
  41     { "_Alignof",		RID_ALIGNOF,   D_CONLY },
  42 +   { "_Atomic",		RID_ATOMIC,    D_CONLY },
  43     { "_Bool",		RID_BOOL,      D_CONLY },
  44     { "_Complex",		RID_COMPLEX,	0 },
  45     { "_Imaginary",	RID_IMAGINARY, D_CONLY },
  46 *************** const struct attribute_spec c_common_att
  47 *** 639,644 ****
  48 --- 641,648 ----
  49     /* The same comments as for noreturn attributes apply to const ones.  */
  50     { "const",                  0, 0, true,  false, false,
  51   			      handle_const_attribute, false },
  52 +   { "atomic",		      0, 0, false, true, false,
  53 + 			      handle_atomic_attribute, false},
  54     { "transparent_union",      0, 0, false, false, false,
  55   			      handle_transparent_union_attribute, false },
  56     { "constructor",            0, 1, true,  false, false,
  57 *************** handle_const_attribute (tree *node, tree
  58 *** 6888,6893 ****
  59 --- 6892,6926 ----
  60     return NULL_TREE;
  61   }
  62   
  63 + 
  64 + /* Handle an "atomic" attribute; arguments as in
  65 +    struct attribute_spec.handler.  */
  66 + 
  67 + static tree
  68 + handle_atomic_attribute (tree *node, tree name, tree ARG_UNUSED (args),
  69 + 			int ARG_UNUSED (flags), bool *no_add_attrs)
  70 + {
  71 +   bool ignored = true;
  72 +   if (TYPE_P (*node) && TREE_CODE (*node) != ARRAY_TYPE)
  73 +     {
  74 +       tree type = *node;
  75 + 
  76 +       if (!TYPE_ATOMIC (type))
  77 + 	{
  78 + 	  *node = build_qualified_type (type, 
  79 + 					(TYPE_QUALS (type) | TYPE_QUAL_ATOMIC));
  80 + 	  ignored = false;
  81 + 	}
  82 +     }
  83 + 
  84 +   if (ignored)
  85 +     {
  86 +       warning (OPT_Wattributes, "%qE attribute ignored", name);
  87 +       *no_add_attrs = true;
  88 +     }
  89 +   return NULL_TREE;
  90 + }
  91 + 
  92   /* Handle a "transparent_union" attribute; arguments as in
  93      struct attribute_spec.handler.  */
  94   
  95 *************** sync_resolve_params (location_t loc, tre
  96 *** 10075,10080 ****
  97 --- 10108,10114 ----
  98        call to check_function_arguments what ever type the user used.  */
  99     function_args_iter_next (&iter);
 100     ptype = TREE_TYPE (TREE_TYPE ((*params)[0]));
 101 +   ptype = TYPE_MAIN_VARIANT (ptype);
 102   
 103     /* For the rest of the values, we need to cast these to FTYPE, so that we
 104        don't get warnings for passing pointer types, etc.  */
 105 *************** keyword_is_type_qualifier (enum rid keyw
 106 *** 11471,11476 ****
 107 --- 11505,11511 ----
 108       case RID_CONST:
 109       case RID_VOLATILE:
 110       case RID_RESTRICT:
 111 +     case RID_ATOMIC:
 112         return true;
 113       default:
 114         return false;
 115 Index: gcc/c-family/c-format.c
 116 ===================================================================
 117 *** gcc/c-family/c-format.c	(revision 202709)
 118 --- gcc/c-family/c-format.c	(working copy)
 119 *************** check_format_types (format_wanted_type *
 120 *** 2374,2379 ****
 121 --- 2374,2380 ----
 122   		  && pedantic
 123   		  && (TYPE_READONLY (cur_type)
 124   		      || TYPE_VOLATILE (cur_type)
 125 + 		      || TYPE_ATOMIC (cur_type)
 126   		      || TYPE_RESTRICT (cur_type)))
 127   		warning (OPT_Wformat_, "extra type qualifiers in format "
 128   			 "argument (argument %d)",
 129 Index: gcc/c-family/c-pretty-print.c
 130 ===================================================================
 131 *** gcc/c-family/c-pretty-print.c	(revision 202709)
 132 --- gcc/c-family/c-pretty-print.c	(working copy)
 133 *************** pp_c_cv_qualifiers (c_pretty_printer *pp
 134 *** 179,186 ****
 135 --- 179,194 ----
 136     if (p != NULL && (*p == '*' || *p == '&'))
 137       pp_c_whitespace (pp);
 138   
 139 +   if (qualifiers & TYPE_QUAL_ATOMIC)
 140 +     {
 141 +       pp_c_ws_string (pp, func_type ? "__attribute__((atomic))" : "_Atomic");
 142 +       previous = true;
 143 +     }
 144 + 
 145     if (qualifiers & TYPE_QUAL_CONST)
 146       {
 147 +       if (previous)
 148 +         pp_c_whitespace (pp);
 149         pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const");
 150         previous = true;
 151       }
 152 Index: gcc/c/c-aux-info.c
 153 ===================================================================
 154 *** gcc/c/c-aux-info.c	(revision 202709)
 155 --- gcc/c/c-aux-info.c	(working copy)
 156 *************** gen_type (const char *ret_val, tree t, f
 157 *** 285,290 ****
 158 --- 285,292 ----
 159         switch (TREE_CODE (t))
 160   	{
 161   	case POINTER_TYPE:
 162 + 	  if (TYPE_ATOMIC (t))
 163 + 	    ret_val = concat ("_Atomic ", ret_val, NULL);
 164   	  if (TYPE_READONLY (t))
 165   	    ret_val = concat ("const ", ret_val, NULL);
 166   	  if (TYPE_VOLATILE (t))
 167 *************** gen_type (const char *ret_val, tree t, f
 168 *** 425,430 ****
 169 --- 427,434 ----
 170   	  gcc_unreachable ();
 171   	}
 172       }
 173 +   if (TYPE_ATOMIC (t))
 174 +     ret_val = concat ("_Atomic ", ret_val, NULL);
 175     if (TYPE_READONLY (t))
 176       ret_val = concat ("const ", ret_val, NULL);
 177     if (TYPE_VOLATILE (t))
 178 Index: gcc/c/c-typeck.c
 179 ===================================================================
 180 *** gcc/c/c-typeck.c	(revision 202709)
 181 --- gcc/c/c-typeck.c	(working copy)
 182 *************** convert_for_assignment (location_t locat
 183 *** 5588,5595 ****
 184   	  else if (TREE_CODE (ttr) != FUNCTION_TYPE
 185   		   && TREE_CODE (ttl) != FUNCTION_TYPE)
 186   	    {
 187 ! 	      if (TYPE_QUALS_NO_ADDR_SPACE (ttr)
 188 ! 		  & ~TYPE_QUALS_NO_ADDR_SPACE (ttl))
 189   		{
 190   		  WARN_FOR_QUALIFIERS (location, 0,
 191   				       G_("passing argument %d of %qE discards "
 192 --- 5588,5596 ----
 193   	  else if (TREE_CODE (ttr) != FUNCTION_TYPE
 194   		   && TREE_CODE (ttl) != FUNCTION_TYPE)
 195   	    {
 196 ! 	      /* Assignments between atomic and non-atomic objects are OK.  */
 197 ! 	      if (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttr)
 198 ! 		  & ~TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC (ttl))
 199   		{
 200   		  WARN_FOR_QUALIFIERS (location, 0,
 201   				       G_("passing argument %d of %qE discards "
 202 Index: gcc/c/c-tree.h
 203 ===================================================================
 204 *** gcc/c/c-tree.h	(revision 202709)
 205 --- gcc/c/c-tree.h	(working copy)
 206 *************** struct c_declspecs {
 207 *** 328,333 ****
 208 --- 328,335 ----
 209     BOOL_BITFIELD volatile_p : 1;
 210     /* Whether "restrict" was specified.  */
 211     BOOL_BITFIELD restrict_p : 1;
 212 +   /* Whether "_Atomic" was specified.  */
 213 +   BOOL_BITFIELD atomic_p : 1;
 214     /* Whether "_Sat" was specified.  */
 215     BOOL_BITFIELD saturating_p : 1;
 216     /* Whether any alignment specifier (even with zero alignment) was
 217 Index: gcc/c/c-decl.c
 218 ===================================================================
 219 *** gcc/c/c-decl.c	(revision 202709)
 220 --- gcc/c/c-decl.c	(working copy)
 221 *************** shadow_tag_warned (const struct c_declsp
 222 *** 3709,3714 ****
 223 --- 3709,3715 ----
 224                      && declspecs->typespec_kind != ctsk_tagfirstref
 225   		   && (declspecs->const_p
 226   		       || declspecs->volatile_p
 227 + 		       || declspecs->atomic_p
 228   		       || declspecs->restrict_p
 229   		       || declspecs->address_space))
 230   	    {
 231 *************** shadow_tag_warned (const struct c_declsp
 232 *** 3798,3803 ****
 233 --- 3799,3805 ----
 234   
 235     if (!warned && !in_system_header && (declspecs->const_p
 236   				       || declspecs->volatile_p
 237 + 				       || declspecs->atomic_p
 238   				       || declspecs->restrict_p
 239   				       || declspecs->address_space))
 240       {
 241 *************** quals_from_declspecs (const struct c_dec
 242 *** 3829,3834 ****
 243 --- 3831,3837 ----
 244     int quals = ((specs->const_p ? TYPE_QUAL_CONST : 0)
 245   	       | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0)
 246   	       | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0)
 247 + 	       | (specs->atomic_p ? TYPE_QUAL_ATOMIC : 0)
 248   	       | (ENCODE_QUAL_ADDR_SPACE (specs->address_space)));
 249     gcc_assert (!specs->type
 250   	      && !specs->decl_attr
 251 *************** grokdeclarator (const struct c_declarato
 252 *** 4908,4913 ****
 253 --- 4911,4917 ----
 254     int constp;
 255     int restrictp;
 256     int volatilep;
 257 +   int atomicp;
 258     int type_quals = TYPE_UNQUALIFIED;
 259     tree name = NULL_TREE;
 260     bool funcdef_flag = false;
 261 *************** grokdeclarator (const struct c_declarato
 262 *** 5062,5067 ****
 263 --- 5066,5072 ----
 264     constp = declspecs->const_p + TYPE_READONLY (element_type);
 265     restrictp = declspecs->restrict_p + TYPE_RESTRICT (element_type);
 266     volatilep = declspecs->volatile_p + TYPE_VOLATILE (element_type);
 267 +   atomicp = declspecs->atomic_p + TYPE_ATOMIC (element_type);
 268     as1 = declspecs->address_space;
 269     as2 = TYPE_ADDR_SPACE (element_type);
 270     address_space = ADDR_SPACE_GENERIC_P (as1)? as2 : as1;
 271 *************** grokdeclarator (const struct c_declarato
 272 *** 5074,5079 ****
 273 --- 5079,5087 ----
 274   	pedwarn (loc, OPT_Wpedantic, "duplicate %<restrict%>");
 275         if (volatilep > 1)
 276   	pedwarn (loc, OPT_Wpedantic, "duplicate %<volatile%>");
 277 +       if (atomicp > 1)
 278 + 	pedwarn (loc, OPT_Wpedantic, "duplicate %<_Atomic%>");
 279 + 
 280       }
 281   
 282     if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2)
 283 *************** grokdeclarator (const struct c_declarato
 284 *** 5087,5092 ****
 285 --- 5095,5101 ----
 286     type_quals = ((constp ? TYPE_QUAL_CONST : 0)
 287   		| (restrictp ? TYPE_QUAL_RESTRICT : 0)
 288   		| (volatilep ? TYPE_QUAL_VOLATILE : 0)
 289 + 		| (atomicp ? TYPE_QUAL_ATOMIC : 0)
 290   		| ENCODE_QUAL_ADDR_SPACE (address_space));
 291   
 292     /* Warn about storage classes that are invalid for certain
 293 *************** grokdeclarator (const struct c_declarato
 294 *** 5652,5660 ****
 295   	  }
 296   	case cdk_pointer:
 297   	  {
 298   	    /* Merge any constancy or volatility into the target type
 299   	       for the pointer.  */
 300 - 
 301   	    if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
 302   		&& type_quals)
 303   	      pedwarn (loc, OPT_Wpedantic,
 304 --- 5661,5676 ----
 305   	  }
 306   	case cdk_pointer:
 307   	  {
 308 + 	    if (atomicp)
 309 + 	      {
 310 + 		error_at (loc,
 311 + 			  "ISO C forbids _Atomic qualifier function types");
 312 + 		type = error_mark_node;
 313 + 		break;
 314 + 	      }
 315 + 
 316   	    /* Merge any constancy or volatility into the target type
 317   	       for the pointer.  */
 318   	    if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
 319   		&& type_quals)
 320   	      pedwarn (loc, OPT_Wpedantic,
 321 *************** build_null_declspecs (void)
 322 *** 8822,8827 ****
 323 --- 8838,8844 ----
 324     ret->thread_p = false;
 325     ret->const_p = false;
 326     ret->volatile_p = false;
 327 +   ret->atomic_p = false;
 328     ret->restrict_p = false;
 329     ret->saturating_p = false;
 330     ret->alignas_p = false;
 331 *************** declspecs_add_qual (source_location loc,
 332 *** 8883,8888 ****
 333 --- 8900,8909 ----
 334         specs->restrict_p = true;
 335         specs->locations[cdw_restrict] = loc;
 336         break;
 337 +     case RID_ATOMIC:
 338 +       dupe = specs->atomic_p;
 339 +       specs->atomic_p = true;
 340 +       break;
 341       default:
 342         gcc_unreachable ();
 343       }
 344 Index: gcc/c/c-parser.c
 345 ===================================================================
 346 *** gcc/c/c-parser.c	(revision 202709)
 347 --- gcc/c/c-parser.c	(working copy)
 348 *************** c_token_starts_typename (c_token *token)
 349 *** 489,494 ****
 350 --- 489,495 ----
 351   	case RID_UNION:
 352   	case RID_TYPEOF:
 353   	case RID_CONST:
 354 + 	case RID_ATOMIC:
 355   	case RID_VOLATILE:
 356   	case RID_RESTRICT:
 357   	case RID_ATTRIBUTE:
 358 *************** c_token_is_qualifier (c_token *token)
 359 *** 571,576 ****
 360 --- 572,578 ----
 361   	case RID_VOLATILE:
 362   	case RID_RESTRICT:
 363   	case RID_ATTRIBUTE:
 364 + 	case RID_ATOMIC:
 365   	  return true;
 366   	default:
 367   	  return false;
 368 *************** c_token_starts_declspecs (c_token *token
 369 *** 651,656 ****
 370 --- 653,659 ----
 371   	case RID_ACCUM:
 372   	case RID_SAT:
 373   	case RID_ALIGNAS:
 374 + 	case RID_ATOMIC:
 375   	  return true;
 376   	default:
 377   	  return false;
 378 *************** c_parser_static_assert_declaration_no_se
 379 *** 1948,1955 ****
 380 --- 1951,1960 ----
 381        restrict
 382        volatile
 383        address-space-qualifier
 384 +      atomic
 385   
 386      (restrict is new in C99.)
 387 +    (atomic is new in C11.)
 388   
 389      GNU extensions:
 390   
 391 *************** c_parser_declspecs (c_parser *parser, st
 392 *** 2171,2176 ****
 393 --- 2176,2192 ----
 394   	  t = c_parser_typeof_specifier (parser);
 395   	  declspecs_add_type (loc, specs, t);
 396   	  break;
 397 + 	case RID_ATOMIC:
 398 + 	  if (!flag_isoc11)
 399 + 	    {
 400 + 	      if (flag_isoc99)
 401 + 		pedwarn (loc, OPT_Wpedantic,
 402 + 			 "ISO C99 does not support _Atomic qualifier");
 403 + 	      else
 404 + 		pedwarn (loc, OPT_Wpedantic,
 405 + 			 "ISO C90 does not support _Atomic qualifier");
 406 + 	    }
 407 + 	  /* Fallthru.  */
 408   	case RID_CONST:
 409   	case RID_VOLATILE:
 410   	case RID_RESTRICT:
 411 *************** c_parser_attribute_any_word (c_parser *p
 412 *** 3487,3492 ****
 413 --- 3503,3509 ----
 414   	case RID_SAT:
 415   	case RID_TRANSACTION_ATOMIC:
 416   	case RID_TRANSACTION_CANCEL:
 417 + 	case RID_ATOMIC:
 418   	  ok = true;
 419   	  break;
 420   	default:
 421 Index: gcc/objc/objc-act.c
 422 ===================================================================
 423 *** gcc/objc/objc-act.c	(revision 202709)
 424 --- gcc/objc/objc-act.c	(working copy)
 425 *************** objc_push_parm (tree parm)
 426 *** 8244,8249 ****
 427 --- 8244,8250 ----
 428     c_apply_type_quals_to_decl
 429     ((TYPE_READONLY (TREE_TYPE (parm)) ? TYPE_QUAL_CONST : 0)
 430      | (TYPE_RESTRICT (TREE_TYPE (parm)) ? TYPE_QUAL_RESTRICT : 0)
 431 +    | (TYPE_ATOMIC (TREE_TYPE (parm)) ? TYPE_QUAL_ATOMIC : 0)
 432      | (TYPE_VOLATILE (TREE_TYPE (parm)) ? TYPE_QUAL_VOLATILE : 0), parm);
 433   
 434     objc_parmlist = chainon (objc_parmlist, parm);
 435 Index: gcc/cp/cp-tree.h
 436 ===================================================================
 437 *** gcc/cp/cp-tree.h	(revision 202709)
 438 --- gcc/cp/cp-tree.h	(working copy)
 439 *************** enum languages { lang_c, lang_cplusplus,
 440 *** 1292,1297 ****
 441 --- 1292,1301 ----
 442   #define CP_TYPE_VOLATILE_P(NODE)			\
 443     ((cp_type_quals (NODE) & TYPE_QUAL_VOLATILE) != 0)
 444   
 445 + /* Nonzero if this type is atomic-qualified.  */
 446 + #define CP_TYPE_ATOMIC_P(NODE)				\
 447 +   ((cp_type_quals (NODE) & TYPE_QUAL_ATOMIC) != 0)
 448 + 
 449   /* Nonzero if this type is restrict-qualified.  */
 450   #define CP_TYPE_RESTRICT_P(NODE)			\
 451     ((cp_type_quals (NODE) & TYPE_QUAL_RESTRICT) != 0)
 452 *************** typedef enum cp_decl_spec {
 453 *** 4757,4762 ****
 454 --- 4761,4767 ----
 455     ds_const,
 456     ds_volatile,
 457     ds_restrict,
 458 +   ds_atomic,
 459     ds_inline,
 460     ds_virtual,
 461     ds_explicit,
 462 Index: gcc/cp/cvt.c
 463 ===================================================================
 464 *** gcc/cp/cvt.c	(revision 202709)
 465 --- gcc/cp/cvt.c	(working copy)
 466 *************** diagnose_ref_binding (location_t loc, tr
 467 *** 385,390 ****
 468 --- 385,396 ----
 469         else if (CP_TYPE_VOLATILE_P (ttl))
 470   	msg = G_("conversion to volatile reference type %q#T "
 471   	         "from rvalue of type %qT");
 472 +       else if (CP_TYPE_ATOMIC_P (ttl) && decl)
 473 + 	msg = G_("initialization of atomic reference type %q#T from "
 474 + 	         "rvalue of type %qT");
 475 +       else if (CP_TYPE_ATOMIC_P (ttl))
 476 + 	msg = G_("conversion to atomic reference type %q#T "
 477 + 	         "from rvalue of type %qT");
 478         else if (decl)
 479   	msg = G_("initialization of non-const reference type %q#T from "
 480   	         "rvalue of type %qT");
 481 Index: gcc/cp/decl.c
 482 ===================================================================
 483 *** gcc/cp/decl.c	(revision 202709)
 484 --- gcc/cp/decl.c	(working copy)
 485 *************** build_ptrmemfunc_type (tree type)
 486 *** 7976,7981 ****
 487 --- 7976,7982 ----
 488         TYPE_READONLY (t) = (type_quals & TYPE_QUAL_CONST) != 0;
 489         TYPE_VOLATILE (t) = (type_quals & TYPE_QUAL_VOLATILE) != 0;
 490         TYPE_RESTRICT (t) = (type_quals & TYPE_QUAL_RESTRICT) != 0;
 491 +       TYPE_ATOMIC (t) = (type_quals & TYPE_QUAL_ATOMIC) != 0;
 492         TYPE_MAIN_VARIANT (t) = unqualified_variant;
 493         TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (unqualified_variant);
 494         TYPE_NEXT_VARIANT (unqualified_variant) = t;
 495 *************** grokdeclarator (const cp_declarator *dec
 496 *** 9191,9196 ****
 497 --- 9192,9199 ----
 498       type_quals |= TYPE_QUAL_VOLATILE;
 499     if (decl_spec_seq_has_spec_p (declspecs, ds_restrict))
 500       type_quals |= TYPE_QUAL_RESTRICT;
 501 +   if (decl_spec_seq_has_spec_p (declspecs, ds_atomic))
 502 +     type_quals |= TYPE_QUAL_ATOMIC;
 503     if (sfk == sfk_conversion && type_quals != TYPE_UNQUALIFIED)
 504       error ("qualifiers are not allowed on declaration of %<operator %T%>",
 505   	   ctor_return_type);
 506 Index: gcc/cp/mangle.c
 507 ===================================================================
 508 *** gcc/cp/mangle.c	(revision 202709)
 509 --- gcc/cp/mangle.c	(working copy)
 510 *************** dump_substitution_candidates (void)
 511 *** 326,331 ****
 512 --- 326,332 ----
 513         if (TYPE_P (el) &&
 514   	  (CP_TYPE_RESTRICT_P (el)
 515   	   || CP_TYPE_VOLATILE_P (el)
 516 + 	   || CP_TYPE_ATOMIC_P (el)
 517   	   || CP_TYPE_CONST_P (el)))
 518   	fprintf (stderr, "CV-");
 519         fprintf (stderr, "%s (%s at %p)\n",
 520 Index: gcc/cp/pt.c
 521 ===================================================================
 522 *** gcc/cp/pt.c	(revision 202709)
 523 --- gcc/cp/pt.c	(working copy)
 524 *************** check_cv_quals_for_unify (int strict, tr
 525 *** 16574,16580 ****
 526         if ((TREE_CODE (arg) == REFERENCE_TYPE
 527   	   || TREE_CODE (arg) == FUNCTION_TYPE
 528   	   || TREE_CODE (arg) == METHOD_TYPE)
 529 ! 	  && (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)))
 530   	return 0;
 531   
 532         if ((!POINTER_TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
 533 --- 16574,16581 ----
 534         if ((TREE_CODE (arg) == REFERENCE_TYPE
 535   	   || TREE_CODE (arg) == FUNCTION_TYPE
 536   	   || TREE_CODE (arg) == METHOD_TYPE)
 537 ! 	  && (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE 
 538 ! 			    | TYPE_QUAL_ATOMIC)))
 539   	return 0;
 540   
 541         if ((!POINTER_TYPE_P (arg) && TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
 542 Index: gcc/cp/rtti.c
 543 ===================================================================
 544 *** gcc/cp/rtti.c	(revision 202709)
 545 --- gcc/cp/rtti.c	(working copy)
 546 *************** qualifier_flags (tree type)
 547 *** 808,813 ****
 548 --- 808,815 ----
 549       flags |= 2;
 550     if (quals & TYPE_QUAL_RESTRICT)
 551       flags |= 4;
 552 +   if (quals & TYPE_QUAL_ATOMIC)
 553 +     flags |= 8;
 554     return flags;
 555   }
 556   
 557 Index: gcc/cp/parser.c
 558 ===================================================================
 559 *** gcc/cp/parser.c	(revision 202709)
 560 --- gcc/cp/parser.c	(working copy)
 561 *************** cp_parser_type_specifier (cp_parser* par
 562 *** 14125,14130 ****
 563 --- 14125,14138 ----
 564   	*is_cv_qualifier = true;
 565         break;
 566   
 567 +     case RID_ATOMIC:
 568 +       ds = ds_atomic;
 569 +       if (is_cv_qualifier)
 570 + 	*is_cv_qualifier = true;
 571 +       if (!flag_isoc11)
 572 +         pedwarn (token->location, 0, "_Atomic qualifier provided in ISO C11");
 573 +       break;
 574 + 
 575       case RID_RESTRICT:
 576         ds = ds_restrict;
 577         if (is_cv_qualifier)
 578 *************** cp_parser_cv_qualifier_seq_opt (cp_parse
 579 *** 17381,17386 ****
 580 --- 17389,17398 ----
 581   	  cv_qualifier = TYPE_QUAL_RESTRICT;
 582   	  break;
 583   
 584 + 	case RID_ATOMIC:
 585 + 	  cv_qualifier = TYPE_QUAL_ATOMIC;
 586 + 	  break;
 587 + 
 588   	default:
 589   	  cv_qualifier = TYPE_UNQUALIFIED;
 590   	  break;
 591 *************** set_and_check_decl_spec_loc (cp_decl_spe
 592 *** 23541,23546 ****
 593 --- 23553,23559 ----
 594   	    "const",
 595   	    "volatile",
 596   	    "restrict",
 597 + 	    "_Atomic"
 598   	    "inline",
 599   	    "virtual",
 600   	    "explicit",
 601 Index: gcc/cp/semantics.c
 602 ===================================================================
 603 *** gcc/cp/semantics.c	(revision 202709)
 604 --- gcc/cp/semantics.c	(working copy)
 605 *************** non_const_var_error (tree r)
 606 *** 7773,7778 ****
 607 --- 7773,7781 ----
 608         else if (CP_TYPE_VOLATILE_P (type))
 609   	inform (DECL_SOURCE_LOCATION (r),
 610   		"%q#D is volatile", r);
 611 +       else if (CP_TYPE_ATOMIC_P (type))
 612 + 	inform (DECL_SOURCE_LOCATION (r),
 613 + 		"%q#D is atomic", r);
 614         else if (!DECL_INITIAL (r)
 615   	       || !TREE_CONSTANT (DECL_INITIAL (r)))
 616   	inform (DECL_SOURCE_LOCATION (r),
 617 Index: gcc/cp/tree.c
 618 ===================================================================
 619 *** gcc/cp/tree.c	(revision 202709)
 620 --- gcc/cp/tree.c	(working copy)
 621 *************** cp_build_qualified_type_real (tree type,
 622 *** 1059,1072 ****
 623     /* A reference or method type shall not be cv-qualified.
 624        [dcl.ref], [dcl.fct].  This used to be an error, but as of DR 295
 625        (in CD1) we always ignore extra cv-quals on functions.  */
 626 !   if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
 627         && (TREE_CODE (type) == REFERENCE_TYPE
 628   	  || TREE_CODE (type) == FUNCTION_TYPE
 629   	  || TREE_CODE (type) == METHOD_TYPE))
 630       {
 631         if (TREE_CODE (type) == REFERENCE_TYPE)
 632 ! 	bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
 633 !       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
 634       }
 635   
 636     /* But preserve any function-cv-quals on a FUNCTION_TYPE.  */
 637 --- 1059,1073 ----
 638     /* A reference or method type shall not be cv-qualified.
 639        [dcl.ref], [dcl.fct].  This used to be an error, but as of DR 295
 640        (in CD1) we always ignore extra cv-quals on functions.  */
 641 !   if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_ATOMIC)
 642         && (TREE_CODE (type) == REFERENCE_TYPE
 643   	  || TREE_CODE (type) == FUNCTION_TYPE
 644   	  || TREE_CODE (type) == METHOD_TYPE))
 645       {
 646         if (TREE_CODE (type) == REFERENCE_TYPE)
 647 ! 	bad_quals |= type_quals 
 648 ! 		    & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_ATOMIC);
 649 !       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_ATOMIC);
 650       }
 651   
 652     /* But preserve any function-cv-quals on a FUNCTION_TYPE.  */
 653 *************** cv_unqualified (tree type)
 654 *** 1142,1148 ****
 655       return type;
 656   
 657     quals = cp_type_quals (type);
 658 !   quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
 659     return cp_build_qualified_type (type, quals);
 660   }
 661   
 662 --- 1143,1149 ----
 663       return type;
 664   
 665     quals = cp_type_quals (type);
 666 !   quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE|TYPE_QUAL_ATOMIC);
 667     return cp_build_qualified_type (type, quals);
 668   }
 669   
 670 Index: gcc/cp/typeck.c
 671 ===================================================================
 672 *** gcc/cp/typeck.c	(revision 202709)
 673 --- gcc/cp/typeck.c	(working copy)
 674 *************** cp_type_quals (const_tree type)
 675 *** 8751,8757 ****
 676     /* METHOD and REFERENCE_TYPEs should never have quals.  */
 677     gcc_assert ((TREE_CODE (type) != METHOD_TYPE
 678   	       && TREE_CODE (type) != REFERENCE_TYPE)
 679 ! 	      || ((quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE))
 680   		  == TYPE_UNQUALIFIED));
 681     return quals;
 682   }
 683 --- 8751,8757 ----
 684     /* METHOD and REFERENCE_TYPEs should never have quals.  */
 685     gcc_assert ((TREE_CODE (type) != METHOD_TYPE
 686   	       && TREE_CODE (type) != REFERENCE_TYPE)
 687 ! 	    || ((quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE|TYPE_QUAL_ATOMIC))
 688   		  == TYPE_UNQUALIFIED));
 689     return quals;
 690   }
 691 *************** bool
 692 *** 8811,8817 ****
 693   cv_qualified_p (const_tree type)
 694   {
 695     int quals = cp_type_quals (type);
 696 !   return (quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE)) != 0;
 697   }
 698   
 699   /* Returns nonzero if the TYPE contains a mutable member.  */
 700 --- 8811,8817 ----
 701   cv_qualified_p (const_tree type)
 702   {
 703     int quals = cp_type_quals (type);
 704 !   return (quals & (TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE|TYPE_QUAL_ATOMIC)) != 0;
 705   }
 706   
 707   /* Returns nonzero if the TYPE contains a mutable member.  */
 708 Index: gcc/doc/generic.texi
 709 ===================================================================
 710 *** gcc/doc/generic.texi	(revision 202709)
 711 --- gcc/doc/generic.texi	(working copy)
 712 *************** This macro holds if the type is @code{co
 713 *** 2547,2552 ****
 714 --- 2547,2555 ----
 715   @item CP_TYPE_VOLATILE_P
 716   This macro holds if the type is @code{volatile}-qualified.
 717   
 718 + @item CP_TYPE_ATOMIC_P
 719 + This macro holds if the type is @code{atomic}-qualified.
 720 + 
 721   @item CP_TYPE_RESTRICT_P
 722   This macro holds if the type is @code{restrict}-qualified.
 723   

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2013-09-26 22:28:39, 3.3 KB) [[attachment:C11atomic1.patch]]
  • [get | view] (2013-09-26 22:29:03, 10.1 KB) [[attachment:C11atomic2.patch]]
  • [get | view] (2013-09-26 22:29:32, 23.8 KB) [[attachment:C11atomic3.patch]]
  • [get | view] (2013-09-26 22:30:03, 11.1 KB) [[attachment:C11atomic4.patch]]
  • [get | view] (2013-09-26 22:30:34, 13.8 KB) [[attachment:C11atomic5.patch]]
  • [get | view] (2013-09-26 22:31:14, 0.6 KB) [[attachment:C11atomic6.patch]]
  • [get | view] (2013-09-26 22:31:49, 8.6 KB) [[attachment:C11stdatomic.patch]]
  • [get | view] (2013-09-30 15:02:51, 47.7 KB) [[attachment:atomicproto.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.