aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2014-07-01 03:13:17 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2014-07-01 03:13:17 +0000
commit9378b06e5c414f565fb2eeff32234c1e5d84491a (patch)
tree936639ab85de8ce1b38079e49a50992c1f725252
parent5bcb66dffabd20f12fd8392820aa7dd00280091e (diff)
downloadgcc-9378b06e5c414f565fb2eeff32234c1e5d84491a.zip
gcc-9378b06e5c414f565fb2eeff32234c1e5d84491a.tar.gz
gcc-9378b06e5c414f565fb2eeff32234c1e5d84491a.tar.bz2
re PR c++/58781 (Unicode strings broken in a strange way)
cp/ 2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/58781 PR c++/60249 PR c++/59867 * parser.c (cp_parser_userdef_string_literal()): Take a tree not a cp_token*. (cp_parser_string_literal(): Don't hack the token stream! testsuite/ 2014-06-28 Edward Smith-Rowland <3dw4rd@verizon.net> PR c++/58781 PR c++/60249 PR c++/59867 * testsuite/g++.dg/cpp0x/pr58781.C: New. * testsuite/g++.dg/cpp0x/pr60249.C: New. * testsuite/g++.dg/cpp1y/pr59867.C: New. From-SVN: r212186
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c23
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr58781.C18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr60249.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr59867.C52
6 files changed, 108 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cc98833..ce67fcd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2014-06-30 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/58781
+ PR c++/60249
+ PR c++/59867
+ * parser.c (cp_parser_userdef_string_literal()): Take a tree
+ not a cp_token*. (cp_parser_string_literal(): Don't hack
+ the token stream!
+
2014-06-30 Jason Merrill <jason@redhat.com>
PR c++/61659
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 013fc6e..8ff57c7 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1899,7 +1899,7 @@ static tree cp_parser_string_literal
static tree cp_parser_userdef_char_literal
(cp_parser *);
static tree cp_parser_userdef_string_literal
- (cp_token *);
+ (tree);
static tree cp_parser_userdef_numeric_literal
(cp_parser *);
@@ -3721,8 +3721,7 @@ cp_parser_string_literal (cp_parser *parser, bool translate, bool wide_ok)
{
tree literal = build_userdef_literal (suffix_id, value,
OT_NONE, NULL_TREE);
- tok->u.value = literal;
- return cp_parser_userdef_string_literal (tok);
+ value = cp_parser_userdef_string_literal (literal);
}
}
else
@@ -3970,9 +3969,8 @@ cp_parser_userdef_numeric_literal (cp_parser *parser)
as arguments. */
static tree
-cp_parser_userdef_string_literal (cp_token *token)
+cp_parser_userdef_string_literal (tree literal)
{
- tree literal = token->u.value;
tree suffix_id = USERDEF_LITERAL_SUFFIX_ID (literal);
tree name = cp_literal_operator_id (IDENTIFIER_POINTER (suffix_id));
tree value = USERDEF_LITERAL_VALUE (literal);
@@ -23224,10 +23222,17 @@ cp_parser_template_declaration_after_export (cp_parser* parser, bool member_p)
ok = false;
}
if (!ok)
- error ("literal operator template %qD has invalid parameter list."
- " Expected non-type template argument pack <char...>"
- " or <typename CharT, CharT...>",
- decl);
+ {
+ if (cxx_dialect >= cxx1y)
+ error ("literal operator template %qD has invalid parameter list."
+ " Expected non-type template argument pack <char...>"
+ " or <typename CharT, CharT...>",
+ decl);
+ else
+ error ("literal operator template %qD has invalid parameter list."
+ " Expected non-type template argument pack <char...>",
+ decl);
+ }
}
/* Register member declarations. */
if (member_p && !friend_p && decl && !DECL_CLASS_TEMPLATE_P (decl))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bf35498..6c81942 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2014-06-30 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ PR c++/58781
+ PR c++/60249
+ PR c++/59867
+ * testsuite/g++.dg/cpp0x/pr58781.C: New.
+ * testsuite/g++.dg/cpp0x/pr60249.C: New.
+ * testsuite/g++.dg/cpp1y/pr59867.C: New.
+
2014-06-30 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gfortran.dg/round_4.f90: Skip for powerpc*-*-linux* since the
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr58781.C b/gcc/testsuite/g++.dg/cpp0x/pr58781.C
new file mode 100644
index 0000000..58c972f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr58781.C
@@ -0,0 +1,18 @@
+// PR c++/58781
+// { dg-do compile { target c++11 } }
+
+#include <cstddef>
+
+int
+operator""_s(const char32_t *a, size_t b)
+{
+ return 0;
+}
+
+int
+f()
+{
+ using a = decltype(U"\x1181"_s);
+ using b = decltype(U"\x8111"_s);
+ using c = decltype(U" \x1181"_s);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr60249.C b/gcc/testsuite/g++.dg/cpp0x/pr60249.C
new file mode 100644
index 0000000..e650dcb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr60249.C
@@ -0,0 +1,6 @@
+// PR c++/60249
+// { dg-do compile { target c++11 } }
+
+decltype(""_) x; // { dg-error "unable to find string literal operator" }
+
+// { dg-error "invalid type in declaration before" "invalid" { target *-*-* } 4 }
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59867.C b/gcc/testsuite/g++.dg/cpp1y/pr59867.C
new file mode 100644
index 0000000..0f27a20
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59867.C
@@ -0,0 +1,52 @@
+// PR c++/59867
+// { dg-do compile { target c++14 } }
+
+#include <iostream>
+using namespace std;
+
+// constant
+template<typename T, T x>
+ struct meta_value
+ {
+ typedef meta_value type;
+ typedef T value_type;
+ static const T value = x;
+ };
+
+// array
+template<typename T, T... data>
+ struct meta_array
+ {
+ typedef meta_array type;
+ typedef T item_type;
+ };
+
+// static array -> runtime array conversion utility
+template<typename T>
+ struct array_gen;
+
+template<typename T, T... xs>
+ struct array_gen<meta_array<T, xs...>>
+ {
+ static const T value[sizeof...(xs)];
+ };
+
+template<typename T, T... xs>
+ const T
+ array_gen<meta_array<T, xs...>>::value[sizeof...(xs)] = {xs...};
+
+// static string
+template<typename T, T... xs>
+ constexpr meta_array<T, xs...>
+ operator""_s()
+ {
+ static_assert(sizeof...(xs) == 3, "What's wrong with you?");
+ return meta_array<T, xs...>();
+ }
+
+int
+main()
+{
+ auto a = "123"_s;
+ const char (& xs)[3] = array_gen<decltype("123"_s)>::value;
+}