PR c++/88373 - wrong parse error with ~.
authorMarek Polacek <polacek@redhat.com>
Thu, 6 Dec 2018 19:43:17 +0000 (19:43 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 6 Dec 2018 19:43:17 +0000 (19:43 +0000)
* parser.c (cp_parser_template_name): Check tag_type for
none_type.

* g++.dg/cpp2a/fn-template19.C: New test.

From-SVN: r266865

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/fn-template19.C [new file with mode: 0644]

index 89f2d8896abe1c858a867c809b01010a709e3f4b..1a3e73e40c6dcb2793d773db9781a602b5081fb5 100644 (file)
@@ -1,3 +1,9 @@
+2018-12-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88373 - wrong parse error with ~.
+       * parser.c (cp_parser_template_name): Check tag_type for
+       none_type.
+
 2018-12-06  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * cp-tree.h (finish_asm_stmt): Update declaration.
index ceae72a7709e7d0fe8308631a0897b0407caa5b7..adfe09e494dcb34941d1d2def6edde82d400eefa 100644 (file)
@@ -16579,7 +16579,8 @@ cp_parser_template_name (cp_parser* parser,
       if (!found
          && (cxx_dialect > cxx17)
          && !scoped_p
-         && cp_lexer_next_token_is (parser->lexer, CPP_LESS))
+         && cp_lexer_next_token_is (parser->lexer, CPP_LESS)
+         && tag_type == none_type)
        {
          /* [temp.names] says "A name is also considered to refer to a template
             if it is an unqualified-id followed by a < and name lookup finds
index acac4fdcee59a8feadc7fb7de67d950b332b2209..047b4b3bf01fbad42ec8ecbe2c1024f82596b18c 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-06  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/88373 - wrong parse error with ~.
+       * g++.dg/cpp2a/fn-template19.C: New test.
+
 2018-12-06  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc.dg/vect/vect-over-widen-23.c: Remove unwanted line.
diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template19.C b/gcc/testsuite/g++.dg/cpp2a/fn-template19.C
new file mode 100644 (file)
index 0000000..1d6b43b
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/88373
+// { dg-do compile }
+// { dg-options "-std=c++2a" }
+
+template <class T>
+constexpr T value = T {};
+
+template <class T, T t>
+struct S {};
+
+using U = S <int, ~value <int>>;