[Bug c++/90236] bogus error with auto non-type template argument

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 24 20:40:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90236

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Clearly it's this hunk:

@@ -6985,27 +7071,10 @@ convert_nontype_argument (tree type, tree expr,
tsubst_flags_t complain)
       itself value-dependent, since what we want here is its address.  */;
       else
    {
-     if (!DECL_P (expr))
-       {
-         if (complain & tf_error)
-       error ("%qE is not a valid template argument for type %qT "
-              "because it is not an object with linkage",
-              expr, type);
-         return NULL_TREE;
-       }
-
-     /* DR 1155 allows internal linkage in C++11 and up.  */
-     linkage_kind linkage = decl_linkage (expr);
-     if (linkage < (cxx_dialect >= cxx11 ? lk_internal : lk_external))
-       {
-         if (complain & tf_error)
-       error ("%qE is not a valid template argument for type %qT "
-              "because object %qD does not have linkage",
-              expr, type, expr);
-         return NULL_TREE;
-       }
-
      expr = build_address (expr);
+
+     if (invalid_tparm_referent_p (type, expr, complain))
+       return NULL_TREE;
    }

       if (!same_type_p (type, TREE_TYPE (expr)))


More information about the Gcc-bugs mailing list