[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    Re: [cfe-commits] [Patch 7 of 7] -verify fixes and enhancement
From:       "Andy Gibbs" <andyg1001 () hotmail ! co ! uk>
Date:       2012-06-30 21:13:18
Message-ID: BLU134-DS2F0FA0044B57E1A92DA79E7E40 () phx ! gbl
[Download RAW message or body]

Dies ist eine mehrteilige Nachricht im MIME-Format.


Part 7: As mentioned before, these really attach to part 5 since this is the 
only patch that requires changes to test-cases.  It also contains a full 
test-case for the patches as a whole.  I have also added another test within 
this test-case to show that following patch 5, -verify now correctly handles 
expected-* directives inside included files.


Thanks again,
Andy

 

["verify-part7.diff" (application/octet-stream)]

ADDED   tools/clang/test/ARCMT/verify.m
Index: tools/clang/test/ARCMT/verify.m
==================================================================
--- tools/clang/test/ARCMT/verify.m
+++ tools/clang/test/ARCMT/verify.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -arcmt-check -verify %s
+
+#if 0
+// expected-error {{should be ignored}}
+#endif
+
+#error should not be ignored
+// expected-error@-1 {{should not be ignored}}

ADDED   tools/clang/test/Frontend/verify.c
Index: tools/clang/test/Frontend/verify.c
==================================================================
--- tools/clang/test/Frontend/verify.c
+++ tools/clang/test/Frontend/verify.c
@@ -0,0 +1,109 @@
+// 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

ADDED   tools/clang/test/Frontend/verify-directive.h
Index: tools/clang/test/Frontend/verify-directive.h
==================================================================
--- tools/clang/test/Frontend/verify-directive.h
+++ tools/clang/test/Frontend/verify-directive.h
@@ -0,0 +1,2 @@
+// Check that directives inside includes are included!
+// expected-error@1 {{include file test}}

Index: tools/clang/test/Lexer/bcpl-escaped-newline.c
==================================================================
--- tools/clang/test/Lexer/bcpl-escaped-newline.c
+++ tools/clang/test/Lexer/bcpl-escaped-newline.c
@@ -3,10 +3,11 @@
 
 //\
 #error bar
 
 //??/
-#error qux // expected-error {{qux}}
+#error qux
+// expected-error@-1 {{qux}}
 
 // Trailing whitespace!
 //\ 
 #error quux

Index: tools/clang/test/Lexer/conflict-marker.c
==================================================================
--- tools/clang/test/Lexer/conflict-marker.c
+++ tools/clang/test/Lexer/conflict-marker.c
@@ -1,28 +1,28 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only
 
 // 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;
 =======
 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;
 ==== YOURS conflict-marker.c
 int z = 2;

Index: tools/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
==================================================================
--- tools/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
+++ tools/clang/test/Modules/Inputs/Module.framework/Headers/Module.h
@@ -1,6 +1,6 @@
-// expected-warning{{umbrella header}}
+// expected-warning 0-1 {{umbrella header}}
 
 #ifndef MODULE_H
 #define MODULE_H
 const char *getModuleVersion(void);
 

Index: tools/clang/test/PCH/attrs.c
==================================================================
--- tools/clang/test/PCH/attrs.c
+++ tools/clang/test/PCH/attrs.c
@@ -6,12 +6,13 @@
 // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s 
 
 #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

Index: tools/clang/test/PCH/cxx-static_assert.cpp
==================================================================
--- tools/clang/test/PCH/cxx-static_assert.cpp
+++ tools/clang/test/PCH/cxx-static_assert.cpp
@@ -7,14 +7,15 @@
 
 #ifndef HEADER
 #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;
 
 #endif

Index: tools/clang/test/PCH/cxx-trailing-return.cpp
==================================================================
--- tools/clang/test/PCH/cxx-trailing-return.cpp
+++ tools/clang/test/PCH/cxx-trailing-return.cpp
@@ -2,14 +2,16 @@
 // RUN: %clang_cc1 -pedantic-errors -std=c++11 -include-pch %t-cxx11 -verify %s
 
 #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

Index: tools/clang/test/PCH/cxx0x-default-delete.cpp
==================================================================
--- tools/clang/test/PCH/cxx0x-default-delete.cpp
+++ tools/clang/test/PCH/cxx0x-default-delete.cpp
@@ -7,28 +7,28 @@
 #ifndef PASS1
 #define PASS1
 
 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
 
 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

Index: tools/clang/test/PCH/cxx0x-delegating-ctors.cpp
==================================================================
--- tools/clang/test/PCH/cxx0x-delegating-ctors.cpp
+++ tools/clang/test/PCH/cxx0x-delegating-ctors.cpp
@@ -6,15 +6,19 @@
 // RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s 
 
 #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

Index: tools/clang/test/PCH/cxx11-constexpr.cpp
==================================================================
--- tools/clang/test/PCH/cxx11-constexpr.cpp
+++ tools/clang/test/PCH/cxx11-constexpr.cpp
@@ -4,15 +4,15 @@
 #ifndef HEADER_INCLUDED
 
 #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;
 };
 
 struct D : B {
@@ -22,8 +22,10 @@
 
 #else
 
 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

Index: tools/clang/test/PCH/cxx11-enum-template.cpp
==================================================================
--- tools/clang/test/PCH/cxx11-enum-template.cpp
+++ tools/clang/test/PCH/cxx11-enum-template.cpp
@@ -5,11 +5,11 @@
 
 #define HEADER_INCLUDED
 
 template<typename T> struct S {
   enum class E {
-    e = T() // expected-error {{conversion from 'double' to 'int'}}
+    e = T()
   };
 };
 
 S<int> a;
 S<long>::E b;
@@ -18,9 +18,9 @@
 
 #else
 
 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

Index: tools/clang/test/PCH/cxx11-user-defined-literals.cpp
==================================================================
--- tools/clang/test/PCH/cxx11-user-defined-literals.cpp
+++ tools/clang/test/PCH/cxx11-user-defined-literals.cpp
@@ -6,16 +6,17 @@
 #define HEADER_INCLUDED
 
 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
 
 int j = ""_foo;
 int k = f(0);
 int *l = f(&k);
 struct S {};
 int m = f(S()); // expected-error {{no matching}}
+                // expected-note@11 {{substitution failure}}
 
 #endif

Index: tools/clang/test/PCH/ms-if-exists.cpp
==================================================================
--- tools/clang/test/PCH/ms-if-exists.cpp
+++ tools/clang/test/PCH/ms-if-exists.cpp
@@ -9,11 +9,11 @@
     { }
     t.foo();
   }
 
   __if_not_exists(T::bar) {
-    int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}}
+    int *i = t;
     { }
   }
 }
 #else
 struct HasFoo { 
@@ -23,7 +23,8 @@
   void bar(int);
   void bar(float);
 };
 
 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

