mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 11:36:09 +00:00

VerifyDiagnosticConsumer previously would not check that the diagnostic and its matching directive referenced the same source file. Common practice was to create directives that referenced other files but only by line number, and this led to problems such as when the file containing the directive didn't have enough lines to match the location of the diagnostic in the other file, leading to bizarre file formatting and other oddities. This patch causes VerifyDiagnosticConsumer to match source files as well as line numbers. Therefore, a new syntax is made available for directives, for example: // expected-error@file:line {{diagnostic message}} This extends the @line feature where "file" is the file where the diagnostic is generated. The @line syntax is still available and uses the current file for the diagnostic. "file" can be specified either as a relative or absolute path - although the latter has less usefulness, I think! The #include search paths will be used to locate the file and if it is not found an error will be generated. The new check is not optional: if the directive is in a different file to the diagnostic, the file must be specified. Therefore, a number of test-cases have been updated with regard to this. This closes out PR15613. llvm-svn: 179677
28 lines
819 B
C
28 lines
819 B
C
// Test this without pch.
|
|
// RUN: %clang_cc1 -include %S/functions.h -fsyntax-only -verify %s
|
|
|
|
// Test with pch.
|
|
// RUN: %clang_cc1 -emit-pch -o %t %S/functions.h
|
|
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
|
|
|
|
int f0(int x0, int y0, ...) { return x0 + y0; }
|
|
|
|
float *test_f1(int val, double x, double y) {
|
|
if (val > 5)
|
|
return f1(x, y);
|
|
else
|
|
return f1(x); // expected-error{{too few arguments to function call}}
|
|
// expected-note@functions.h:7{{'f1' declared here}}
|
|
}
|
|
|
|
void test_g0(int *x, float * y) {
|
|
g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}}
|
|
// expected-note@functions.h:9{{passing argument to parameter here}}
|
|
g0(x);
|
|
}
|
|
|
|
void __attribute__((noreturn)) test_abort(int code) {
|
|
do_abort(code);
|
|
}
|
|
|