Commit 7c05e50c by Edward Smith-Rowland Committed by Edward Smith-Rowland

PR cpp/23827 - standard C++ should not have hex float preprocessor


libcpp/

2014-08-27  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR cpp/23827 - standard C++ should not have hex float preprocessor
	tokens
	* libcpp/init.c (lang_flags): Change CXX98 flag for extended numbers
	from 1 to 0.
	* libcpp/expr.c (cpp_classify_number): Weite error message for improper
	use of hex floating literal.


gcc/testsuite/

2014-08-27  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR cpp/23827 - standard C++ should not have hex float preprocessor
	tokens
	* g++.dg/cpp/pr23827_cxx11.C: New.
	* g++.dg/cpp/pr23827_cxx98.C: New.
	* g++.dg/cpp/pr23827_cxx98_neg.C: New.
	* gcc.dg/cpp/pr23827_c90.c: New.
	* gcc.dg/cpp/pr23827_c90_neg.c: New.
	* gcc.dg/cpp/pr23827_c99.c: New.

From-SVN: r214616
parent 241622a5
2014-08-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* g++.dg/cpp/pr23827_cxx11.C: New.
* g++.dg/cpp/pr23827_cxx98.C: New.
* g++.dg/cpp/pr23827_cxx98_neg.C: New.
* gcc.dg/cpp/pr23827_c90.c: New.
* gcc.dg/cpp/pr23827_c90_neg.c: New.
* gcc.dg/cpp/pr23827_c99.c: New.
2014-08-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52892
......
// { dg-do run { target c++11 } }
// { dg-options "-pedantic-errors" }
#define f (
#define l )
#define str(x) #x
#define xstr(x) str(x)
// C90 and C++98: "0x1p+( 0x1p+)"
// C99 and C++11: "0x1p+f 0x1p+l"
const char *s = xstr(0x1p+f 0x1p+l);
extern "C" void abort (void);
extern "C" int strcmp (const char *, const char *);
int
main()
{
if (strcmp (s, "0x1p+( 0x1p+)"))
return 0; // Correct C99 and C++11 behavior.
else
abort (); // Correct C90 and C++ behavior.
}
// { dg-do run { target c++98_only } }
// { dg-options "-ansi -pedantic-errors" }
#define f (
#define l )
#define str(x) #x
#define xstr(x) str(x)
// C90 and C++98: "0x1p+( 0x1p+)"
// C99 and C++11: "0x1p+f 0x1p+l"
const char *s = xstr(0x1p+f 0x1p+l);
extern "C" void abort (void);
extern "C" int strcmp (const char *, const char *);
int
main()
{
if (strcmp (s, "0x1p+( 0x1p+)"))
abort (); // Correct C99 and C++11 behavior.
else
return 0; // Correct C90 and C++ behavior.
}
// { dg-do compile { target c++98_only } }
/* { dg-options "-ansi -pedantic-errors" } */
double x = 0x3.1415babep0; // { dg-error "use of C..11 hexadecimal floating constant" }
/* { dg-do run } */
/* { dg-options "-std=c90 -pedantic-errors" } */
#define f (
#define l )
#define str(x) #x
#define xstr(x) str(x)
/* C90 and C++98: "0x1p+( 0x1p+)" */
/* C99 and C++11: "0x1p+f 0x1p+l" */
const char *s = xstr(0x1p+f 0x1p+l);
void abort (void);
int strcmp (const char *, const char *);
int
main()
{
if (strcmp (s, "0x1p+( 0x1p+)"))
abort (); /* Correct C99 and C++11 behavior. */
else
return 0; /* Correct C90 and C++ behavior. */
}
/* { dg-do compile } */
/* { dg-options "-std=c90 -pedantic-errors" } */
double x = 0x3.1415babep0; /* { dg-error "use of C99 hexadecimal floating constant" } */
/* { dg-do run { target c++11 } } */
/* { dg-options "-pedantic-errors" } */
#define f (
#define l )
#define str(x) #x
#define xstr(x) str(x)
/* C90 and C++98: "0x1p+( 0x1p+)" */
/* C99 and C++11: "0x1p+f 0x1p+l" */
const char *s = xstr(0x1p+f 0x1p+l);
void abort (void);
int strcmp (const char *, const char *);
int
main()
{
if (strcmp (s, "0x1p+( 0x1p+)"))
return 0; /* Correct C99 and C++11 behavior. */
else
abort (); /* Correct C90 and C++ behavior. */
}
2014-08-28 Edward Smith-Rowland <3dw4rd@verizon.net>
PR cpp/23827 - standard C++ should not have hex float preprocessor
tokens
* libcpp/init.c (lang_flags): Change CXX98 flag for extended numbers
from 1 to 0.
* libcpp/expr.c (cpp_classify_number): Weite error message for improper
use of hex floating literal.
2014-08-23 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/cpplib.h (enum c_lang): Add CLK_GNUCXX1Z, CLK_CXX1Z;
......
......@@ -540,9 +540,16 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
SYNTAX_ERROR_AT (virtual_location,
"no digits in hexadecimal floating constant");
if (radix == 16 && CPP_PEDANTIC (pfile) && !CPP_OPTION (pfile, c99))
cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
"use of C99 hexadecimal floating constant");
if (radix == 16 && CPP_PEDANTIC (pfile)
&& !CPP_OPTION (pfile, extended_numbers))
{
if (CPP_OPTION (pfile, cplusplus))
cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
"use of C++11 hexadecimal floating constant");
else
cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
"use of C99 hexadecimal floating constant");
}
if (float_flag == AFTER_EXPON)
{
......
......@@ -103,7 +103,7 @@ static const struct lang_flags lang_defaults[] =
/* STDC99 */ { 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1 },
/* STDC11 */ { 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 },
/* GNUCXX */ { 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 },
/* CXX98 */ { 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1 },
/* CXX98 */ { 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1 },
/* GNUCXX11 */ { 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0 },
/* CXX11 */ { 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1 },
/* GNUCXX14 */ { 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment