]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/77948 (Option processing of -std=c++11 -std=gnu++11 doesn't reset ext_numer...
authorJakub Jelinek <jakub@redhat.com>
Mon, 31 Oct 2016 16:38:21 +0000 (17:38 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 31 Oct 2016 16:38:21 +0000 (17:38 +0100)
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

gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/c-family/c.opt
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr77948-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr77948-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr77948-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr77948-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr77948-5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/pr77948-6.C [new file with mode: 0644]

index 6e9676192638f1ad81d2e1e09896491265e34262..6457418030224d654ac24d8c79a01f03157f0ecf 100644 (file)
@@ -1,3 +1,12 @@
+2016-10-31  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <aldyh@redhat.com>
 
        PR debug/77773
index c39930708d6192cb00a956e8dd05f68c13671c41..4a0b9952fa691c75fcabf9da4324ef34d24f5f51 100644 (file)
@@ -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;
index 458d453cdd8c9f9ebc82ab40a7e8d9bf6f1ea8ff..7e86dbf6bb7bac4b476cca2186f5f2984258a098 100644 (file)
@@ -1705,7 +1705,7 @@ C ObjC C++ ObjC++ Joined
 -femit-struct-debug-detailed=<spec-list>       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.
 
index 037096cb4f926cf4c74025d5659ed13e6b8d602d..c298d498eb8a875a8628f078d7cb630534f344c8 100644 (file)
@@ -1,5 +1,13 @@
 2016-10-31  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..e7795e9
--- /dev/null
@@ -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 (file)
index 0000000..7b84c5f
--- /dev/null
@@ -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 (file)
index 0000000..64d4f5b
--- /dev/null
@@ -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 (file)
index 0000000..7b66b98
--- /dev/null
@@ -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 (file)
index 0000000..bec34a1
--- /dev/null
@@ -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 (file)
index 0000000..b8a13b5
--- /dev/null
@@ -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" }
+}
This page took 0.105371 seconds and 5 git commands to generate.