re PR c++/71182 (parser.c cp_lexer_previous_token sanitizer detects member call on...
authorJakub Jelinek <jakub@redhat.com>
Wed, 4 Jan 2017 20:05:14 +0000 (21:05 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 4 Jan 2017 20:05:14 +0000 (21:05 +0100)
PR c++/71182
* parser.c (cp_lexer_previous_token): Use vec_safe_address in the
assertion, as lexer->buffer may be NULL.

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

From-SVN: r244070

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

index 48061a02f8b13f60e6f7d6c53db1f4ba082d6079..16294204b6d776a0b6285bf2b17573129d908f54 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71182
+       * parser.c (cp_lexer_previous_token): Use vec_safe_address in the
+       assertion, as lexer->buffer may be NULL.
+
 2017-01-04  Marek Polacek  <polacek@redhat.com>
 
        PR c++/77545
index b94270d39f83d351b0c4595e8fbe21cda4765cfa..b4b8f13df2cc6629aab95b13e5b112d124035002 100644 (file)
@@ -766,7 +766,7 @@ cp_lexer_previous_token (cp_lexer *lexer)
   /* Skip past purged tokens.  */
   while (tp->purged_p)
     {
-      gcc_assert (tp != lexer->buffer->address ());
+      gcc_assert (tp != vec_safe_address (lexer->buffer));
       tp--;
     }
 
index 5a3da3ba85da82f6215e37a5115b00adbd8501b1..53ba248dab91a68192ce855bc20b05e0e8080b83 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/71182
+       * g++.dg/cpp0x/pr71182.C: New test.
+
 2017-01-04  Kelvin Nilsen  <kelvin@gcc.gnu.org>
 
        PR target/78056
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr71182.C b/gcc/testsuite/g++.dg/cpp0x/pr71182.C
new file mode 100644 (file)
index 0000000..c5c0c54
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/71182
+// { dg-do compile { target c++11 } }
+
+class A {
+  template <typename> void As();
+};
+template <typename T> class B : A {
+  void f() {
+    A *g ;
+    g ? g->As<T>() : nullptr;
+  }
+};