re PR c++/65072 (Segfault when parsing dectlype in trailing return type)
authorMarek Polacek <polacek@redhat.com>
Fri, 20 Mar 2015 14:56:53 +0000 (14:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 20 Mar 2015 14:56:53 +0000 (14:56 +0000)
PR c++/65072
* typeck.c (lookup_anon_field): Make sure we're dealing with the main
variant.

* g++.dg/cpp0x/pr65072.C: New test.

From-SVN: r221535

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr65072.C [new file with mode: 0644]

index f90e447cc988f26825fcbcaaf384f839c2a11901..dadf6739ad1c7a11d39e919d16957eb60a8aaf05 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-20  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65072
+       * typeck.c (lookup_anon_field): Make sure we're dealing with the main
+       variant.
+
 2015-03-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/65046
index 4c128b7ebe472cf255094da12080acaa65043800..e9d4cae57051aa36327c07c9d3abd09b0d8d92c1 100644 (file)
@@ -2213,6 +2213,8 @@ lookup_anon_field (tree t, tree type)
 {
   tree field;
 
+  t = TYPE_MAIN_VARIANT (t);
+
   for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
     {
       if (TREE_STATIC (field))
index 884fb62745911c5b51370e422adde1aad8431ea4..c489b28c3e470bbe44c52bf12395fa89f40eb0d2 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-20  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/65072
+       * g++.dg/cpp0x/pr65072.C: New test.
+
 2015-03-20  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/64715
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr65072.C b/gcc/testsuite/g++.dg/cpp0x/pr65072.C
new file mode 100644 (file)
index 0000000..b8fa888
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/65075
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wno-pedantic" }
+
+template <typename> class C
+{
+  struct
+  {
+    int i;
+  };
+  auto operator*(const C m) -> decltype (m.i);
+};
+void fn1 (const C<float>);
+C<float> a;