aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-05-15 18:51:11 -0400
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:03:32 -0300
commit1f5d9aa6dfcf70fb3b0582db9ce0e0864fe699c1 (patch)
tree936cf8ce6ee011d3a4931e69f432d4d7ed416385 /gcc
parentef3111ed0ad2f5b15d09bbc7b09ef212997bda8d (diff)
downloadgcc-1f5d9aa6dfcf70fb3b0582db9ce0e0864fe699c1.zip
gcc-1f5d9aa6dfcf70fb3b0582db9ce0e0864fe699c1.tar.gz
gcc-1f5d9aa6dfcf70fb3b0582db9ce0e0864fe699c1.tar.bz2
c++: decltype of invalid non-dependent expr [PR57943]
We sometimes fail to reject an invalid non-dependent operand to decltype when inside a template, because finish_decltype_type resolves the decltype to the TREE_TYPE of the operand before we ever instantiate and fully process the operand. Fix this by adding a call to instantiate_non_dependent_expr_sfinae in finish_decltype_type. gcc/cp/ChangeLog: PR c++/57943 * semantics.c (finish_decltype_type): Call instantiate_non_dependent_expr_sfinae on the expression. gcc/testsuite/ChangeLog: PR c++/57943 * g++.dg/cpp0x/decltype76.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/decltype76.C7
4 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index acd2d7b..4b9fc52 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-16 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/57943
+ * semantics.c (finish_decltype_type): Call
+ instantiate_non_dependent_expr_sfinae on the expression.
+
2020-05-15 Patrick Palka <ppalka@redhat.com>
Revert:
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d90816e..64587c7 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9746,6 +9746,14 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
return type;
}
+ else if (processing_template_decl)
+ {
+ ++cp_unevaluated_operand;
+ expr = instantiate_non_dependent_expr_sfinae (expr, complain);
+ --cp_unevaluated_operand;
+ if (expr == error_mark_node)
+ return error_mark_node;
+ }
/* The type denoted by decltype(e) is defined as follows: */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 875ac82..a7f7771 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-05-16 Patrick Palka <ppalka@redhat.com>
+
+ PR c++/57943
+ * g++.dg/cpp0x/decltype76.C: New test.
+
2020-05-15 Jason Merrill <jason@redhat.com>
* g++.dg/coroutines/coro.h: Always #include <utility>.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype76.C b/gcc/testsuite/g++.dg/cpp0x/decltype76.C
new file mode 100644
index 0000000..239fe6d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype76.C
@@ -0,0 +1,7 @@
+// PR c+/57943
+// { dg-do compile { target c++11 } }
+
+struct a { };
+
+template <typename T = decltype (a(0))> // { dg-error "" }
+void f() { }