re PR c++/77752 (ICE on C++ code on x86_64-linux-gnu (internal compiler error: Segmen...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 21 Mar 2017 10:18:51 +0000 (10:18 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 21 Mar 2017 10:18:51 +0000 (10:18 +0000)
/cp
2017-03-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/77752
* name-lookup.c (pushtag_1): Add check for bogus, non template,
std::initializer_list.

/testsuite
2017-03-21  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/77752
* g++.dg/cpp0x/initlist97.C: New.
* g++.dg/cpp0x/initlist85.C: Update.

From-SVN: r246310

gcc/cp/ChangeLog
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist85.C
gcc/testsuite/g++.dg/cpp0x/initlist97.C [new file with mode: 0644]

index 20eaf630224f27915e59c0647d0acafe15456c7c..3db9895d5a8cb14da8ac17eb8d37ace6d29c7b0c 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/77752
+       * name-lookup.c (pushtag_1): Add check for bogus, non template,
+       std::initializer_list.
+
 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/35878
index 994f7f0c5c36eb6e89fcb76bc920c8e45fbbc52e..4d7d3a1bad4c613ecd47862cb6801f17c6d6cebc 100644 (file)
@@ -6207,6 +6207,15 @@ pushtag_1 (tree name, tree type, tag_scope scope)
          decl = pushdecl_with_scope_1 (decl, b, /*is_friend=*/false);
          if (decl == error_mark_node)
            return decl;
+
+         if (DECL_CONTEXT (decl) == std_node
+             && strcmp (TYPE_NAME_STRING (type), "initializer_list") == 0
+             && !CLASSTYPE_TEMPLATE_INFO (type))
+           {
+             error ("declaration of std::initializer_list does not match "
+                    "#include <initializer_list>, isn't a template");
+             return error_mark_node;
+           }
        }
 
       if (! in_class)
index 69cf11200da2cdf7db19ff83709d5d9ccf4ecdcf..a4d58737308acc3ee9529d764bd463be49971af0 100644 (file)
@@ -1,3 +1,9 @@
+2017-03-21  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/77752
+       * g++.dg/cpp0x/initlist97.C: New.
+       * g++.dg/cpp0x/initlist85.C: Update.
+
 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/67338
index fa4fb617b33e59fb33ea71ab8fca7ec68449f137..0b5ce497e491c172bd202fd7a86e6f299bd93f20 100644 (file)
@@ -3,14 +3,12 @@
 
 namespace std
 {
-  struct initializer_list {};  // { dg-message "initializer_list" }
+  struct initializer_list {};  // { dg-error "declaration" }
 }
 
 void foo(std::initializer_list &);
 
 void f()
 {
-  foo({1, 2});
+  foo({1, 2});  // { dg-error "invalid initialization" }
 }
-
-// { dg-prune-output "compilation terminated" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist97.C b/gcc/testsuite/g++.dg/cpp0x/initlist97.C
new file mode 100644 (file)
index 0000000..be47415
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/77752
+// { dg-do compile { target c++11 } }
+
+namespace std {
+  class initializer_list;  // { dg-error "declaration" }
+}
+void f(std::initializer_list l) { f({2}); }  // { dg-error "incomplete type" }