diff options
author | Edward Smith-Rowland <3dw4rd@verizon.net> | 2014-08-28 02:38:24 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2014-08-28 02:38:24 +0000 |
commit | 7c05e50c733d217f7f1da1f5173584fbc5032d2e (patch) | |
tree | 52684ca4b76255d7a5b61ebbf050e5ead8070089 /gcc | |
parent | 241622a51492ed70c63a75c32a60b4e76e020774 (diff) | |
download | gcc-7c05e50c733d217f7f1da1f5173584fbc5032d2e.zip gcc-7c05e50c733d217f7f1da1f5173584fbc5032d2e.tar.gz gcc-7c05e50c733d217f7f1da1f5173584fbc5032d2e.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C | 23 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C | 23 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/pr23827_c90.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/pr23827_c90_neg.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/pr23827_c99.c | 23 |
7 files changed, 111 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4b5def9..43e950d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +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 diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C new file mode 100644 index 0000000..c1862ce --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx11.C @@ -0,0 +1,23 @@ +// { 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. +} diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C new file mode 100644 index 0000000..cd4ee22 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98.C @@ -0,0 +1,23 @@ +// { 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. +} diff --git a/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C new file mode 100644 index 0000000..39d9fe4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp/pr23827_cxx98_neg.C @@ -0,0 +1,4 @@ +// { 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" } diff --git a/gcc/testsuite/gcc.dg/cpp/pr23827_c90.c b/gcc/testsuite/gcc.dg/cpp/pr23827_c90.c new file mode 100644 index 0000000..e7ddc76 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr23827_c90.c @@ -0,0 +1,23 @@ +/* { 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. */ +} diff --git a/gcc/testsuite/gcc.dg/cpp/pr23827_c90_neg.c b/gcc/testsuite/gcc.dg/cpp/pr23827_c90_neg.c new file mode 100644 index 0000000..020697c --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr23827_c90_neg.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c90 -pedantic-errors" } */ + +double x = 0x3.1415babep0; /* { dg-error "use of C99 hexadecimal floating constant" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/pr23827_c99.c b/gcc/testsuite/gcc.dg/cpp/pr23827_c99.c new file mode 100644 index 0000000..4671c2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/pr23827_c99.c @@ -0,0 +1,23 @@ +/* { 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. */ +} |