View | Details | Return to bug 23479 | Differences between
and this patch

Collapse All | Expand All

(-)./gcc/doc/extend.texi.orig (+19 lines)
Lines 79-84 Link Here
79
* Pragmas::             Pragmas accepted by GCC.
79
* Pragmas::             Pragmas accepted by GCC.
80
* Unnamed Fields::      Unnamed struct/union fields within structs/unions.
80
* Unnamed Fields::      Unnamed struct/union fields within structs/unions.
81
* Thread-Local::        Per-thread variables.
81
* Thread-Local::        Per-thread variables.
82
* Binary constants::    Binary constants using the `0b' prefix.
82
@end menu
83
@end menu
83
84
84
@node Statement Exprs
85
@node Statement Exprs
Lines 9743-9748 Link Here
9743
@end quotation
9744
@end quotation
9744
@end itemize
9745
@end itemize
9745
9746
9747
@node Binary constants
9748
@section Binary constants using the `0b' prefix
9749
@cindex Binary constants using the `0b' prefix
9750
9751
Integer constants can be written as binary constants, consisting of a
9752
sequence of `0' and `1' digits, prefixed by `0b'.  This is
9753
particularly useful in environments that operate a lot on the
9754
bit-level (like microcontrollers).
9755
9756
The following statements are identical:
9757
9758
@smallexample
9759
i =       42;
9760
i =     0x2a;
9761
i =      052;
9762
i = 0b101010;
9763
@end smallexample
9764
9746
@node C++ Extensions
9765
@node C++ Extensions
9747
@chapter Extensions to the C++ Language
9766
@chapter Extensions to the C++ Language
9748
@cindex extensions, C++ language
9767
@cindex extensions, C++ language
(-)./libcpp/include/cpplib.h.orig (+1 lines)
Lines 729-734 Link Here
729
#define CPP_N_DECIMAL	0x0100
729
#define CPP_N_DECIMAL	0x0100
730
#define CPP_N_HEX	0x0200
730
#define CPP_N_HEX	0x0200
731
#define CPP_N_OCTAL	0x0400
731
#define CPP_N_OCTAL	0x0400
732
#define CPP_N_BINARY	0x0800
732
733
733
#define CPP_N_UNSIGNED	0x1000	/* Properties.  */
734
#define CPP_N_UNSIGNED	0x1000	/* Properties.  */
734
#define CPP_N_IMAGINARY	0x2000
735
#define CPP_N_IMAGINARY	0x2000
(-)./libcpp/expr.c.orig (-1 / +20 lines)
Lines 75-80 Link Here
75
#define SYNTAX_ERROR2(msgid, arg) \
75
#define SYNTAX_ERROR2(msgid, arg) \
76
  do { cpp_error (pfile, CPP_DL_ERROR, msgid, arg); goto syntax_error; } \
76
  do { cpp_error (pfile, CPP_DL_ERROR, msgid, arg); goto syntax_error; } \
77
  while(0)
77
  while(0)
78
#define SYNTAX_ERROR3(msgid, arg1, arg2) \
79
  do { cpp_error (pfile, CPP_DL_ERROR, msgid, arg1, arg2); goto syntax_error; } \
80
  while(0)
78
81
79
/* Subroutine of cpp_classify_number.  S points to a float suffix of
82
/* Subroutine of cpp_classify_number.  S points to a float suffix of
80
   length LEN, possibly zero.  Returns 0 for an invalid suffix, or a
83
   length LEN, possibly zero.  Returns 0 for an invalid suffix, or a
Lines 171-176 Link Here
171
	  radix = 16;
174
	  radix = 16;
172
	  str++;
175
	  str++;
173
	}
176
	}
177
      else if ((*str == 'b' || *str == 'B') && (str[1] == '0' || str[1] == '1'))
178
	{
179
	  radix = 2;
180
	  str++;
181
	}
174
    }
182
    }
175
183
176
  /* Now scan for a well-formed integer or float.  */
184
  /* Now scan for a well-formed integer or float.  */
Lines 209-215 Link Here
209
    radix = 10;
217
    radix = 10;
210
218
211
  if (max_digit >= radix)
219
  if (max_digit >= radix)
212
    SYNTAX_ERROR2 ("invalid digit \"%c\" in octal constant", '0' + max_digit);
220
    SYNTAX_ERROR3 ("invalid digit \"%c\" in %s constant", '0' + max_digit,
221
		   radix == 2? "binary": "octal");
213
222
214
  if (float_flag != NOT_FLOAT)
223
  if (float_flag != NOT_FLOAT)
215
    {
224
    {
Lines 288-298 Link Here
288
  if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
297
  if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
289
    cpp_error (pfile, CPP_DL_PEDWARN,
298
    cpp_error (pfile, CPP_DL_PEDWARN,
290
	       "imaginary constants are a GCC extension");
299
	       "imaginary constants are a GCC extension");
300
  if (radix == 2 && CPP_PEDANTIC (pfile))
301
    cpp_error (pfile, CPP_DL_PEDWARN,
302
	       "binary constants are a GCC extension");
291
303
292
  if (radix == 10)
304
  if (radix == 10)
293
    result |= CPP_N_DECIMAL;
305
    result |= CPP_N_DECIMAL;
294
  else if (radix == 16)
306
  else if (radix == 16)
295
    result |= CPP_N_HEX;
307
    result |= CPP_N_HEX;
308
  else if (radix == 2)
309
    result |= CPP_N_BINARY;
296
  else
310
  else
297
    result |= CPP_N_OCTAL;
311
    result |= CPP_N_OCTAL;
298
312
Lines 343-348 Link Here
343
	  base = 16;
357
	  base = 16;
344
	  p += 2;
358
	  p += 2;
345
	}
359
	}
360
      else if ((type & CPP_N_RADIX) == CPP_N_BINARY)
361
	{
362
	  base = 2;
363
	  p += 2;
364
	}
346
365
347
      /* We can add a digit to numbers strictly less than this without
366
      /* We can add a digit to numbers strictly less than this without
348
	 needing the precision and slowness of double integers.  */
367
	 needing the precision and slowness of double integers.  */

Return to bug 23479