forked from OSchip/llvm-project
Strengthen -Wint-conversion to default to an error
Clang has traditionally allowed C programs to implicitly convert integers to pointers and pointers to integers, despite it not being valid to do so except under special circumstances (like converting the integer 0, which is the null pointer constant, to a pointer). In C89, this would result in undefined behavior per 3.3.4, and in C99 this rule was strengthened to be a constraint violation instead. Constraint violations are most often handled as an error. This patch changes the warning to default to an error in all C modes (it is already an error in C++). This gives us better security posture by calling out potential programmer mistakes in code but still allows users who need this behavior to use -Wno-error=int-conversion to retain the warning behavior, or -Wno-int-conversion to silence the diagnostic entirely. Differential Revision: https://reviews.llvm.org/D129881
This commit is contained in:
parent
b5c7213647
commit
7068aa9841
|
@ -1,5 +1,5 @@
|
|||
// RUN: %check_clang_tidy %s bugprone-no-escape %t
|
||||
// RUN: %check_clang_tidy %s -assume-filename=bugprone-no-escape.c bugprone-no-escape %t -- -- -fblocks
|
||||
// RUN: %check_clang_tidy %s bugprone-no-escape %t -- -- -Wno-int-conversion
|
||||
// RUN: %check_clang_tidy %s -assume-filename=bugprone-no-escape.c bugprone-no-escape %t -- -- -fblocks -Wno-int-conversion
|
||||
|
||||
typedef struct dispatch_queue_s *dispatch_queue_t;
|
||||
typedef struct dispatch_time_s *dispatch_time_t;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %check_clang_tidy %s performance-no-int-to-ptr %t
|
||||
// RUN: %check_clang_tidy %s performance-no-int-to-ptr %t -- -- -Wno-int-conversion
|
||||
|
||||
void *t0(char x) {
|
||||
return x;
|
||||
|
|
|
@ -26,7 +26,7 @@ class TestDiagnostics(unittest.TestCase):
|
|||
# FIXME: We aren't getting notes here for some reason.
|
||||
tu = get_tu('#define A x\nvoid *A = 1;\n')
|
||||
self.assertEqual(len(tu.diagnostics), 1)
|
||||
self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Warning)
|
||||
self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Error)
|
||||
self.assertEqual(tu.diagnostics[0].location.line, 2)
|
||||
self.assertEqual(tu.diagnostics[0].location.column, 7)
|
||||
self.assertIn('incompatible', tu.diagnostics[0].spelling)
|
||||
|
@ -53,7 +53,7 @@ class TestDiagnostics(unittest.TestCase):
|
|||
def test_diagnostic_range(self):
|
||||
tu = get_tu('void f() { int i = "a"; }')
|
||||
self.assertEqual(len(tu.diagnostics), 1)
|
||||
self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Warning)
|
||||
self.assertEqual(tu.diagnostics[0].severity, Diagnostic.Error)
|
||||
self.assertEqual(tu.diagnostics[0].location.line, 1)
|
||||
self.assertEqual(tu.diagnostics[0].location.column, 16)
|
||||
self.assertRegex(tu.diagnostics[0].spelling,
|
||||
|
|
|
@ -297,6 +297,11 @@ Improvements to Clang's diagnostics
|
|||
member of the contained class.
|
||||
- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
|
||||
comments.
|
||||
- The ``-Wint-conversion`` warning diagnostic for implicit int <-> pointer
|
||||
conversions now defaults to an error in all C language modes. It may be
|
||||
downgraded to a warning with ``-Wno-error=int-conversion``, or disabled
|
||||
entirely with ``-Wno-int-conversion``.
|
||||
|
||||
|
||||
Non-comprehensive list of changes in this release
|
||||
-------------------------------------------------
|
||||
|
|
|
@ -8037,24 +8037,6 @@ def err_incompatible_qualified_id : Error<
|
|||
"sending type to parameter of incompatible type}0,1"
|
||||
"|%diff{casting $ to incompatible type $|"
|
||||
"casting type to incompatible type}0,1}2">;
|
||||
def ext_typecheck_convert_pointer_int : ExtWarn<
|
||||
"incompatible pointer to integer conversion "
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
"|%diff{passing $ to parameter of type $|"
|
||||
"passing to parameter of different type}0,1"
|
||||
"|%diff{returning $ from a function with result type $|"
|
||||
"returning from function with different return type}0,1"
|
||||
"|%diff{converting $ to type $|converting between types}0,1"
|
||||
"|%diff{initializing $ with an expression of type $|"
|
||||
"initializing with expression of different type}0,1"
|
||||
"|%diff{sending $ to parameter of type $|"
|
||||
"sending to parameter of different type}0,1"
|
||||
"|%diff{casting $ to type $|casting between types}0,1}2"
|
||||
"%select{|; dereference with *|"
|
||||
"; take the address with &|"
|
||||
"; remove *|"
|
||||
"; remove &}3">,
|
||||
InGroup<IntConversion>;
|
||||
def err_typecheck_convert_pointer_int : Error<
|
||||
"incompatible pointer to integer conversion "
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
|
@ -8072,24 +8054,9 @@ def err_typecheck_convert_pointer_int : Error<
|
|||
"; take the address with &|"
|
||||
"; remove *|"
|
||||
"; remove &}3">;
|
||||
def ext_typecheck_convert_int_pointer : ExtWarn<
|
||||
"incompatible integer to pointer conversion "
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
"|%diff{passing $ to parameter of type $|"
|
||||
"passing to parameter of different type}0,1"
|
||||
"|%diff{returning $ from a function with result type $|"
|
||||
"returning from function with different return type}0,1"
|
||||
"|%diff{converting $ to type $|converting between types}0,1"
|
||||
"|%diff{initializing $ with an expression of type $|"
|
||||
"initializing with expression of different type}0,1"
|
||||
"|%diff{sending $ to parameter of type $|"
|
||||
"sending to parameter of different type}0,1"
|
||||
"|%diff{casting $ to type $|casting between types}0,1}2"
|
||||
"%select{|; dereference with *|"
|
||||
"; take the address with &|"
|
||||
"; remove *|"
|
||||
"; remove &}3">,
|
||||
InGroup<IntConversion>, SFINAEFailure;
|
||||
def ext_typecheck_convert_pointer_int : ExtWarn<
|
||||
err_typecheck_convert_pointer_int.Text>,
|
||||
InGroup<IntConversion>, DefaultError;
|
||||
def err_typecheck_convert_int_pointer : Error<
|
||||
"incompatible integer to pointer conversion "
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
|
@ -8107,6 +8074,9 @@ def err_typecheck_convert_int_pointer : Error<
|
|||
"; take the address with &|"
|
||||
"; remove *|"
|
||||
"; remove &}3">;
|
||||
def ext_typecheck_convert_int_pointer : ExtWarn<
|
||||
err_typecheck_convert_int_pointer.Text>,
|
||||
InGroup<IntConversion>, DefaultError;
|
||||
def ext_typecheck_convert_pointer_void_func : Extension<
|
||||
"%select{%diff{assigning to $ from $|assigning to different types}0,1"
|
||||
"|%diff{passing $ to parameter of type $|"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_analyze_cc1 -w %s -verify \
|
||||
// RUN: %clang_analyze_cc1 -w -Wno-int-conversion %s -verify \
|
||||
// RUN: -analyzer-checker=core,alpha.core,debug.ExprInspection
|
||||
|
||||
#ifdef HEADER // A clever trick to avoid splitting up the test.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_analyze_cc1 -w -verify %s \
|
||||
// RUN: %clang_analyze_cc1 -w -Wno-int-conversion -verify %s \
|
||||
// RUN: -analyzer-checker=core \
|
||||
// RUN: -analyzer-checker=unix.cstring.NullArg \
|
||||
// RUN: -analyzer-checker=alpha.unix.cstring \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_analyze_cc1 -std=c89 -analyzer-checker=core %s
|
||||
// RUN: %clang_analyze_cc1 -std=c89 -Wno-int-conversion -analyzer-checker=core %s
|
||||
x;
|
||||
y(void **z) { // no-crash
|
||||
*z = x;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -Wno-strict-prototypes -Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-purge=none -verify %s -Wno-error=return-type
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -Wno-strict-prototypes -Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -verify %s -Wno-error=return-type
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -Wno-int-conversion -Wno-strict-prototypes -Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -analyzer-purge=none -verify %s -Wno-error=return-type
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -Wno-int-conversion -Wno-strict-prototypes -Wno-tautological-constant-compare -Wtautological-unsigned-zero-compare -analyzer-checker=core,deadcode,alpha.core -std=gnu99 -verify %s -Wno-error=return-type
|
||||
|
||||
typedef unsigned uintptr_t;
|
||||
|
||||
|
@ -10,7 +10,7 @@ extern void __assert_fail (__const char *__assertion, __const char *__file,
|
|||
#define assert(expr) \
|
||||
((expr) ? (void)(0) : __assert_fail (#expr, __FILE__, __LINE__, __func__))
|
||||
|
||||
void f1(int *p) {
|
||||
void f1(int *p) {
|
||||
if (p) *p = 1;
|
||||
else *p = 0; // expected-warning{{ereference}}
|
||||
}
|
||||
|
@ -20,48 +20,48 @@ struct foo_struct {
|
|||
};
|
||||
|
||||
int f2(struct foo_struct* p) {
|
||||
|
||||
|
||||
if (p)
|
||||
p->x = 1;
|
||||
|
||||
|
||||
return p->x++; // expected-warning{{Access to field 'x' results in a dereference of a null pointer (loaded from variable 'p')}}
|
||||
}
|
||||
|
||||
int f3(char* x) {
|
||||
|
||||
|
||||
int i = 2;
|
||||
|
||||
|
||||
if (x)
|
||||
return x[i - 1];
|
||||
|
||||
|
||||
return x[i+1]; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}}
|
||||
}
|
||||
|
||||
int f3_b(char* x) {
|
||||
|
||||
|
||||
int i = 2;
|
||||
|
||||
|
||||
if (x)
|
||||
return x[i - 1];
|
||||
|
||||
|
||||
return x[i+1]++; // expected-warning{{Array access (from variable 'x') results in a null pointer dereference}}
|
||||
}
|
||||
|
||||
int f4(int *p) {
|
||||
|
||||
|
||||
uintptr_t x = (uintptr_t) p;
|
||||
|
||||
|
||||
if (x)
|
||||
return 1;
|
||||
|
||||
|
||||
int *q = (int*) x;
|
||||
return *q; // expected-warning{{Dereference of null pointer (loaded from variable 'q')}}
|
||||
}
|
||||
|
||||
int f4_b(void) {
|
||||
short array[2];
|
||||
uintptr_t x = array; // expected-warning{{incompatible pointer to integer conversion}}
|
||||
short *p = x; // expected-warning{{incompatible integer to pointer conversion}}
|
||||
uintptr_t x = array;
|
||||
short *p = x;
|
||||
|
||||
// The following branch should be infeasible.
|
||||
if (!(p == &array[0])) {
|
||||
|
@ -80,21 +80,21 @@ int f4_b(void) {
|
|||
}
|
||||
|
||||
int f5(void) {
|
||||
|
||||
|
||||
char *s = "hello world";
|
||||
return s[0]; // no-warning
|
||||
}
|
||||
|
||||
int bar(int* p, int q) __attribute__((nonnull));
|
||||
|
||||
int f6(int *p) {
|
||||
int f6(int *p) {
|
||||
return !p ? bar(p, 1) // expected-warning {{Null pointer passed to 1st parameter expecting 'nonnull'}}
|
||||
: bar(p, 0); // no-warning
|
||||
}
|
||||
|
||||
int bar2(int* p, int q) __attribute__((nonnull(1)));
|
||||
|
||||
int f6b(int *p) {
|
||||
int f6b(int *p) {
|
||||
return !p ? bar2(p, 1) // expected-warning {{Null pointer passed to 1st parameter expecting 'nonnull'}}
|
||||
: bar2(p, 0); // no-warning
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ void f6d(int *p) {
|
|||
// At this point, 'p' cannot be null.
|
||||
if (!p) {
|
||||
int *q = 0;
|
||||
*q = 0xDEADBEEF; // no-warning
|
||||
}
|
||||
*q = 0xDEADBEEF; // no-warning
|
||||
}
|
||||
}
|
||||
|
||||
void f6e(int *p, int offset) {
|
||||
|
@ -123,38 +123,38 @@ void f6e(int *p, int offset) {
|
|||
int* qux();
|
||||
|
||||
int f7(int x) {
|
||||
|
||||
|
||||
int* p = 0;
|
||||
|
||||
|
||||
if (0 == x)
|
||||
p = qux();
|
||||
|
||||
|
||||
if (0 == x)
|
||||
*p = 1; // no-warning
|
||||
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int* f7b(int *x) {
|
||||
|
||||
|
||||
int* p = 0;
|
||||
|
||||
|
||||
if (((void*)0) == x)
|
||||
p = qux();
|
||||
|
||||
|
||||
if (((void*)0) == x)
|
||||
*p = 1; // no-warning
|
||||
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int* f7c(int *x) {
|
||||
|
||||
|
||||
int* p = 0;
|
||||
|
||||
|
||||
if (((void*)0) == x)
|
||||
p = qux();
|
||||
|
||||
|
||||
if (((void*)0) != x)
|
||||
return x;
|
||||
|
||||
|
@ -164,15 +164,15 @@ int* f7c(int *x) {
|
|||
}
|
||||
|
||||
int* f7c2(int *x) {
|
||||
|
||||
|
||||
int* p = 0;
|
||||
|
||||
|
||||
if (((void*)0) == x)
|
||||
p = qux();
|
||||
|
||||
|
||||
if (((void*)0) == x)
|
||||
return x;
|
||||
|
||||
|
||||
*p = 1; // expected-warning{{null}}
|
||||
return x;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ void f8(int *p, int *q) {
|
|||
if (!p)
|
||||
if (p)
|
||||
*p = 1; // no-warning
|
||||
|
||||
|
||||
if (q)
|
||||
if (!q)
|
||||
*q = 1; // no-warning
|
||||
|
@ -217,7 +217,7 @@ int* f10(int* p, signed char x, int y) {
|
|||
// LHS and RHS have different bitwidths. The new symbolic value
|
||||
// for 'x' should have a bitwidth of 8.
|
||||
x &= y;
|
||||
|
||||
|
||||
// This tests that our symbolication worked, and that we correctly test
|
||||
// x against 0 (with the same bitwidth).
|
||||
if (!x) {
|
||||
|
@ -270,7 +270,7 @@ void f12(HF12ITEM i, char *q) {
|
|||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*p = 1; // no-warning
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
|
||||
#define NULL ((void *)0)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion %s -verify
|
||||
// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -fblocks -fobjc-arc -w -Wno-int-conversion -analyzer-checker=osx.NumberObjectConversion -analyzer-config osx.NumberObjectConversion:Pedantic=true -DPEDANTIC %s -verify
|
||||
|
||||
#include "Inputs/system-header-simulator-objc.h"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// At the moment the whole of the destination array content is invalidated.
|
||||
// If a.s1 region has a symbolic offset, the whole region of 'a' is invalidated.
|
||||
// Specific triple set to test structures of size 0.
|
||||
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
|
||||
// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu -analyzer-checker=core,unix.Malloc,debug.ExprInspection -Wno-error=int-conversion -verify -analyzer-config eagerly-assume=false %s
|
||||
|
||||
typedef __typeof(sizeof(int)) size_t;
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ char *dr064_1(int i, int *pi) {
|
|||
}
|
||||
|
||||
char *dr064_2(int i, int *pi) {
|
||||
return (*pi = i, 0); /* expected-warning {{incompatible integer to pointer conversion returning 'int' from a function with result type 'char *'}} */
|
||||
return (*pi = i, 0); /* expected-error {{incompatible integer to pointer conversion returning 'int' from a function with result type 'char *'}} */
|
||||
}
|
||||
|
||||
/* WG14 DR068: yes
|
||||
|
|
|
@ -299,10 +299,10 @@ void dr261(void) {
|
|||
/* This is an invalid initialization/assignment because the right-hand side
|
||||
* does not have pointer to void or pointer to char type and is not the null
|
||||
* pointer constant. */
|
||||
char *p2 = (42, 1 - 1); /* expected-warning {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'}}
|
||||
char *p2 = (42, 1 - 1); /* expected-error {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'}}
|
||||
expected-warning {{left operand of comma operator has no effect}}
|
||||
*/
|
||||
p1 = (42, 1 - 1); /* expected-warning {{incompatible integer to pointer conversion assigning to 'char *' from 'int'}}
|
||||
p1 = (42, 1 - 1); /* expected-error {{incompatible integer to pointer conversion assigning to 'char *' from 'int'}}
|
||||
expected-warning {{left operand of comma operator has no effect}}
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-apple-darwin -Wno-int-conversion %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
int* foo(int** a, int* b, int* c) {
|
||||
return __sync_val_compare_and_swap (a, b, c);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -emit-llvm -o - %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -triple i386-unknown-unknown -O1 -Wno-int-conversion -emit-llvm -o - %s | FileCheck %s
|
||||
// CHECK-LABEL: define{{.*}} i32 @f0
|
||||
// CHECK: ret i32 1
|
||||
// CHECK-LABEL: define{{.*}} i32 @f1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-MOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -Wno-implicit-function-declaration -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-implicit-function-declaration -target-feature +mte -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-implicit-function-declaration -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion -target-feature +mops -target-feature +mte -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-MOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion -target-feature +mops -Wno-implicit-function-declaration -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion -Wno-implicit-function-declaration -target-feature +mte -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -Wno-int-conversion -Wno-implicit-function-declaration -w -S -emit-llvm -o - %s | FileCheck --check-prefix=CHECK-NOMOPS %s
|
||||
|
||||
#include <arm_acle.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -emit-llvm < %s
|
||||
// RUN: %clang_cc1 -emit-llvm -Wno-int-conversion < %s
|
||||
|
||||
volatile unsigned char* const __attribute__((address_space(1))) serial_ctrl = 0x02;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -no-opaque-pointers -triple i386-pc-linux-gnu -ffreestanding -Wno-pointer-to-int-cast -verify -emit-llvm -o - %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -triple i386-pc-linux-gnu -ffreestanding -Wno-pointer-to-int-cast -Wno-int-conversion -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -11,10 +11,10 @@ char a2[2][5] = { "asdf" };
|
|||
|
||||
// Double-implicit-conversions of array/functions (not legal C, but
|
||||
// clang accepts it for gcc compat).
|
||||
intptr_t b = a; // expected-warning {{incompatible pointer to integer conversion}}
|
||||
intptr_t b = a;
|
||||
int c(void);
|
||||
void *d = c;
|
||||
intptr_t e = c; // expected-warning {{incompatible pointer to integer conversion}}
|
||||
intptr_t e = c;
|
||||
|
||||
int f, *g = __extension__ &f, *h = (1 != 1) ? &f : &f;
|
||||
|
||||
|
@ -59,7 +59,7 @@ struct {
|
|||
} __attribute__((__packed__)) gv1 = { .a = 0x0, .b = 7, };
|
||||
|
||||
// PR5118
|
||||
// CHECK: @gv2 ={{.*}} global %struct.anon.0 <{ i8 1, i8* null }>, align 1
|
||||
// CHECK: @gv2 ={{.*}} global %struct.anon.0 <{ i8 1, i8* null }>, align 1
|
||||
struct {
|
||||
unsigned char a;
|
||||
char *b;
|
||||
|
@ -67,9 +67,9 @@ struct {
|
|||
|
||||
// Global references
|
||||
// CHECK: @g11.l0 = internal global i32 ptrtoint (i32 ()* @g11 to i32)
|
||||
long g11(void) {
|
||||
long g11(void) {
|
||||
static long l0 = (long) g11;
|
||||
return l0;
|
||||
return l0;
|
||||
}
|
||||
|
||||
// CHECK: @g12 ={{.*}} global i32 ptrtoint (i8* @g12_tmp to i32)
|
||||
|
@ -156,7 +156,7 @@ void g29(void) {
|
|||
// CHECK: @g29.b = internal global [1 x i32] [i32 ptrtoint ([5 x i8]* @.str.1 to i32)], align 4
|
||||
// CHECK: @g29.c = internal global [1 x i32] [i32 97], align 4
|
||||
static DCC_SRVR_NM a = { {"@"} };
|
||||
static int b[1] = { "asdf" }; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char[5]'}}
|
||||
static int b[1] = { "asdf" };
|
||||
static int c[1] = { L"a" };
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -S %s -o -
|
||||
// RUN: %clang_cc1 -S -Wno-int-conversions %s -o -
|
||||
|
||||
typedef int Int;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -emit-llvm %s -o -
|
||||
// RUN: %clang_cc1 -emit-llvm -Wno-int-conversion %s -o -
|
||||
|
||||
int test(void* i)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -Wno-error=return-type %s -emit-llvm-only
|
||||
// RUN: %clang_cc1 -Wno-error=return-type -Wno-error=int-conversion %s -emit-llvm-only
|
||||
// REQUIRES: LP64
|
||||
|
||||
// Mismatched type between return and function result.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -no-opaque-pointers -triple armv7-apple-darwin -target-feature +neon %s -emit-llvm -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -Wno-int-conversion -triple armv7-apple-darwin -target-feature +neon %s -emit-llvm -o - | FileCheck %s
|
||||
|
||||
typedef struct _zend_ini_entry zend_ini_entry;
|
||||
struct _zend_ini_entry {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -no-opaque-pointers -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,NULL-INVALID
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -triple i386-unknown-unknown %s -emit-llvm -fno-delete-null-pointer-checks -o - | FileCheck %s -check-prefixes=CHECK,NULL-VALID
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -Wno-int-conversion -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,NULL-INVALID
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -Wno-int-conversion -triple i386-unknown-unknown %s -emit-llvm -fno-delete-null-pointer-checks -o - | FileCheck %s -check-prefixes=CHECK,NULL-VALID
|
||||
|
||||
int b(char* x);
|
||||
|
||||
|
@ -70,7 +70,7 @@ void test1(void) {
|
|||
int bork[4][13][15];
|
||||
// CHECK: call void @function1(i16 noundef signext 1, i32* noundef {{.*}})
|
||||
function1(1, bork);
|
||||
// CHECK: call void @function(i16 noundef signext 1, i32* noundef {{.*}})
|
||||
// CHECK: call void @function(i16 noundef signext 1, i32* noundef {{.*}})
|
||||
function(1, bork[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -Wno-objc-root-class -fblocks -o /dev/null -triple x86_64-- -emit-llvm %s
|
||||
// RUN: %clang_cc1 -Wno-objc-root-class -Wno-int-conversion -fblocks -o /dev/null -triple x86_64-- -emit-llvm %s
|
||||
// REQUIRES: asserts
|
||||
// Verify there is no assertion.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// REQUIRES: amdgpu-registered-target
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
|
||||
// RUN: %clang_cc1 -no-opaque-pointers -Wno-error=int-conversion -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
// CHECK-LABEL: @test_builtin_clz(
|
||||
// CHECK: tail call i32 @llvm.ctlz.i32(i32 %a, i1 true)
|
||||
|
|
|
@ -11,12 +11,12 @@ void f(float a) {} // expected-note{{passing argument to parameter 'a' here
|
|||
|
||||
void f2(int *aPtr, int a, float *bPtr, char c) {
|
||||
float fl = 0;
|
||||
ip(a); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with &}}
|
||||
i(aPtr); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
|
||||
ii(&a); // expected-warning{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove &}}
|
||||
ip(a); // expected-error{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'; take the address with &}}
|
||||
i(aPtr); // expected-error{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
|
||||
ii(&a); // expected-error{{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; remove &}}
|
||||
fp(*bPtr); // expected-error{{passing 'float' to parameter of incompatible type 'float *'; remove *}}
|
||||
f(bPtr); // expected-error{{passing 'float *' to parameter of incompatible type 'float'; dereference with *}}
|
||||
a = aPtr; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int *'; dereference with *}}
|
||||
a = aPtr; // expected-error{{incompatible pointer to integer conversion assigning to 'int' from 'int *'; dereference with *}}
|
||||
fl = bPtr + a; // expected-error{{assigning to 'float' from incompatible type 'float *'; dereference with *}}
|
||||
bPtr = bPtr[a]; // expected-error{{assigning to 'float *' from incompatible type 'float'; take the address with &}}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// RUN: cp %s %t
|
||||
// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -fixit %t
|
||||
// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -Werror %t
|
||||
// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -Wno-int-conversion -fixit %t
|
||||
// RUN: %clang_cc1 -x objective-c -Wundeclared-selector -Wno-int-conversion -Werror %t
|
||||
// rdar://14039037
|
||||
|
||||
@interface NSObject @end
|
||||
|
|
|
@ -57,7 +57,7 @@ void rdar11040133(void) {
|
|||
// CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' []
|
||||
// CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16
|
||||
// CHECK: +-{{.*[/\\]}}serialized-diags.c:19:6: note: 'taz' declared here []
|
||||
// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
|
||||
// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: error: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
|
||||
// CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17
|
||||
// CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: []
|
||||
// CHECK: Number FIXITs = 0
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// RUN: %clang_cc1 -ftabstop 3 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-3 -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -ftabstop 4 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-4 -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -ftabstop 5 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-5 -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -ftabstop 3 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-3 -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -ftabstop 4 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-4 -strict-whitespace %s
|
||||
// RUN: %clang_cc1 -ftabstop 5 -fsyntax-only -Wno-error=int-conversion %s 2>&1 | FileCheck -check-prefix=CHECK-5 -strict-whitespace %s
|
||||
|
||||
// tab
|
||||
void* a = 1;
|
||||
|
|
|
@ -6,7 +6,7 @@ int *test_foo(void) {
|
|||
|
||||
char *test_bar(void) {
|
||||
return bar(); // expected-error{{call to undeclared function 'bar'; ISO C99 and later do not support implicit function declarations}} \
|
||||
// expected-warning{{incompatible integer to pointer conversion}}
|
||||
// expected-error{{incompatible integer to pointer conversion}}
|
||||
}
|
||||
|
||||
#undef WANT_FOO // expected-note{{macro was #undef'd here}}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
int *A1 = (objc_string)0; // expected-warning {{aka 'NSString *'}}
|
||||
|
||||
char A2 = (objc_encode){}; // expected-error {{not a compile-time constant}} \
|
||||
expected-warning {{char[2]}}
|
||||
expected-error {{char[2]}}
|
||||
|
||||
int *A3 = (objc_protocol)0; // expected-warning {{aka 'Protocol *'}}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void test2(void) {
|
|||
}
|
||||
int test3(void) {
|
||||
int a[2];
|
||||
a[0] = test3; // expected-warning{{incompatible pointer to integer conversion assigning to 'int' from 'int (void)'}}
|
||||
a[0] = test3; // expected-error{{incompatible pointer to integer conversion assigning to 'int' from 'int (void)'}}
|
||||
return 0;
|
||||
}
|
||||
short x; void test4(char c) { x += c; }
|
||||
|
|
|
@ -11,7 +11,7 @@ int ary2[] = { x, y, z }; // expected-error{{initializer element is not a compil
|
|||
|
||||
extern int fileScopeExtern[3] = { 1, 3, 5 }; // expected-warning{{'extern' variable has an initializer}}
|
||||
|
||||
static long ary3[] = { 1, "abc", 3, 4 }; // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[4]'}}
|
||||
static long ary3[] = { 1, "abc", 3, 4 }; // expected-error{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[4]'}}
|
||||
|
||||
void func(void) {
|
||||
int x = 1;
|
||||
|
@ -24,7 +24,7 @@ void func(void) {
|
|||
|
||||
int x4 = { 1, 2 }; // expected-warning{{excess elements in scalar initializer}}
|
||||
|
||||
int y[4][3] = {
|
||||
int y[4][3] = {
|
||||
{ 1, 3, 5 },
|
||||
{ 2, 4, 6 },
|
||||
{ 3, 5, 7 },
|
||||
|
@ -34,7 +34,7 @@ void func(void) {
|
|||
1, 3, 5, 2, 4, 6, 3, 5, 7
|
||||
};
|
||||
|
||||
int y3[4][3] = {
|
||||
int y3[4][3] = {
|
||||
{ 1, 3, 5 },
|
||||
{ 2, 4, 6 },
|
||||
{ 3, 5, 7 },
|
||||
|
@ -46,27 +46,27 @@ void func(void) {
|
|||
int a,b,c;
|
||||
} z = { 1 };
|
||||
|
||||
struct threeElements *p = 7; // expected-warning{{incompatible integer to pointer conversion initializing 'struct threeElements *' with an expression of type 'int'}}
|
||||
|
||||
struct threeElements *p = 7; // expected-error{{incompatible integer to pointer conversion initializing 'struct threeElements *' with an expression of type 'int'}}
|
||||
|
||||
extern int blockScopeExtern[3] = { 1, 3, 5 }; // expected-error{{'extern' variable cannot have an initializer}}
|
||||
|
||||
|
||||
static long x2[3] = { 1.0,
|
||||
"abc", // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[4]'}}
|
||||
"abc", // expected-error{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[4]'}}
|
||||
5.8 }; // expected-warning {{implicit conversion from 'double' to 'long' changes value from 5.8 to 5}}
|
||||
}
|
||||
|
||||
void test(void) {
|
||||
int y1[3] = {
|
||||
int y1[3] = {
|
||||
{ 1, 2, 3 } // expected-warning{{excess elements in scalar initializer}}
|
||||
};
|
||||
int y3[4][3] = {
|
||||
int y3[4][3] = {
|
||||
{ 1, 3, 5 },
|
||||
{ 2, 4, 6 },
|
||||
{ 3, 5, 7 },
|
||||
{ 4, 6, 8 },
|
||||
{ }, // expected-warning{{use of GNU empty initializer extension}} expected-warning{{excess elements in array initializer}}
|
||||
};
|
||||
int y4[4][3] = {
|
||||
int y4[4][3] = {
|
||||
{ 1, 3, 5, 2 }, // expected-warning{{excess elements in array initializer}}
|
||||
{ 4, 6 },
|
||||
{ 3, 5, 7 },
|
||||
|
@ -86,13 +86,13 @@ void allLegalAndSynonymous(void) {
|
|||
{ 4, 5, 6 }
|
||||
};
|
||||
short q3[4][3][2] = {
|
||||
{
|
||||
{
|
||||
{ 1 },
|
||||
},
|
||||
{
|
||||
{
|
||||
{ 2, 3 },
|
||||
},
|
||||
{
|
||||
{
|
||||
{ 4, 5 },
|
||||
{ 6 },
|
||||
},
|
||||
|
@ -109,8 +109,8 @@ void legal(void) {
|
|||
}
|
||||
|
||||
unsigned char asso_values[] = { 34 };
|
||||
int legal2(void) {
|
||||
return asso_values[0];
|
||||
int legal2(void) {
|
||||
return asso_values[0];
|
||||
}
|
||||
|
||||
void illegal(void) {
|
||||
|
@ -120,13 +120,13 @@ void illegal(void) {
|
|||
{ 4, 5, 6 }
|
||||
};
|
||||
short q3[4][3][] = { // expected-error{{array has incomplete element type 'short[]'}}
|
||||
{
|
||||
{
|
||||
{ 1 },
|
||||
},
|
||||
{
|
||||
{
|
||||
{ 2, 3 },
|
||||
},
|
||||
{
|
||||
{
|
||||
{ 4, 5 },
|
||||
{ 6 },
|
||||
},
|
||||
|
@ -167,11 +167,11 @@ void charArrays(void) {
|
|||
|
||||
char c[] = { "Hello" };
|
||||
int l[sizeof(c) == 6 ? 1 : -1];
|
||||
|
||||
int i[] = { "Hello "}; // expected-warning{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char[7]'}}
|
||||
|
||||
int i[] = { "Hello "}; // expected-error{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char[7]'}}
|
||||
char c2[] = { "Hello", "Good bye" }; //expected-warning{{excess elements in char array initializer}}
|
||||
|
||||
int i2[1] = { "Hello" }; //expected-warning{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char[6]'}}
|
||||
int i2[1] = { "Hello" }; //expected-error{{incompatible pointer to integer conversion initializing 'int' with an expression of type 'char[6]'}}
|
||||
char c3[5] = { "Hello" };
|
||||
char c4[4] = { "Hello" }; //expected-warning{{initializer-string for char array is too long}}
|
||||
|
||||
|
@ -204,14 +204,14 @@ void autoStructTest(void) {
|
|||
struct s1 {char a; char b;} t1;
|
||||
struct s2 {struct s1 c;} t2 = { t1 };
|
||||
// The following is a less than great diagnostic (though it's on par with EDG).
|
||||
struct s1 t3[] = {t1, t1, "abc", 0}; //expected-warning{{incompatible pointer to integer conversion initializing 'char' with an expression of type 'char[4]'}}
|
||||
struct s1 t3[] = {t1, t1, "abc", 0}; //expected-error{{incompatible pointer to integer conversion initializing 'char' with an expression of type 'char[4]'}}
|
||||
int t4[sizeof t3 == 6 ? 1 : -1];
|
||||
}
|
||||
struct foo { int z; } w;
|
||||
int bar (void) {
|
||||
int bar (void) {
|
||||
struct foo z = { w }; //expected-error{{initializing 'int' with an expression of incompatible type 'struct foo'}}
|
||||
return z.z;
|
||||
}
|
||||
return z.z;
|
||||
}
|
||||
struct s3 {void (*a)(void);} t5 = {autoStructTest};
|
||||
struct {int a; int b[];} t6 = {1, {1, 2, 3}}; // expected-warning{{flexible array initialization is a GNU extension}} \
|
||||
// expected-note{{initialized flexible array member 'b' is here}}
|
||||
|
@ -273,7 +273,7 @@ void test_matrix(void) {
|
|||
1.0f, 2.0f, 3.0f, 4.0f,
|
||||
5.0f, 6.0f, 7.0f, 8.0f,
|
||||
9.0f, 10.0f, 11.0f, 12.0f,
|
||||
13.0f, 14.0f, 15.0f, 16.0f
|
||||
13.0f, 14.0f, 15.0f, 16.0f
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -160,16 +160,16 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
|
|||
__atomic_load(CI, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
|
||||
|
||||
__c11_atomic_store(i, 1, memory_order_seq_cst);
|
||||
__c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
|
||||
__c11_atomic_store(p, 1, memory_order_seq_cst); // expected-error {{incompatible integer to pointer conversion}}
|
||||
(int)__c11_atomic_store(f, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
|
||||
|
||||
__atomic_store_n(I, 4, memory_order_release);
|
||||
__atomic_store_n(I, 4.0, memory_order_release);
|
||||
__atomic_store_n(CI, 4, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
|
||||
__atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
|
||||
__atomic_store_n(I, P, memory_order_release); // expected-error {{parameter of type 'int'}}
|
||||
__atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
|
||||
__atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
|
||||
__atomic_store_n(I, I, memory_order_release); // expected-warning {{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
|
||||
__atomic_store_n(I, I, memory_order_release); // expected-error {{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
|
||||
|
||||
__atomic_store(I, *P, memory_order_release);
|
||||
__atomic_store(CI, I, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
|
||||
|
@ -225,11 +225,11 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
|
|||
|
||||
_Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
|
||||
_Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
|
||||
_Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
|
||||
_Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{passing 'int **' to parameter of type 'int'}}
|
||||
(void)__atomic_compare_exchange_n(CI, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
|
||||
(void)__atomic_compare_exchange_n(I, CI, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
|
||||
|
||||
_Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
|
||||
_Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{passing 'int' to parameter of type 'int *'}}
|
||||
_Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
|
||||
_Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
|
||||
(void)__atomic_compare_exchange(CI, I, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
|
||||
|
@ -253,7 +253,7 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
|
|||
// Ensure the <stdatomic.h> macros behave appropriately.
|
||||
atomic_int n = ATOMIC_VAR_INIT(123);
|
||||
atomic_init(&n, 456);
|
||||
atomic_init(&n, (void*)0); // expected-warning {{passing 'void *' to parameter of type 'int'}}
|
||||
atomic_init(&n, (void*)0); // expected-error {{passing 'void *' to parameter of type 'int'}}
|
||||
|
||||
const atomic_wchar_t cawt;
|
||||
atomic_init(&cawt, L'x'); // expected-error {{non-const}}
|
||||
|
@ -275,7 +275,7 @@ void f(_Atomic(int) *i, const _Atomic(int) *ci,
|
|||
k = atomic_exchange(&n, 72);
|
||||
k = atomic_exchange_explicit(&n, k, memory_order_release);
|
||||
|
||||
atomic_compare_exchange_strong(&n, k, k); // expected-warning {{take the address with &}}
|
||||
atomic_compare_exchange_strong(&n, k, k); // expected-error {{take the address with &}}
|
||||
atomic_compare_exchange_weak(&n, &k, k);
|
||||
atomic_compare_exchange_strong_explicit(&n, &k, k, memory_order_seq_cst); // expected-error {{too few arguments}}
|
||||
atomic_compare_exchange_weak_explicit(&n, &k, k, memory_order_seq_cst, memory_order_acquire);
|
||||
|
|
|
@ -98,7 +98,7 @@ bptr foo5(int j) {
|
|||
}
|
||||
|
||||
int (*funcptr3[5])(long);
|
||||
int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
|
||||
int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-error {{incompatible pointer to integer conversion}}
|
||||
int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}}
|
||||
// expected-warning@-1 {{a function declaration without a prototype is deprecated in all versions of C}}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ void test2(int a) {
|
|||
}
|
||||
|
||||
void test3(unsigned *b) {
|
||||
__builtin_alloca_with_align(b, 32); // expected-warning {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
|
||||
__builtin_alloca_with_align(b, 32); // expected-error {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
|
||||
}
|
||||
|
||||
void test4(int a) {
|
||||
|
|
|
@ -25,7 +25,7 @@ int test4(int *a) {
|
|||
}
|
||||
|
||||
int test5(int *a, unsigned *b) {
|
||||
a = __builtin_assume_aligned(a, 32, b); // expected-warning {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
|
||||
a = __builtin_assume_aligned(a, 32, b); // expected-error {{incompatible pointer to integer conversion passing 'unsigned int *' to parameter of type}}
|
||||
return a[0];
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ void invalid_uses(void) {
|
|||
__builtin_dump_struct(&a, 2); // expected-error {{expected a callable expression as 2nd argument to '__builtin_dump_struct', found 'int'}}
|
||||
__builtin_dump_struct(b, goodfunc); // expected-error {{expected pointer to struct as 1st argument to '__builtin_dump_struct', found 'void *'}}
|
||||
__builtin_dump_struct(&a, badfunc1); // expected-error {{too many arguments to function call, expected 1, have 2}} expected-note {{in call to printing function with arguments '("%s", "struct A")'}}
|
||||
__builtin_dump_struct(&a, badfunc2); // expected-warning-re 1+{{incompatible pointer to integer conversion passing 'char[{{.*}}]' to parameter of type 'int'}}
|
||||
__builtin_dump_struct(&a, badfunc2); // expected-error-re 1+{{incompatible pointer to integer conversion passing 'char[{{.*}}]' to parameter of type 'int'}}
|
||||
// expected-note@-1 1+{{in call to printing function with arguments '("}}
|
||||
__builtin_dump_struct(&a, badfunc3); // expected-error {{too many arguments to function call, expected 0, have 2}} expected-note {{in call to printing function with arguments '("%s", "struct A")'}}
|
||||
__builtin_dump_struct(a, goodfunc); // expected-error {{expected pointer to struct as 1st argument to '__builtin_dump_struct', found 'struct A'}}
|
||||
|
|
|
@ -33,7 +33,7 @@ unsigned invalid2(const int *arg) {
|
|||
}
|
||||
|
||||
void *invalid3(struct s *arg) {
|
||||
return __builtin_preserve_field_info(arg->a, 1); // expected-warning {{incompatible integer to pointer conversion returning 'unsigned int' from a function with result type 'void *'}}
|
||||
return __builtin_preserve_field_info(arg->a, 1); // expected-error {{incompatible integer to pointer conversion returning 'unsigned int' from a function with result type 'void *'}}
|
||||
}
|
||||
|
||||
unsigned valid4(struct s *arg) {
|
||||
|
|
|
@ -28,7 +28,7 @@ void test7(void) {
|
|||
const void *X;
|
||||
X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
|
||||
X = CFSTR("\0"); // no-warning
|
||||
X = CFSTR(242); // expected-error {{CFString literal is not a string constant}} expected-warning {{incompatible integer to pointer conversion}}
|
||||
X = CFSTR(242); // expected-error {{CFString literal is not a string constant}} expected-error {{incompatible integer to pointer conversion}}
|
||||
X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
|
||||
}
|
||||
|
||||
|
@ -201,8 +201,8 @@ void test18(void) {
|
|||
result = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst));
|
||||
|
||||
ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src)); // expected-error {{too few arguments to function call}}
|
||||
ptr = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
|
||||
ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
|
||||
ptr = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-error {{incompatible integer to pointer conversion}}
|
||||
ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-error {{incompatible integer to pointer conversion}}
|
||||
}
|
||||
|
||||
void no_ms_builtins(void) {
|
||||
|
|
|
@ -11,7 +11,7 @@ static int *p = (int []){2,4};
|
|||
static int x = (int){1};
|
||||
|
||||
static int *p2 = (int []){2,x}; // expected-error {{initializer element is not a compile-time constant}}
|
||||
static long *p3 = (long []){2,"x"}; // expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[2]'}}
|
||||
static long *p3 = (long []){2,"x"}; // expected-error {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char[2]'}}
|
||||
|
||||
typedef struct { } cache_t; // expected-warning{{empty struct is a GNU extension}}
|
||||
static cache_t clo_I1_cache = ((cache_t) { } ); // expected-warning{{use of GNU empty initializer extension}}
|
||||
|
|
|
@ -90,7 +90,7 @@ extern int f1(void);
|
|||
|
||||
int f0(int a) {
|
||||
// GCC considers this a warning.
|
||||
return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-warning {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
|
||||
return a ? f1() : nil; // expected-warning {{pointer/integer type mismatch in conditional expression ('int' and 'void *')}} expected-error {{incompatible pointer to integer conversion returning 'void *' from a function with result type 'int'}}
|
||||
}
|
||||
|
||||
int f2(int x) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_cc1 -triple %itanium_abi_triple %s -fsyntax-only -verify -pedantic
|
||||
enum e {A,
|
||||
enum e {A,
|
||||
B = 42LL << 32, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
|
||||
C = -4, D = 12456 };
|
||||
|
||||
|
@ -11,7 +11,7 @@ enum g { // too negative
|
|||
enum h { e = -2147483648, // too pos
|
||||
f = 2147483648, // expected-warning {{ISO C restricts enumerator values to range of 'int'}}
|
||||
i = 0xFFFF0000 // expected-warning {{too large}}
|
||||
};
|
||||
};
|
||||
|
||||
// minll maxull
|
||||
enum x // expected-warning {{enumeration values exceed range of largest integer}}
|
||||
|
@ -91,7 +91,7 @@ static enum e1 badfunc(struct s1 *q) {
|
|||
typedef enum {
|
||||
an_enumerator = 20
|
||||
} an_enum;
|
||||
char * s = (an_enum) an_enumerator; // expected-warning {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'an_enum'}}
|
||||
char * s = (an_enum) an_enumerator; // expected-error {{incompatible integer to pointer conversion initializing 'char *' with an expression of type 'an_enum'}}
|
||||
|
||||
// PR4515
|
||||
enum PR4515 {PR4515a=1u,PR4515b=(PR4515a-2)/2};
|
||||
|
|
|
@ -14,10 +14,10 @@ int PR10013(void) {
|
|||
int *PR10013_x = 0;
|
||||
{
|
||||
extern int PR10013_x;
|
||||
extern int PR10013_x;
|
||||
extern int PR10013_x;
|
||||
}
|
||||
|
||||
return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
|
||||
|
||||
return PR10013_x; // expected-error{{incompatible pointer to integer conversion}}
|
||||
}
|
||||
|
||||
static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
|
||||
|
|
|
@ -64,11 +64,11 @@ void check_string_literal( FILE* fp, const char* s, char *buf, ... ) {
|
|||
printf("abc\
|
||||
def"
|
||||
"%*d", 1, 1); // no-warning
|
||||
|
||||
|
||||
// <rdar://problem/6079850>, allow 'unsigned' (instead of 'int') to be used for both
|
||||
// the field width and precision. This deviates from C99, but is reasonably safe
|
||||
// and is also accepted by GCC.
|
||||
printf("%*d", (unsigned) 1, 1); // no-warning
|
||||
printf("%*d", (unsigned) 1, 1); // no-warning
|
||||
}
|
||||
|
||||
// When calling a non-variadic format function (vprintf, vscanf, NSLogv, ...),
|
||||
|
@ -218,7 +218,7 @@ void check_empty_format_string(char* buf, ...)
|
|||
va_start(ap,buf);
|
||||
vprintf("",ap); // expected-warning {{format string is empty}}
|
||||
sprintf(buf, "", 1); // expected-warning {{format string is empty}}
|
||||
|
||||
|
||||
// Don't warn about empty format strings when there are no data arguments.
|
||||
// This can arise from macro expansions and non-standard format string
|
||||
// functions.
|
||||
|
@ -254,7 +254,7 @@ void test_constant_bindings(void) {
|
|||
const char *s3 = "hello";
|
||||
char * const s4 = "hello";
|
||||
extern const char s5[];
|
||||
|
||||
|
||||
printf(s1); // no-warning
|
||||
printf(s2); // no-warning
|
||||
printf(s3); // expected-warning{{not a string literal}}
|
||||
|
@ -279,7 +279,7 @@ void test9(char *P) {
|
|||
|
||||
void torture(va_list v8) {
|
||||
vprintf ("%*.*d", v8); // no-warning
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test10(int x, float f, int i, long long lli) {
|
||||
|
@ -344,7 +344,7 @@ void test12(char *b) {
|
|||
unsigned char buf[4];
|
||||
printf ("%.4s\n", buf); // no-warning
|
||||
printf ("%.4s\n", &buf); // expected-warning{{format specifies type 'char *' but the argument has type 'unsigned char (*)[4]'}}
|
||||
|
||||
|
||||
// Verify that we are checking asprintf
|
||||
asprintf(&b, "%d", "asprintf"); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}}
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ void rdar8269537(void) {
|
|||
extern void rdar8332221_vprintf_scanf(const char *, va_list, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 1, 0)))
|
||||
__attribute__((__format__(__scanf__, 3, 4)));
|
||||
|
||||
|
||||
void rdar8332221(va_list ap, int *x, long *y) {
|
||||
rdar8332221_vprintf_scanf("%", ap, "%d", x); // expected-warning{{incomplete format specifier}}
|
||||
}
|
||||
|
@ -790,7 +790,7 @@ void test_char_pointer_arithmetic(int b) {
|
|||
|
||||
void PR30481(void) {
|
||||
// This caused crashes due to invalid casts.
|
||||
printf(1 > 0); // expected-warning{{format string is not a string literal}} expected-warning{{incompatible integer to pointer conversion}} expected-note@format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}}
|
||||
printf(1 > 0); // expected-warning{{format string is not a string literal}} expected-error{{incompatible integer to pointer conversion}} expected-note@format-strings.c:*{{passing argument to parameter here}} expected-note{{to avoid this}}
|
||||
}
|
||||
|
||||
void test_printf_opaque_ptr(void *op) {
|
||||
|
|
|
@ -96,7 +96,7 @@ enum e { e1, e2 };
|
|||
|
||||
// GNU extension: prototypes and K&R function definitions
|
||||
int isroot(short x, // expected-note{{previous declaration is here}}
|
||||
enum e);
|
||||
enum e);
|
||||
|
||||
int isroot(x, y)
|
||||
short x; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
|
||||
|
@ -121,11 +121,11 @@ a x;
|
|||
a2 x2; // expected-note{{passing argument to parameter here}}
|
||||
void test_x(void) {
|
||||
x(5);
|
||||
x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
|
||||
x2(5); // expected-error{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
|
||||
}
|
||||
|
||||
enum e0 {one};
|
||||
void f3();
|
||||
enum e0 {one};
|
||||
void f3();
|
||||
void f3(enum e0 x) {}
|
||||
|
||||
enum incomplete_enum;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// RUN: %clang_cc1 %s -fsyntax-only -verify -verify=c2x -pedantic -Wno-strict-prototypes
|
||||
|
||||
// PR1892, PR11354
|
||||
void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
|
||||
void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-error {{(aka 'double (*restrict)[5]')}}
|
||||
|
||||
int foo (__const char *__path);
|
||||
int foo(__const char *__restrict __file);
|
||||
|
|
|
@ -92,7 +92,7 @@ int chooseexpr[__builtin_choose_expr(1, 1, expr)];
|
|||
int realop[(__real__ 4) == 4 ? 1 : -1];
|
||||
int imagop[(__imag__ 4) == 0 ? 1 : -1];
|
||||
|
||||
int *PR14729 = 0 ?: 1/0; // expected-error {{not a compile-time constant}} expected-warning 3{{}}
|
||||
int *PR14729 = 0 ?: 1/0; // expected-error {{not a compile-time constant}} expected-warning 2{{}} expected-error {{incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'}}
|
||||
|
||||
int bcp_call_v;
|
||||
int bcp_call_a[] = {__builtin_constant_p(bcp_call_v && 0) ? bcp_call_v && 0 : -1};
|
||||
|
|
|
@ -6,6 +6,6 @@ int a(struct c x, long long y) {
|
|||
goto *l1_ptr;
|
||||
l1:
|
||||
goto *x; // expected-error{{incompatible type}}
|
||||
goto *y; // expected-warning{{incompatible integer to pointer conversion}}
|
||||
goto *y; // expected-error{{incompatible integer to pointer conversion}}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,13 +73,13 @@ void column_major_load(float *p1, int *p2, _Bool *p3, struct Foo *p4) {
|
|||
10, // expected-error {{1st argument must be a pointer to a valid matrix element type}}
|
||||
1ull << 21, // expected-error {{row dimension is outside the allowed range [1, 1048575]}}
|
||||
1ull << 21, // expected-error {{column dimension is outside the allowed range [1, 1048575]}}
|
||||
""); // expected-warning {{incompatible pointer to integer conversion casting 'char[1]' to type 'unsigned long'}}
|
||||
""); // expected-error {{incompatible pointer to integer conversion casting 'char[1]' to type 'unsigned long'}}
|
||||
|
||||
sx5x10_t a13 = __builtin_matrix_column_major_load(
|
||||
10, // expected-error {{1st argument must be a pointer to a valid matrix element type}}
|
||||
*p4, // expected-error {{casting 'struct Foo' to incompatible type 'unsigned long'}}
|
||||
"", // expected-error {{column argument must be a constant unsigned integer expression}}
|
||||
// expected-warning@-1 {{incompatible pointer to integer conversion casting 'char[1]' to type 'unsigned long'}}
|
||||
// expected-error@-1 {{incompatible pointer to integer conversion casting 'char[1]' to type 'unsigned long'}}
|
||||
10);
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ void arrays(int ints[_Nonnull],
|
|||
int vla[_Nonnull GLOBAL_LENGTH],
|
||||
void ** _Nullable reference);
|
||||
void testDecayedType(void) {
|
||||
int produceAnErrorMessage = arrays; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'void (int * _Nonnull, void ** _Nullable, void *** _Nullable, void * _Null_unspecified * _Nonnull * _Nullable, int * _Nonnull, int * _Nonnull, int * _Nonnull, int * _Nonnull, int * _Nonnull, void ** _Nullable)'}}
|
||||
int produceAnErrorMessage = arrays; // expected-error {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'void (int * _Nonnull, void ** _Nullable, void *** _Nullable, void * _Null_unspecified * _Nonnull * _Nullable, int * _Nonnull, int * _Nonnull, int * _Nonnull, int * _Nonnull, int * _Nonnull, void ** _Nullable)'}}
|
||||
}
|
||||
|
||||
int notInFunction[_Nullable 3]; // expected-error {{nullability specifier '_Nullable' cannot be applied to non-pointer type 'int[3]'}}
|
||||
|
|
|
@ -17,10 +17,10 @@ void test(void) {
|
|||
id obj = [Test alloc];
|
||||
struct S sInst;
|
||||
|
||||
charStarFunc(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'char *'}}
|
||||
charFunc("abc"); // expected-warning {{incompatible pointer to integer conversion passing 'char[4]' to parameter of type 'char'}}
|
||||
charStarFunc(1); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'char *'}}
|
||||
charFunc("abc"); // expected-error {{incompatible pointer to integer conversion passing 'char[4]' to parameter of type 'char'}}
|
||||
|
||||
[obj charStarMeth:1]; // expected-warning {{incompatible integer to pointer conversion sending 'int'}}
|
||||
[obj charStarMeth:1]; // expected-error {{incompatible integer to pointer conversion sending 'int'}}
|
||||
[obj structMeth:1]; // expected-error {{sending 'int'}}
|
||||
[obj structMeth:sInst :1]; // expected-error {{sending 'int'}}
|
||||
}
|
||||
|
|
|
@ -21,24 +21,25 @@ int main(void)
|
|||
int i = 0;
|
||||
int *j = nil;
|
||||
|
||||
/* These should all generate warnings. */
|
||||
/* The incompatible pointer types should all generate warnings, while the
|
||||
incompatible integer to/from pointer conversions default to an error. */
|
||||
|
||||
obj = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
|
||||
obj = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
|
||||
obj = j; // expected-warning {{incompatible pointer types assigning to 'id' from 'int *'}}
|
||||
|
||||
obj_p = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
|
||||
obj_p = i; // expected-error {{incompatible integer to pointer conversion assigning to 'id<MyProtocol>' from 'int'}}
|
||||
obj_p = j; // expected-warning {{incompatible pointer types assigning to 'id<MyProtocol>' from 'int *'}}
|
||||
|
||||
obj_c = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
|
||||
obj_c = i; // expected-error {{incompatible integer to pointer conversion assigning to 'MyClass *' from 'int'}}
|
||||
obj_c = j; // expected-warning {{incompatible pointer types assigning to 'MyClass *' from 'int *'}}
|
||||
|
||||
obj_C = i; // expected-warning {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
|
||||
obj_C = i; // expected-error {{incompatible integer to pointer conversion assigning to 'Class' from 'int'}}
|
||||
obj_C = j; // expected-warning {{incompatible pointer types assigning to 'Class' from 'int *'}}
|
||||
|
||||
i = obj; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id'}}
|
||||
i = obj_p; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'id<MyProtocol>'}}
|
||||
i = obj_c; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}}
|
||||
i = obj_C; // expected-warning {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
|
||||
i = obj; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id'}}
|
||||
i = obj_p; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'id<MyProtocol>'}}
|
||||
i = obj_c; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'MyClass *'}}
|
||||
i = obj_C; // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'Class'}}
|
||||
|
||||
j = obj; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id'}}
|
||||
j = obj_p; // expected-warning {{incompatible pointer types assigning to 'int *' from 'id<MyProtocol>'}}
|
||||
|
|
|
@ -30,11 +30,11 @@
|
|||
{
|
||||
return index; // expected-error {{call to undeclared library function 'index'}} \
|
||||
// expected-note {{include the header <strings.h> or explicitly provide a declaration for 'index'}} \
|
||||
// expected-warning {{incompatible pointer to integer conversion returning}}
|
||||
// expected-error {{incompatible pointer to integer conversion returning}}
|
||||
}
|
||||
+ (int) ClassMethod
|
||||
{
|
||||
return index; // expected-warning {{incompatible pointer to integer conversion returning}}
|
||||
return index; // expected-error {{incompatible pointer to integer conversion returning}}
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ struct S { int X; } S;
|
|||
int test5(int X) {
|
||||
int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \
|
||||
expected-warning {{method '-somemsg' not found}} \
|
||||
expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
|
||||
expected-error {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
|
||||
int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@ typedef struct objc_class *Class;
|
|||
@end
|
||||
|
||||
void f0(A *a) { int x = [[a foo] baz]; } // expected-warning {{method '+baz' not found (return type defaults to 'id')}} \
|
||||
// expected-warning {{ncompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
|
||||
// expected-error {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
|
||||
|
|
|
@ -301,5 +301,5 @@ void test(ArraysInMethods *obj) {
|
|||
@end
|
||||
|
||||
void testMessageSendResultType(C0 * _Nullable c0) {
|
||||
int *p = [c0 count]; // expected-warning {{incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'}}
|
||||
int *p = [c0 count]; // expected-error {{incompatible integer to pointer conversion initializing 'int *' with an expression of type 'int'}}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(void) {
|
|||
NSMutableDictionary *dict;
|
||||
id key, val;
|
||||
val = dict[key]; // expected-error {{method for accessing dictionary element must have Objective-C object return type instead of 'int'}} \
|
||||
// expected-warning {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
|
||||
// expected-error {{incompatible integer to pointer conversion assigning to 'id' from 'int'}}
|
||||
dict[key] = val; // expected-error {{method object parameter type 'int' is not object type}}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ void test(void) {
|
|||
NSNumber *n6 = '1'; // expected-error{{numeric literal must be prefixed by '@'}}
|
||||
|
||||
int i;
|
||||
NSNumber *n7 = i; // c-warning{{incompatible integer to pointer conversion}}
|
||||
NSNumber *n7 = i; // c-error{{incompatible integer to pointer conversion}}
|
||||
// arc-error@-1{{implicit conversion of 'int' to 'NSNumber *' is disallowed with ARC}}
|
||||
// cxx-error@-2{{cannot initialize a variable of type 'NSNumber *' with an lvalue of type 'int'}}
|
||||
|
||||
id n8 = 1; // c-warning{{incompatible integer to pointer conversion}}
|
||||
id n8 = 1; // c-error{{incompatible integer to pointer conversion}}
|
||||
// arc-error@-1{{implicit conversion of 'int' to 'id' is disallowed with ARC}}
|
||||
// cxx-error@-2{{cannot initialize a variable of type 'id' with an rvalue of type 'int'}}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,7 @@ void t1(void) {
|
|||
b = 2.1; // expected-warning {{implicit conversion from constant value 2.1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
|
||||
|
||||
b = YES;
|
||||
#ifndef __cplusplus
|
||||
b = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
|
||||
#endif
|
||||
b = ptr; // expected-error {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
|
||||
}
|
||||
|
||||
@interface BoolProp
|
||||
|
@ -41,9 +39,7 @@ void t2(BoolProp *bp) {
|
|||
bp.p = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}}
|
||||
bp.p = b;
|
||||
bp.p = bp.p;
|
||||
#ifndef __cplusplus
|
||||
bp.p = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
|
||||
#endif
|
||||
bp.p = ptr; // expected-error {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}}
|
||||
bp.p = 1;
|
||||
bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void f(atomic_int *i, const atomic_int *ci,
|
|||
__opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group);
|
||||
|
||||
__opencl_atomic_init(&gn, 456);
|
||||
__opencl_atomic_init(&gn, (void*)0); // expected-warning{{incompatible pointer to integer conversion passing '__generic void *' to parameter of type 'int'}}
|
||||
__opencl_atomic_init(&gn, (void*)0); // expected-error{{incompatible pointer to integer conversion passing '__generic void *' to parameter of type 'int'}}
|
||||
}
|
||||
|
||||
void memory_checks(atomic_int *Ap, int *p, int val) {
|
||||
|
|
|
@ -146,7 +146,7 @@ void test_fence() {
|
|||
__builtin_amdgcn_fence(4); // expected-error {{too few arguments to function call, expected 2}}
|
||||
__builtin_amdgcn_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
|
||||
__builtin_amdgcn_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
|
||||
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
const char ptr[] = "workgroup";
|
||||
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void test_atomic_inc32() {
|
|||
val = __builtin_amdgcn_atomic_inc32(4); // expected-error {{too few arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_inc32(&val, val, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_inc32(&val, val, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
|
||||
val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
const char ptr[] = "workgroup";
|
||||
val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
|
||||
int signedVal = 15;
|
||||
|
@ -179,7 +179,7 @@ void test_atomic_inc64() {
|
|||
val = __builtin_amdgcn_atomic_inc64(4); // expected-error {{too few arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_inc64(&val, val, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_inc64(&val, val, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
|
||||
val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
const char ptr[] = "workgroup";
|
||||
val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
|
||||
__INT64_TYPE__ signedVal = 15;
|
||||
|
@ -194,7 +194,7 @@ void test_atomic_dec32() {
|
|||
val = __builtin_amdgcn_atomic_dec32(4); // expected-error {{too few arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_dec32(&val, val, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_dec32(&val, val, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
|
||||
val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
const char ptr[] = "workgroup";
|
||||
val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
|
||||
int signedVal = 15;
|
||||
|
@ -209,7 +209,7 @@ void test_atomic_dec64() {
|
|||
val = __builtin_amdgcn_atomic_dec64(4); // expected-error {{too few arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_dec64(&val, val, 4, 4, 4, 4); // expected-error {{too many arguments to function call, expected 4}}
|
||||
val = __builtin_amdgcn_atomic_dec64(&val, val, 3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
|
||||
val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE, 5); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
|
||||
const char ptr[] = "workgroup";
|
||||
val = __builtin_amdgcn_atomic_dec64(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
|
||||
__INT64_TYPE__ signedVal = 15;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
void foo(char **c) {
|
||||
*c = __FILE__;
|
||||
int x = c; // produce a diagnostic
|
||||
const char **x = c; // produce a diagnostic
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
// Diagnostics:
|
||||
|
||||
// RUN: %clang_cc1 -I %t -ivfsoverlay %t.external.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG-EXTERNAL %s
|
||||
// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{..?}}external-names.h:{{[0-9]*:[0-9]*}}: warning: incompatible pointer
|
||||
// CHECK-DIAG-EXTERNAL: {{.*}}Inputs{{..?}}external-names.h:{{[0-9]*:[0-9]*}}: warning: initializing 'const char **'
|
||||
|
||||
// RUN: %clang_cc1 -I %t -ivfsoverlay %t.yaml -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-DIAG %s
|
||||
// CHECK-DIAG-NOT: Inputs
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -o %t && %run %t
|
||||
// RUN: %clang_dfsan %s -DPROP_OFFSET_LABELS -o %t && %run %t
|
||||
// RUN: %clang_dfsan %s -mllvm -dfsan-combine-offset-labels-on-gep=false -Wno-error=int-conversion -o %t && %run %t
|
||||
// RUN: %clang_dfsan %s -DPROP_OFFSET_LABELS -Wno-error=int-conversion -o %t && %run %t
|
||||
//
|
||||
// REQUIRES: x86_64-target-arch
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// RUN: %clang_dfsan -DUSE_SIGNAL_ACTION %s -o %t && %run %t
|
||||
// RUN: %clang_dfsan %s -o %t && %run %t
|
||||
// RUN: %clang_dfsan -DUSE_SIGNAL_ACTION -Wno-error=int-conversion %s -o %t && %run %t
|
||||
// RUN: %clang_dfsan -Wno-error=int-conversion %s -o %t && %run %t
|
||||
//
|
||||
// REQUIRES: x86_64-target-arch
|
||||
|
||||
|
|
Loading…
Reference in New Issue