@@ -546,6 +546,12 @@ struct cpp_options
/* Nonzero for C++23 delimited escape sequences. */
unsigned char delimited_escape_seqs;
+ /* Nonzero for C++23 named universal character escape sequences. */
+ unsigned char named_uc_escape_seqs;
+
+ /* Nonzero for C2Y 0o prefixed octal integer constants. */
+ unsigned char octal_constants;
+
/* Nonzero for 'true' and 'false' in #if expressions. */
unsigned char true_false;
@@ -577,6 +583,9 @@ struct cpp_options
/* True if warn about differences between C11 and C23. */
signed char cpp_warn_c11_c23_compat;
+ /* True if warn about differences between C23 and C2Y. */
+ signed char cpp_warn_c23_c2y_compat;
+
/* True if warn about differences between C++98 and C++11. */
bool cpp_warn_cxx11_compat;
@@ -711,6 +720,7 @@ enum cpp_warning_reason {
CPP_W_PEDANTIC,
CPP_W_C90_C99_COMPAT,
CPP_W_C11_C23_COMPAT,
+ CPP_W_C23_C2Y_COMPAT,
CPP_W_CXX11_COMPAT,
CPP_W_CXX20_COMPAT,
CPP_W_CXX14_EXTENSIONS,
@@ -108,46 +108,48 @@ struct lang_flags
unsigned int elifdef : 1;
unsigned int warning_directive : 1;
unsigned int delimited_escape_seqs : 1;
+ unsigned int named_uc_escape_seqs : 1;
+ unsigned int octal_constants : 1;
unsigned int true_false : 1;
unsigned int embed : 1;
};
static const struct lang_flags lang_defaults[] = {
- /* u e w
- b d 8 l a t
- x u i i c v s s i r d r e
- x i d u r d n g t h a c z f n e u m
- c c n x c d s i l l l c s r l o o d l d d l f b
- 9 + u i 1 i t g i i i s e i i p p f i e i i a e
- 9 + m d 1 d d r t t t t p g t t e p t f r m l d */
- /* GNUC89 */ { 0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
- /* GNUC99 */ { 1,0,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
- /* GNUC11 */ { 1,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
- /* GNUC17 */ { 1,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
- /* GNUC23 */ { 1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1 },
- /* GNUC2Y */ { 1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,0,1,1,0,1,1 },
- /* STDC89 */ { 0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
- /* STDC94 */ { 0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
- /* STDC99 */ { 1,0,1,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
- /* STDC11 */ { 1,0,1,1,1,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
- /* STDC17 */ { 1,0,1,1,1,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0 },
- /* STDC23 */ { 1,0,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,0,1,1 },
- /* STDC2Y */ { 1,0,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,0,1,1 },
- /* GNUCXX */ { 0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0 },
- /* CXX98 */ { 0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0 },
- /* GNUCXX11 */ { 1,1,1,1,1,1,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0 },
- /* CXX11 */ { 1,1,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,0,0,0,0,0,1,0 },
- /* GNUCXX14 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,1,0 },
- /* CXX14 */ { 1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,1,0 },
- /* GNUCXX17 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,1,0 },
- /* CXX17 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,0 },
- /* GNUCXX20 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,1,0 },
- /* CXX20 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,1,0 },
- /* GNUCXX23 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 },
- /* CXX23 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 },
- /* GNUCXX26 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 },
- /* CXX26 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0 },
- /* ASM */ { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+ /* u e w n
+ b d 8 l a a t
+ x u i i c v s s i r d m o r e
+ x i d u r d n g t h a c z f n e e c u m
+ c c n x c d s i l l l c s r l o o d l d d l d t f b
+ 9 + u i 1 i t g i i i s e i i p p f i e i i u a a e
+ 9 + m d 1 d d r t t t t p g t t e p t f r m c l l d */
+ /* GNUC89 */ { 0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
+ /* GNUC99 */ { 1,0,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
+ /* GNUC11 */ { 1,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
+ /* GNUC17 */ { 1,0,1,1,1,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
+ /* GNUC23 */ { 1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,0,1,1,0,0,0,1,1 },
+ /* GNUC2Y */ { 1,0,1,1,1,1,0,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,1 },
+ /* STDC89 */ { 0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 },
+ /* STDC94 */ { 0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 },
+ /* STDC99 */ { 1,0,1,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 },
+ /* STDC11 */ { 1,0,1,1,1,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 },
+ /* STDC17 */ { 1,0,1,1,1,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0 },
+ /* STDC23 */ { 1,0,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,0,0,0,1,1 },
+ /* STDC2Y */ { 1,0,1,1,1,1,1,1,1,0,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,1 },
+ /* GNUCXX */ { 0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0 },
+ /* CXX98 */ { 0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0 },
+ /* GNUCXX11 */ { 1,1,1,1,1,1,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0 },
+ /* CXX11 */ { 1,1,0,1,1,1,1,1,1,1,1,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0 },
+ /* GNUCXX14 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0 },
+ /* CXX14 */ { 1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0 },
+ /* GNUCXX17 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0 },
+ /* CXX17 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0 },
+ /* GNUCXX20 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0 },
+ /* CXX20 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0 },
+ /* GNUCXX23 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0 },
+ /* CXX23 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0 },
+ /* GNUCXX26 */ { 1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0 },
+ /* CXX26 */ { 1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0 },
+ /* ASM */ { 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
};
/* Sets internal flags correctly for a given language. */
@@ -180,6 +182,8 @@ cpp_set_lang (cpp_reader *pfile, enum c_
CPP_OPTION (pfile, elifdef) = l->elifdef;
CPP_OPTION (pfile, warning_directive) = l->warning_directive;
CPP_OPTION (pfile, delimited_escape_seqs) = l->delimited_escape_seqs;
+ CPP_OPTION (pfile, named_uc_escape_seqs) = l->named_uc_escape_seqs;
+ CPP_OPTION (pfile, octal_constants) = l->octal_constants;
CPP_OPTION (pfile, true_false) = l->true_false;
CPP_OPTION (pfile, embed) = l->embed;
}
@@ -230,6 +234,7 @@ cpp_create_reader (enum c_lang lang, cpp
CPP_OPTION (pfile, warn_endif_labels) = 1;
CPP_OPTION (pfile, cpp_warn_c90_c99_compat) = -1;
CPP_OPTION (pfile, cpp_warn_c11_c23_compat) = -1;
+ CPP_OPTION (pfile, cpp_warn_c23_c2y_compat) = -1;
CPP_OPTION (pfile, cpp_warn_cxx11_compat) = 0;
CPP_OPTION (pfile, cpp_warn_cxx20_compat) = 0;
CPP_OPTION (pfile, cpp_warn_deprecated) = 1;
@@ -1579,7 +1579,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
{
length = 4;
if (identifier_pos
- && !CPP_OPTION (pfile, delimited_escape_seqs)
+ && !CPP_OPTION (pfile, named_uc_escape_seqs)
&& CPP_OPTION (pfile, std))
{
*cp = 0;
@@ -1631,7 +1631,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
cpp_error (pfile, CPP_DL_ERROR,
"empty named universal character escape sequence");
else if ((!identifier_pos || strict)
- && !CPP_OPTION (pfile, delimited_escape_seqs)
+ && !CPP_OPTION (pfile, named_uc_escape_seqs)
&& CPP_OPTION (pfile, cpp_pedantic))
cpp_pedwarning (pfile,
CPP_OPTION (pfile, cplusplus)
@@ -1653,7 +1653,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
{
bool ret = true;
if (identifier_pos
- && (!CPP_OPTION (pfile, delimited_escape_seqs)
+ && (!CPP_OPTION (pfile, named_uc_escape_seqs)
|| !strict))
ret = cpp_warning (pfile, CPP_W_UNICODE,
"%<\\N{%.*s}%> is not a valid "
@@ -1676,7 +1676,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
else
result = 0xC0;
if (identifier_pos
- && (!CPP_OPTION (pfile, delimited_escape_seqs)
+ && (!CPP_OPTION (pfile, named_uc_escape_seqs)
|| !strict))
{
*cp = 0;
@@ -1746,6 +1746,7 @@ _cpp_valid_ucn (cpp_reader *pfile, const
if (delimited && str < limit && *str == '}')
{
+ bool warned = false;
if (length == 32 && identifier_pos)
{
cpp_warning (pfile, CPP_W_UNICODE,
@@ -1755,13 +1756,28 @@ _cpp_valid_ucn (cpp_reader *pfile, const
return false;
}
else if (length == 32)
- cpp_error (pfile, CPP_DL_ERROR,
- "empty delimited escape sequence");
+ {
+ cpp_error (pfile, CPP_DL_ERROR, "empty delimited escape sequence");
+ warned = true;
+ }
else if (!CPP_OPTION (pfile, delimited_escape_seqs)
&& CPP_OPTION (pfile, cpp_pedantic))
- cpp_pedwarning (pfile, (CPP_OPTION (pfile, cplusplus)
- ? CPP_W_CXX23_EXTENSIONS : CPP_W_PEDANTIC),
- "delimited escape sequences are only valid in C++23");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ warned
+ = cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
+ "delimited escape sequences are only valid "
+ "in C++23");
+ else
+ warned
+ = cpp_pedwarning (pfile, CPP_W_PEDANTIC,
+ "delimited escape sequences are only valid "
+ "in C2Y");
+ }
+ if (!warned && CPP_OPTION (pfile, cpp_warn_c23_c2y_compat) > 0)
+ cpp_warning (pfile, CPP_W_C11_C23_COMPAT,
+ "delimited escape sequences are only valid in C2Y");
+
str++;
length = 0;
delimited = false;
@@ -2125,6 +2141,7 @@ convert_hex (cpp_reader *pfile, const uc
if (delimited && from < limit && *from == '}')
{
+ bool warned = false;
from++;
if (!digits_found)
{
@@ -2134,9 +2151,21 @@ convert_hex (cpp_reader *pfile, const uc
}
else if (!CPP_OPTION (pfile, delimited_escape_seqs)
&& CPP_OPTION (pfile, cpp_pedantic))
- cpp_pedwarning (pfile, (CPP_OPTION (pfile, cplusplus)
- ? CPP_W_CXX23_EXTENSIONS : CPP_W_PEDANTIC),
- "delimited escape sequences are only valid in C++23");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ warned
+ = cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
+ "delimited escape sequences are only valid "
+ "in C++23");
+ else
+ warned
+ = cpp_pedwarning (pfile, CPP_W_PEDANTIC,
+ "delimited escape sequences are only valid "
+ "in C2Y");
+ }
+ if (!warned && CPP_OPTION (pfile, cpp_warn_c23_c2y_compat) > 0)
+ cpp_warning (pfile, CPP_W_C11_C23_COMPAT,
+ "delimited escape sequences are only valid in C2Y");
delimited = false;
extend_char_range (&char_range, loc_reader);
}
@@ -2229,6 +2258,7 @@ convert_oct (cpp_reader *pfile, const uc
{
if (from < limit && *from == '}')
{
+ bool warned = false;
from++;
if (count == 1)
{
@@ -2238,10 +2268,21 @@ convert_oct (cpp_reader *pfile, const uc
}
else if (!CPP_OPTION (pfile, delimited_escape_seqs)
&& CPP_OPTION (pfile, cpp_pedantic))
- cpp_pedwarning (pfile, (CPP_OPTION (pfile, cplusplus)
- ? CPP_W_CXX23_EXTENSIONS : CPP_W_PEDANTIC),
- "delimited escape sequences are only valid "
- "in C++23");
+ {
+ if (CPP_OPTION (pfile, cplusplus))
+ warned
+ = cpp_pedwarning (pfile, CPP_W_CXX23_EXTENSIONS,
+ "delimited escape sequences are only "
+ "valid in C++23");
+ else
+ warned
+ = cpp_pedwarning (pfile, CPP_W_PEDANTIC,
+ "delimited escape sequences are only "
+ "valid in C2Y");
+ }
+ if (!warned && CPP_OPTION (pfile, cpp_warn_c23_c2y_compat) > 0)
+ cpp_warning (pfile, CPP_W_C11_C23_COMPAT,
+ "delimited escape sequences are only valid in C2Y");
extend_char_range (&char_range, loc_reader);
}
else
@@ -556,6 +556,7 @@ cpp_classify_number (cpp_reader *pfile,
enum {NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON} float_flag;
bool seen_digit;
bool seen_digit_sep;
+ bool zero_o_prefix;
if (ud_suffix)
*ud_suffix = NULL;
@@ -571,6 +572,7 @@ cpp_classify_number (cpp_reader *pfile,
radix = 10;
seen_digit = false;
seen_digit_sep = false;
+ zero_o_prefix = false;
/* First, interpret the radix. */
if (*str == '0')
@@ -601,6 +603,17 @@ cpp_classify_number (cpp_reader *pfile,
SYNTAX_ERROR_AT (virtual_location,
"digit separator after base indicator");
}
+ else if ((*str == 'o' || *str == 'O') && !CPP_OPTION (pfile, cplusplus))
+ {
+ if (ISDIGIT (str[1]))
+ {
+ zero_o_prefix = true;
+ str++;
+ }
+ else if (DIGIT_SEP (str[1]))
+ SYNTAX_ERROR_AT (virtual_location,
+ "digit separator after base indicator");
+ }
}
/* Now scan for a well-formed integer or float. */
@@ -694,6 +707,12 @@ cpp_classify_number (cpp_reader *pfile,
"invalid prefix %<0b%> for floating constant");
return CPP_N_INVALID;
}
+ if (zero_o_prefix)
+ {
+ cpp_error_with_line (pfile, CPP_DL_ERROR, virtual_location, 0,
+ "invalid prefix %<0o%> for floating constant");
+ return CPP_N_INVALID;
+ }
if (radix == 16 && !seen_digit)
SYNTAX_ERROR_AT (virtual_location,
@@ -897,8 +916,7 @@ cpp_classify_number (cpp_reader *pfile,
if (radix == 2)
{
bool warned = false;
- if (!CPP_OPTION (pfile, binary_constants)
- && CPP_PEDANTIC (pfile))
+ if (!CPP_OPTION (pfile, binary_constants) && CPP_PEDANTIC (pfile))
{
if (CPP_OPTION (pfile, cplusplus))
warned
@@ -916,6 +934,19 @@ cpp_classify_number (cpp_reader *pfile,
virtual_location, 0,
"binary constants are a C23 feature");
}
+ if (zero_o_prefix)
+ {
+ bool warned = false;
+ if (!CPP_OPTION (pfile, octal_constants) && CPP_PEDANTIC (pfile))
+ warned
+ = cpp_pedwarning_with_line (pfile, CPP_W_PEDANTIC, virtual_location,
+ 0, "%<0o%> prefixed constants are a C2Y "
+ "feature or GCC extension");
+ if (!warned && CPP_OPTION (pfile, cpp_warn_c23_c2y_compat) > 0)
+ cpp_warning_with_line (pfile, CPP_W_C23_C2Y_COMPAT,
+ virtual_location, 0,
+ "%<0o%> prefixed constants are a C2Y feature");
+ }
if (radix == 10)
result |= CPP_N_DECIMAL;
@@ -967,6 +998,8 @@ cpp_interpret_integer (cpp_reader *pfile
{
base = 8;
p++;
+ if (*p == 'o' || *p == 'O')
+ p++;
}
else if ((type & CPP_N_RADIX) == CPP_N_HEX)
{
@@ -452,7 +452,7 @@ C ObjC Alias(Wc11-c23-compat)
Deprecated in favor of -Wc11-c23-compat.
Wc23-c2y-compat
-C ObjC Var(warn_c23_c2y_compat) Init(-1) Warning
+C ObjC CPP(cpp_warn_c23_c2y_compat) CppReason(CPP_W_C23_C2Y_COMPAT) Var(warn_c23_c2y_compat) Init(-1) Warning
Warn about features not present in ISO C23, but present in ISO C2Y.
Wc90-c99-compat
@@ -1892,7 +1892,7 @@ set_std_c23 (int iso)
static void
set_std_c2y (int iso)
{
- cpp_set_lang (parse_in, iso ? CLK_STDC23: CLK_GNUC23);
+ cpp_set_lang (parse_in, iso ? CLK_STDC2Y : CLK_GNUC2Y);
flag_no_asm = iso;
flag_no_nonansi_builtin = iso;
flag_iso = iso;
@@ -899,6 +899,10 @@ interpret_integer (const cpp_token *toke
{
max_bits_per_digit = 3;
prefix_len = 1;
+ if (token->val.str.len > 2
+ && (token->val.str.text[1] == 'o'
+ || token->val.str.text[1] == 'O'))
+ prefix_len = 2;
}
else if ((flags & CPP_N_RADIX) == CPP_N_HEX)
{
@@ -0,0 +1,5 @@
+/* { dg-do compile { target bitint575 } } */
+/* { dg-options "-std=c2y" } */
+
+static_assert (0o177777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777wb / 2wb * 2wb + 1wb == 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwb, "");
+static_assert (0O3211423263360473024126605062402061031423012516423720422320324010721642021266620206352436541213777372642147046071532121506001467430513304743521547653653136162305775772330633147605317353126354wb == 0x1a2626b3784ec2856c28ca04310cc4c154e89f4224d06a023a3a208adb20867547ac28bffbeb4467130e6b451a30066f18a5b13c751b3eaf565e39317fbfa6c66ccf8567bacacecwb, "");
@@ -0,0 +1,11 @@
+/* Test that octal constants are diagnosed in C23 mode: -pedantic. */
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -pedantic" } */
+
+int a = 0o7; /* { dg-warning "'0o' prefixed constants" } */
+#if 0o107 /* { dg-warning "'0o' prefixed constants" } */
+#endif
+
+int b = 0O7; /* { dg-warning "'0o' prefixed constants" } */
+#if 0O107 /* { dg-warning "'0o' prefixed constants" } */
+#endif
@@ -0,0 +1,11 @@
+/* Test that octal constants are diagnosed in C23 mode: -pedantic-errors. */
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+
+int a = 0o7; /* { dg-error "'0o' prefixed constants" } */
+#if 0o107 /* { dg-error "'0o' prefixed constants" } */
+#endif
+
+int b = 0O7; /* { dg-error "'0o' prefixed constants" } */
+#if 0O107 /* { dg-error "'0o' prefixed constants" } */
+#endif
@@ -0,0 +1,5 @@
+/* Test C2Y octal constants. Valid syntax and types. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+#include "octal-constants-1.c"
@@ -0,0 +1,11 @@
+/* Test that octal constants are accepted in C2Y mode: compat warnings. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -Wc23-c2y-compat" } */
+
+int a = 0o7; /* { dg-warning "C2Y feature" } */
+#if 0o107 /* { dg-warning "C2Y feature" } */
+#endif
+
+int b = 0O7; /* { dg-warning "C2Y feature" } */
+#if 0O107 /* { dg-warning "C2Y feature" } */
+#endif
@@ -0,0 +1,9 @@
+/* Test C2Y octal constants. Invalid constants. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+int a = 0o; /* { dg-error "invalid suffix" } */
+int b = 0Oa; /* { dg-error "invalid suffix" } */
+int c = 0O08; /* { dg-error "invalid digit" } */
+int d = 0o1.1; /* { dg-error "invalid prefix" } */
+int e = 0O0p0; /* { dg-error "invalid suffix" } */
@@ -0,0 +1,87 @@
+/* P2290R3 - Delimited escape sequences */
+/* { dg-do compile } */
+/* { dg-require-effective-target wchar } */
+/* { dg-options "-std=c23 -pedantic -Wno-c++-compat" } */
+
+#include <wchar.h>
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+
+const char32_t *a = U"\u{1234}\u{10fffd}\u{000000000000000000000000000000000000000000000000000000000001234}\u{10FFFD}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char32_t *b = U"\x{1234}\x{10fffd}\x{000000000000000000000000000000000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char32_t *c = U"\o{1234}\o{4177775}\o{000000000000000000000000000000000000000000000000000000000000000000000000004177775}";/* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *d = u"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *e = u"\x{1234}\x{BffD}\x{000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *f = u"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *g = L"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *h = L"\x{1234}\x{bFFd}\x{000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *i = L"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char *k = "\x{34}\x{000000000000000003D}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char *l = "\o{34}\o{000000000000000176}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+
+#if U'\u{1234}' != U'\u1234' || U'\u{10fffd}' != U'\U0010FFFD' \
+ || U'\x{00000001234}' != U'\x1234' || U'\x{010fffd}' != U'\x10FFFD' \
+ || U'\o{1234}' != U'\x29c' || U'\o{004177775}' != U'\x10FFFD' \
+ || u'\u{1234}' != u'\u1234' || u'\u{0bffd}' != u'\uBFFD' \
+ || u'\x{00000001234}' != u'\x1234' || u'\x{0Bffd}' != u'\x0bFFD' \
+ || u'\o{1234}' != u'\x29c' || u'\o{00137775}' != u'\xBFFD' \
+ || L'\u{1234}' != L'\u1234' || L'\u{0bffd}' != L'\uBFFD' \
+ || L'\x{00000001234}' != L'\x1234' || L'\x{0bffd}' != L'\x0bFFD' \
+ || L'\o{1234}' != L'\x29c' || L'\o{00137775}' != L'\xBFFD' \
+ || '\x{34}' != '\x034' || '\x{0003d}' != '\x003D' \
+ || '\o{34}' != '\x1C' || '\o{176}' != '\x007E'
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+#error Bad
+#endif
+
+int
+main ()
+{
+ if (a[0] != U'\u1234' || a[0] != U'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || a[1] != U'\U0010FFFD' || a[1] != U'\u{000010fFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || a[2] != a[0]
+ || a[3] != a[1]
+ || b[0] != U'\x1234' || b[0] != U'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || b[1] != U'\x10FFFD' || b[1] != U'\x{0010fFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || b[2] != b[0]
+ || c[0] != U'\x29c' || c[0] != U'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || c[1] != U'\x10FFFD' || c[1] != U'\o{4177775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || c[2] != c[1])
+ __builtin_abort ();
+ if (d[0] != u'\u1234' || d[0] != u'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || d[1] != u'\U0000BFFD' || d[1] != u'\u{00000bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || d[2] != d[0]
+ || e[0] != u'\x1234' || e[0] != u'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || e[1] != u'\xBFFD' || e[1] != u'\x{00bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || e[2] != e[0]
+ || f[0] != u'\x29c' || f[0] != u'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || f[1] != u'\xbFFD' || f[1] != u'\o{137775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || f[2] != f[1])
+ __builtin_abort ();
+ if (g[0] != L'\u1234' || g[0] != L'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || g[1] != L'\U0000BFFD' || g[1] != L'\u{00000bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || g[2] != g[0]
+ || h[0] != L'\x1234' || h[0] != L'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || h[1] != L'\xBFFD' || h[1] != L'\x{00bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || h[2] != h[0]
+ || i[0] != L'\x29c' || i[0] != L'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || i[1] != L'\xbFFD' || i[1] != L'\o{137775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || i[2] != i[1])
+ __builtin_abort ();
+ if (k[0] != '\x034' || k[0] != '\x{0034}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || k[1] != '\x3D' || k[1] != '\x{3d}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || l[0] != '\x1c' || l[0] != '\o{0034}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || l[1] != '\x07e' || l[1] != '\o{176}' || l[1] != '\176') /* { dg-warning "delimited escape sequences are only valid in" } */
+ __builtin_abort ();
+ return 0;
+}
@@ -0,0 +1,87 @@
+/* P2290R3 - Delimited escape sequences */
+/* { dg-do compile } */
+/* { dg-require-effective-target wchar } */
+/* { dg-options "-std=c23 -pedantic-errors -Wno-c++-compat" } */
+
+#include <wchar.h>
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+
+const char32_t *a = U"\u{1234}\u{10fffd}\u{000000000000000000000000000000000000000000000000000000000001234}\u{10FFFD}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char32_t *b = U"\x{1234}\x{10fffd}\x{000000000000000000000000000000000000000000000000000000000001234}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char32_t *c = U"\o{1234}\o{4177775}\o{000000000000000000000000000000000000000000000000000000000000000000000000004177775}";/* { dg-error "delimited escape sequences are only valid in" } */
+const char16_t *d = u"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char16_t *e = u"\x{1234}\x{BffD}\x{000001234}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char16_t *f = u"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const wchar_t *g = L"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const wchar_t *h = L"\x{1234}\x{bFFd}\x{000001234}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const wchar_t *i = L"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char *k = "\x{34}\x{000000000000000003D}"; /* { dg-error "delimited escape sequences are only valid in" } */
+const char *l = "\o{34}\o{000000000000000176}"; /* { dg-error "delimited escape sequences are only valid in" } */
+
+#if U'\u{1234}' != U'\u1234' || U'\u{10fffd}' != U'\U0010FFFD' \
+ || U'\x{00000001234}' != U'\x1234' || U'\x{010fffd}' != U'\x10FFFD' \
+ || U'\o{1234}' != U'\x29c' || U'\o{004177775}' != U'\x10FFFD' \
+ || u'\u{1234}' != u'\u1234' || u'\u{0bffd}' != u'\uBFFD' \
+ || u'\x{00000001234}' != u'\x1234' || u'\x{0Bffd}' != u'\x0bFFD' \
+ || u'\o{1234}' != u'\x29c' || u'\o{00137775}' != u'\xBFFD' \
+ || L'\u{1234}' != L'\u1234' || L'\u{0bffd}' != L'\uBFFD' \
+ || L'\x{00000001234}' != L'\x1234' || L'\x{0bffd}' != L'\x0bFFD' \
+ || L'\o{1234}' != L'\x29c' || L'\o{00137775}' != L'\xBFFD' \
+ || '\x{34}' != '\x034' || '\x{0003d}' != '\x003D' \
+ || '\o{34}' != '\x1C' || '\o{176}' != '\x007E'
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-error "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+#error Bad
+#endif
+
+int
+main ()
+{
+ if (a[0] != U'\u1234' || a[0] != U'\u{1234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || a[1] != U'\U0010FFFD' || a[1] != U'\u{000010fFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || a[2] != a[0]
+ || a[3] != a[1]
+ || b[0] != U'\x1234' || b[0] != U'\x{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || b[1] != U'\x10FFFD' || b[1] != U'\x{0010fFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || b[2] != b[0]
+ || c[0] != U'\x29c' || c[0] != U'\o{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || c[1] != U'\x10FFFD' || c[1] != U'\o{4177775}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || c[2] != c[1])
+ __builtin_abort ();
+ if (d[0] != u'\u1234' || d[0] != u'\u{1234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || d[1] != u'\U0000BFFD' || d[1] != u'\u{00000bFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || d[2] != d[0]
+ || e[0] != u'\x1234' || e[0] != u'\x{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || e[1] != u'\xBFFD' || e[1] != u'\x{00bFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || e[2] != e[0]
+ || f[0] != u'\x29c' || f[0] != u'\o{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || f[1] != u'\xbFFD' || f[1] != u'\o{137775}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || f[2] != f[1])
+ __builtin_abort ();
+ if (g[0] != L'\u1234' || g[0] != L'\u{1234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || g[1] != L'\U0000BFFD' || g[1] != L'\u{00000bFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || g[2] != g[0]
+ || h[0] != L'\x1234' || h[0] != L'\x{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || h[1] != L'\xBFFD' || h[1] != L'\x{00bFfD}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || h[2] != h[0]
+ || i[0] != L'\x29c' || i[0] != L'\o{001234}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || i[1] != L'\xbFFD' || i[1] != L'\o{137775}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || i[2] != i[1])
+ __builtin_abort ();
+ if (k[0] != '\x034' || k[0] != '\x{0034}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || k[1] != '\x3D' || k[1] != '\x{3d}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || l[0] != '\x1c' || l[0] != '\o{0034}' /* { dg-error "delimited escape sequences are only valid in" } */
+ || l[1] != '\x07e' || l[1] != '\o{176}' || l[1] != '\176') /* { dg-error "delimited escape sequences are only valid in" } */
+ __builtin_abort ();
+ return 0;
+}
@@ -0,0 +1,6 @@
+/* N3353 - Delimited escape sequences */
+/* { dg-do run } */
+/* { dg-require-effective-target wchar } */
+/* { dg-options "-std=c2y -pedantic-errors -Wno-c++-compat" } */
+
+#include "../../c-c++-common/cpp/delimited-escape-seq-1.c"
@@ -0,0 +1,5 @@
+/* N3353 - Delimited escape sequences */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors -Wno-c++-compat" } */
+
+#include "../../c-c++-common/cpp/delimited-escape-seq-2.c"
@@ -0,0 +1,30 @@
+/* P2290R3 - Delimited escape sequences */
+/* { dg-do compile } */
+/* { dg-require-effective-target wchar } */
+/* { dg-options "-std=c2y -pedantic-errors -Wno-c++-compat" } */
+
+typedef __CHAR32_TYPE__ char32_t;
+
+const char32_t *a = U"\u{}"; /* { dg-error "empty delimited escape sequence" } */
+ /* { dg-error "is not a valid universal character" "" { target c } .-1 } */
+const char32_t *b = U"\u{12" "34}"; /* { dg-error "'\\\\u\\{' not terminated with '\\}' after" } */
+const char32_t *c = U"\u{0000ffffffff}"; /* { dg-error "is not a valid universal character" } */
+const char32_t *d = U"\u{010000edcb}"; /* { dg-error "is not a valid universal character" } */
+const char32_t *e = U"\u{02000000000000000000edcb}"; /* { dg-error "is not a valid universal character" } */
+const char32_t *f = U"\u{123ghij}"; /* { dg-error "'\\\\u\\{' not terminated with '\\}' after" } */
+const char32_t *g = U"\u{123.}"; /* { dg-error "'\\\\u\\{' not terminated with '\\}' after" } */
+const char32_t *h = U"\u{.}"; /* { dg-error "'\\\\u\\{' not terminated with '\\}' after" } */
+const char32_t *i = U"\x{}"; /* { dg-error "empty delimited escape sequence" } */
+const char32_t *j = U"\x{12" "34}"; /* { dg-error "'\\\\x\\{' not terminated with '\\}' after" } */
+const char32_t *k = U"\x{0000ffffffff}";
+const char32_t *l = U"\x{010000edcb}"; /* { dg-error "hex escape sequence out of range" } */
+const char32_t *m = U"\x{02000000000000000000edcb}"; /* { dg-error "hex escape sequence out of range" } */
+const char32_t *n = U"\x{123ghij}"; /* { dg-error "'\\\\x\\{' not terminated with '\\}' after" } */
+const char32_t *o = U"\x{123.}"; /* { dg-error "'\\\\x\\{' not terminated with '\\}' after" } */
+const char32_t *p = U"\o{}"; /* { dg-error "empty delimited escape sequence" } */
+const char32_t *q = U"\o{12" "34}"; /* { dg-error "'\\\\o\\{' not terminated with '\\}' after" } */
+const char32_t *r = U"\o{0000037777777777}";
+const char32_t *s = U"\o{040000166713}"; /* { dg-error "octal escape sequence out of range" } */
+const char32_t *t = U"\o{02000000000000000000000166713}";/* { dg-error "octal escape sequence out of range" } */
+const char32_t *u = U"\o{1238}"; /* { dg-error "'\\\\o\\{' not terminated with '\\}' after" } */
+const char32_t *v = U"\o{.}"; /* { dg-error "'\\\\o\\{' not terminated with '\\}' after" } */
@@ -0,0 +1,87 @@
+/* P2290R3 - Delimited escape sequences */
+/* { dg-do compile } */
+/* { dg-require-effective-target wchar } */
+/* { dg-options "-std=c2y -Wc23-c2y-compat -Wno-c++-compat" } */
+
+#include <wchar.h>
+typedef __CHAR16_TYPE__ char16_t;
+typedef __CHAR32_TYPE__ char32_t;
+
+const char32_t *a = U"\u{1234}\u{10fffd}\u{000000000000000000000000000000000000000000000000000000000001234}\u{10FFFD}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char32_t *b = U"\x{1234}\x{10fffd}\x{000000000000000000000000000000000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char32_t *c = U"\o{1234}\o{4177775}\o{000000000000000000000000000000000000000000000000000000000000000000000000004177775}";/* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *d = u"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *e = u"\x{1234}\x{BffD}\x{000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char16_t *f = u"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *g = L"\u{1234}\u{bFFd}\u{00000000000000000000000000000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *h = L"\x{1234}\x{bFFd}\x{000001234}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const wchar_t *i = L"\o{1234}\o{137775}\o{000000000000000137775}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char *k = "\x{34}\x{000000000000000003D}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+const char *l = "\o{34}\o{000000000000000176}"; /* { dg-warning "delimited escape sequences are only valid in" } */
+
+#if U'\u{1234}' != U'\u1234' || U'\u{10fffd}' != U'\U0010FFFD' \
+ || U'\x{00000001234}' != U'\x1234' || U'\x{010fffd}' != U'\x10FFFD' \
+ || U'\o{1234}' != U'\x29c' || U'\o{004177775}' != U'\x10FFFD' \
+ || u'\u{1234}' != u'\u1234' || u'\u{0bffd}' != u'\uBFFD' \
+ || u'\x{00000001234}' != u'\x1234' || u'\x{0Bffd}' != u'\x0bFFD' \
+ || u'\o{1234}' != u'\x29c' || u'\o{00137775}' != u'\xBFFD' \
+ || L'\u{1234}' != L'\u1234' || L'\u{0bffd}' != L'\uBFFD' \
+ || L'\x{00000001234}' != L'\x1234' || L'\x{0bffd}' != L'\x0bFFD' \
+ || L'\o{1234}' != L'\x29c' || L'\o{00137775}' != L'\xBFFD' \
+ || '\x{34}' != '\x034' || '\x{0003d}' != '\x003D' \
+ || '\o{34}' != '\x1C' || '\o{176}' != '\x007E'
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+/* { dg-warning "delimited escape sequences are only valid in" "" { target *-*-* } .-11 } */
+#error Bad
+#endif
+
+int
+main ()
+{
+ if (a[0] != U'\u1234' || a[0] != U'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || a[1] != U'\U0010FFFD' || a[1] != U'\u{000010fFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || a[2] != a[0]
+ || a[3] != a[1]
+ || b[0] != U'\x1234' || b[0] != U'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || b[1] != U'\x10FFFD' || b[1] != U'\x{0010fFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || b[2] != b[0]
+ || c[0] != U'\x29c' || c[0] != U'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || c[1] != U'\x10FFFD' || c[1] != U'\o{4177775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || c[2] != c[1])
+ __builtin_abort ();
+ if (d[0] != u'\u1234' || d[0] != u'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || d[1] != u'\U0000BFFD' || d[1] != u'\u{00000bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || d[2] != d[0]
+ || e[0] != u'\x1234' || e[0] != u'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || e[1] != u'\xBFFD' || e[1] != u'\x{00bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || e[2] != e[0]
+ || f[0] != u'\x29c' || f[0] != u'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || f[1] != u'\xbFFD' || f[1] != u'\o{137775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || f[2] != f[1])
+ __builtin_abort ();
+ if (g[0] != L'\u1234' || g[0] != L'\u{1234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || g[1] != L'\U0000BFFD' || g[1] != L'\u{00000bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || g[2] != g[0]
+ || h[0] != L'\x1234' || h[0] != L'\x{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || h[1] != L'\xBFFD' || h[1] != L'\x{00bFfD}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || h[2] != h[0]
+ || i[0] != L'\x29c' || i[0] != L'\o{001234}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || i[1] != L'\xbFFD' || i[1] != L'\o{137775}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || i[2] != i[1])
+ __builtin_abort ();
+ if (k[0] != '\x034' || k[0] != '\x{0034}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || k[1] != '\x3D' || k[1] != '\x{3d}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || l[0] != '\x1c' || l[0] != '\o{0034}' /* { dg-warning "delimited escape sequences are only valid in" } */
+ || l[1] != '\x07e' || l[1] != '\o{176}' || l[1] != '\176') /* { dg-warning "delimited escape sequences are only valid in" } */
+ __builtin_abort ();
+ return 0;
+}
@@ -0,0 +1,311 @@
+/* Test for octal integer constants. */
+
+/* Derived from: binary-constants-1.c, by Jakub Jelinek <jakub@redhat.com>. */
+/* Origin: Joerg Wunsch <j.gnu@uriah.heep.sax.de>. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+#include <limits.h>
+
+/* Assertion that constant C is of type T. */
+#define ASSERT_CONST_TYPE(C, T) \
+ do { \
+ typedef T type; \
+ typedef type **typepp; \
+ typedef __typeof__((C)) ctype; \
+ typedef ctype **ctypepp; \
+ typepp x = 0; \
+ ctypepp y = 0; \
+ x = y; \
+ y = x; \
+ } while (0)
+
+/* (T *) if E is zero, (void *) otherwise. */
+#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
+
+/* (T *) if E is nonzero, (void *) otherwise. */
+#define type_if(T, E) type_if_not(T, !(E))
+
+/* Combine pointer types, all but one (void *). */
+#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
+#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
+#define type_comb4(T1, T2, T3, T4) \
+ type_comb2(T1, type_comb2(T2, type_comb2(T3, T4)))
+#define type_comb6(T1, T2, T3, T4, T5, T6) \
+ type_comb2(T1, \
+ type_comb2(T2, \
+ type_comb2(T3, \
+ type_comb2(T4, \
+ type_comb2(T5, T6)))))
+
+/* (T1 *) if E1, otherwise (T2 *) if E2. */
+#define first_of2p(T1, E1, T2, E2) type_comb2(type_if(T1, (E1)), \
+ type_if(T2, (!(E1) && (E2))))
+/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3. */
+#define first_of3p(T1, E1, T2, E2, T3, E3) \
+ type_comb3(type_if(T1, (E1)), \
+ type_if(T2, (!(E1) && (E2))), \
+ type_if(T3, (!(E1) && !(E2) && (E3))))
+/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise
+ (T4 *) if E4. */
+#define first_of4p(T1, E1, T2, E2, T3, E3, T4, E4) \
+ type_comb4(type_if(T1, (E1)), \
+ type_if(T2, (!(E1) && (E2))), \
+ type_if(T3, (!(E1) && !(E2) && (E3))), \
+ type_if(T4, (!(E1) && !(E2) && !(E3) && (E4))))
+/* (T1 *) if E1, otherwise (T2 *) if E2, otherwise (T3 *) if E3, otherwise
+ (T4 *) if E4, otherwise (T5 *) if E5, otherwise (T6 *) if E6. */
+#define first_of6p(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \
+ type_comb6(type_if(T1, (E1)), \
+ type_if(T2, (!(E1) && (E2))), \
+ type_if(T3, (!(E1) && !(E2) && (E3))), \
+ type_if(T4, (!(E1) && !(E2) && !(E3) && (E4))), \
+ type_if(T5, (!(E1) && !(E2) && !(E3) && !(E4) && (E5))), \
+ type_if(T6, (!(E1) && !(E2) && !(E3) \
+ && !(E4) && !(E5) && (E6))))
+
+/* Likewise, but return the original type rather than a pointer type. */
+#define first_of2(T1, E1, T2, E2) \
+ __typeof__(*((first_of2p(T1, (E1), T2, (E2)))0))
+#define first_of3(T1, E1, T2, E2, T3, E3) \
+ __typeof__(*((first_of3p(T1, (E1), T2, (E2), T3, (E3)))0))
+#define first_of4(T1, E1, T2, E2, T3, E3, T4, E4) \
+ __typeof__(*((first_of4p(T1, (E1), T2, (E2), T3, (E3), T4, (E4)))0))
+#define first_of6(T1, E1, T2, E2, T3, E3, T4, E4, T5, E5, T6, E6) \
+ __typeof__(*((first_of6p(T1, (E1), T2, (E2), T3, (E3), \
+ T4, (E4), T5, (E5), T6, (E6)))0))
+
+/* Types of constants according to the C99 rules. */
+#define C99_UNSUF_TYPE(C) \
+ first_of6(int, (C) <= INT_MAX, \
+ unsigned int, (C) <= UINT_MAX, \
+ long int, (C) <= LONG_MAX, \
+ unsigned long int, (C) <= ULONG_MAX, \
+ long long int, (C) <= LLONG_MAX, \
+ unsigned long long int, (C) <= ULLONG_MAX)
+#define C99_SUFu_TYPE(C) \
+ first_of3(unsigned int, (C) <= UINT_MAX, \
+ unsigned long int, (C) <= ULONG_MAX, \
+ unsigned long long int, (C) <= ULLONG_MAX)
+#define C99_SUFl_TYPE(C) \
+ first_of4(long int, (C) <= LONG_MAX, \
+ unsigned long int, (C) <= ULONG_MAX, \
+ long long int, (C) <= LLONG_MAX, \
+ unsigned long long int, (C) <= ULLONG_MAX)
+#define C99_SUFul_TYPE(C) \
+ first_of2(unsigned long int, (C) <= ULONG_MAX, \
+ unsigned long long int, (C) <= ULLONG_MAX)
+#define C99_SUFll_TYPE(C) \
+ first_of2(long long int, (C) <= LLONG_MAX, \
+ unsigned long long int, (C) <= ULLONG_MAX)
+
+/* Checks that constants have correct type. */
+#define CHECK_UNSUF_TYPE(C) \
+ ASSERT_CONST_TYPE((C), C99_UNSUF_TYPE((C)))
+#define CHECK_SUFu_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFu_TYPE((C)))
+#define CHECK_SUFl_TYPE(C) \
+ ASSERT_CONST_TYPE((C), C99_SUFl_TYPE((C)))
+#define CHECK_SUFul_TYPE(C) ASSERT_CONST_TYPE((C), C99_SUFul_TYPE((C)))
+#define CHECK_SUFll_TYPE(C) \
+ ASSERT_CONST_TYPE((C), C99_SUFll_TYPE((C)))
+#define CHECK_SUFull_TYPE(C) ASSERT_CONST_TYPE((C), unsigned long long int)
+
+/* Check an octal or hexadecimal value, with all suffixes. */
+#define CHECK_CONST(C) \
+ CHECK_UNSUF_TYPE(C); \
+ CHECK_SUFu_TYPE(C##u); \
+ CHECK_SUFu_TYPE(C##U); \
+ CHECK_SUFl_TYPE(C##l); \
+ CHECK_SUFl_TYPE(C##L); \
+ CHECK_SUFul_TYPE(C##ul); \
+ CHECK_SUFul_TYPE(C##uL); \
+ CHECK_SUFul_TYPE(C##Ul); \
+ CHECK_SUFul_TYPE(C##UL); \
+ CHECK_SUFll_TYPE(C##ll); \
+ CHECK_SUFll_TYPE(C##LL); \
+ CHECK_SUFull_TYPE(C##ull); \
+ CHECK_SUFull_TYPE(C##uLL); \
+ CHECK_SUFull_TYPE(C##Ull); \
+ CHECK_SUFull_TYPE(C##ULL);
+
+#define CHECK_OCT_CONST(C) \
+ CHECK_CONST(0o##C); \
+ CHECK_CONST(0O##C);
+
+/* True iff "long long" is at least B bits. This presumes that (B-2)/3 is at
+ most 63. */
+#define LLONG_AT_LEAST(B) \
+ (LLONG_MAX >> ((B)-2)/3 >> ((B)-2)/3 \
+ >> ((B)-2 - ((B)-2)/3 - ((B)-2)/3))
+
+#define LLONG_HAS_BITS(B) (LLONG_AT_LEAST((B)) && !LLONG_AT_LEAST((B) + 1))
+
+#define FOO 0o1307
+#if !FOO
+# error "preprocessor does not accept octal constants"
+#endif
+
+void
+foo (void)
+{
+ /* Check all 2^n and 2^n - 1 up to 2^72 - 1. */
+ CHECK_OCT_CONST(1);
+ CHECK_OCT_CONST(2);
+ CHECK_OCT_CONST(3);
+ CHECK_OCT_CONST(4);
+ CHECK_OCT_CONST(7);
+ CHECK_OCT_CONST(10);
+ CHECK_OCT_CONST(17);
+ CHECK_OCT_CONST(20);
+ CHECK_OCT_CONST(37);
+ CHECK_OCT_CONST(40);
+ CHECK_OCT_CONST(77);
+ CHECK_OCT_CONST(100);
+ CHECK_OCT_CONST(177);
+ CHECK_OCT_CONST(200);
+ CHECK_OCT_CONST(377);
+ CHECK_OCT_CONST(400);
+ CHECK_OCT_CONST(777);
+ CHECK_OCT_CONST(1000);
+ CHECK_OCT_CONST(1777);
+ CHECK_OCT_CONST(2000);
+ CHECK_OCT_CONST(3777);
+ CHECK_OCT_CONST(4000);
+ CHECK_OCT_CONST(7777);
+ CHECK_OCT_CONST(10000);
+ CHECK_OCT_CONST(17777);
+ CHECK_OCT_CONST(20000);
+ CHECK_OCT_CONST(37777);
+ CHECK_OCT_CONST(40000);
+ CHECK_OCT_CONST(77777);
+ CHECK_OCT_CONST(100000);
+ CHECK_OCT_CONST(177777);
+ CHECK_OCT_CONST(200000);
+ CHECK_OCT_CONST(377777);
+ CHECK_OCT_CONST(400000);
+ CHECK_OCT_CONST(777777);
+ CHECK_OCT_CONST(1000000);
+ CHECK_OCT_CONST(1777777);
+ CHECK_OCT_CONST(2000000);
+ CHECK_OCT_CONST(3777777);
+ CHECK_OCT_CONST(4000000);
+ CHECK_OCT_CONST(7777777);
+ CHECK_OCT_CONST(10000000);
+ CHECK_OCT_CONST(17777777);
+ CHECK_OCT_CONST(20000000);
+ CHECK_OCT_CONST(37777777);
+ CHECK_OCT_CONST(40000000);
+ CHECK_OCT_CONST(77777777);
+ CHECK_OCT_CONST(100000000);
+ CHECK_OCT_CONST(177777777);
+ CHECK_OCT_CONST(200000000);
+ CHECK_OCT_CONST(377777777);
+ CHECK_OCT_CONST(400000000);
+ CHECK_OCT_CONST(777777777);
+ CHECK_OCT_CONST(1000000000);
+ CHECK_OCT_CONST(1777777777);
+ CHECK_OCT_CONST(2000000000);
+ CHECK_OCT_CONST(3777777777);
+ CHECK_OCT_CONST(4000000000);
+ CHECK_OCT_CONST(7777777777);
+ CHECK_OCT_CONST(10000000000);
+ CHECK_OCT_CONST(17777777777);
+ CHECK_OCT_CONST(20000000000);
+ CHECK_OCT_CONST(37777777777);
+ CHECK_OCT_CONST(40000000000);
+ CHECK_OCT_CONST(77777777777);
+ CHECK_OCT_CONST(100000000000);
+ CHECK_OCT_CONST(177777777777);
+ CHECK_OCT_CONST(200000000000);
+ CHECK_OCT_CONST(377777777777);
+ CHECK_OCT_CONST(400000000000);
+ CHECK_OCT_CONST(777777777777);
+ CHECK_OCT_CONST(1000000000000);
+ CHECK_OCT_CONST(1777777777777);
+ CHECK_OCT_CONST(2000000000000);
+ CHECK_OCT_CONST(3777777777777);
+ CHECK_OCT_CONST(4000000000000);
+ CHECK_OCT_CONST(7777777777777);
+ CHECK_OCT_CONST(10000000000000);
+ CHECK_OCT_CONST(17777777777777);
+ CHECK_OCT_CONST(20000000000000);
+ CHECK_OCT_CONST(37777777777777);
+ CHECK_OCT_CONST(40000000000000);
+ CHECK_OCT_CONST(77777777777777);
+ CHECK_OCT_CONST(100000000000000);
+ CHECK_OCT_CONST(177777777777777);
+ CHECK_OCT_CONST(200000000000000);
+ CHECK_OCT_CONST(377777777777777);
+ CHECK_OCT_CONST(400000000000000);
+ CHECK_OCT_CONST(777777777777777);
+ CHECK_OCT_CONST(1000000000000000);
+ CHECK_OCT_CONST(1777777777777777);
+ CHECK_OCT_CONST(2000000000000000);
+ CHECK_OCT_CONST(3777777777777777);
+ CHECK_OCT_CONST(4000000000000000);
+ CHECK_OCT_CONST(7777777777777777);
+ CHECK_OCT_CONST(10000000000000000);
+ CHECK_OCT_CONST(17777777777777777);
+ CHECK_OCT_CONST(20000000000000000);
+ CHECK_OCT_CONST(37777777777777777);
+ CHECK_OCT_CONST(40000000000000000);
+ CHECK_OCT_CONST(77777777777777777);
+ CHECK_OCT_CONST(100000000000000000);
+ CHECK_OCT_CONST(177777777777777777);
+ CHECK_OCT_CONST(200000000000000000);
+ CHECK_OCT_CONST(377777777777777777);
+ CHECK_OCT_CONST(400000000000000000);
+ CHECK_OCT_CONST(777777777777777777);
+ CHECK_OCT_CONST(1000000000000000000);
+ CHECK_OCT_CONST(1777777777777777777);
+ CHECK_OCT_CONST(2000000000000000000);
+ CHECK_OCT_CONST(3777777777777777777);
+ CHECK_OCT_CONST(4000000000000000000);
+ CHECK_OCT_CONST(7777777777777777777);
+ CHECK_OCT_CONST(10000000000000000000);
+ CHECK_OCT_CONST(17777777777777777777);
+ CHECK_OCT_CONST(20000000000000000000);
+ CHECK_OCT_CONST(37777777777777777777);
+ CHECK_OCT_CONST(40000000000000000000);
+ CHECK_OCT_CONST(77777777777777777777);
+ CHECK_OCT_CONST(100000000000000000000);
+ CHECK_OCT_CONST(177777777777777777777);
+ CHECK_OCT_CONST(200000000000000000000);
+ CHECK_OCT_CONST(377777777777777777777);
+ CHECK_OCT_CONST(400000000000000000000);
+ CHECK_OCT_CONST(777777777777777777777);
+ CHECK_OCT_CONST(1000000000000000000000);
+ CHECK_OCT_CONST(1777777777777777777777);
+#if LLONG_AT_LEAST(65)
+ CHECK_OCT_CONST(2000000000000000000000);
+ CHECK_OCT_CONST(3777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(66)
+ CHECK_OCT_CONST(4000000000000000000000);
+ CHECK_OCT_CONST(7777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(67)
+ CHECK_OCT_CONST(10000000000000000000000);
+ CHECK_OCT_CONST(17777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(68)
+ CHECK_OCT_CONST(20000000000000000000000);
+ CHECK_OCT_CONST(37777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(69)
+ CHECK_OCT_CONST(40000000000000000000000);
+ CHECK_OCT_CONST(77777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(70)
+ CHECK_OCT_CONST(100000000000000000000000);
+ CHECK_OCT_CONST(177777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(71)
+ CHECK_OCT_CONST(200000000000000000000000);
+ CHECK_OCT_CONST(377777777777777777777777);
+#endif
+#if LLONG_AT_LEAST(72)
+ CHECK_OCT_CONST(400000000000000000000000);
+ CHECK_OCT_CONST(777777777777777777777777);
+#endif
+}
@@ -0,0 +1,16 @@
+/* Test for octal integer constants: -pedantic warnings. */
+
+/* Origin: Joerg Wunsch <j.gnu@uriah.heep.sax.de>. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -ftrack-macro-expansion=0" } */
+
+#define FOO 0o1307
+
+int
+foo (void)
+{
+#if FOO /* { dg-warning "'0o' prefixed constants are a C2Y feature or GCC extension" } */
+ return 23;
+#endif
+ return 0o1307; /* { dg-warning "'0o' prefixed constants are a C2Y feature or GCC extension" } */
+}
@@ -0,0 +1,16 @@
+/* Test for octal integer constants: -pedantic-errors. */
+
+/* Origin: Joerg Wunsch <j.gnu@uriah.heep.sax.de>. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors -ftrack-macro-expansion=0" } */
+
+#define FOO 0o1307
+
+int
+foo (void)
+{
+#if FOO /* { dg-error "'0o' prefixed constants are a C2Y feature or GCC extension" } */
+ return 23;
+#endif
+ return 0o1307; /* { dg-error "'0o' prefixed constants are a C2Y feature or GCC extension" } */
+}
@@ -0,0 +1,18 @@
+/* Test for octal integer constants: random errors. */
+
+/* Origin: Joerg Wunsch <j.gnu@uriah.heep.sax.de>. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+void
+foo(void)
+{
+ double d;
+ int i;
+
+ d = 0o1307;
+ d = 0o1307p1; /* { dg-error "invalid suffix 'p1' on integer constant" } */
+ d = 0x1307p1;
+ i = 0oa011; /* { dg-error "invalid suffix 'oa011' on integer constant" } */
+ i = 0o118; /* { dg-error "invalid digit '8' in octal constant" } */
+}
@@ -0,0 +1,18 @@
+/*
+ Origin: Dodji Seketeli <dodji@redhat.com>
+ { dg-options "-std=iso9899:1999 -pedantic" }
+ { dg-do compile }
+ */
+
+#include "system-octal-constants-1.h"
+
+int
+foo (void)
+{
+#if OCTAL_INT_CONSTANT_IN_SYSTEM_HEADER /* A octal constant defined
+ in system header. No
+ warning. */
+ return 23;
+#endif
+ return 0o1307; /* { dg-warning "'0o' prefixed constants are a C2Y feature or GCC extension" } */
+}
@@ -0,0 +1,3 @@
+#pragma GCC system_header
+
+#define OCTAL_INT_CONSTANT_IN_SYSTEM_HEADER 0o1307