re PR c++/61614 (Bogus error: taking address of temporary array)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 27 Jun 2014 14:04:28 +0000 (14:04 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 27 Jun 2014 14:04:28 +0000 (14:04 +0000)
/cp
2014-06-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/61614
* semantics.c (finish_compound_literal): Revert r204228.

/testsuite
2014-06-27  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/61614
* g++.dg/ext/complit14.C: New.

From-SVN: r212073

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/complit14.C [new file with mode: 0644]

index e8aee0f..90ec8ad 100644 (file)
@@ -1,5 +1,10 @@
 2014-06-27  Paolo Carlini  <paolo.carlini@oracle.com>
 
+       PR c++/61614
+       * semantics.c (finish_compound_literal): Revert r204228.
+
+2014-06-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
        * parser.c (cp_parser_compound_literal_p): New.
        (cp_parser_postfix_expression, cp_parser_sizeof_operand): Use it.
 
index 241884c..456df7b 100644 (file)
@@ -2607,7 +2607,6 @@ finish_compound_literal (tree type, tree compound_literal,
   if ((!at_function_scope_p () || CP_TYPE_CONST_P (type))
       && TREE_CODE (type) == ARRAY_TYPE
       && !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
-      && !cp_unevaluated_operand
       && initializer_constant_valid_p (compound_literal, type))
     {
       tree decl = create_temporary_var (type);
index 04d08b5..979f2e6 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-27  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/61614
+       * g++.dg/ext/complit14.C: New.
+
 2014-06-27  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/61160
diff --git a/gcc/testsuite/g++.dg/ext/complit14.C b/gcc/testsuite/g++.dg/ext/complit14.C
new file mode 100644 (file)
index 0000000..aed765d
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/61614
+// { dg-options "" }
+
+int Fn (...);
+
+void
+Test ()
+{
+  int j = Fn ((const int[]) { 0 });                    // OK
+  unsigned long sz = sizeof Fn ((const int[]) { 0 });  // Error
+}