diff options
Diffstat (limited to 'clang/test')
24 files changed, 196 insertions, 48 deletions
diff --git a/clang/test/Frontend/verify-directive.h b/clang/test/Frontend/verify-directive.h new file mode 100644 index 00000000000..cb405869b05 --- /dev/null +++ b/clang/test/Frontend/verify-directive.h @@ -0,0 +1,2 @@ +// Check that directives inside includes are included! +// expected-error@1 {{include file test}} diff --git a/clang/test/Frontend/verify-fatal.c b/clang/test/Frontend/verify-fatal.c new file mode 100644 index 00000000000..0e74032a3af --- /dev/null +++ b/clang/test/Frontend/verify-fatal.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -Wfatal-errors -verify %s 2>&1 | FileCheck %s + +#error first fatal +// expected-error@-1 {{first fatal}} + +#error second fatal +// expected-error@-1 {{second fatal}} + + +// CHECK: error: 'error' diagnostics expected but not seen: +// CHECK-NEXT: Line 6 (directive at {{.*}}verify-fatal.c:7): second fatal +// CHECK-NEXT: 1 error generated. diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c new file mode 100644 index 00000000000..59a441dc446 --- /dev/null +++ b/clang/test/Frontend/verify.c @@ -0,0 +1,110 @@ +// RUN: %clang_cc1 -DTEST1 -verify %s +// RUN: %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s +// RUN: %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s +// RUN: %clang_cc1 -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s +// RUN: %clang_cc1 -DTEST5 -verify %s 2>&1 | FileCheck -check-prefix=CHECK5 %s + +// expected-warning@ malformed +// expected-error@7 1 {{missing or invalid line number}} + +// expected-warning@0 malformed +// expected-error@10 {{missing or invalid line number}} + +// expected-warning@-50 malformed +// expected-error@13 {{missing or invalid line number}} + +// expected-warning malformed +// expected-error@16 {{cannot find start}} + +// expected-error 0+ {{should also be ignored}} + +#ifdef TEST1 +#if 0 +// expected-error {{should be ignored}} +#endif + +#error should not be ignored +// expected-error@-1 1+ {{should not be ignored}} + +#line 90 +unexpected a; // expected-error@+0 + {{unknown type}} + +#line 60 +unexpected b; // expected-error@33 1-1 {{unknown type}} + +// expected-error@+2 {{file not found}} check that multi-line handled correctly: \ + +#include "missing_header_file.include" +#endif + +#ifdef TEST2 +#define MACRO some_value // expected-error {{define_error}} +#undef MACRO extra_token // expected-warning {{undef_error}} +#line -2 // expected-error {{line_error}} +#error AAA // expected-error {{BBB}} <- this shall be part of diagnostic +#warning CCC // expected-warning {{DDD}} <- this shall be part of diagnostic + +#if 0 +// This is encapsulated in "#if 0" so that the expected-* checks below +// are not inadvertently included in the diagnostic checking! + +// CHECK2: error: 'error' diagnostics expected but not seen: +// CHECK2-NEXT: Line 41: define_error +// CHECK2-NEXT: Line 43: line_error +// CHECK2-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK2-NEXT: Line 43: #line directive requires a positive integer argument +// CHECK2-NEXT: Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: error: 'warning' diagnostics expected but not seen: +// CHECK2-NEXT: Line 42: undef_error +// CHECK2-NEXT: error: 'warning' diagnostics seen but not expected: +// CHECK2-NEXT: Line 42: extra tokens at end of #undef directive +// CHECK2-NEXT: Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: 7 errors generated. +#endif +#endif + +#ifdef TEST3 +#ifndef TEST3 // expected-note {{line_67}} + // expected-note {{line_68_ignored}} +# ifdef UNDEFINED // expected-note {{line_69_ignored}} +# endif // expected-note {{line_70_ignored}} +#elif defined(TEST3) // expected-note {{line_71}} +# if 1 // expected-note {{line_72}} + // expected-note {{line_73}} +# else // expected-note {{line_74}} + // expected-note {{line_75_ignored}} +# ifndef TEST3 // expected-note {{line_76_ignored}} +# endif // expected-note {{line_77_ignored}} +# endif // expected-note {{line_78}} +#endif + +// CHECK3: error: 'note' diagnostics expected but not seen: +// CHECK3-NEXT: Line 67: line_67 +// CHECK3-NEXT: Line 71: line_71 +// CHECK3-NEXT: Line 72: line_72 +// CHECK3-NEXT: Line 73: line_73 +// CHECK3-NEXT: Line 74: line_74 +// CHECK3-NEXT: Line 78: line_78 +// CHECK3-NEXT: 6 errors generated. +#endif + +#ifdef TEST4 +#include "missing_header_file.include" // expected-error {{include_error}} + +// CHECK4: error: 'error' diagnostics expected but not seen: +// CHECK4-NEXT: Line 92: include_error +// CHECK4-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK4-NEXT: Line 92: 'missing_header_file.include' file not found +// CHECK4-NEXT: 2 errors generated. +#endif + +#ifdef TEST5 +#include "verify-directive.h" +// expected-error@50 {{source file test}} + +// CHECK5: error: 'error' diagnostics expected but not seen: +// CHECK5-NEXT: Line 1 (directive at {{.*}}verify-directive.h:2): include file test +// CHECK5-NEXT: Line 50 (directive at {{.*}}verify.c:103): source file test +// CHECK5-NEXT: 2 errors generated. +#endif + diff --git a/clang/test/Lexer/bcpl-escaped-newline.c b/clang/test/Lexer/bcpl-escaped-newline.c index 4d4a7b5e89e..d87ee9b83ae 100644 --- a/clang/test/Lexer/bcpl-escaped-newline.c +++ b/clang/test/Lexer/bcpl-escaped-newline.c @@ -5,7 +5,8 @@ #error bar //??/ -#error qux // expected-error {{qux}} +#error qux +// expected-error@-1 {{qux}} // Trailing whitespace! //\ diff --git a/clang/test/Lexer/conflict-marker.c b/clang/test/Lexer/conflict-marker.c index 2a8e43b0cbd..e5bc7f33e45 100644 --- a/clang/test/Lexer/conflict-marker.c +++ b/clang/test/Lexer/conflict-marker.c @@ -3,8 +3,8 @@ // Test that we recover gracefully from conflict markers left in input files. // PR5238 -// diff3 style -<<<<<<< .mine // expected-error {{version control conflict marker in file}} +// diff3 style expected-error@+1 {{version control conflict marker in file}} +<<<<<<< .mine int x = 4; ||||||| int x = 123; @@ -12,15 +12,15 @@ int x = 123; float x = 17; >>>>>>> .r91107 -// normal style. -<<<<<<< .mine // expected-error {{version control conflict marker in file}} +// normal style expected-error@+1 {{version control conflict marker in file}} +<<<<<<< .mine typedef int y; ======= typedef struct foo *y; >>>>>>> .r91107 -// Perforce style. ->>>> ORIGINAL conflict-marker.c#6 // expected-error {{version control conflict marker in file}} +// Perforce style expected-error@+1 {{version control conflict marker in file}} +>>>> ORIGINAL conflict-marker.c#6 int z = 1; ==== THEIRS conflict-marker.c#7 int z = 0; diff --git a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h index 738b2221cbb..f8949848bd4 100644 --- a/clang/test/Modules/Inputs/Module.framework/Headers/Module.h +++ b/clang/test/Modules/Inputs/Module.framework/Headers/Module.h @@ -1,4 +1,8 @@ -// expected-warning{{umbrella header}} +// expected-warning 0-1 {{umbrella header}} + +// FIXME: The "umbrella header" warning should be moved to a separate test. +// This "0-1" is only here because the warning is only emitted when the +// module is (otherwise) successfully included. #ifndef MODULE_H #define MODULE_H diff --git a/clang/test/Modules/on-demand-build.m b/clang/test/Modules/on-demand-build.m index cf1ae99ce0c..4ee6b58d96b 100644 --- a/clang/test/Modules/on-demand-build.m +++ b/clang/test/Modules/on-demand-build.m @@ -7,10 +7,7 @@ @interface OtherClass @end - - - -// in module: expected-note{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} +// in module: expected-note@17{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} void test_getModuleVersion() { const char *version = getModuleVersion(); const char *version2 = [Module version]; diff --git a/clang/test/PCH/attrs.c b/clang/test/PCH/attrs.c index 2f868ac6624..6a4b8f667cb 100644 --- a/clang/test/PCH/attrs.c +++ b/clang/test/PCH/attrs.c @@ -8,10 +8,11 @@ #ifndef HEADER #define HEADER -int f(int) __attribute__((visibility("default"), overloadable)); // expected-note{{previous overload}} +int f(int) __attribute__((visibility("default"), overloadable)); #else double f(double); // expected-error{{overloadable}} + // expected-note@11{{previous overload}} #endif diff --git a/clang/test/PCH/chain-staticvar-instantiation.cpp b/clang/test/PCH/chain-staticvar-instantiation.cpp index 0ab093f18d6..850b8d185e3 100644 --- a/clang/test/PCH/chain-staticvar-instantiation.cpp +++ b/clang/test/PCH/chain-staticvar-instantiation.cpp @@ -36,7 +36,8 @@ int g2 = NS::TS<int, 2>::value; #else //===----------------------------------------------------------------------===// -#warning reached main file // expected-warning {{reached main file}} +// expected-warning@+1 {{reached main file}} +#warning reached main file int g3 = NS::TS<int, 2>::value; diff --git a/clang/test/PCH/cxx-static_assert.cpp b/clang/test/PCH/cxx-static_assert.cpp index ace12e0922d..8049525fb59 100644 --- a/clang/test/PCH/cxx-static_assert.cpp +++ b/clang/test/PCH/cxx-static_assert.cpp @@ -9,11 +9,12 @@ #define HEADER template<int N> struct T { - static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}} + static_assert(N == 2, "N is not 2!"); }; #else +// expected-error@12 {{static_assert failed "N is not 2!"}} T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} T<2> t2; diff --git a/clang/test/PCH/cxx-trailing-return.cpp b/clang/test/PCH/cxx-trailing-return.cpp index ff85f6d1c5f..aa3879077f0 100644 --- a/clang/test/PCH/cxx-trailing-return.cpp +++ b/clang/test/PCH/cxx-trailing-return.cpp @@ -4,12 +4,14 @@ #ifndef HEADER_INCLUDED #define HEADER_INCLUDED -typedef auto f() -> int; // expected-note {{here}} -typedef int g(); // expected-note {{here}} +typedef auto f() -> int; +typedef int g(); #else typedef void f; // expected-error {{typedef redefinition with different types ('void' vs 'auto () -> int')}} + // expected-note@7 {{here}} typedef void g; // expected-error {{typedef redefinition with different types ('void' vs 'int ()')}} + // expected-note@8 {{here}} #endif diff --git a/clang/test/PCH/cxx0x-default-delete.cpp b/clang/test/PCH/cxx0x-default-delete.cpp index 6eb65d61df4..39a90b858fd 100644 --- a/clang/test/PCH/cxx0x-default-delete.cpp +++ b/clang/test/PCH/cxx0x-default-delete.cpp @@ -9,15 +9,15 @@ struct foo { foo() = default; - void bar() = delete; // expected-note{{deleted here}} + void bar() = delete; }; struct baz { - ~baz() = delete; // expected-note{{deleted here}} + ~baz() = delete; }; class quux { - ~quux() = default; // expected-note{{private here}} + ~quux() = default; }; #else @@ -25,10 +25,10 @@ class quux { foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}} foo f; void fn() { - f.bar(); // expected-error{{deleted function}} + f.bar(); // expected-error{{deleted function}} expected-note@12{{deleted here}} } -baz bz; // expected-error{{deleted function}} -quux qx; // expected-error{{private destructor}} +baz bz; // expected-error{{deleted function}} expected-note@16{{deleted here}} +quux qx; // expected-error{{private destructor}} expected-note@20{{private here}} #endif diff --git a/clang/test/PCH/cxx0x-delegating-ctors.cpp b/clang/test/PCH/cxx0x-delegating-ctors.cpp index f2b7e903625..bf5daefa558 100644 --- a/clang/test/PCH/cxx0x-delegating-ctors.cpp +++ b/clang/test/PCH/cxx0x-delegating-ctors.cpp @@ -8,13 +8,17 @@ #ifndef PASS1 #define PASS1 struct foo { - foo(int) : foo() { } // expected-note{{it delegates to}} + foo(int) : foo() { } foo(); - foo(bool) : foo('c') { } // expected-note{{it delegates to}} - foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \ - // expected-note{{which delegates to}} + foo(bool) : foo('c') { } + foo(char) : foo(true) { } }; #else foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \ // expected-note{{which delegates to}} + +// expected-note@11{{it delegates to}} +// expected-note@13{{it delegates to}} +// expected-error@14{{creates a delegation cycle}} +// expected-note@14{{which delegates to}} #endif diff --git a/clang/test/PCH/cxx11-constexpr.cpp b/clang/test/PCH/cxx11-constexpr.cpp index 338543ecf93..ce43206d396 100644 --- a/clang/test/PCH/cxx11-constexpr.cpp +++ b/clang/test/PCH/cxx11-constexpr.cpp @@ -6,11 +6,11 @@ #define HEADER_INCLUDED struct B { - B(); // expected-note {{here}} + B(); constexpr B(char) {} }; -struct C { // expected-note {{not an aggregate and has no constexpr constructors}} +struct C { B b; double d = 0.0; }; @@ -24,6 +24,8 @@ struct D : B { static_assert(D(4).k == 9, ""); constexpr int f(C c) { return 0; } // expected-error {{not a literal type}} +// expected-note@13 {{not an aggregate and has no constexpr constructors}} constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}} + // expected-note@9 {{here}} #endif diff --git a/clang/test/PCH/cxx11-enum-template.cpp b/clang/test/PCH/cxx11-enum-template.cpp index 70b0ff9ecbd..ca70601da77 100644 --- a/clang/test/PCH/cxx11-enum-template.cpp +++ b/clang/test/PCH/cxx11-enum-template.cpp @@ -7,7 +7,7 @@ template<typename T> struct S { enum class E { - e = T() // expected-error {{conversion from 'double' to 'int'}} + e = T() }; }; @@ -20,7 +20,7 @@ template struct S<char>; int k1 = (int)S<int>::E::e; int k2 = (int)decltype(b)::e; -int k3 = (int)decltype(c)::e; // expected-note {{here}} +int k3 = (int)decltype(c)::e; // expected-error@10 {{conversion from 'double' to 'int'}} expected-note {{here}} int k4 = (int)S<char>::E::e; #endif diff --git a/clang/test/PCH/cxx11-user-defined-literals.cpp b/clang/test/PCH/cxx11-user-defined-literals.cpp index 4a7c24b9944..7ad17f55d71 100644 --- a/clang/test/PCH/cxx11-user-defined-literals.cpp +++ b/clang/test/PCH/cxx11-user-defined-literals.cpp @@ -8,7 +8,7 @@ using size_t = decltype(sizeof(int)); int operator"" _foo(const char *p, size_t); -template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } // expected-note {{substitution failure}} +template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } #else @@ -17,5 +17,6 @@ int k = f(0); int *l = f(&k); struct S {}; int m = f(S()); // expected-error {{no matching}} + // expected-note@11 {{substitution failure}} #endif diff --git a/clang/test/PCH/ms-if-exists.cpp b/clang/test/PCH/ms-if-exists.cpp index 4bea198d9ba..be29ac62ef2 100644 --- a/clang/test/PCH/ms-if-exists.cpp +++ b/clang/test/PCH/ms-if-exists.cpp @@ -11,7 +11,7 @@ void f(T t) { } __if_not_exists(T::bar) { - int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}} + int *i = t; { } } } @@ -25,5 +25,6 @@ struct HasBar { }; template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}} + // expected-error@14{{no viable conversion from 'HasFoo' to 'int *'}} template void f(HasBar); #endif diff --git a/clang/test/PCH/replaced-decl.m b/clang/test/PCH/replaced-decl.m index b9fee950d7a..5636a574616 100644 --- a/clang/test/PCH/replaced-decl.m +++ b/clang/test/PCH/replaced-decl.m @@ -12,11 +12,12 @@ #elif !defined(HEADER2) #define HEADER2 -@interface I // expected-note {{previous}} +@interface I @end #else typedef int I; // expected-error {{redefinition}} + // expected-note@15 {{previous}} #endif diff --git a/clang/test/PCH/typo2.cpp b/clang/test/PCH/typo2.cpp index f9b4c833e04..9aa97bdfb17 100644 --- a/clang/test/PCH/typo2.cpp +++ b/clang/test/PCH/typo2.cpp @@ -4,10 +4,11 @@ #ifndef HEADER_INCLUDED #define HEADER_INCLUDED -void func(struct Test); // expected-note{{'Test' declared here}} +void func(struct Test); #else ::Yest *T; // expected-error{{did you mean 'Test'}} + // expected-note@7{{'Test' declared here}} #endif diff --git a/clang/test/PCH/variables.c b/clang/test/PCH/variables.c index 9f90b37d416..2c8c1368e17 100644 --- a/clang/test/PCH/variables.c +++ b/clang/test/PCH/variables.c @@ -11,12 +11,12 @@ extern float y; extern int *ip, x; -float z; // expected-note{{previous}} +float z; -int z2 = 17; // expected-note{{previous}} +int z2 = 17; #define MAKE_HAPPY(X) X##Happy -int MAKE_HAPPY(Very); // expected-note{{previous definition is here}} +int MAKE_HAPPY(Very); #define A_MACRO_IN_THE_PCH 492 #define FUNCLIKE_MACRO(X, Y) X ## Y @@ -32,9 +32,9 @@ int UNIQUE(a); // a1 int *ip2 = &x; float *fp = &ip; // expected-warning{{incompatible pointer types}} -double z; // expected-error{{redefinition}} -int z2 = 18; // expected-error{{redefinition}} -double VeryHappy; // expected-error{{redefinition}} +double z; // expected-error{{redefinition}} expected-note@14{{previous}} +int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}} +double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}} int Q = A_MACRO_IN_THE_PCH; diff --git a/clang/test/Preprocessor/line-directive.c b/clang/test/Preprocessor/line-directive.c index da3c53368f8..ffa7c5a4197 100644 --- a/clang/test/Preprocessor/line-directive.c +++ b/clang/test/Preprocessor/line-directive.c @@ -33,8 +33,11 @@ // These are checked by the RUN line. #line 92 "blonk.c" -#error ABC // expected-error {{#error ABC}} -#error DEF // expected-error {{#error DEF}} +#error ABC +#error DEF +// expected-error@-2 {{ABC}} +#line 150 +// expected-error@-3 {{DEF}} // Verify that linemarker diddling of the system header flag works. diff --git a/clang/test/Preprocessor/macro_paste_c_block_comment.c b/clang/test/Preprocessor/macro_paste_c_block_comment.c index 92b2f601885..c558be58ee7 100644 --- a/clang/test/Preprocessor/macro_paste_c_block_comment.c +++ b/clang/test/Preprocessor/macro_paste_c_block_comment.c @@ -1,8 +1,9 @@ // RUN: %clang_cc1 %s -Eonly -verify +// expected-error@9 {{EOF}} #define COMM / ## * COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}} // Demonstrate that an invalid preprocessing token // doesn't swallow the rest of the file... -#error EOF // expected-error {{EOF}} +#error EOF diff --git a/clang/test/Preprocessor/warning_tests.c b/clang/test/Preprocessor/warning_tests.c index 96b96efc7e6..3f2865cdb47 100644 --- a/clang/test/Preprocessor/warning_tests.c +++ b/clang/test/Preprocessor/warning_tests.c @@ -6,14 +6,16 @@ #if __has_warning("not valid") // expected-warning {{__has_warning expected option name}} #endif +// expected-warning@+2 {{Should have -Wparentheses}} #if __has_warning("-Wparentheses") -#warning Should have -Wparentheses // expected-warning {{Should have -Wparentheses}} +#warning Should have -Wparentheses #endif #if __has_warning(-Wfoo) // expected-error {{builtin warning check macro requires a parenthesized string}} #endif +// expected-warning@+3 {{Not a valid warning flag}} #if __has_warning("-Wnot-a-valid-warning-flag-at-all") #else -#warning Not a valid warning flag // expected-warning {{Not a valid warning flag}} -#endif
\ No newline at end of file +#warning Not a valid warning flag +#endif diff --git a/clang/test/SemaCXX/warn-deprecated-header.cpp b/clang/test/SemaCXX/warn-deprecated-header.cpp index f6ac2cb6393..015e7751b93 100644 --- a/clang/test/SemaCXX/warn-deprecated-header.cpp +++ b/clang/test/SemaCXX/warn-deprecated-header.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fdeprecated-macro -verify %s // RUN: %clang_cc1 -fsyntax-only -Werror %s +// expected-warning@+2 {{This file is deprecated.}} #ifdef __DEPRECATED -#warning This file is deprecated. // expected-warning {{This file is deprecated.}} +#warning This file is deprecated. #endif |