&& scope != error_mark_node
&& scope != global_namespace)
{
- if (cp_warn_deprecated_use (scope))
+ if ((TREE_CODE (scope) == NAMESPACE_DECL || OVERLOAD_TYPE_P (scope))
+ && cp_warn_deprecated_use (scope))
return;
if (TYPE_P (scope))
scope = CP_TYPE_CONTEXT (scope);
--- /dev/null
+// PR c++/99318
+// { dg-do compile { target c++11 } }
+
+template <typename T>
+struct S {
+ [[deprecated("foo")]] unsigned m_fn (char const chr)
+ {
+ using index_t = unsigned;
+ return T::arr[static_cast<index_t>(chr)]; // { dg-bogus "deprecated" }
+ }
+};
+
+extern unsigned int arr[];
+
+struct R {
+ [[deprecated("foo")]] unsigned m_fn (char const chr)
+ {
+ using index_t = unsigned;
+ return arr[static_cast<index_t>(chr)]; // { dg-bogus "deprecated" }
+ }
+};
--- /dev/null
+// { dg-do compile { target c++11 } }
+// Test attribute deprecated on :: with class, enum, and namespace.
+
+struct [[deprecated]] S { static void fn(); static const int s = 0; };
+union [[deprecated]] U { static void fn(); static const int u = 0; };
+enum [[deprecated]] E { X };
+enum class [[deprecated]] SE { Y };
+namespace [[deprecated]] N { struct S { }; }
+
+void
+g ()
+{
+ S::fn(); // { dg-warning "deprecated" }
+ (void) S::s; // { dg-warning "deprecated" }
+ U::fn(); // { dg-warning "deprecated" }
+ (void) U::u; // { dg-warning "deprecated" }
+ (void) E::X; // { dg-warning "deprecated" }
+ (void) SE::Y; // { dg-warning "deprecated" }
+ N::S s; // { dg-warning "deprecated" }
+}