diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-12-16 02:32:55 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-12-16 02:32:55 +0000 |
commit | a0cdb61c3e1cb110810a74a0364dc3ac409e6311 (patch) | |
tree | c31512bfeb34f3979c135bbc4d808a32d2274c61 /clang/test | |
parent | 0637cda9f6da03e77f8ca111055ada0eba3541f5 (diff) | |
download | llvm-a0cdb61c3e1cb110810a74a0364dc3ac409e6311.zip llvm-a0cdb61c3e1cb110810a74a0364dc3ac409e6311.tar.gz llvm-a0cdb61c3e1cb110810a74a0364dc3ac409e6311.tar.bz2 |
Merging r196212:
------------------------------------------------------------------------
r196212 | alp | 2013-12-02 22:13:01 -0800 (Mon, 02 Dec 2013) | 22 lines
Emit an extension warning when changing system header tokens
clang converts keywords to identifiers for compatibility with various system
headers such as GNU libc.
Implement a -Wkeyword-compat extension warning to diagnose those cases. The
warning is on by default but will generally be ignored in system headers. It
can however be enabled globally to aid standards conformance testing.
This also changes the __uptr keyword avoidance from r195710 to no longer
special-case system headers, bringing it in line with other similar workarounds
in clang.
Implementation returns bool for symmetry with token annotation functions.
Some examples:
warning: keyword '__is_pod' will be treated as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_pod
warning: keyword '__uptr' will be treated as an identifier here [-Wkeyword-compat]
union w *__uptr;
------------------------------------------------------------------------
llvm-svn: 197359
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/PCH/cxx-traits.cpp | 4 | ||||
-rw-r--r-- | clang/test/PCH/cxx-traits.h | 4 | ||||
-rw-r--r-- | clang/test/Sema/Inputs/ms-keyword-system-header.h | 3 | ||||
-rw-r--r-- | clang/test/Sema/ms-keyword-system-header.c | 2 |
4 files changed, 10 insertions, 3 deletions
diff --git a/clang/test/PCH/cxx-traits.cpp b/clang/test/PCH/cxx-traits.cpp index 938f36f..ffdfccc 100644 --- a/clang/test/PCH/cxx-traits.cpp +++ b/clang/test/PCH/cxx-traits.cpp @@ -2,9 +2,11 @@ // RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s // RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h -// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -include-pch %t -DPCH -fsyntax-only -verify %s +#ifdef PCH // expected-no-diagnostics +#endif bool _Is_pod_comparator = __is_pod<int>::__value; bool _Is_empty_check = __is_empty<int>::__value; diff --git a/clang/test/PCH/cxx-traits.h b/clang/test/PCH/cxx-traits.h index 8b62002..836804e 100644 --- a/clang/test/PCH/cxx-traits.h +++ b/clang/test/PCH/cxx-traits.h @@ -1,12 +1,12 @@ // Header for PCH test cxx-traits.cpp template<typename _Tp> -struct __is_pod { +struct __is_pod { // expected-warning {{keyword '__is_pod' will be treated as an identifier for the remainder of the translation unit}} enum { __value }; }; template<typename _Tp> -struct __is_empty { +struct __is_empty { // expected-warning {{keyword '__is_empty' will be treated as an identifier for the remainder of the translation unit}} enum { __value }; }; diff --git a/clang/test/Sema/Inputs/ms-keyword-system-header.h b/clang/test/Sema/Inputs/ms-keyword-system-header.h index 13cfe3a..43a3db7 100644 --- a/clang/test/Sema/Inputs/ms-keyword-system-header.h +++ b/clang/test/Sema/Inputs/ms-keyword-system-header.h @@ -2,5 +2,8 @@ typedef union { union w *__uptr; +#if defined(MS) && defined(NOT_SYSTEM) + // expected-warning@-2 {{keyword '__uptr' will be treated as an identifier here}} +#endif int *__iptr; } WS __attribute__((__transparent_union__)); diff --git a/clang/test/Sema/ms-keyword-system-header.c b/clang/test/Sema/ms-keyword-system-header.c index bf7a9f4..b4ff568 100644 --- a/clang/test/Sema/ms-keyword-system-header.c +++ b/clang/test/Sema/ms-keyword-system-header.c @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fms-extensions -D MS -isystem %S/Inputs %s -fsyntax-only -verify +// RUN: %clang_cc1 -fms-extensions -D MS -Wno-keyword-compat -I %S/Inputs %s -fsyntax-only -verify +// RUN: %clang_cc1 -fms-extensions -D MS -D NOT_SYSTEM -I %S/Inputs %s -fsyntax-only -verify // RUN: %clang_cc1 -isystem %S/Inputs %s -fsyntax-only -verify // PR17824: GNU libc uses MS keyword __uptr as an identifier in C mode |