]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/91230 - wrong error with __PRETTY_FUNCTION__ and generic lambda.
authorMarek Polacek <polacek@redhat.com>
Fri, 2 Aug 2019 13:29:05 +0000 (13:29 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 2 Aug 2019 13:29:05 +0000 (13:29 +0000)
* pt.c (value_dependent_expression_p): Consider __PRETTY_FUNCTION__
inside a template function value-dependent.

* g++.dg/cpp1y/lambda-generic-pretty1.C: New test.

From-SVN: r274010

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1y/lambda-generic-pretty1.C [new file with mode: 0644]

index 8621f5733be5820ef68e8e67c6871c9e206dfe86..4f04385b59062f5a80ed4f2d8e97f95eb317bc0d 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-02  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2019-08-02  Marek Polacek  <polacek@redhat.com>
+       
+       PR c++/91230 - wrong error with __PRETTY_FUNCTION__ and generic lambda.
+       * pt.c (value_dependent_expression_p): Consider __PRETTY_FUNCTION__
+       inside a template function value-dependent.
+
 2019-07-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/90098 - partial specialization and class non-type parms.
index 7069e2f3047ede6aca1e0f57378eb229cd4c7509..a2a986b1db1beb1db9b8b01e4281fcaea1ea3df1 100644 (file)
@@ -25562,7 +25562,14 @@ value_dependent_expression_p (tree expression)
       if (DECL_HAS_VALUE_EXPR_P (expression))
        {
          tree value_expr = DECL_VALUE_EXPR (expression);
-         if (value_dependent_expression_p (value_expr))
+         if (value_dependent_expression_p (value_expr)
+             /* __PRETTY_FUNCTION__ inside a template function is dependent
+                on the name of the function.  */
+             || (DECL_PRETTY_FUNCTION_P (expression)
+                 /* It might be used in a template, but not a template
+                    function, in which case its DECL_VALUE_EXPR will be
+                    "top level".  */
+                 && value_expr == error_mark_node))
            return true;
        }
       return false;
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-pretty1.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-pretty1.C
new file mode 100644 (file)
index 0000000..4d3246b
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/91230
+// { dg-do compile { target c++14 } }
+
+struct StringWrapper {
+    const char* Value;
+};
+
+template <typename T>
+void f() {
+    [](auto) {
+        StringWrapper{__PRETTY_FUNCTION__};
+    };
+}
+
+int main() {
+    f<int>();
+}