From 65e5a578a8c9a1212ceb19ab0bf5d309465f1c5d Mon Sep 17 00:00:00 2001 From: Ed Smith-Rowland <3dw4rd@verizon.net> Date: Sun, 4 Aug 2013 19:11:21 +0000 Subject: [PATCH] re PR c++/58072 ([C++11] Error messages involving user-defined literals are poor (refer to tokens)) gcc/c-family: 2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net> PR c++/58072 * c-common.c (c_parse_error): Catch user-defined literal tokens and provide useful error strings. gcc/testsuite: 2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net> PR c++/58072 * g++.dg/cpp0x/pr58072.C: New. From-SVN: r201475 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-common.c | 12 ++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/pr58072.C | 18 ++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr58072.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 019ee80736a..d8ca539b3fc 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net> + + PR c++/58072 + * c-common.c (c_parse_error): Catch user-defined literal tokens and + provide useful error strings. + 2013-08-03 Gabriel Dos Reis * c-ada-spec.c (pp_ada_tree_identifier): Use specialized pretty diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7bba376f369..2c806abe470 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -9352,6 +9352,18 @@ c_parse_error (const char *gmsgid, enum cpp_ttype token_type, free (message); message = NULL; } + else if (token_type == CPP_CHAR_USERDEF + || token_type == CPP_WCHAR_USERDEF + || token_type == CPP_CHAR16_USERDEF + || token_type == CPP_CHAR32_USERDEF) + message = catenate_messages (gmsgid, + " before user-defined character literal"); + else if (token_type == CPP_STRING_USERDEF + || token_type == CPP_WSTRING_USERDEF + || token_type == CPP_STRING16_USERDEF + || token_type == CPP_STRING32_USERDEF + || token_type == CPP_UTF8STRING_USERDEF) + message = catenate_messages (gmsgid, " before user-defined string literal"); else if (token_type == CPP_STRING || token_type == CPP_WSTRING || token_type == CPP_STRING16 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f98ca348ff9..f356d55c990 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-08-04 Ed Smith-Rowland <3dw4rd@verizon.net> + + PR c++/58072 + * g++.dg/cpp0x/pr58072.C: New. + 2013-08-03 Bill Schmidt * gcc.dg/torture/pr57993-2.cpp: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr58072.C b/gcc/testsuite/g++.dg/cpp0x/pr58072.C new file mode 100644 index 00000000000..941d7c7499c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr58072.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-std=c++11" } + +// PR c++/58072 + +extern 'c'void*blah(void*); // { dg-error "expected unqualified-id before user-defined character literal" } +extern L'c'void*Lblah(void*); // { dg-error "expected unqualified-id before user-defined character literal" } +extern u'c'void*ublah(void*); // { dg-error "expected unqualified-id before user-defined character literal" } +extern U'c'void*Ublah(void*); // { dg-error "expected unqualified-id before user-defined character literal" } + +extern "c"void*strblah(void*); // { dg-error "expected unqualified-id before user-defined string literal" } +extern L"c"void*Lstrblah(void*); // { dg-error "expected unqualified-id before user-defined string literal" } +extern u"c"void*ustrblah(void*); // { dg-error "expected unqualified-id before user-defined string literal" } +extern U"c"void*Ustrblah(void*); // { dg-error "expected unqualified-id before user-defined string literal" } +extern u8"c"void*u8strblah(void*); // { dg-error "expected unqualified-id before user-defined string literal" } + +extern 123void*ULLblah(void*); // { dg-error "expected unqualified-id before numeric constant" } +extern 123.456void*Ldblblah(void*); // { dg-error "expected unqualified-id before numeric constant" }