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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197995
91177308-0d34-0410-b5e6-
96231b3b80d8
"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<
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)
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) {
-// 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{{}}
}