Re: C++ PATCH to add test for c++/90236

2019-04-25 Thread Marek Polacek
On Thu, Apr 25, 2019 at 03:56:40PM -0400, Jason Merrill wrote:
> On Wed, Apr 24, 2019 at 5:26 PM Marek Polacek  wrote:
> >
> > This valid test started to be accepted with r265789, which removed the
> > following checks.
> 
> It didn't remove them, it moved them into invalid_tparm_referent_p.
> And changed the tests for C++17.

Hmm, I didn't see that.

> > I wonder if we want to remove them in gcc 8, or just leave them in place.
> 
> I wouldn't mess with GCC 8; that's a big patch, and it's not a
> regression, it's a C++17 change we didn't implement before.

Makes sense; I closed the BZ.  Thanks,

Marek


Re: C++ PATCH to add test for c++/90236

2019-04-25 Thread Jason Merrill
On Wed, Apr 24, 2019 at 5:26 PM Marek Polacek  wrote:
>
> This valid test started to be accepted with r265789, which removed the
> following checks.

It didn't remove them, it moved them into invalid_tparm_referent_p.
And changed the tests for C++17.

> I wonder if we want to remove them in gcc 8, or just leave them in place.

I wouldn't mess with GCC 8; that's a big patch, and it's not a
regression, it's a C++17 change we didn't implement before.

Jason


C++ PATCH to add test for c++/90236

2019-04-24 Thread Marek Polacek
This valid test started to be accepted with r265789, which removed the
following checks.  I wonder if we want to remove them in gcc 8, or
just leave them in place.  For trunk I'm going to add the new test.

@@ -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)))

Tested on x86_64-linux, applying to trunk.

2019-04-24  Marek Polacek  

PR c++/90236
* g++.dg/cpp1z/nontype-auto16.C: New test.

diff --git gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C 
gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C
new file mode 100644
index 000..695bb11d780
--- /dev/null
+++ gcc/testsuite/g++.dg/cpp1z/nontype-auto16.C
@@ -0,0 +1,13 @@
+// PR c++/90236
+// { dg-do compile { target c++17 } }
+
+struct foo { };
+
+template  void fnc() { } 
+
+void
+test()
+{
+  static constexpr foo a;
+  fnc();
+}