diff options
Diffstat (limited to 'test/Lexer')
-rw-r--r-- | test/Lexer/Inputs/case-insensitive-include.h | 8 | ||||
-rw-r--r-- | test/Lexer/case-insensitive-include-ms.c | 18 | ||||
-rw-r--r-- | test/Lexer/case-insensitive-include.c | 35 | ||||
-rw-r--r-- | test/Lexer/case-insensitive-system-include.c | 10 | ||||
-rw-r--r-- | test/Lexer/cxx-features.cpp | 73 | ||||
-rw-r--r-- | test/Lexer/cxx1y_digit_separators.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/eof-conflict-marker.c | 11 | ||||
-rw-r--r-- | test/Lexer/half-literal.cpp | 3 | ||||
-rw-r--r-- | test/Lexer/has_feature_efficiency_sanitizer.cpp | 12 | ||||
-rw-r--r-- | test/Lexer/hexfloat.cpp | 32 | ||||
-rw-r--r-- | test/Lexer/opencl-half-literal.cl | 10 |
11 files changed, 173 insertions, 42 deletions
diff --git a/test/Lexer/Inputs/case-insensitive-include.h b/test/Lexer/Inputs/case-insensitive-include.h new file mode 100644 index 0000000000000..954090fc93b45 --- /dev/null +++ b/test/Lexer/Inputs/case-insensitive-include.h @@ -0,0 +1,8 @@ +#ifndef CASE_INSENSITIVE_INCLUDE_H +#define CASE_INSENSITIVE_INCLUDE_H + +struct S { + int x; +}; + +#endif diff --git a/test/Lexer/case-insensitive-include-ms.c b/test/Lexer/case-insensitive-include-ms.c new file mode 100644 index 0000000000000..86bd8bba68ebd --- /dev/null +++ b/test/Lexer/case-insensitive-include-ms.c @@ -0,0 +1,18 @@ +// REQUIRES: case-insensitive-filesystem + +// RUN: mkdir -p %T/apath +// RUN: cp %S/Inputs/case-insensitive-include.h %T +// RUN: cd %T +// RUN: %clang_cc1 -fsyntax-only -fms-compatibility %s -include %s -I %T -verify +// RUN: %clang_cc1 -fsyntax-only -fms-compatibility -fdiagnostics-parseable-fixits %s -include %s -I %T 2>&1 | FileCheck %s + +#include "..\Output\.\case-insensitive-include.h" +#include "..\Output\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\"" +#include "..\output\.\case-insensitive-include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"..\\Output\\.\\case-insensitive-include.h\"" + +#include "apath\..\.\case-insensitive-include.h" +#include "apath\..\.\Case-Insensitive-Include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath\\..\\.\\case-insensitive-include.h\"" +#include "APath\..\.\case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-( diff --git a/test/Lexer/case-insensitive-include.c b/test/Lexer/case-insensitive-include.c new file mode 100644 index 0000000000000..13e5b5994269d --- /dev/null +++ b/test/Lexer/case-insensitive-include.c @@ -0,0 +1,35 @@ +// REQUIRES: case-insensitive-filesystem + +// RUN: mkdir -p %T/apath +// RUN: mkdir -p %T/asystempath +// RUN: cp %S/Inputs/case-insensitive-include.h %T +// RUN: cp %S/Inputs/case-insensitive-include.h %T/asystempath/case-insensitive-include2.h +// RUN: cd %T +// RUN: %clang_cc1 -fsyntax-only %s -include %s -I %T -isystem %T/asystempath -verify +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -include %s -I %T -isystem %T/asystempath 2>&1 | FileCheck %s + +// Known standard header, so warn: +#include <StdDef.h> // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:20}:"<stddef.h>" + +#include "case-insensitive-include.h" +#include "Case-Insensitive-Include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:38}:"\"case-insensitive-include.h\"" + +#include "../Output/./case-insensitive-include.h" +#include "../Output/./Case-Insensitive-Include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\"" +#include "../output/./case-insensitive-include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:50}:"\"../Output/./case-insensitive-include.h\"" + +#include "apath/.././case-insensitive-include.h" +#include "apath/.././Case-Insensitive-Include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:49}:"\"apath/.././case-insensitive-include.h\"" +#include "APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-( + +#include "../Output/./apath/.././case-insensitive-include.h" +#include "../Output/./APath/.././case-insensitive-include.h" // For the sake of efficiency, this case is not diagnosed. :-( +#include "../output/./apath/.././case-insensitive-include.h" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:61}:"\"../Output/./apath/.././case-insensitive-include.h\"" + +#include "CASE-INSENSITIVE-INCLUDE2.H" // Found in an -isystem directory. No warning. diff --git a/test/Lexer/case-insensitive-system-include.c b/test/Lexer/case-insensitive-system-include.c new file mode 100644 index 0000000000000..9d5289cda2da2 --- /dev/null +++ b/test/Lexer/case-insensitive-system-include.c @@ -0,0 +1,10 @@ +// REQUIRES: case-insensitive-filesystem + +// RUN: mkdir -p %T/asystempath +// RUN: cp %S/Inputs/case-insensitive-include.h %T/asystempath/ +// RUN: cd %T +// RUN: %clang_cc1 -fsyntax-only %s -include %s -isystem %T/asystempath -verify -Wnonportable-system-include-path +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -include %s -isystem %T/asystempath -Wnonportable-system-include-path 2>&1 | FileCheck %s + +#include "CASE-INSENSITIVE-INCLUDE.H" // expected-warning {{non-portable path}} +// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:10-[[@LINE-1]]:38}:"\"case-insensitive-include.h\"" diff --git a/test/Lexer/cxx-features.cpp b/test/Lexer/cxx-features.cpp index 6c4a092b1c48f..e047ec3dfb13b 100644 --- a/test/Lexer/cxx-features.cpp +++ b/test/Lexer/cxx-features.cpp @@ -1,132 +1,137 @@ // RUN: %clang_cc1 -std=c++98 -verify %s // RUN: %clang_cc1 -std=c++11 -verify %s // RUN: %clang_cc1 -std=c++1y -fsized-deallocation -verify %s -// RUN: %clang_cc1 -std=c++1y -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s +// RUN: %clang_cc1 -std=c++14 -fsized-deallocation -verify %s +// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -verify %s +// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s // RUN: %clang_cc1 -fcoroutines -DCOROUTINES -verify %s // expected-no-diagnostics +// FIXME using `defined` in a macro has undefined behavior. #if __cplusplus < 201103L -#define check(macro, cxx98, cxx11, cxx1y) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98 -#elif __cplusplus < 201304L -#define check(macro, cxx98, cxx11, cxx1y) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11 +#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx98 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx98 +#elif __cplusplus < 201402L +#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx11 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx11 +#elif __cplusplus < 201406L +#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx14 == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx14 #else -#define check(macro, cxx98, cxx11, cxx1y) cxx1y == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1y +#define check(macro, cxx98, cxx11, cxx14, cxx1z) cxx1z == 0 ? defined(__cpp_##macro) : __cpp_##macro != cxx1z #endif -#if check(binary_literals, 0, 0, 201304) +#if check(binary_literals, 0, 0, 201304, 201304) #error "wrong value for __cpp_binary_literals" #endif -#if check(digit_separators, 0, 0, 201309) +#if check(digit_separators, 0, 0, 201309, 201309) #error "wrong value for __cpp_digit_separators" #endif -#if check(init_captures, 0, 0, 201304) +#if check(init_captures, 0, 0, 201304, 201304) #error "wrong value for __cpp_init_captures" #endif -#if check(generic_lambdas, 0, 0, 201304) +#if check(generic_lambdas, 0, 0, 201304, 201304) #error "wrong value for __cpp_generic_lambdas" #endif -#if check(sized_deallocation, 0, 0, 201309) +#if check(sized_deallocation, 0, 0, 201309, 201309) #error "wrong value for __cpp_sized_deallocation" #endif -#if check(constexpr, 0, 200704, 201304) +#if check(constexpr, 0, 200704, 201304, 201304) #error "wrong value for __cpp_constexpr" #endif -#if check(decltype_auto, 0, 0, 201304) +#if check(decltype_auto, 0, 0, 201304, 201304) #error "wrong value for __cpp_decltype_auto" #endif -#if check(return_type_deduction, 0, 0, 201304) +#if check(return_type_deduction, 0, 0, 201304, 201304) #error "wrong value for __cpp_return_type_deduction" #endif -#if check(runtime_arrays, 0, 0, 0) +#if check(runtime_arrays, 0, 0, 0, 0) #error "wrong value for __cpp_runtime_arrays" #endif -#if check(aggregate_nsdmi, 0, 0, 201304) +#if check(aggregate_nsdmi, 0, 0, 201304, 201304) #error "wrong value for __cpp_aggregate_nsdmi" #endif -#if check(variable_templates, 0, 0, 201304) +#if check(variable_templates, 0, 0, 201304, 201304) #error "wrong value for __cpp_variable_templates" #endif -#if check(unicode_characters, 0, 200704, 200704) +#if check(unicode_characters, 0, 200704, 200704, 200704) #error "wrong value for __cpp_unicode_characters" #endif -#if check(raw_strings, 0, 200710, 200710) +#if check(raw_strings, 0, 200710, 200710, 200710) #error "wrong value for __cpp_raw_strings" #endif -#if check(unicode_literals, 0, 200710, 200710) +#if check(unicode_literals, 0, 200710, 200710, 200710) #error "wrong value for __cpp_unicode_literals" #endif -#if check(user_defined_literals, 0, 200809, 200809) +#if check(user_defined_literals, 0, 200809, 200809, 200809) #error "wrong value for __cpp_user_defined_literals" #endif -#if check(lambdas, 0, 200907, 200907) +#if check(lambdas, 0, 200907, 200907, 200907) #error "wrong value for __cpp_lambdas" #endif -#if check(range_based_for, 0, 200907, 200907) +#if check(range_based_for, 0, 200907, 200907, 200907) #error "wrong value for __cpp_range_based_for" #endif -#if check(static_assert, 0, 200410, 200410) +#if check(static_assert, 0, 200410, 200410, 200410) #error "wrong value for __cpp_static_assert" #endif -#if check(decltype, 0, 200707, 200707) +#if check(decltype, 0, 200707, 200707, 200707) #error "wrong value for __cpp_decltype" #endif -#if check(attributes, 0, 200809, 200809) +#if check(attributes, 0, 200809, 200809, 200809) #error "wrong value for __cpp_attributes" #endif -#if check(rvalue_references, 0, 200610, 200610) +#if check(rvalue_references, 0, 200610, 200610, 200610) #error "wrong value for __cpp_rvalue_references" #endif -#if check(variadic_templates, 0, 200704, 200704) +#if check(variadic_templates, 0, 200704, 200704, 200704) #error "wrong value for __cpp_variadic_templates" #endif -#if check(initializer_lists, 0, 200806, 200806) +#if check(initializer_lists, 0, 200806, 200806, 200806) #error "wrong value for __cpp_initializer_lists" #endif -#if check(delegating_constructors, 0, 200604, 200604) +#if check(delegating_constructors, 0, 200604, 200604, 200604) #error "wrong value for __cpp_delegating_constructors" #endif -#if check(nsdmi, 0, 200809, 200809) +#if check(nsdmi, 0, 200809, 200809, 200809) #error "wrong value for __cpp_nsdmi" #endif -#if check(inheriting_constructors, 0, 200802, 200802) +#if check(inheriting_constructors, 0, 200802, 200802, 200802) #error "wrong value for __cpp_inheriting_constructors" #endif -#if check(ref_qualifiers, 0, 200710, 200710) +#if check(ref_qualifiers, 0, 200710, 200710, 200710) #error "wrong value for __cpp_ref_qualifiers" #endif -#if check(alias_templates, 0, 200704, 200704) +#if check(alias_templates, 0, 200704, 200704, 200704) #error "wrong value for __cpp_alias_templates" #endif -#if check(experimental_concepts, 0, 0, CONCEPTS_TS) +#if check(experimental_concepts, 0, 0, CONCEPTS_TS, CONCEPTS_TS) #error "wrong value for __cpp_experimental_concepts" #endif diff --git a/test/Lexer/cxx1y_digit_separators.cpp b/test/Lexer/cxx1y_digit_separators.cpp index c4c6aee963da0..55366342eda0d 100644 --- a/test/Lexer/cxx1y_digit_separators.cpp +++ b/test/Lexer/cxx1y_digit_separators.cpp @@ -48,6 +48,9 @@ namespace floating { float r = 0.'0e1; // expected-error {{digit separator cannot appear at start of digit sequence}} float s = 0.0'e1; // expected-error {{digit separator cannot appear at end of digit sequence}} float t = 0.0e'1; // expected-error {{digit separator cannot appear at start of digit sequence}} + float u = 0x.'p1f; // expected-error {{hexadecimal floating literal requires a significand}} + float v = 0e'f; // expected-error {{exponent has no digits}} + float w = 0x0p'f; // expected-error {{exponent has no digits}} } #line 123'456 diff --git a/test/Lexer/eof-conflict-marker.c b/test/Lexer/eof-conflict-marker.c new file mode 100644 index 0000000000000..e0c35401ccbf6 --- /dev/null +++ b/test/Lexer/eof-conflict-marker.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -verify -fsyntax-only +// vim: set binary noeol: + +// This file intentionally ends without a \n on the last line. Make sure your +// editor doesn't add one. + +>>>> ORIGINAL +// expected-error@-1 {{version control conflict marker in file}} +<<<< +// expected-error@-1 {{expected identifier or '('}} +<<<<
\ No newline at end of file diff --git a/test/Lexer/half-literal.cpp b/test/Lexer/half-literal.cpp new file mode 100644 index 0000000000000..32af3faef9aa1 --- /dev/null +++ b/test/Lexer/half-literal.cpp @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +float a = 1.0h; // expected-error{{invalid suffix 'h' on floating constant}} +float b = 1.0H; // expected-error{{invalid suffix 'H' on floating constant}} diff --git a/test/Lexer/has_feature_efficiency_sanitizer.cpp b/test/Lexer/has_feature_efficiency_sanitizer.cpp new file mode 100644 index 0000000000000..ef9e273602558 --- /dev/null +++ b/test/Lexer/has_feature_efficiency_sanitizer.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -E -fsanitize=efficiency-cache-frag %s -o - | FileCheck --check-prefix=CHECK-ESAN %s +// RUN: %clang_cc1 -E -fsanitize=efficiency-working-set %s -o - | FileCheck --check-prefix=CHECK-ESAN %s +// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-ESAN %s + +#if __has_feature(efficiency_sanitizer) +int EfficiencySanitizerEnabled(); +#else +int EfficiencySanitizerDisabled(); +#endif + +// CHECK-ESAN: EfficiencySanitizerEnabled +// CHECK-NO-ESAN: EfficiencySanitizerDisabled diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp index 6985c7fbe2a49..163db72f56f29 100644 --- a/test/Lexer/hexfloat.cpp +++ b/test/Lexer/hexfloat.cpp @@ -1,15 +1,31 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -pedantic %s // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s -float f = 0x1p+1; // expected-warning{{hexadecimal floating constants are a C99 feature}} -double e = 0x.p0; //expected-error{{hexadecimal floating constants require a significand}} -double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} -float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} -double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} +// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify -pedantic %s +double e = 0x.p0; // expected-error-re {{hexadecimal floating {{constant|literal}} requires a significand}} + +float f = 0x1p+1; +double d = 0x.2p2; +float g = 0x1.2p2; +double h = 0x1.p2; +#if __cplusplus <= 201402L +// expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}} +// expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}} +// expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}} +// expected-warning@-5 {{hexadecimal floating literals are a C++1z feature}} +#endif // PR12717: In order to minimally diverge from the C++ standard, we do not lex // 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain // an underscore. -double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}} +double i = 0p+3; // expected-error {{invalid suffix 'p' on integer constant}} #define PREFIX(x) foo ## x double foo0p = 1, j = PREFIX(0p+3); // ok -double k = 0x42_amp+3; // expected-error-re{{{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator""_amp'}}}} +double k = 0x42_amp+3; +#if __cplusplus > 201402L +// expected-error@-2 {{no matching literal operator for call to 'operator""_amp+3'}} +#elif __cplusplus >= 201103L +// expected-error@-4 {{no matching literal operator for call to 'operator""_amp'}} +#else +// expected-error@-6 {{invalid suffix '_amp' on integer constant}} +#endif diff --git a/test/Lexer/opencl-half-literal.cl b/test/Lexer/opencl-half-literal.cl new file mode 100644 index 0000000000000..42ca5146b1fb5 --- /dev/null +++ b/test/Lexer/opencl-half-literal.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -triple spir-unknown-unknown + +#pragma OPENCL EXTENSION cl_khr_fp16 : enable + +constant half a = 1.0h; +constant half aa = 1.0H; +constant half b = 1.0hh; // expected-error{{invalid suffix 'hh' on floating constant}} +constant half c = 1.0fh; // expected-error{{invalid suffix 'fh' on floating constant}} +constant half d = 1.0lh; // expected-error{{invalid suffix 'lh' on floating constant}} +constant half e = 1.0hf; // expected-error{{invalid suffix 'hf' on floating constant}} |