re PR c++/84325 (internal compiler error, in cxx_eval_constant_expression gcc/cp...
authorMarek Polacek <polacek@redhat.com>
Mon, 26 Feb 2018 18:41:56 +0000 (18:41 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 26 Feb 2018 18:41:56 +0000 (18:41 +0000)
PR c++/84325
* tree.c (replace_placeholders_r): Only check TREE_CONSTANT on
non-types.

* g++.dg/cpp1z/pr84325.C: New test.

From-SVN: r258008

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/pr84325.C [new file with mode: 0644]

index 59d4ceead6713eff18418fbdc92df60c5358030c..7499992a73a6703d7c92ac90e1e2f9f6a8ee8840 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-26  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84325
+       * tree.c (replace_placeholders_r): Only check TREE_CONSTANT on
+       non-types.
+
 2018-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/84447 - ICE with deleted inherited ctor with default arg.
index 39c1ef28b2d04a5f5dea72d63d550ea26626834c..41d9002d8f946636614b8bac4eedec2e71aa5d02 100644 (file)
@@ -3091,7 +3091,7 @@ replace_placeholders_r (tree* t, int* walk_subtrees, void* data_)
   replace_placeholders_t *d = static_cast<replace_placeholders_t*>(data_);
   tree obj = d->obj;
 
-  if (TREE_CONSTANT (*t))
+  if (TYPE_P (*t) || TREE_CONSTANT (*t))
     {
       *walk_subtrees = false;
       return NULL_TREE;
index ba25b2e19e4340fd03b376364b53ce06b4d31390..6fd236cd1afabc010f917de5298737ca7d7a8fbb 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-26  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84325
+       * g++.dg/cpp1z/pr84325.C: New test.
+
 2018-02-26  Carl Love  <cel@us.ibm.com>
 
        * gcc.target/powerpc/builtins-3.c: Move vec_neg builtin tests to
diff --git a/gcc/testsuite/g++.dg/cpp1z/pr84325.C b/gcc/testsuite/g++.dg/cpp1z/pr84325.C
new file mode 100644 (file)
index 0000000..dddadc3
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/84325
+// { dg-do compile }
+// { dg-options "-std=c++17" }
+
+struct seconds { int i_{0}; constexpr seconds (int) {} };
+template <char... _Digits> constexpr seconds operator""_s() {
+  return seconds(0);
+}
+constexpr seconds operator""_s(long double i) {
+  return seconds(0);
+}
+template<class TYPE>
+struct Param {
+  constexpr static inline seconds time_to_wait{10_s};
+};
+struct Empty {};
+Param<Empty> p;