Module Name:    src
Committed By:   christos
Date:           Fri Sep 14 20:46:46 UTC 2018

Modified Files:
        src/external/gpl3/gcc.old/dist/gcc/c-family: c-format.c c-format.h

Log Message:
The syslog format attribute is a superset of the printf format attribute
so allow functions marked with the printf format attribute to call syslog
without producing warnings with -Wmissing-format-attribute.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
    src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c \
    src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c
diff -u src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.5 src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.6
--- src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.5	Wed Aug  1 20:02:49 2018
+++ src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c	Fri Sep 14 16:46:46 2018
@@ -887,70 +887,70 @@ static const format_kind_info format_typ
     printf_flag_specs, printf_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
     'w', 0, 'p', 0, 'L', 0,
-    &integer_type_node, &integer_type_node
+    &integer_type_node, &integer_type_node, format_type_error
   },
   { "asm_fprintf",   asm_fprintf_length_specs,  asm_fprintf_char_table, " +#0-", NULL,
     asm_fprintf_flag_specs, asm_fprintf_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_EMPTY_PREC_OK,
     'w', 0, 'p', 0, 'L', 0,
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "gcc_diag",   gcc_diag_length_specs,  gcc_diag_char_table, "q+#", NULL,
     gcc_diag_flag_specs, gcc_diag_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_M_OK,
     0, 0, 'p', 0, 'L', 0,
-    NULL, &integer_type_node
+    NULL, &integer_type_node, format_type_error
   },
   { "gcc_tdiag",   gcc_tdiag_length_specs,  gcc_tdiag_char_table, "q+#", NULL,
     gcc_tdiag_flag_specs, gcc_tdiag_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_M_OK,
     0, 0, 'p', 0, 'L', 0,
-    NULL, &integer_type_node
+    NULL, &integer_type_node, format_type_error
   },
   { "gcc_cdiag",   gcc_cdiag_length_specs,  gcc_cdiag_char_table, "q+#", NULL,
     gcc_cdiag_flag_specs, gcc_cdiag_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_M_OK,
     0, 0, 'p', 0, 'L', 0,
-    NULL, &integer_type_node
+    NULL, &integer_type_node, format_type_error
   },
   { "gcc_cxxdiag",   gcc_cxxdiag_length_specs,  gcc_cxxdiag_char_table, "q+#", NULL,
     gcc_cxxdiag_flag_specs, gcc_cxxdiag_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_M_OK,
     0, 0, 'p', 0, 'L', 0,
-    NULL, &integer_type_node
+    NULL, &integer_type_node, format_type_error
   },
   { "gcc_gfc", gcc_gfc_length_specs, gcc_gfc_char_table, "q+#", NULL,
     gcc_gfc_flag_specs, gcc_gfc_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_M_OK,
     0, 0, 0, 0, 0, 0,
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "NSString",   NULL,  NULL, NULL, NULL,
     NULL, NULL,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL, 0, 0, 0, 0, 0, 0,
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "gnu_scanf",    scanf_length_specs,   scan_char_table,  "*'I", NULL,
     scanf_flag_specs, scanf_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK,
     'w', 0, 0, '*', 'L', 'm',
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "gnu_strftime", NULL,                 time_char_table,  "_-0^#", "EO",
     strftime_flag_specs, strftime_flag_pairs,
     FMT_FLAG_FANCY_PERCENT_OK|FMT_FLAG_M_OK, 'w', 0, 0, 0, 0, 0,
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "gnu_strfmon",  strfmon_length_specs, monetary_char_table, "=^+(!-", NULL,
     strfmon_flag_specs, strfmon_flag_pairs,
     FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', 0,
-    NULL, NULL
+    NULL, NULL, format_type_error
   },
   { "gnu_syslog",   printf_length_specs,  print_char_table, " +#0-'I", NULL,
     printf_flag_specs, printf_flag_pairs,
     FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK|FMT_FLAG_M_OK,
     'w', 0, 'p', 0, 'L', 0,
-    &integer_type_node, &integer_type_node
+    &integer_type_node, &integer_type_node, printf_format_type
   },
 };
 
@@ -1098,19 +1098,25 @@ check_function_format (tree attrs, int n
 		params = tree_cons (NULL_TREE, argarray[i], params);
 	      check_format_info (&info, params);
 	    }
+	  const format_kind_info *fi = &format_types[info.format_type];
 	  if (warn_suggest_attribute_format && info.first_arg_num == 0
-	      && (format_types[info.format_type].flags
-		  & (int) FMT_FLAG_ARG_CONVERT))
+	      && (fi->flags & (int) FMT_FLAG_ARG_CONVERT))
 	    {
 	      tree c;
 	      for (c = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl));
 		   c;
 		   c = TREE_CHAIN (c))
-		if (is_attribute_p ("format", TREE_PURPOSE (c))
-		    && (decode_format_type (IDENTIFIER_POINTER
-					    (TREE_VALUE (TREE_VALUE (c))))
-			== info.format_type))
-		  break;
+		{
+		  if (!is_attribute_p ("format", TREE_PURPOSE (c)))
+		     continue;
+		  int format_type = decode_format_type (
+		      IDENTIFIER_POINTER (TREE_VALUE (TREE_VALUE (c))));
+		  if (format_type == format_type_error)
+		     continue;
+		  if (format_type == info.format_type ||
+		      format_type == fi->parent_format_type)
+		    break;
+		}
 	      if (c == NULL_TREE)
 		{
 		  /* Check if the current function has a parameter to which
@@ -1130,7 +1136,7 @@ check_function_format (tree attrs, int n
 		  if (args != 0)
 		    warning (OPT_Wsuggest_attribute_format, "function might "
 			     "be possible candidate for %qs format attribute",
-			     format_types[info.format_type].name);
+			     fi->name);
 		}
 	    }
 	}
Index: src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h
diff -u src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.5 src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.6
--- src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.5	Wed Aug  1 20:02:49 2018
+++ src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h	Fri Sep 14 16:46:46 2018
@@ -253,6 +253,8 @@ struct format_kind_info
   /* Pointer to type of argument expected if '*' is used for a precision,
      or NULL if '*' not used for precisions.  */
   tree *precision_type;
+  /* A format type that is a subset of our format */
+  int	parent_format_type;
 };
 
 #define T_I	&integer_type_node

Reply via email to