t.p.northover created this revision.
Herald added a subscriber: mcrosier.

While looking into the regression tests' compatibility with C++14, many of the 
failures were because that specification defined UDLs for imaginary constants, 
specifically ones ending in 'i' and 'il'. This conflicted with the previous GNU 
extension that allowed them purely as a builtin literal syntax so they'd been 
disabled in C++14 mode.

GCC's behaviour is to use the builtin constants in all "-std=gnu++N" modes but 
disable them for "-std=c++11" and "-std=c++14" (they are still permitted in 
"-std=c++98"). This seemed inconsistent (and likely an implementation detail 
rather than intended behaviour) so my patch makes the decision purely on 
whether we're in GNU mode.

Does it look reasonable?

Tim.


https://reviews.llvm.org/D33424

Files:
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/SemaCXX/constexpr-printing.cpp
  clang/unittests/AST/DeclTest.cpp


Index: clang/unittests/AST/DeclTest.cpp
===================================================================
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -26,7 +26,7 @@
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector<std::string> Args(1, "-std=c++11");
+  std::vector<std::string> Args(1, "-std=gnu++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
       Factory->create(),
Index: clang/test/SemaCXX/constexpr-printing.cpp
===================================================================
--- clang/test/SemaCXX/constexpr-printing.cpp
+++ clang/test/SemaCXX/constexpr-printing.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple 
x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S &s);
Index: clang/lib/Lex/LiteralSupport.cpp
===================================================================
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -653,7 +653,7 @@
         }
       }
       // "i", "if", and "il" are user-defined suffixes in C++1y.
-      if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
+      if (*s == 'i' && !PP.getLangOpts().GNUMode)
         break;
       // fall through.
     case 'j':


Index: clang/unittests/AST/DeclTest.cpp
===================================================================
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -26,7 +26,7 @@
   // This is a regression test for a memory leak in APValues for structs that
   // allocate memory. This test only fails if run under valgrind with full leak
   // checking enabled.
-  std::vector<std::string> Args(1, "-std=c++11");
+  std::vector<std::string> Args(1, "-std=gnu++11");
   Args.push_back("-fno-ms-extensions");
   ASSERT_TRUE(runToolOnCodeWithArgs(
       Factory->create(),
Index: clang/test/SemaCXX/constexpr-printing.cpp
===================================================================
--- clang/test/SemaCXX/constexpr-printing.cpp
+++ clang/test/SemaCXX/constexpr-printing.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 %s -std=gnu++11 -fsyntax-only -verify -triple x86_64-linux-gnu
 
 struct S;
 constexpr int extract(const S &s);
Index: clang/lib/Lex/LiteralSupport.cpp
===================================================================
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -653,7 +653,7 @@
         }
       }
       // "i", "if", and "il" are user-defined suffixes in C++1y.
-      if (*s == 'i' && PP.getLangOpts().CPlusPlus14)
+      if (*s == 'i' && !PP.getLangOpts().GNUMode)
         break;
       // fall through.
     case 'j':
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to