aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/semantics.cc9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/dr2351-2.C16
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 7d46c3c..82f9dd8 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -3164,7 +3164,14 @@ finish_compound_literal (tree type, tree compound_literal,
{
/* DR2351 */
if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0)
- return void_node;
+ {
+ if (!processing_template_decl)
+ return void_node;
+ TREE_TYPE (compound_literal) = type;
+ TREE_HAS_CONSTRUCTOR (compound_literal) = 1;
+ CONSTRUCTOR_IS_DEPENDENT (compound_literal) = 0;
+ return compound_literal;
+ }
else if (VOID_TYPE_P (type)
&& processing_template_decl
&& maybe_zero_constructor_nelts (compound_literal))
diff --git a/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C b/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C
new file mode 100644
index 0000000..deb1718
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/dr2351-2.C
@@ -0,0 +1,16 @@
+// DR2351
+// { dg-do compile { target c++11 } }
+
+void bar (int);
+
+template <typename T>
+auto foo (T t) -> decltype (bar (t), void{})
+{
+ return bar (t);
+}
+
+int
+main ()
+{
+ foo (0);
+}