@@ -339,6 +339,32 @@ build_template_info (tree template_decl, tree template_args)
return result;
}
+/* DECL_TEMPLATE_INFO, if applicable, or NULL_TREE. */
+
+static tree
+decl_template_info (const_tree decl)
+{
+ /* This needs to match template_info_decl_check. */
+ if (DECL_LANG_SPECIFIC (decl))
+ switch (TREE_CODE (decl))
+ {
+ case FUNCTION_DECL:
+ if (DECL_THUNK_P (decl))
+ break;
+ gcc_fallthrough ();
+ case VAR_DECL:
+ case FIELD_DECL:
+ case TYPE_DECL:
+ case CONCEPT_DECL:
+ case TEMPLATE_DECL:
+ return DECL_TEMPLATE_INFO (decl);
+
+ default:
+ break;
+ }
+ return NULL_TREE;
+}
+
/* Return the template info node corresponding to T, whatever T is. */
tree
@@ -353,8 +379,8 @@ get_template_info (const_tree t)
|| TREE_CODE (t) == PARM_DECL)
return NULL;
- if (DECL_P (t) && DECL_LANG_SPECIFIC (t))
- tinfo = DECL_TEMPLATE_INFO (t);
+ if (DECL_P (t))
+ tinfo = decl_template_info (t);
if (!tinfo && DECL_IMPLICIT_TYPEDEF_P (t))
t = TREE_TYPE (t);
new file mode 100644
@@ -0,0 +1,24 @@
+// PR c++/113498
+// { dg-do compile { target c++20 } }
+
+template<int d>
+struct S_Base
+{
+ static constexpr int D = d;
+};
+
+template<int d>
+struct S : public S_Base<d>
+{
+ using S_Base<d>::D;
+ constexpr void f() const
+ requires(D > 0) {}
+
+};
+
+int main(int, char**)
+{
+ S<1> s;
+ s.f();
+ return 0;
+}