OSDN Git Service

PR c++/53995
[pf3gnuchains/gcc-fork.git] / gcc / cp / decl.c
index 90746a5..572efcd 100644 (file)
@@ -2947,9 +2947,9 @@ tree
 define_label (location_t location, tree name)
 {
   tree ret;
-  timevar_start (TV_NAME_LOOKUP);
+  bool running = timevar_cond_start (TV_NAME_LOOKUP);
   ret = define_label_1 (location, name);
-  timevar_stop (TV_NAME_LOOKUP);
+  timevar_cond_stop (TV_NAME_LOOKUP, running);
   return ret;
 }
 
@@ -4216,6 +4216,20 @@ check_tag_decl (cp_decl_specifier_seq *declspecs)
         error ("%<constexpr%> cannot be used for type declarations");
     }
 
+  if (declspecs->attributes && declared_type)
+    {
+      location_t loc = input_location;
+      if (!CLASS_TYPE_P (declared_type)
+         || !CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type))
+       /* For a non-template class, use the name location; for a template
+          class (an explicit instantiation), use the current location.  */
+       input_location = location_of (declared_type);
+      warning (0, "attribute ignored in declaration of %q#T", declared_type);
+      warning (0, "attribute for %q#T must follow the %qs keyword",
+              declared_type, class_key_or_enum_as_string (declared_type));
+      input_location = loc;
+    }
+
   return declared_type;
 }
 
@@ -4240,14 +4254,6 @@ shadow_tag (cp_decl_specifier_seq *declspecs)
   if (!t)
     return NULL_TREE;
 
-  if (declspecs->attributes)
-    {
-      warning (0, "attribute ignored in declaration of %q+#T", t);
-      warning (0, "attribute for %q+#T must follow the %qs keyword",
-              t, class_key_or_enum_as_string (t));
-
-    }
-
   if (maybe_process_partial_specialization (t) == error_mark_node)
     return NULL_TREE;
 
@@ -4414,7 +4420,8 @@ start_decl (const cp_declarator *declarator,
     }
 
   /* If #pragma weak was used, mark the decl weak now.  */
-  maybe_apply_pragma_weak (decl);
+  if (!processing_template_decl)
+    maybe_apply_pragma_weak (decl);
 
   if (TREE_CODE (decl) == FUNCTION_DECL
       && DECL_DECLARED_INLINE_P (decl)
@@ -10569,6 +10576,17 @@ check_default_argument (tree decl, tree arg)
       return error_mark_node;
     }
 
+  if (warn_zero_as_null_pointer_constant
+      && c_inhibit_evaluation_warnings == 0
+      && (TYPE_PTR_P (decl_type) || TYPE_PTR_TO_MEMBER_P (decl_type))
+      && null_ptr_cst_p (arg)
+      && !NULLPTR_TYPE_P (TREE_TYPE (arg)))
+    {
+      warning (OPT_Wzero_as_null_pointer_constant,
+              "zero as null pointer constant");
+      return nullptr_node;
+    }
+
   /* [dcl.fct.default]
 
      Local variables shall not be used in default argument
@@ -12329,6 +12347,12 @@ finish_enum_value_list (tree enumtype)
   for (t = TYPE_MAIN_VARIANT (enumtype); t; t = TYPE_NEXT_VARIANT (t))
     TYPE_VALUES (t) = TYPE_VALUES (enumtype);
 
+  if (at_class_scope_p ()
+      && COMPLETE_TYPE_P (current_class_type)
+      && UNSCOPED_ENUM_P (enumtype))
+    insert_late_enum_def_into_classtype_sorted_fields (enumtype,
+                                                      current_class_type);
+
   /* Finish debugging output for this type.  */
   rest_of_type_compilation (enumtype, namespace_bindings_p ());
 }