summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorTim Northover <tnorthover@apple.com>2017-08-08 22:03:54 +0000
committerTim Northover <tnorthover@apple.com>2017-08-08 22:03:54 +0000
commit8fbb4c40b30606dbfe347edc985628920153f75d (patch)
tree3071c18e02eb55b13a490da8dd4411771845578d /clang/test
parentd36945bf3a67fabfb5e28726deaede4295dcc574 (diff)
downloadbcm5719-llvm-8fbb4c40b30606dbfe347edc985628920153f75d.tar.gz
bcm5719-llvm-8fbb4c40b30606dbfe347edc985628920153f75d.zip
Lexer: always allow imaginary constants in GNU mode.
llvm-svn: 310423
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Lexer/imaginary-constants.cpp25
-rw-r--r--clang/test/SemaCXX/constexpr-printing.cpp2
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/test/Lexer/imaginary-constants.cpp b/clang/test/Lexer/imaginary-constants.cpp
new file mode 100644
index 00000000000..3a176be54a1
--- /dev/null
+++ b/clang/test/Lexer/imaginary-constants.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++98 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++11 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=gnu++14 -DHAVE_IMAGINARY=1
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -DHAVE_IMAGINARY=0
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DHAVE_IMAGINARY=0 -DCXX14=1
+
+// Imaginary constants are a GNU extension that became problematic when C++14
+// defined its own versions. Until then they're supported even in
+// standards-compliant mode.
+#if HAVE_IMAGINARY
+// expected-no-diagnostics
+#elif CXX14
+// expected-error@+9 {{no matching literal operator for call to 'operator""i' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
+// expected-error@+9 {{no matching literal operator for call to 'operator""il' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}}
+// expected-error@+9 {{invalid suffix 'ill' on integer constant}}
+#else
+// expected-error@+5 {{invalid suffix 'i' on integer constant}}
+// expected-error@+5 {{invalid suffix 'il' on integer constant}}
+// expected-error@+7 {{invalid suffix 'ill' on integer constant}}
+#endif
+
+_Complex int val1 = 2i;
+_Complex long val2 = 2il;
+_Complex long long val3 = 2ill;
diff --git a/clang/test/SemaCXX/constexpr-printing.cpp b/clang/test/SemaCXX/constexpr-printing.cpp
index 7f6a9c6a82f..3112fdeb355 100644
--- a/clang/test/SemaCXX/constexpr-printing.cpp
+++ b/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);
OpenPOWER on IntegriCloud