Index: tools/clang/test/PCH/replaced-decl.m
==================================================================
--- tools/clang/test/PCH/replaced-decl.m
+++ tools/clang/test/PCH/replaced-decl.m
@@ -10,13 +10,14 @@
 @class I;
 
 #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

Index: tools/clang/test/PCH/typo2.cpp
==================================================================
--- tools/clang/test/PCH/typo2.cpp
+++ tools/clang/test/PCH/typo2.cpp
@@ -2,12 +2,13 @@
 // RUN: %clang_cc1 -include-pch %t.pch %s -verify
 
 #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

Index: tools/clang/test/PCH/variables.c
==================================================================
--- tools/clang/test/PCH/variables.c
+++ tools/clang/test/PCH/variables.c
@@ -9,16 +9,16 @@
 #define HEADER
 
 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
 
 #define PASTE2(x,y) x##y
@@ -30,13 +30,13 @@
 
 #else
 
 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;
 
 int R = FUNCLIKE_MACRO(A_MACRO_, IN_THE_PCH);
 

Index: tools/clang/test/Preprocessor/line-directive.c
==================================================================
--- tools/clang/test/Preprocessor/line-directive.c
+++ tools/clang/test/Preprocessor/line-directive.c
@@ -31,12 +31,15 @@
 # 42 "foo" 1 2   // expected-error {{invalid flag line marker directive}}
 
 
 // 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.
 
 # 192 "glomp.h" // not a system header.

Index: tools/clang/test/Preprocessor/macro_paste_c_block_comment.c
==================================================================
--- tools/clang/test/Preprocessor/macro_paste_c_block_comment.c
+++ tools/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

Index: tools/clang/test/Preprocessor/warning_tests.c
==================================================================
--- tools/clang/test/Preprocessor/warning_tests.c
+++ tools/clang/test/Preprocessor/warning_tests.c
@@ -4,16 +4,18 @@
 #endif
 
 #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}}
+#warning Not a valid warning flag
 #endif

Index: tools/clang/test/SemaCXX/warn-deprecated-header.cpp
==================================================================
--- tools/clang/test/SemaCXX/warn-deprecated-header.cpp
+++ tools/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



_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic