diff options
Diffstat (limited to 'test/Preprocessor')
-rw-r--r-- | test/Preprocessor/assembler-with-cpp.c | 5 | ||||
-rw-r--r-- | test/Preprocessor/clang_headers.c | 2 | ||||
-rw-r--r-- | test/Preprocessor/has_include.c | 32 | ||||
-rw-r--r-- | test/Preprocessor/header_lookup1.c | 4 | ||||
-rw-r--r-- | test/Preprocessor/include-directive2.c | 2 | ||||
-rw-r--r-- | test/Preprocessor/init.c | 304 | ||||
-rw-r--r-- | test/Preprocessor/objc-pp.m | 2 | ||||
-rw-r--r-- | test/Preprocessor/pragma-pushpop-macro.c | 8 | ||||
-rw-r--r-- | test/Preprocessor/pragma_diagnostic_sections.cpp | 80 | ||||
-rw-r--r-- | test/Preprocessor/pragma_unknown.c | 2 | ||||
-rw-r--r-- | test/Preprocessor/predefined-macros.c | 12 | ||||
-rw-r--r-- | test/Preprocessor/print_line_empty_file.c | 12 | ||||
-rw-r--r-- | test/Preprocessor/pushable-diagnostics.c | 6 | ||||
-rw-r--r-- | test/Preprocessor/stdint.c | 100 | ||||
-rw-r--r-- | test/Preprocessor/warn-macro-unused.c | 5 |
15 files changed, 351 insertions, 225 deletions
diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c index 0543077..a9c4294 100644 --- a/test/Preprocessor/assembler-with-cpp.c +++ b/test/Preprocessor/assembler-with-cpp.c @@ -72,3 +72,8 @@ 11: T11(b) // CHECK-Identifiers-True: 11: #0 + +// This should not crash +// rdar://8823139 +# ## +// CHECK-Identifiers-False: # ## diff --git a/test/Preprocessor/clang_headers.c b/test/Preprocessor/clang_headers.c index f2dec4f..41bd754 100644 --- a/test/Preprocessor/clang_headers.c +++ b/test/Preprocessor/clang_headers.c @@ -1,3 +1,3 @@ -// RUN: %clang_cc1 -E %s +// RUN: %clang_cc1 -ffreestanding -E %s #include <limits.h> diff --git a/test/Preprocessor/has_include.c b/test/Preprocessor/has_include.c index c34c348..fdcae78 100644 --- a/test/Preprocessor/has_include.c +++ b/test/Preprocessor/has_include.c @@ -1,23 +1,23 @@ -// RUN: %clang_cc1 -Eonly -verify %s +// RUN: %clang_cc1 -ffreestanding -Eonly -verify %s // Try different path permutations of __has_include with existing file. -#if __has_include("stdio.h") +#if __has_include("stdint.h") #else #error "__has_include failed (1)." #endif -#if __has_include(<stdio.h>) +#if __has_include(<stdint.h>) #else #error "__has_include failed (2)." #endif // Try unary expression. -#if !__has_include("stdio.h") +#if !__has_include("stdint.h") #error "__has_include failed (5)." #endif // Try binary expression. -#if __has_include("stdio.h") && __has_include("stddef.h") +#if __has_include("stdint.h") && __has_include("stddef.h") #else #error "__has_include failed (6)." #endif @@ -44,12 +44,12 @@ #endif // Try unary expression. -#if !__has_include_next("stdio.h") // expected-warning {{#include_next in primary source file}} +#if !__has_include_next("stdint.h") // expected-warning {{#include_next in primary source file}} #error "__has_include_next failed (5)." #endif // Try binary expression. -#if __has_include_next("stdio.h") && __has_include("stddef.h") // expected-warning {{#include_next in primary source file}} +#if __has_include_next("stdint.h") && __has_include("stddef.h") // expected-warning {{#include_next in primary source file}} #else #error "__has_include_next failed (6)." #endif @@ -68,16 +68,16 @@ // FIXME: I don't quite know how to avoid preprocessor side effects. // Use FileCheck? // It also assert due to unterminated #if's. -//#if __has_include("stdio.h" -//#if __has_include "stdio.h") -//#if __has_include(stdio.h) +//#if __has_include("stdint.h" +//#if __has_include "stdint.h") +//#if __has_include(stdint.h) //#if __has_include() //#if __has_include( //#if __has_include) //#if __has_include -//#if __has_include(<stdio.h> -//#if __has_include<stdio.h>) -//#if __has_include("stdio.h) -//#if __has_include(stdio.h") -//#if __has_include(<stdio.h) -//#if __has_include(stdio.h>) +//#if __has_include(<stdint.h> +//#if __has_include<stdint.h>) +//#if __has_include("stdint.h) +//#if __has_include(stdint.h") +//#if __has_include(<stdint.h) +//#if __has_include(stdint.h>) diff --git a/test/Preprocessor/header_lookup1.c b/test/Preprocessor/header_lookup1.c index f93d0af..f52e4fe 100644 --- a/test/Preprocessor/header_lookup1.c +++ b/test/Preprocessor/header_lookup1.c @@ -1,2 +1,2 @@ -// RUN: %clang -fno-ms-extensions -I /usr/include %s -E | grep 'stdio.h.*3.*4' -#include <stdio.h> +// RUN: %clang -fno-ms-extensions %s -E | grep 'stddef.h.*3.*4' +#include <stddef.h> diff --git a/test/Preprocessor/include-directive2.c b/test/Preprocessor/include-directive2.c index b205325..5f1ee3c 100644 --- a/test/Preprocessor/include-directive2.c +++ b/test/Preprocessor/include-directive2.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Eonly -verify %s +// RUN: %clang_cc1 -ffreestanding -Eonly -verify %s # define HEADER <float.h> # include HEADER diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index 6c27a6c..98b0535 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -417,6 +417,104 @@ // I386:#define __tune_nocona__ 1 // I386:#define i386 1 // +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu < /dev/null | FileCheck -check-prefix I386-LINUX %s +// +// I386-LINUX:#define __CHAR16_TYPE__ unsigned short +// I386-LINUX:#define __CHAR32_TYPE__ unsigned int +// I386-LINUX:#define __CHAR_BIT__ 8 +// I386-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 +// I386-LINUX:#define __DBL_DIG__ 15 +// I386-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16 +// I386-LINUX:#define __DBL_HAS_DENORM__ 1 +// I386-LINUX:#define __DBL_HAS_INFINITY__ 1 +// I386-LINUX:#define __DBL_HAS_QUIET_NAN__ 1 +// I386-LINUX:#define __DBL_MANT_DIG__ 53 +// I386-LINUX:#define __DBL_MAX_10_EXP__ 308 +// I386-LINUX:#define __DBL_MAX_EXP__ 1024 +// I386-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308 +// I386-LINUX:#define __DBL_MIN_10_EXP__ (-307) +// I386-LINUX:#define __DBL_MIN_EXP__ (-1021) +// I386-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308 +// I386-LINUX:#define __DECIMAL_DIG__ 21 +// I386-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F +// I386-LINUX:#define __FLT_DIG__ 6 +// I386-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F +// I386-LINUX:#define __FLT_EVAL_METHOD__ 0 +// I386-LINUX:#define __FLT_HAS_DENORM__ 1 +// I386-LINUX:#define __FLT_HAS_INFINITY__ 1 +// I386-LINUX:#define __FLT_HAS_QUIET_NAN__ 1 +// I386-LINUX:#define __FLT_MANT_DIG__ 24 +// I386-LINUX:#define __FLT_MAX_10_EXP__ 38 +// I386-LINUX:#define __FLT_MAX_EXP__ 128 +// I386-LINUX:#define __FLT_MAX__ 3.40282347e+38F +// I386-LINUX:#define __FLT_MIN_10_EXP__ (-37) +// I386-LINUX:#define __FLT_MIN_EXP__ (-125) +// I386-LINUX:#define __FLT_MIN__ 1.17549435e-38F +// I386-LINUX:#define __FLT_RADIX__ 2 +// I386-LINUX:#define __INT16_TYPE__ short +// I386-LINUX:#define __INT32_TYPE__ int +// I386-LINUX:#define __INT64_C_SUFFIX__ LL +// I386-LINUX:#define __INT64_TYPE__ long long int +// I386-LINUX:#define __INT8_TYPE__ char +// I386-LINUX:#define __INTMAX_MAX__ 9223372036854775807LL +// I386-LINUX:#define __INTMAX_TYPE__ long long int +// I386-LINUX:#define __INTMAX_WIDTH__ 64 +// I386-LINUX:#define __INTPTR_TYPE__ int +// I386-LINUX:#define __INTPTR_WIDTH__ 32 +// I386-LINUX:#define __INT_MAX__ 2147483647 +// I386-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L +// I386-LINUX:#define __LDBL_DIG__ 18 +// I386-LINUX:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L +// I386-LINUX:#define __LDBL_HAS_DENORM__ 1 +// I386-LINUX:#define __LDBL_HAS_INFINITY__ 1 +// I386-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1 +// I386-LINUX:#define __LDBL_MANT_DIG__ 64 +// I386-LINUX:#define __LDBL_MAX_10_EXP__ 4932 +// I386-LINUX:#define __LDBL_MAX_EXP__ 16384 +// I386-LINUX:#define __LDBL_MAX__ 1.18973149535723176502e+4932L +// I386-LINUX:#define __LDBL_MIN_10_EXP__ (-4931) +// I386-LINUX:#define __LDBL_MIN_EXP__ (-16381) +// I386-LINUX:#define __LDBL_MIN__ 3.36210314311209350626e-4932L +// I386-LINUX:#define __LITTLE_ENDIAN__ 1 +// I386-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL +// I386-LINUX:#define __LONG_MAX__ 2147483647L +// I386-LINUX:#define __NO_INLINE__ 1 +// I386-LINUX:#define __NO_MATH_INLINES 1 +// I386-LINUX:#define __POINTER_WIDTH__ 32 +// I386-LINUX:#define __PTRDIFF_TYPE__ int +// I386-LINUX:#define __PTRDIFF_WIDTH__ 32 +// I386-LINUX:#define __REGISTER_PREFIX__ +// I386-LINUX:#define __SCHAR_MAX__ 127 +// I386-LINUX:#define __SHRT_MAX__ 32767 +// I386-LINUX:#define __SIG_ATOMIC_WIDTH__ 32 +// I386-LINUX:#define __SIZEOF_DOUBLE__ 8 +// I386-LINUX:#define __SIZEOF_FLOAT__ 4 +// I386-LINUX:#define __SIZEOF_INT__ 4 +// I386-LINUX:#define __SIZEOF_LONG_DOUBLE__ 12 +// I386-LINUX:#define __SIZEOF_LONG_LONG__ 8 +// I386-LINUX:#define __SIZEOF_LONG__ 4 +// I386-LINUX:#define __SIZEOF_POINTER__ 4 +// I386-LINUX:#define __SIZEOF_PTRDIFF_T__ 4 +// I386-LINUX:#define __SIZEOF_SHORT__ 2 +// I386-LINUX:#define __SIZEOF_SIZE_T__ 4 +// I386-LINUX:#define __SIZEOF_WCHAR_T__ 4 +// I386-LINUX:#define __SIZEOF_WINT_T__ 4 +// I386-LINUX:#define __SIZE_TYPE__ unsigned int +// I386-LINUX:#define __SIZE_WIDTH__ 32 +// I386-LINUX:#define __UINTMAX_TYPE__ long long unsigned int +// I386-LINUX:#define __USER_LABEL_PREFIX__ +// I386-LINUX:#define __WCHAR_MAX__ 2147483647 +// I386-LINUX:#define __WCHAR_TYPE__ int +// I386-LINUX:#define __WCHAR_WIDTH__ 32 +// I386-LINUX:#define __WINT_TYPE__ unsigned int +// I386-LINUX:#define __WINT_WIDTH__ 32 +// I386-LINUX:#define __i386 1 +// I386-LINUX:#define __i386__ 1 +// I386-LINUX:#define __nocona 1 +// I386-LINUX:#define __nocona__ 1 +// I386-LINUX:#define __tune_nocona__ 1 +// I386-LINUX:#define i386 1 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s // // MSP430:#define MSP430 1 @@ -508,106 +606,6 @@ // MSP430:#define __WINT_WIDTH__ 16 // MSP430:#define __clang__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=pic16-none-none < /dev/null | FileCheck -check-prefix PIC16 %s -// -// PIC16:#define __CHAR16_TYPE__ unsigned short -// PIC16:#define __CHAR32_TYPE__ unsigned int -// PIC16:#define __CHAR_BIT__ 8 -// PIC16:#define __DBL_DENORM_MIN__ 1.40129846e-45F -// PIC16:#define __DBL_DIG__ 6 -// PIC16:#define __DBL_EPSILON__ 1.19209290e-7F -// PIC16:#define __DBL_HAS_DENORM__ 1 -// PIC16:#define __DBL_HAS_INFINITY__ 1 -// PIC16:#define __DBL_HAS_QUIET_NAN__ 1 -// PIC16:#define __DBL_MANT_DIG__ 24 -// PIC16:#define __DBL_MAX_10_EXP__ 38 -// PIC16:#define __DBL_MAX_EXP__ 128 -// PIC16:#define __DBL_MAX__ 3.40282347e+38F -// PIC16:#define __DBL_MIN_10_EXP__ (-37) -// PIC16:#define __DBL_MIN_EXP__ (-125) -// PIC16:#define __DBL_MIN__ 1.17549435e-38F -// PIC16:#define __DECIMAL_DIG__ -1 -// PIC16:#define __FLT_DENORM_MIN__ 1.40129846e-45F -// PIC16:#define __FLT_DIG__ 6 -// PIC16:#define __FLT_EPSILON__ 1.19209290e-7F -// PIC16:#define __FLT_EVAL_METHOD__ 0 -// PIC16:#define __FLT_HAS_DENORM__ 1 -// PIC16:#define __FLT_HAS_INFINITY__ 1 -// PIC16:#define __FLT_HAS_QUIET_NAN__ 1 -// PIC16:#define __FLT_MANT_DIG__ 24 -// PIC16:#define __FLT_MAX_10_EXP__ 38 -// PIC16:#define __FLT_MAX_EXP__ 128 -// PIC16:#define __FLT_MAX__ 3.40282347e+38F -// PIC16:#define __FLT_MIN_10_EXP__ (-37) -// PIC16:#define __FLT_MIN_EXP__ (-125) -// PIC16:#define __FLT_MIN__ 1.17549435e-38F -// PIC16:#define __FLT_RADIX__ 2 -// PIC16:#define __INT16_TYPE__ short -// PIC16:#define __INT32_C_SUFFIX__ L -// PIC16:#define __INT32_TYPE__ long int -// PIC16:#define __INT8_TYPE__ char -// PIC16:#define __INTMAX_MAX__ 2147483647L -// PIC16:#define __INTMAX_TYPE__ long int -// PIC16:#define __INTMAX_WIDTH__ 32 -// PIC16:#define __INTPTR_TYPE__ short -// PIC16:#define __INTPTR_WIDTH__ 16 -// PIC16:#define __INT_MAX__ 32767 -// PIC16:#define __LDBL_DENORM_MIN__ 1.40129846e-45F -// PIC16:#define __LDBL_DIG__ 6 -// PIC16:#define __LDBL_EPSILON__ 1.19209290e-7F -// PIC16:#define __LDBL_HAS_DENORM__ 1 -// PIC16:#define __LDBL_HAS_INFINITY__ 1 -// PIC16:#define __LDBL_HAS_QUIET_NAN__ 1 -// PIC16:#define __LDBL_MANT_DIG__ 24 -// PIC16:#define __LDBL_MAX_10_EXP__ 38 -// PIC16:#define __LDBL_MAX_EXP__ 128 -// PIC16:#define __LDBL_MAX__ 3.40282347e+38F -// PIC16:#define __LDBL_MIN_10_EXP__ (-37) -// PIC16:#define __LDBL_MIN_EXP__ (-125) -// PIC16:#define __LDBL_MIN__ 1.17549435e-38F -// PIC16:#define __LONG_LONG_MAX__ 2147483647LL -// PIC16:#define __LONG_MAX__ 2147483647L -// PIC16:#define __NO_INLINE__ 1 -// PIC16:#define __PIC16 1 -// PIC16:#define __POINTER_WIDTH__ 16 -// PIC16:#define __PTRDIFF_TYPE__ int -// PIC16:#define __PTRDIFF_WIDTH__ 16 -// PIC16:#define __SCHAR_MAX__ 127 -// PIC16:#define __SHRT_MAX__ 32767 -// PIC16:#define __SIG_ATOMIC_WIDTH__ 32 -// PIC16:#define __SIZEOF_DOUBLE__ 4 -// PIC16:#define __SIZEOF_FLOAT__ 4 -// PIC16:#define __SIZEOF_INT__ 2 -// PIC16:#define __SIZEOF_LONG_DOUBLE__ 4 -// PIC16:#define __SIZEOF_LONG_LONG__ 4 -// PIC16:#define __SIZEOF_LONG__ 4 -// PIC16:#define __SIZEOF_POINTER__ 2 -// PIC16:#define __SIZEOF_PTRDIFF_T__ 2 -// PIC16:#define __SIZEOF_SHORT__ 2 -// PIC16:#define __SIZEOF_SIZE_T__ 2 -// PIC16:#define __SIZEOF_WCHAR_T__ 2 -// PIC16:#define __SIZEOF_WINT_T__ 2 -// PIC16:#define __SIZE_TYPE__ unsigned int -// PIC16:#define __SIZE_WIDTH__ 16 -// PIC16:#define __UINTMAX_TYPE__ long unsigned int -// PIC16:#define __USER_LABEL_PREFIX__ _ -// PIC16:#define __WCHAR_MAX__ 32767 -// PIC16:#define __WCHAR_TYPE__ int -// PIC16:#define __WCHAR_WIDTH__ 16 -// PIC16:#define __WINT_TYPE__ int -// PIC16:#define __WINT_WIDTH__ 16 -// PIC16:#define __address(Addr) __attribute__((section("Address="#Addr))) -// PIC16:#define __clang__ 1 -// PIC16:#define __config(conf) asm("CONFIG "#conf) -// PIC16:#define __idlocs(value) asm("__IDLOCS "#value) -// PIC16:#define __llvm__ 1 -// PIC16:#define __pic16 1 -// PIC16:#define __section(SectName) __attribute__((section(SectName))) -// PIC16:#define interrupt __attribute__((section("interrupt=0x4"))) __attribute__((used)) -// PIC16:#define near __attribute__((section("Address=NEAR"))) -// PIC16:#define ram __attribute__((address_space(0))) -// PIC16:#define rom __attribute__((address_space(1))) -// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s // // PPC64:#define _ARCH_PPC 1 @@ -1193,6 +1191,112 @@ // X86_64:#define __x86_64 1 // X86_64:#define __x86_64__ 1 // +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -check-prefix X86_64-LINUX %s +// +// X86_64-LINUX:#define _LP64 1 +// X86_64-LINUX:#define __CHAR16_TYPE__ unsigned short +// X86_64-LINUX:#define __CHAR32_TYPE__ unsigned int +// X86_64-LINUX:#define __CHAR_BIT__ 8 +// X86_64-LINUX:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 +// X86_64-LINUX:#define __DBL_DIG__ 15 +// X86_64-LINUX:#define __DBL_EPSILON__ 2.2204460492503131e-16 +// X86_64-LINUX:#define __DBL_HAS_DENORM__ 1 +// X86_64-LINUX:#define __DBL_HAS_INFINITY__ 1 +// X86_64-LINUX:#define __DBL_HAS_QUIET_NAN__ 1 +// X86_64-LINUX:#define __DBL_MANT_DIG__ 53 +// X86_64-LINUX:#define __DBL_MAX_10_EXP__ 308 +// X86_64-LINUX:#define __DBL_MAX_EXP__ 1024 +// X86_64-LINUX:#define __DBL_MAX__ 1.7976931348623157e+308 +// X86_64-LINUX:#define __DBL_MIN_10_EXP__ (-307) +// X86_64-LINUX:#define __DBL_MIN_EXP__ (-1021) +// X86_64-LINUX:#define __DBL_MIN__ 2.2250738585072014e-308 +// X86_64-LINUX:#define __DECIMAL_DIG__ 21 +// X86_64-LINUX:#define __FLT_DENORM_MIN__ 1.40129846e-45F +// X86_64-LINUX:#define __FLT_DIG__ 6 +// X86_64-LINUX:#define __FLT_EPSILON__ 1.19209290e-7F +// X86_64-LINUX:#define __FLT_EVAL_METHOD__ 0 +// X86_64-LINUX:#define __FLT_HAS_DENORM__ 1 +// X86_64-LINUX:#define __FLT_HAS_INFINITY__ 1 +// X86_64-LINUX:#define __FLT_HAS_QUIET_NAN__ 1 +// X86_64-LINUX:#define __FLT_MANT_DIG__ 24 +// X86_64-LINUX:#define __FLT_MAX_10_EXP__ 38 +// X86_64-LINUX:#define __FLT_MAX_EXP__ 128 +// X86_64-LINUX:#define __FLT_MAX__ 3.40282347e+38F +// X86_64-LINUX:#define __FLT_MIN_10_EXP__ (-37) +// X86_64-LINUX:#define __FLT_MIN_EXP__ (-125) +// X86_64-LINUX:#define __FLT_MIN__ 1.17549435e-38F +// X86_64-LINUX:#define __FLT_RADIX__ 2 +// X86_64-LINUX:#define __INT16_TYPE__ short +// X86_64-LINUX:#define __INT32_TYPE__ int +// X86_64-LINUX:#define __INT64_C_SUFFIX__ L +// X86_64-LINUX:#define __INT64_TYPE__ long int +// X86_64-LINUX:#define __INT8_TYPE__ char +// X86_64-LINUX:#define __INTMAX_MAX__ 9223372036854775807L +// X86_64-LINUX:#define __INTMAX_TYPE__ long int +// X86_64-LINUX:#define __INTMAX_WIDTH__ 64 +// X86_64-LINUX:#define __INTPTR_TYPE__ long int +// X86_64-LINUX:#define __INTPTR_WIDTH__ 64 +// X86_64-LINUX:#define __INT_MAX__ 2147483647 +// X86_64-LINUX:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L +// X86_64-LINUX:#define __LDBL_DIG__ 18 +// X86_64-LINUX:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L +// X86_64-LINUX:#define __LDBL_HAS_DENORM__ 1 +// X86_64-LINUX:#define __LDBL_HAS_INFINITY__ 1 +// X86_64-LINUX:#define __LDBL_HAS_QUIET_NAN__ 1 +// X86_64-LINUX:#define __LDBL_MANT_DIG__ 64 +// X86_64-LINUX:#define __LDBL_MAX_10_EXP__ 4932 +// X86_64-LINUX:#define __LDBL_MAX_EXP__ 16384 +// X86_64-LINUX:#define __LDBL_MAX__ 1.18973149535723176502e+4932L +// X86_64-LINUX:#define __LDBL_MIN_10_EXP__ (-4931) +// X86_64-LINUX:#define __LDBL_MIN_EXP__ (-16381) +// X86_64-LINUX:#define __LDBL_MIN__ 3.36210314311209350626e-4932L +// X86_64-LINUX:#define __LITTLE_ENDIAN__ 1 +// X86_64-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL +// X86_64-LINUX:#define __LONG_MAX__ 9223372036854775807L +// X86_64-LINUX:#define __LP64__ 1 +// X86_64-LINUX:#define __MMX__ 1 +// X86_64-LINUX:#define __NO_INLINE__ 1 +// X86_64-LINUX:#define __NO_MATH_INLINES 1 +// X86_64-LINUX:#define __POINTER_WIDTH__ 64 +// X86_64-LINUX:#define __PTRDIFF_TYPE__ long int +// X86_64-LINUX:#define __PTRDIFF_WIDTH__ 64 +// X86_64-LINUX:#define __REGISTER_PREFIX__ +// X86_64-LINUX:#define __SCHAR_MAX__ 127 +// X86_64-LINUX:#define __SHRT_MAX__ 32767 +// X86_64-LINUX:#define __SIG_ATOMIC_WIDTH__ 32 +// X86_64-LINUX:#define __SIZEOF_DOUBLE__ 8 +// X86_64-LINUX:#define __SIZEOF_FLOAT__ 4 +// X86_64-LINUX:#define __SIZEOF_INT__ 4 +// X86_64-LINUX:#define __SIZEOF_LONG_DOUBLE__ 16 +// X86_64-LINUX:#define __SIZEOF_LONG_LONG__ 8 +// X86_64-LINUX:#define __SIZEOF_LONG__ 8 +// X86_64-LINUX:#define __SIZEOF_POINTER__ 8 +// X86_64-LINUX:#define __SIZEOF_PTRDIFF_T__ 8 +// X86_64-LINUX:#define __SIZEOF_SHORT__ 2 +// X86_64-LINUX:#define __SIZEOF_SIZE_T__ 8 +// X86_64-LINUX:#define __SIZEOF_WCHAR_T__ 4 +// X86_64-LINUX:#define __SIZEOF_WINT_T__ 4 +// X86_64-LINUX:#define __SIZE_TYPE__ long unsigned int +// X86_64-LINUX:#define __SIZE_WIDTH__ 64 +// X86_64-LINUX:#define __SSE2_MATH__ 1 +// X86_64-LINUX:#define __SSE2__ 1 +// X86_64-LINUX:#define __SSE_MATH__ 1 +// X86_64-LINUX:#define __SSE__ 1 +// X86_64-LINUX:#define __UINTMAX_TYPE__ long unsigned int +// X86_64-LINUX:#define __USER_LABEL_PREFIX__ +// X86_64-LINUX:#define __WCHAR_MAX__ 2147483647 +// X86_64-LINUX:#define __WCHAR_TYPE__ int +// X86_64-LINUX:#define __WCHAR_WIDTH__ 32 +// X86_64-LINUX:#define __WINT_TYPE__ unsigned int +// X86_64-LINUX:#define __WINT_WIDTH__ 32 +// X86_64-LINUX:#define __amd64 1 +// X86_64-LINUX:#define __amd64__ 1 +// X86_64-LINUX:#define __nocona 1 +// X86_64-LINUX:#define __nocona__ 1 +// X86_64-LINUX:#define __tune_nocona__ 1 +// X86_64-LINUX:#define __x86_64 1 +// X86_64-LINUX:#define __x86_64__ 1 +// // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s // GNUSOURCE:#define _GNU_SOURCE 1 // diff --git a/test/Preprocessor/objc-pp.m b/test/Preprocessor/objc-pp.m index 3e09325..0ec288c 100644 --- a/test/Preprocessor/objc-pp.m +++ b/test/Preprocessor/objc-pp.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic +// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -ffreestanding #import <stdint.h> // no warning on #import in objc mode. diff --git a/test/Preprocessor/pragma-pushpop-macro.c b/test/Preprocessor/pragma-pushpop-macro.c index 87cceaa..71b0e0e 100644 --- a/test/Preprocessor/pragma-pushpop-macro.c +++ b/test/Preprocessor/pragma-pushpop-macro.c @@ -25,9 +25,17 @@ int pmx3 = X; #pragma pop_macro("Y") int pmy1 = Y; +// Have a stray 'push' to show we don't crash when having inbalanced +// push/pop +#pragma push_macro("Y") +#define Y 4 +int pmy2 = Y; + // CHECK: int pmx0 = 1 // CHECK: int pmy0 = 2 // CHECK: int pmx1 = 1 // CHECK: int pmx2 = 2 // CHECK: int pmx3 = 1 // CHECK: int pmy1 = 3 +// CHECK: int pmy2 = 4 + diff --git a/test/Preprocessor/pragma_diagnostic_sections.cpp b/test/Preprocessor/pragma_diagnostic_sections.cpp new file mode 100644 index 0000000..69436b0 --- /dev/null +++ b/test/Preprocessor/pragma_diagnostic_sections.cpp @@ -0,0 +1,80 @@ +// RUN: %clang_cc1 -fsyntax-only -Wall -Wunused-macros -Wunused-parameter -Wno-uninitialized -verify %s + +// rdar://8365684 +struct S { + void m1() { int b = b==b; } // expected-warning {{always evaluates to true}} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" + void m2() { int b = b==b; } +#pragma clang diagnostic pop + + void m3() { int b = b==b; } // expected-warning {{always evaluates to true}} +}; + +//------------------------------------------------------------------------------ + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wtautological-compare" +template <typename T> +struct TS { + void m() { T b = b==b; } +}; +#pragma clang diagnostic pop + +void f() { + TS<int> ts; + ts.m(); +} + +//------------------------------------------------------------------------------ + +#define UNUSED_MACRO1 // expected-warning {{macro is not used}} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-macros" +#define UNUSED_MACRO2 +#pragma clang diagnostic pop + +//------------------------------------------------------------------------------ + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreturn-type" +int g() { } +#pragma clang diagnostic pop + +//------------------------------------------------------------------------------ + +void ww( +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" + int x, +#pragma clang diagnostic pop + int y) // expected-warning {{unused}} +{ +} + +//------------------------------------------------------------------------------ + +struct S2 { + int x, y; + S2() : +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreorder" + y(), + x() +#pragma clang diagnostic pop + {} +}; + +//------------------------------------------------------------------------------ + +// rdar://8790245 +#define MYMACRO \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") \ + _Pragma("clang diagnostic pop") +MYMACRO +#undef MYMACRO + +//------------------------------------------------------------------------------ diff --git a/test/Preprocessor/pragma_unknown.c b/test/Preprocessor/pragma_unknown.c index c185153..0672ade 100644 --- a/test/Preprocessor/pragma_unknown.c +++ b/test/Preprocessor/pragma_unknown.c @@ -21,7 +21,7 @@ #pragma STDC CX_LIMITED_RANGE IN_BETWEEN // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}} #pragma STDC CX_LIMITED_RANGE // expected-warning {{expected 'ON' or 'OFF' or 'DEFAULT' in pragma}} -#pragma STDC CX_LIMITED_RANGE ON FULL POWER // expected-warning {{expected end of macro in STDC pragma}} +#pragma STDC CX_LIMITED_RANGE ON FULL POWER // expected-warning {{expected end of macro in pragma}} #pragma STDC SO_GREAT // expected-warning {{unknown pragma in STDC namespace}} #pragma STDC // expected-warning {{unknown pragma in STDC namespace}} diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c new file mode 100644 index 0000000..85a0cb8 --- /dev/null +++ b/test/Preprocessor/predefined-macros.c @@ -0,0 +1,12 @@ +// This test verifies that the correct macros are predefined. It currently +// only checks for Microsoft macros. + +// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions -fmsc-version=1300 -o - | FileCheck %s + + +// CHECK: #define _INTEGRAL_MAX_BITS 64 +// CHECK: #define _MSC_EXTENSIONS 1 +// CHECK: #define _MSC_VER 1300 +// CHECK: #define _M_IX86 600 +// CHECK: #define _M_IX86_FP +// CHECK: #define _WIN32 1 diff --git a/test/Preprocessor/print_line_empty_file.c b/test/Preprocessor/print_line_empty_file.c new file mode 100644 index 0000000..868d0b7 --- /dev/null +++ b/test/Preprocessor/print_line_empty_file.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -E %s | FileCheck %s + +#line 21 "" +int foo() { return 42; } + +#line 4 "bug.c" +int bar() { return 21; } + +// CHECK: # 21 "" +// CHECK: int foo() { return 42; } +// CHECK: # 4 "bug.c" +// CHECK: int bar() { return 21; } diff --git a/test/Preprocessor/pushable-diagnostics.c b/test/Preprocessor/pushable-diagnostics.c index 567a866f..877eaaa 100644 --- a/test/Preprocessor/pushable-diagnostics.c +++ b/test/Preprocessor/pushable-diagnostics.c @@ -4,14 +4,14 @@ #pragma clang diagnostic puhs // expected-warning {{pragma diagnostic expected 'error', 'warning', 'ignored', 'fatal', 'push', or 'pop'}} -char a = 'df'; // expected-warning{{multi-character character constant}} +int a = 'df'; // expected-warning{{multi-character character constant}} #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmultichar" -char b = 'df'; // no warning. +int b = 'df'; // no warning. #pragma clang diagnostic pop -char c = 'df'; // expected-warning{{multi-character character constant}} +int c = 'df'; // expected-warning{{multi-character character constant}} #pragma clang diagnostic pop // expected-warning{{pragma diagnostic pop could not pop, no matching push}} diff --git a/test/Preprocessor/stdint.c b/test/Preprocessor/stdint.c index f8bb921..b3ae843 100644 --- a/test/Preprocessor/stdint.c +++ b/test/Preprocessor/stdint.c @@ -421,106 +421,6 @@ // MSP430:INTMAX_C_(0) 0L // MSP430:UINTMAX_C_(0) 0UL // -// RUN: %clang_cc1 -E -ffreestanding -triple=pic16-none-none %s | FileCheck -check-prefix PIC16 %s -// -// PIC16:typedef signed long int int32_t; -// PIC16:typedef unsigned long int uint32_t; -// PIC16:typedef int32_t int_least32_t; -// PIC16:typedef uint32_t uint_least32_t; -// PIC16:typedef int32_t int_fast32_t; -// PIC16:typedef uint32_t uint_fast32_t; -// -// PIC16:typedef signed short int16_t; -// PIC16:typedef unsigned short uint16_t; -// PIC16:typedef int16_t int_least16_t; -// PIC16:typedef uint16_t uint_least16_t; -// PIC16:typedef int16_t int_fast16_t; -// PIC16:typedef uint16_t uint_fast16_t; -// -// PIC16:typedef signed char int8_t; -// PIC16:typedef unsigned char uint8_t; -// PIC16:typedef int8_t int_least8_t; -// PIC16:typedef uint8_t uint_least8_t; -// PIC16:typedef int8_t int_fast8_t; -// PIC16:typedef uint8_t uint_fast8_t; -// -// PIC16:typedef int16_t intptr_t; -// PIC16:typedef uint16_t uintptr_t; -// -// PIC16:typedef long int intmax_t; -// PIC16:typedef long unsigned int uintmax_t; -// -// PIC16:INT8_MAX_ 127 -// PIC16:INT8_MIN_ (-127 -1) -// PIC16:UINT8_MAX_ 255 -// PIC16:INT_LEAST8_MIN_ (-127 -1) -// PIC16:INT_LEAST8_MAX_ 127 -// PIC16:UINT_LEAST8_MAX_ 255 -// PIC16:INT_FAST8_MIN_ (-127 -1) -// PIC16:INT_FAST8_MAX_ 127 -// PIC16:UINT_FAST8_MAX_ 255 -// -// PIC16:INT16_MAX_ 32767 -// PIC16:INT16_MIN_ (-32767 -1) -// PIC16:UINT16_MAX_ 65535 -// PIC16:INT_LEAST16_MIN_ (-32767 -1) -// PIC16:INT_LEAST16_MAX_ 32767 -// PIC16:UINT_LEAST16_MAX_ 65535 -// PIC16:INT_FAST16_MIN_ (-32767 -1) -// PIC16:INT_FAST16_MAX_ 32767 -// PIC16:UINT_FAST16_MAX_ 65535 -// -// PIC16:INT32_MAX_ 2147483647L -// PIC16:INT32_MIN_ (-2147483647L -1) -// PIC16:UINT32_MAX_ 4294967295UL -// PIC16:INT_LEAST32_MIN_ (-2147483647L -1) -// PIC16:INT_LEAST32_MAX_ 2147483647L -// PIC16:UINT_LEAST32_MAX_ 4294967295UL -// PIC16:INT_FAST32_MIN_ (-2147483647L -1) -// PIC16:INT_FAST32_MAX_ 2147483647L -// PIC16:UINT_FAST32_MAX_ 4294967295UL -// -// PIC16:INT64_MAX_ INT64_MAX -// PIC16:INT64_MIN_ INT64_MIN -// PIC16:UINT64_MAX_ UINT64_MAX -// PIC16:INT_LEAST64_MIN_ INT_LEAST64_MIN -// PIC16:INT_LEAST64_MAX_ INT_LEAST64_MAX -// PIC16:UINT_LEAST64_MAX_ UINT_LEAST64_MAX -// PIC16:INT_FAST64_MIN_ INT_FAST64_MIN -// PIC16:INT_FAST64_MAX_ INT_FAST64_MAX -// PIC16:UINT_FAST64_MAX_ UINT_FAST64_MAX -// -// PIC16:INTPTR_MIN_ (-32767 -1) -// PIC16:INTPTR_MAX_ 32767 -// PIC16:UINTPTR_MAX_ 65535 -// PIC16:PTRDIFF_MIN_ (-32767 -1) -// PIC16:PTRDIFF_MAX_ 32767 -// PIC16:SIZE_MAX_ 65535 -// -// PIC16:INTMAX_MIN_ (-2147483647L -1) -// PIC16:INTMAX_MAX_ 2147483647L -// PIC16:UINTMAX_MAX_ 4294967295UL -// -// PIC16:SIG_ATOMIC_MIN_ (-2147483647L -1) -// PIC16:SIG_ATOMIC_MAX_ 2147483647L -// PIC16:WINT_MIN_ (-32767 -1) -// PIC16:WINT_MAX_ 32767 -// -// PIC16:WCHAR_MAX_ 32767 -// PIC16:WCHAR_MIN_ (-32767 -1) -// -// PIC16:INT8_C_(0) 0 -// PIC16:UINT8_C_(0) 0U -// PIC16:INT16_C_(0) 0 -// PIC16:UINT16_C_(0) 0U -// PIC16:INT32_C_(0) 0L -// PIC16:UINT32_C_(0) 0UL -// PIC16:INT64_C_(0) INT64_C(0) -// PIC16:UINT64_C_(0) UINT64_C(0) -// -// PIC16:INTMAX_C_(0) 0L -// PIC16:UINTMAX_C_(0) 0UL -// // RUN: %clang_cc1 -E -ffreestanding -triple=powerpc64-none-none %s | FileCheck -check-prefix PPC64 %s // // PPC64:typedef signed long int int64_t; diff --git a/test/Preprocessor/warn-macro-unused.c b/test/Preprocessor/warn-macro-unused.c new file mode 100644 index 0000000..8a6d7c2 --- /dev/null +++ b/test/Preprocessor/warn-macro-unused.c @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 %s -Wunused-macros -Dfoo -Dfoo -verify + +#define unused // expected-warning {{macro is not used}} +#define unused +unused |