diff options
author | Alp Toker <alp@nuanti.com> | 2013-12-25 01:47:02 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2013-12-25 01:47:02 +0000 |
commit | 5294e6e0944af40e76f9685ee2ac38229aee8923 (patch) | |
tree | 9bf47eebddd1a54c421cff1a9100e0502d65b778 | |
parent | 38799b1471b211b4bf6db80a7eb3d470f0b1cc95 (diff) | |
download | llvm-5294e6e0944af40e76f9685ee2ac38229aee8923.zip llvm-5294e6e0944af40e76f9685ee2ac38229aee8923.tar.gz llvm-5294e6e0944af40e76f9685ee2ac38229aee8923.tar.bz2 |
Don't reserve __builtin_types_compatible_p as a C++ keyword
Even g++ considers this a valid C++ identifier and it should only have been
visible in C mode.
Also drop the associated low-value diagnostic.
llvm-svn: 197995
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/include/clang/Basic/TokenKinds.def | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 11 | ||||
-rw-r--r-- | clang/test/SemaCXX/types_compatible_p.cpp | 9 |
4 files changed, 8 insertions, 16 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 3a3c93d..71d118a 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -367,8 +367,6 @@ def warn_redecl_library_builtin : Warning< "incompatible redeclaration of library function %0">, InGroup<DiagGroup<"incompatible-library-redeclaration">>; def err_builtin_definition : Error<"definition of builtin function %0">; -def err_types_compatible_p_in_cplusplus : Error< - "__builtin_types_compatible_p is not valid in C++">; def warn_builtin_unknown : Warning<"use of unknown builtin %0">, InGroup<ImplicitFunctionDeclare>, DefaultError; def warn_dyn_class_memaccess : Warning< diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index a76d86b..54f78536 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -348,7 +348,7 @@ KEYWORD(__builtin_choose_expr , KEYALL) KEYWORD(__builtin_offsetof , KEYALL) // __builtin_types_compatible_p is a GNU C extension that we handle like a C++ // type trait. -TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYALL) +TYPE_TRAIT_2(__builtin_types_compatible_p, TypeCompatible, KEYNOCXX) KEYWORD(__builtin_va_arg , KEYALL) KEYWORD(__extension__ , KEYALL) KEYWORD(__imag , KEYALL) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index a0c123f..2591dbfe 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3707,16 +3707,7 @@ static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, ExprResult Sema::BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef<TypeSourceInfo *> Args, SourceLocation RParenLoc) { - QualType ResultType = Context.BoolTy; - // __builtin_types_compatible_p is a GNU C extension, not a C++ type trait. - if (Kind == BTT_TypeCompatible) { - ResultType = Context.IntTy; - if (getLangOpts().CPlusPlus) { - Diag(KWLoc, diag::err_types_compatible_p_in_cplusplus) - << SourceRange(KWLoc, RParenLoc); - return ExprError(); - } - } + QualType ResultType = Context.getLogicalOperationType(); bool Dependent = false; for (unsigned I = 0, N = Args.size(); I != N; ++I) { diff --git a/clang/test/SemaCXX/types_compatible_p.cpp b/clang/test/SemaCXX/types_compatible_p.cpp index 4aa9a1c..ebff53f 100644 --- a/clang/test/SemaCXX/types_compatible_p.cpp +++ b/clang/test/SemaCXX/types_compatible_p.cpp @@ -1,5 +1,8 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s +// RUN: %clang_cc1 -fsyntax-only -x c %s -bool f() { - return __builtin_types_compatible_p(int, const int); // expected-error{{C++}} +// Test that GNU C extension __builtin_types_compatible_p() is not available in C++ mode. + +int f() { + return __builtin_types_compatible_p(int, const int); // expected-error{{}} } |