This is the mail archive of the gcc-patches@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]

RFC: PATCH: PR c++/40075: deprecated("xxx") doesn't work on function parameter


cp_parser_parameter_declaration_list supresses deprecated("xxx") so
that deprecated("xxx") doesn't work on function parameter in C++. This
This patch reverts the part of

http://gcc.gnu.org/ml/gcc-patches/2008-09/msg00645.html

which will make C and C++ compilers behave the same. I don't know which
behavior is preferred.



H.J.
----
gcc/cp

2009-05-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/40075
	* decl.h (deprecated_states): Moved to ...
	* decl.c (deprecated_states): Here.
	(deprecated_state): Make it static.
	(type_is_deprecated): Removed.
	(grokparms): Don't call warn_deprecated_use here.

	* parser.c (cp_parser_parameter_declaration_list): Don't
	set deprecated_state here.

gcc/testsuite/

2009-05-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR c++/40075
	* g++.dg/warn/deprecated-6.C: Add dg-warning on parameter.
	* g++.dg/warn/deprecated.C: Likewise.

--- gcc/cp/decl.c.foo	2009-05-08 13:54:31.000000000 -0700
+++ gcc/cp/decl.c	2009-05-08 15:51:17.000000000 -0700
@@ -234,7 +234,13 @@ VEC(tree, gc) *deferred_mark_used_calls;
    with __attribute__((deprecated)).  An object declared as
    __attribute__((deprecated)) suppresses warnings of uses of other
    deprecated items.  */
-enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
+
+enum deprecated_states {
+  DEPRECATED_NORMAL,
+  DEPRECATED_SUPPRESS
+};
+
+static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
 
 
 /* A TREE_LIST of VAR_DECLs.  The TREE_PURPOSE is a RECORD_TYPE or
@@ -9610,32 +9616,6 @@ check_default_argument (tree decl, tree 
   return arg;
 }
 
-/* Returns a deprecated type used within TYPE, or NULL_TREE if none.  */
-
-static tree
-type_is_deprecated (tree type)
-{
-  enum tree_code code;
-  if (TREE_DEPRECATED (type))
-    return type;
-  if (TYPE_NAME (type)
-      && TREE_DEPRECATED (TYPE_NAME (type)))
-    return type;
-
-  code = TREE_CODE (type);
-
-  if (code == POINTER_TYPE || code == REFERENCE_TYPE
-      || code == OFFSET_TYPE || code == FUNCTION_TYPE
-      || code == METHOD_TYPE || code == ARRAY_TYPE)
-    return type_is_deprecated (TREE_TYPE (type));
-
-  if (TYPE_PTRMEMFUNC_P (type))
-    return type_is_deprecated
-      (TREE_TYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (type))));
-
-  return NULL_TREE;
-}
-
 /* Decode the list of parameter types for a function type.
    Given the list of things declared inside the parens,
    return a list of types.
@@ -9693,13 +9673,6 @@ grokparms (tree parmlist, tree *parms)
 
       if (type != error_mark_node)
 	{
-	  if (deprecated_state != DEPRECATED_SUPPRESS)
-	    {
-	      tree deptype = type_is_deprecated (type);
-	      if (deptype)
-		warn_deprecated_use (deptype, NULL_TREE);
-	    }
-
 	  /* Top-level qualifiers on the parameters are
 	     ignored for function types.  */
 	  type = cp_build_qualified_type (type, 0);
--- gcc/cp/decl.h.foo	2009-03-31 16:22:19.000000000 -0700
+++ gcc/cp/decl.h	2009-05-08 15:49:30.000000000 -0700
@@ -35,16 +35,3 @@ enum decl_context
 extern tree grokdeclarator (const cp_declarator *,
 			    const cp_decl_specifier_seq *,
 			    enum decl_context, int, tree*);
-
-/* States indicating how grokdeclarator() should handle declspecs marked
-   with __attribute__((deprecated)).  An object declared as
-   __attribute__((deprecated)) suppresses warnings of uses of other
-   deprecated items.  */
-
-enum deprecated_states {
-  DEPRECATED_NORMAL,
-  DEPRECATED_SUPPRESS
-};
-
-extern enum deprecated_states deprecated_state;
-
--- gcc/cp/parser.c.foo	2009-05-07 13:07:03.000000000 -0700
+++ gcc/cp/parser.c	2009-05-08 15:05:10.000000000 -0700
@@ -14041,10 +14041,6 @@ cp_parser_parameter_declaration_list (cp
 					   /*template_parm_p=*/false,
 					   &parenthesized_p);
 
-      /* We don't know yet if the enclosing context is deprecated, so wait
-	 and warn in grokparms if appropriate.  */
-      deprecated_state = DEPRECATED_SUPPRESS;
-
       if (parameter)
 	decl = grokdeclarator (parameter->declarator,
 			       &parameter->decl_specifiers,
@@ -14052,8 +14048,6 @@ cp_parser_parameter_declaration_list (cp
 			       parameter->default_argument != NULL_TREE,
 			       &parameter->decl_specifiers.attributes);
 
-      deprecated_state = DEPRECATED_NORMAL;
-
       /* If a parse error occurred parsing the parameter declaration,
 	 then the entire parameter-declaration-list is erroneous.  */
       if (decl == error_mark_node)
--- gcc/testsuite/g++.dg/warn/deprecated-6.C.foo	2009-05-08 13:54:31.000000000 -0700
+++ gcc/testsuite/g++.dg/warn/deprecated-6.C	2009-05-08 15:12:54.000000000 -0700
@@ -15,8 +15,8 @@ INT1 f2(void) { return 0; }		/* { dg-war
 
 INT2 f3(void) __attribute__ ((__deprecated__("Please avoid f3"))); 
 INT2 f4(void) { return 0; }		/* { dg-warning "'INT2' is deprecated .declared at \[^\n\]*: Please avoid INT2" "" } */
-int f5(INT2 x);				/* { dg-warning "'INT2' is deprecated" "" } */
-int f6(INT2 x) __attribute__ ((__deprecated__("Please avoid f6")));
+int f5(INT2 x);				/* { dg-warning "'INT2' is deprecated .declared at \[^\n\]*: Please avoid INT2" "" } */
+int f6(INT2 x) __attribute__ ((__deprecated__("Please avoid f6"))); /* { dg-warning "'INT2' is deprecated .declared at \[^\n\]*: Please avoid INT2" "" } */
 
 typedef enum Color {red, green, blue} Color __attribute__((deprecated("Please avoid Color")));
 
--- gcc/testsuite/g++.dg/warn/deprecated.C.foo	2007-09-24 16:15:35.000000000 -0700
+++ gcc/testsuite/g++.dg/warn/deprecated.C	2009-05-08 15:13:42.000000000 -0700
@@ -18,7 +18,7 @@ INT1 f2(void) { return 0; }		/* { dg-war
 INT2 f3(void) __attribute__ ((__deprecated__)); 
 INT2 f4(void) { return 0; }		/* { dg-warning "'INT2' is deprecated" "" } */
 int f5(INT2 x);				/* { dg-warning "'INT2' is deprecated" "" } */
-int f6(INT2 x) __attribute__ ((__deprecated__));
+int f6(INT2 x) __attribute__ ((__deprecated__)); /* { dg-warning "'INT2' is deprecated" "" } */
 
 typedef enum Color {red, green, blue} Color __attribute__((deprecated));
 


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