* PR c++/64626 - C++14 single quote should not always be a digit separator
@ 2015-03-08 18:33 Ed Smith-Rowland
2015-03-08 18:52 ` Jakub Jelinek
0 siblings, 1 reply; 7+ messages in thread
From: Ed Smith-Rowland @ 2015-03-08 18:33 UTC (permalink / raw)
To: gcc-patches, Daniel Krügler, Jason Merrill, Paolo Carlini
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
I just look to see if a lexed number in libcpp ends in a '.
If so, back up one character and let string processing handle it.
I get one warning and one error for each instance but I'd rather not
error when it should pass.
Built and tests clean on x86_64-linux.
OK?
[-- Attachment #2: CL_pr64626 --]
[-- Type: text/plain, Size: 382 bytes --]
libcpp/
2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
* expr.c (parse_has_attribute): New function; (eval_token): Look for
__has_attribute__ and route to parse_has_attribute.
gcc/testsuite/
2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
g++.dg/cpp1y/pr64626.C: New.
g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings.
[-- Attachment #3: patch_pr64626_2 --]
[-- Type: text/plain, Size: 2577 bytes --]
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c (revision 221218)
+++ libcpp/lex.c (working copy)
@@ -1400,6 +1400,9 @@
NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
cur++;
}
+ /* A number can't end with a digit separator. */
+ if (DIGIT_SEP (cur[-1]))
+ --cur;
pfile->buffer->cur = cur;
}
Index: gcc/testsuite/g++.dg/cpp1y/pr64626.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/pr64626.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr64626.C (working copy)
@@ -0,0 +1,20 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+#define STR(s) #s
+int
+main()
+{
+ int i = 1'2;
+ const char *s[3]
+ {
+ STR(1' '),
+ STR(..),
+ STR(%:%),
+ };
+}
+#if 0
+1' '
+..
+%:%
+#endif
Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (revision 221218)
+++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (working copy)
@@ -10,7 +10,7 @@
i = 0004''000'000; // { dg-error "adjacent digit separators" }
i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK
i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" }
- i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "digit separator outside digit sequence" }
+ i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" }
unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" }
double d = 0.0;
@@ -18,9 +18,15 @@
d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" }
d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" }
d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" }
- d = 1.602'176'565e'-19; // { dg-error "digit separator adjacent to exponent" }
+ d = 1.602'176'565e'-19; // { dg-error "missing terminating" }
d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" }
d = 1.602'176'565e-1'9; // OK
- d = 1.602'176'565e-19'; // { dg-error "digit separator outside digit sequence" }
+ d = 1.602'176'565e-19'; // { dg-error "missing terminating" }
float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" }
}
+
+// { dg-warning "missing terminating" { target *-*-* } 13 }
+
+// { dg-warning "missing terminating" { target *-*-* } 21 }
+
+// { dg-warning "missing terminating" { target *-*-* } 24 }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-08 18:33 PR c++/64626 - C++14 single quote should not always be a digit separator Ed Smith-Rowland
@ 2015-03-08 18:52 ` Jakub Jelinek
2015-03-09 15:16 ` Ed Smith-Rowland
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2015-03-08 18:52 UTC (permalink / raw)
To: Ed Smith-Rowland
Cc: gcc-patches, Daniel Krügler, Jason Merrill, Paolo Carlini
On Sun, Mar 08, 2015 at 02:33:03PM -0400, Ed Smith-Rowland wrote:
> I just look to see if a lexed number in libcpp ends in a '.
> If so, back up one character and let string processing handle it.
>
> I get one warning and one error for each instance but I'd rather not error
> when it should pass.
>
> Built and tests clean on x86_64-linux.
>
> OK?
>
>
>
> libcpp/
>
> 2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
>
> PR c++/64626
> * expr.c (parse_has_attribute): New function; (eval_token): Look for
> __has_attribute__ and route to parse_has_attribute.
This ChangeLog entry doesn't match the patch, you've changed
lex.c (lex_number) instead...
> --- libcpp/lex.c (revision 221218)
> +++ libcpp/lex.c (working copy)
> @@ -1400,6 +1400,9 @@
> NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
> cur++;
> }
> + /* A number can't end with a digit separator. */
> + if (DIGIT_SEP (cur[-1]))
> + --cur;
>
> pfile->buffer->cur = cur;
> }
Jakub
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-08 18:52 ` Jakub Jelinek
@ 2015-03-09 15:16 ` Ed Smith-Rowland
2015-03-09 17:12 ` Ed Smith-Rowland
2015-03-09 19:22 ` Jason Merrill
0 siblings, 2 replies; 7+ messages in thread
From: Ed Smith-Rowland @ 2015-03-09 15:16 UTC (permalink / raw)
To: Jakub Jelinek
Cc: gcc-patches, Daniel Krügler, Jason Merrill, Paolo Carlini
[-- Attachment #1: Type: text/plain, Size: 1240 bytes --]
On 03/08/2015 02:52 PM, Jakub Jelinek wrote:
> On Sun, Mar 08, 2015 at 02:33:03PM -0400, Ed Smith-Rowland wrote:
>> I just look to see if a lexed number in libcpp ends in a '.
>> If so, back up one character and let string processing handle it.
>>
>> I get one warning and one error for each instance but I'd rather not error
>> when it should pass.
>>
>> Built and tests clean on x86_64-linux.
>>
>> OK?
>>
>>
>> libcpp/
>>
>> 2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
>>
>> PR c++/64626
>> * expr.c (parse_has_attribute): New function; (eval_token): Look for
>> __has_attribute__ and route to parse_has_attribute.
> This ChangeLog entry doesn't match the patch, you've changed
> lex.c (lex_number) instead...
>
>> --- libcpp/lex.c (revision 221218)
>> +++ libcpp/lex.c (working copy)
>> @@ -1400,6 +1400,9 @@
>> NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
>> cur++;
>> }
>> + /* A number can't end with a digit separator. */
>> + if (DIGIT_SEP (cur[-1]))
>> + --cur;
>>
>> pfile->buffer->cur = cur;
>> }
> Jakub
>
Sigh. A paste-o from another CL entry.
Also, I decided I should treat the following:
0'';
123''''';
It won't hurt and it's easy.
Here is a new patch and CL.
Ed
[-- Attachment #2: patch_pr64626_3 --]
[-- Type: text/plain, Size: 3314 bytes --]
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c (revision 221218)
+++ libcpp/lex.c (working copy)
@@ -1400,6 +1400,9 @@
NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
cur++;
}
+ /* A number can't end with a digit separator. */
+ while (cur > pfile->buffer->cur && DIGIT_SEP (cur[-1]))
+ --cur;
pfile->buffer->cur = cur;
}
Index: gcc/testsuite/g++.dg/cpp1y/pr64626-1.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/pr64626-1.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr64626-1.C (working copy)
@@ -0,0 +1,20 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+#define STR(s) #s
+int
+main()
+{
+ int i = 1'2;
+ const char *s[3]
+ {
+ STR(1' '),
+ STR(..),
+ STR(%:%),
+ };
+}
+#if 0
+1' '
+..
+%:%
+#endif
Index: gcc/testsuite/g++.dg/cpp1y/pr64626-2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/pr64626-2.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr64626-2.C (working copy)
@@ -0,0 +1,12 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+0''; // { dg-error "empty character constant" }
+
+123'''; // { dg-error "empty character constant" }
+
+// { dg-error "expected unqualified-id before numeric constant" { target *-*-* } 4 }
+
+// { dg-warning "missing terminating" { target *-*-* } 6 }
+// { dg-error "missing terminating" { target *-*-* } 6 }
+// { dg-error "expected unqualified-id before numeric constant" { target *-*-* } 6 }
Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (revision 221218)
+++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (working copy)
@@ -10,7 +10,7 @@
i = 0004''000'000; // { dg-error "adjacent digit separators" }
i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK
i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" }
- i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "digit separator outside digit sequence" }
+ i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" }
unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" }
double d = 0.0;
@@ -18,9 +18,15 @@
d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" }
d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" }
d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" }
- d = 1.602'176'565e'-19; // { dg-error "digit separator adjacent to exponent" }
+ d = 1.602'176'565e'-19; // { dg-error "missing terminating" }
d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" }
d = 1.602'176'565e-1'9; // OK
- d = 1.602'176'565e-19'; // { dg-error "digit separator outside digit sequence" }
+ d = 1.602'176'565e-19'; // { dg-error "missing terminating" }
float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" }
}
+
+// { dg-warning "missing terminating" { target *-*-* } 13 }
+
+// { dg-warning "missing terminating" { target *-*-* } 21 }
+
+// { dg-warning "missing terminating" { target *-*-* } 24 }
[-- Attachment #3: CL_pr64626_2 --]
[-- Type: text/plain, Size: 394 bytes --]
libcpp/
2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
* lex.c (lex_number): If a number ends with digit-seps (') skip back
and let lex_string take them.
gcc/testsuite/
2015-03-09 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
g++.dg/cpp1y/pr64626-1.C: New.
g++.dg/cpp1y/pr64626-2.C: New.
g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-09 15:16 ` Ed Smith-Rowland
@ 2015-03-09 17:12 ` Ed Smith-Rowland
2015-03-09 19:22 ` Jason Merrill
1 sibling, 0 replies; 7+ messages in thread
From: Ed Smith-Rowland @ 2015-03-09 17:12 UTC (permalink / raw)
To: Jakub Jelinek
Cc: gcc-patches, Daniel Krügler, Jason Merrill, Paolo Carlini
Forget this last patch.
The syntax of my dg lines was wrong and I'm seeing errors I'm not sure I
like.
I need to look at this further.
I'm sorry for the noise.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-09 15:16 ` Ed Smith-Rowland
2015-03-09 17:12 ` Ed Smith-Rowland
@ 2015-03-09 19:22 ` Jason Merrill
2015-03-16 3:27 ` Ed Smith-Rowland
1 sibling, 1 reply; 7+ messages in thread
From: Jason Merrill @ 2015-03-09 19:22 UTC (permalink / raw)
To: Ed Smith-Rowland, Jakub Jelinek
Cc: gcc-patches, Daniel Krügler, Paolo Carlini
OK, thanks.
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-09 19:22 ` Jason Merrill
@ 2015-03-16 3:27 ` Ed Smith-Rowland
2015-03-16 13:19 ` Jason Merrill
0 siblings, 1 reply; 7+ messages in thread
From: Ed Smith-Rowland @ 2015-03-16 3:27 UTC (permalink / raw)
To: Jason Merrill, Jakub Jelinek
Cc: gcc-patches, Daniel Krügler, Paolo Carlini
[-- Attachment #1: Type: text/plain, Size: 247 bytes --]
OK,
Here is a new try at PR c++/64626 - C++14 single quote should not always
be a digit separator.
I decided to look for multiple terminating single quotes.
The test cases have bee adjusted and debugged.
Built and tested on x86_64-linux.
Ed
[-- Attachment #2: CL_pr64626_2 --]
[-- Type: text/plain, Size: 394 bytes --]
libcpp/
2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
* lex.c (lex_number): If a number ends with digit-seps (') skip back
and let lex_string take them.
gcc/testsuite/
2015-03-16 Edward Smith-Rowland <3dw4rd@verizon.net>
PR c++/64626
g++.dg/cpp1y/pr64626-1.C: New.
g++.dg/cpp1y/pr64626-2.C: New.
g++.dg/cpp1y/digit-sep-neg.C: Adjust errors and warnings.
[-- Attachment #3: patch_pr64626_3 --]
[-- Type: text/plain, Size: 3342 bytes --]
Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c (revision 221440)
+++ libcpp/lex.c (working copy)
@@ -1400,6 +1400,9 @@
NORMALIZE_STATE_UPDATE_IDNUM (nst, *cur);
cur++;
}
+ /* A number can't end with a digit separator. */
+ while (cur > pfile->buffer->cur && DIGIT_SEP (cur[-1]))
+ --cur;
pfile->buffer->cur = cur;
}
Index: gcc/testsuite/g++.dg/cpp1y/pr64626-1.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/pr64626-1.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr64626-1.C (working copy)
@@ -0,0 +1,20 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+#define STR(s) #s
+int
+main()
+{
+ int i = 1'2;
+ const char *s[3]
+ {
+ STR(1' '),
+ STR(..),
+ STR(%:%),
+ };
+}
+#if 0
+1' '
+..
+%:%
+#endif
Index: gcc/testsuite/g++.dg/cpp1y/pr64626-2.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/pr64626-2.C (revision 0)
+++ gcc/testsuite/g++.dg/cpp1y/pr64626-2.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/64626
+// { dg-do compile { target c++14 } }
+
+0''; // { dg-error "empty character constant" }
+
+123'''; // { dg-error "empty character constant" }
+
+// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 4 }
+
+// { dg-error "missing terminating" "missing terminating" { target *-*-* } 6 }
+// { dg-error "expected unqualified-id" "expected unqualified-id" { target *-*-* } 6 }
Index: gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C
===================================================================
--- gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (revision 221440)
+++ gcc/testsuite/g++.dg/cpp1y/digit-sep-neg.C (working copy)
@@ -10,7 +10,7 @@
i = 0004''000'000; // { dg-error "adjacent digit separators" }
i = 0B1'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0; // OK
i = 0b'0001'0000'0000'0000'0000'0000; // { dg-error "digit separator after base indicator" }
- i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "digit separator outside digit sequence" }
+ i = 0b0001'0000'0000'0000'0000'0000'; // { dg-error "missing terminating" }
unsigned u = 0b0001'0000'0000'0000'0000'0000'U; // { dg-error "digit separator outside digit sequence" }
double d = 0.0;
@@ -18,9 +18,13 @@
d = 1.'602'176'565e-19; // { dg-error "digit separator adjacent to decimal point" }
d = 1.602''176'565e-19; // { dg-error "adjacent digit separators" }
d = 1.602'176'565'e-19; // { dg-error "digit separator adjacent to exponent" }
- d = 1.602'176'565e'-19; // { dg-error "digit separator adjacent to exponent" }
+ d = 1.602'176'565e'-19; // { dg-error "missing terminating" }
d = 1.602'176'565e-'19; // { dg-error "digit separator adjacent to exponent" }
d = 1.602'176'565e-1'9; // OK
- d = 1.602'176'565e-19'; // { dg-error "digit separator outside digit sequence" }
+ d = 1.602'176'565e-19'; // { dg-error "missing terminating" }
float f = 1.602'176'565e-19'F; // { dg-error "digit separator outside digit sequence" }
}
+
+// { dg-error "exponent has no digits" "exponent has no digits" { target *-*-* } 21 }
+// { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 14 }
+// { dg-error "expected ';' before" "expected ';' before" { target *-*-* } 25 }
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR c++/64626 - C++14 single quote should not always be a digit separator
2015-03-16 3:27 ` Ed Smith-Rowland
@ 2015-03-16 13:19 ` Jason Merrill
0 siblings, 0 replies; 7+ messages in thread
From: Jason Merrill @ 2015-03-16 13:19 UTC (permalink / raw)
To: Ed Smith-Rowland, Jakub Jelinek
Cc: gcc-patches, Daniel Krügler, Paolo Carlini
OK.
Jason
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-03-16 13:19 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-08 18:33 PR c++/64626 - C++14 single quote should not always be a digit separator Ed Smith-Rowland
2015-03-08 18:52 ` Jakub Jelinek
2015-03-09 15:16 ` Ed Smith-Rowland
2015-03-09 17:12 ` Ed Smith-Rowland
2015-03-09 19:22 ` Jason Merrill
2015-03-16 3:27 ` Ed Smith-Rowland
2015-03-16 13:19 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).