+2018-03-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/84222
+ * cp-tree.h (cp_warn_deprecated_use): Declare.
+ * tree.c (cp_warn_deprecated_use): New function.
+ * typeck2.c (build_functional_cast): Use it.
+ * decl.c (grokparms): Likewise.
+ (grokdeclarator): Likewise. Temporarily push nested class scope
+ around grokparms call for out of class member definitions.
+
2018-03-14 Jason Merrill <jason@redhat.com>
PR c++/84820 - no error for invalid qualified-id.
extern void cxx_print_statistics (void);
extern bool maybe_warn_zero_as_null_pointer_constant (tree, location_t);
+extern void cp_warn_deprecated_use (tree);
/* in ptree.c */
extern void cxx_print_xnode (FILE *, tree, int);
suppress reports of deprecated items. */
if (type && TREE_DEPRECATED (type)
&& deprecated_state != DEPRECATED_SUPPRESS)
- warn_deprecated_use (type, NULL_TREE);
+ cp_warn_deprecated_use (type);
if (type && TREE_CODE (type) == TYPE_DECL)
{
typedef_decl = type;
if (TREE_DEPRECATED (type)
&& DECL_ARTIFICIAL (typedef_decl)
&& deprecated_state != DEPRECATED_SUPPRESS)
- warn_deprecated_use (type, NULL_TREE);
+ cp_warn_deprecated_use (type);
}
/* No type at all: default to `int', and set DEFAULTED_INT
because it was not a user-defined typedef. */
explicitp = 2;
}
- arg_types = grokparms (declarator->u.function.parameters,
- &parms);
+ tree pushed_scope = NULL_TREE;
+ if (funcdecl_p
+ && decl_context != FIELD
+ && inner_declarator->u.id.qualifying_scope
+ && CLASS_TYPE_P (inner_declarator->u.id.qualifying_scope))
+ pushed_scope
+ = push_scope (inner_declarator->u.id.qualifying_scope);
+
+ arg_types = grokparms (declarator->u.function.parameters, &parms);
+
+ if (pushed_scope)
+ pop_scope (pushed_scope);
if (inner_declarator
&& inner_declarator->kind == cdk_id
{
tree deptype = type_is_deprecated (type);
if (deptype)
- warn_deprecated_use (deptype, NULL_TREE);
+ cp_warn_deprecated_use (deptype);
}
/* Top-level qualifiers on the parameters are
}
}
+/* Wrapper around warn_deprecated_use that doesn't warn for
+ current_class_type. */
+
+void
+cp_warn_deprecated_use (tree node)
+{
+ if (TYPE_P (node)
+ && current_class_type
+ && TYPE_MAIN_VARIANT (node) == current_class_type)
+ return;
+ warn_deprecated_use (node, NULL_TREE);
+}
+
/* Implement -Wzero_as_null_pointer_constant. Return true if the
conditions for the warning hold, false otherwise. */
bool
if (complain & tf_warning
&& TREE_DEPRECATED (type)
&& DECL_ARTIFICIAL (exp))
- warn_deprecated_use (type, NULL_TREE);
+ cp_warn_deprecated_use (type);
}
else
type = exp;
+2018-03-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/84222
+ * g++.dg/warn/deprecated.C (T::member3): Change dg-warning to dg-bogus.
+ * g++.dg/warn/deprecated-6.C (T::member3): Likewise.
+ * g++.dg/warn/deprecated-13.C: New test.
+
2018-03-15 Olga Makhotina <olga.makhotina@intel.com>
* gcc.target/i386/sgx.c (_enclv_u32): Test new intrinsic.
--- /dev/null
+// PR c++/84222
+// { dg-do compile }
+
+struct __attribute__((deprecated)) C { // { dg-message "declared here" }
+ C () {}
+ C (const C &); // { dg-bogus "'C' is deprecated" }
+ C (const C &x, const C &y) { C z = x; } // { dg-bogus "'C' is deprecated" }
+ void foo (const C &x, const C &y); // { dg-bogus "'C' is deprecated" }
+};
+
+void
+C::foo (const C &x, const C &y) // { dg-bogus "'C' is deprecated" }
+{
+ C z = x; // { dg-bogus "'C' is deprecated" }
+}
+
+void
+bar (const C &x, const C &y) // { dg-warning "'C' is deprecated" }
+{
+ C z = x; // { dg-warning "'C' is deprecated" }
+}
+
+template <int N>
+struct __attribute__((deprecated)) D { // { dg-message "declared here" }
+ D () {}
+ D (const D &); // { dg-bogus "is deprecated" }
+ D (const D &x, const D &y) { D z = x; } // { dg-bogus "is deprecated" }
+ void foo (const D &x, const D &y); // { dg-bogus "is deprecated" }
+};
+
+template <int N>
+void
+D<N>::foo // { dg-bogus "is deprecated" "" { xfail *-*-* } }
+(const D &x, const D &y) // { dg-bogus "is deprecated" }
+{
+ D z = x; // { dg-bogus "is deprecated" }
+}
+
+template <int N>
+void
+bar (const D<N> &x, const D<N> &y) // { dg-warning "is deprecated" }
+{
+ D<N> z = x; // { dg-warning "is deprecated" }
+}
inline void T::member1(int) {}
-int T::member3(T *p) // { dg-warning "'T' is deprecated: Please avoid T" }
+int T::member3(T *p) // { dg-bogus "'T' is deprecated: Please avoid T" }
{
p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" } */
(*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated: Please avoid member1" } */
inline void T::member1(int) {}
-int T::member3(T *p) // { dg-warning "'T' is deprecated" }
+int T::member3(T *p) // { dg-bogus "'T' is deprecated" }
{
p->member1(1); /* { dg-warning "'void T::member1\\(int\\)' is deprecated" } */
(*p).member1(2); /* { dg-warning "'void T::member1\\(int\\)' is deprecated" } */
return f1(); /* { dg-warning "'INT1 f1\\(\\)' is deprecated" } */
}
#endif
-
-