From: Jakub Jelinek Date: Mon, 31 Oct 2016 16:38:21 +0000 (+0100) Subject: re PR c++/77948 (Option processing of -std=c++11 -std=gnu++11 doesn't reset ext_numer... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dcb466eca3741d1cb06acb44a4009657cd475781;p=gcc.git re PR c++/77948 (Option processing of -std=c++11 -std=gnu++11 doesn't reset ext_numeric_literals) PR c++/77948 * c.opt (fext-numeric-literals): Add Var and Init. * c-opts.c (c_common_handle_option): Don't clear cpp_opts->ext_numeric_literals for -std=c++{11,14,1z}. (c_common_post_options): Clear it here if not set explicitly. * g++.dg/cpp0x/pr77948-1.C: New test. * g++.dg/cpp0x/pr77948-2.C: New test. * g++.dg/cpp0x/pr77948-3.C: New test. * g++.dg/cpp0x/pr77948-4.C: New test. * g++.dg/cpp0x/pr77948-5.C: New test. * g++.dg/cpp0x/pr77948-6.C: New test. From-SVN: r241707 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 6e967619263..64574180302 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2016-10-31 Jakub Jelinek + + PR c++/77948 + * c.opt (fext-numeric-literals): Add Var and Init. + * c-opts.c (c_common_handle_option): Don't clear + cpp_opts->ext_numeric_literals for -std=c++{11,14,1z}. + (c_common_post_options): Clear it here if not set + explicitly. + 2016-10-28 Aldy Hernandez PR debug/77773 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index c39930708d6..4a0b9952fa6 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -624,31 +624,19 @@ c_common_handle_option (size_t scode, const char *arg, int value, case OPT_std_c__11: case OPT_std_gnu__11: if (!preprocessing_asm_p) - { - set_std_cxx11 (code == OPT_std_c__11 /* ISO */); - if (code == OPT_std_c__11) - cpp_opts->ext_numeric_literals = 0; - } + set_std_cxx11 (code == OPT_std_c__11 /* ISO */); break; case OPT_std_c__14: case OPT_std_gnu__14: if (!preprocessing_asm_p) - { - set_std_cxx14 (code == OPT_std_c__14 /* ISO */); - if (code == OPT_std_c__14) - cpp_opts->ext_numeric_literals = 0; - } + set_std_cxx14 (code == OPT_std_c__14 /* ISO */); break; case OPT_std_c__1z: case OPT_std_gnu__1z: if (!preprocessing_asm_p) - { - set_std_cxx1z (code == OPT_std_c__1z /* ISO */); - if (code == OPT_std_c__1z) - cpp_opts->ext_numeric_literals = 0; - } + set_std_cxx1z (code == OPT_std_c__1z /* ISO */); break; case OPT_std_c90: @@ -923,6 +911,11 @@ c_common_post_options (const char **pfilename) if (warn_narrowing == -1) warn_narrowing = 1; + + /* Unless -f{,no-}ext-numeric-literals has been used explicitly, + for -std=c++{11,14,1z} default to -fno-ext-numeric-literals. */ + if (flag_iso && !global_options_set.x_flag_ext_numeric_literals) + cpp_opts->ext_numeric_literals = 0; } else if (warn_narrowing == -1) warn_narrowing = 0; diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 458d453cdd8..7e86dbf6bb7 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1705,7 +1705,7 @@ C ObjC C++ ObjC++ Joined -femit-struct-debug-detailed= Detailed reduced debug info for structs. fext-numeric-literals -C++ ObjC++ +C++ ObjC++ Var(flag_ext_numeric_literals) Init(1) Interpret imaginary, fixed-point, or other gnu number suffix as the corresponding number literal rather than a user-defined number literal. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 037096cb4f9..c298d498eb8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2016-10-31 Jakub Jelinek + PR c++/77948 + * g++.dg/cpp0x/pr77948-1.C: New test. + * g++.dg/cpp0x/pr77948-2.C: New test. + * g++.dg/cpp0x/pr77948-3.C: New test. + * g++.dg/cpp0x/pr77948-4.C: New test. + * g++.dg/cpp0x/pr77948-5.C: New test. + * g++.dg/cpp0x/pr77948-6.C: New test. + PR tree-optimization/77860 * gcc.dg/pr77860.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-1.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-1.C new file mode 100644 index 00000000000..e7795e95b7f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-1.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=c++11 -std=gnu++11" } + +void +foo () +{ + auto qfp = 1.0q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } + auto Qfp = 1.0Q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-2.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-2.C new file mode 100644 index 00000000000..7b84c5fdea1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-2.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=gnu++11 -std=c++11" } + +void +foo () +{ + auto qfp = 1.0q; // { dg-error "unable to find numeric literal operator" } + auto Qfp = 1.0Q; // { dg-error "unable to find numeric literal operator" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-3.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-3.C new file mode 100644 index 00000000000..64d4f5b14cc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-3.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=c++11 -std=gnu++98" } + +void +foo () +{ + double qfp = 1.0q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } + double Qfp = 1.0Q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-4.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-4.C new file mode 100644 index 00000000000..7b66b983bfa --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-4.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=c++11 -std=c++98" } + +void +foo () +{ + double qfp = 1.0q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } + double Qfp = 1.0Q; // { dg-error "unsupported" "" { target { ! has_q_floating_suffix } } } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-5.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-5.C new file mode 100644 index 00000000000..bec34a15fbd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-5.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=gnu++98 -std=c++11" } + +void +foo () +{ + auto qfp = 1.0q; // { dg-error "unable to find numeric literal operator" } + auto Qfp = 1.0Q; // { dg-error "unable to find numeric literal operator" } +} diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77948-6.C b/gcc/testsuite/g++.dg/cpp0x/pr77948-6.C new file mode 100644 index 00000000000..b8a13b5540a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr77948-6.C @@ -0,0 +1,10 @@ +// PR c++/77948 +// { dg-do compile } +// { dg-options "-std=c++98 -std=c++11" } + +void +foo () +{ + auto qfp = 1.0q; // { dg-error "unable to find numeric literal operator" } + auto Qfp = 1.0Q; // { dg-error "unable to find numeric literal operator" } +}