diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:25:38 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-13 19:25:38 +0000 |
commit | 8746d127c04f5bbaf6c6e88cef8606ca5a6a54e9 (patch) | |
tree | 84c9d77f8c764f04bcef0b1da4eedfa233d67a46 /test/Sema | |
parent | cf1b401909b5e54edfd80656b1a18eaa31f9f6f1 (diff) |
Notes
Diffstat (limited to 'test/Sema')
-rw-r--r-- | test/Sema/address-packed.c | 9 | ||||
-rw-r--r-- | test/Sema/attr-availability.c | 25 | ||||
-rw-r--r-- | test/Sema/attr-deprecated.c | 4 | ||||
-rw-r--r-- | test/Sema/attr-unavailable-message.c | 8 | ||||
-rw-r--r-- | test/Sema/loop-control.c | 48 | ||||
-rw-r--r-- | test/Sema/warn-cast-qual.c | 31 | ||||
-rw-r--r-- | test/Sema/warn-documentation.cpp | 2 |
7 files changed, 113 insertions, 14 deletions
diff --git a/test/Sema/address-packed.c b/test/Sema/address-packed.c index 2799e19c48f13..b0519bacd7587 100644 --- a/test/Sema/address-packed.c +++ b/test/Sema/address-packed.c @@ -329,3 +329,12 @@ void g13(void) { uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + +void *g14(struct Invalid0 *ivl) { + return &(ivl->x); +} diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index e105037c8ed01..1b8cbd256ce97 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -21,6 +21,9 @@ ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduce extern void PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8))); +#ifdef WARN_PARTIAL +// expected-note@+2 2 {{marked partial here}} +#endif enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum { kPartialEnumConstant, }; @@ -35,11 +38,19 @@ void test_10095131() { PartiallyAvailable(); } +#ifdef WARN_PARTIAL +// FIXME: This note should point to the declaration with the availability +// attribute. +// expected-note@+2 {{marked partial here}} +#endif extern void PartiallyAvailable() ; void with_redeclaration() { - PartiallyAvailable(); // Don't warn. - - // enums should never warn. +#ifdef WARN_PARTIAL + // expected-warning@+4 {{'PartiallyAvailable' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}} + // expected-warning@+4 {{'PartialEnum' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}} + // expected-warning@+3 {{'kPartialEnumConstant' is only available on macOS 10.8 or newer}} expected-note@+3 {{__builtin_available}} +#endif + PartiallyAvailable(); enum PartialEnum p = kPartialEnumConstant; } @@ -86,13 +97,13 @@ enum Original { OriginalUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'OriginalUnavailable' has been explicitly marked unavailable here}} }; -enum AllDeprecated { - AllDeprecatedCase, // expected-note + {{'AllDeprecatedCase' has been explicitly marked deprecated here}} +enum AllDeprecated { // expected-note + {{'AllDeprecated' has been explicitly marked deprecated here}} + AllDeprecatedCase, AllDeprecatedUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'AllDeprecatedUnavailable' has been explicitly marked unavailable here}} } __attribute__((availability(macosx, deprecated=10.2))); -enum AllUnavailable { - AllUnavailableCase, // expected-note + {{'AllUnavailableCase' has been explicitly marked unavailable here}} +enum AllUnavailable { // expected-note + {{'AllUnavailable' has been explicitly marked unavailable here}} + AllUnavailableCase, } __attribute__((availability(macosx, unavailable))); enum User { diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index 89c06860fb4e6..9eeef5aed57db 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -104,9 +104,9 @@ foo_dep test17, // expected-warning {{'foo_dep' is deprecated}} test19; // rdar://problem/8518751 -enum __attribute__((deprecated)) Test20 { // expected-note {{'Test20' has been explicitly marked deprecated here}} +enum __attribute__((deprecated)) Test20 { // expected-note 2 {{'Test20' has been explicitly marked deprecated here}} test20_a __attribute__((deprecated)), // expected-note {{'test20_a' has been explicitly marked deprecated here}} - test20_b // expected-note {{'test20_b' has been explicitly marked deprecated here}} + test20_b }; void test20() { enum Test20 f; // expected-warning {{'Test20' is deprecated}} diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c index 415cb2f079a2e..70d5947086f9d 100644 --- a/test/Sema/attr-unavailable-message.c +++ b/test/Sema/attr-unavailable-message.c @@ -36,13 +36,13 @@ void unavail(void) { // rdar://10201690 enum foo { - a = 1, // expected-note {{'a' has been explicitly marked deprecated here}} + a = 1, b __attribute__((deprecated())) = 2, // expected-note {{'b' has been explicitly marked deprecated here}} c = 3 -}__attribute__((deprecated())); +}__attribute__((deprecated())); // expected-note {{'foo' has been explicitly marked deprecated here}} -enum fee { // expected-note {{'fee' has been explicitly marked unavailable here}} - r = 1, // expected-note {{'r' has been explicitly marked unavailable here}} +enum fee { // expected-note 2 {{'fee' has been explicitly marked unavailable here}} + r = 1, s = 2, t = 3 }__attribute__((unavailable())); diff --git a/test/Sema/loop-control.c b/test/Sema/loop-control.c index 6c33e8437bd02..1fc35d10218ee 100644 --- a/test/Sema/loop-control.c +++ b/test/Sema/loop-control.c @@ -119,3 +119,51 @@ void pr8880_23(int x, int y) { for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}} } } + +void pr32648_1(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; switch (y) { case 0: break; } y;}); ++y) {} // no warning + } +} + +void pr32648_2(int x, int y) { + while(x) { + for ( ; ({ ++y; switch (y) { case 0: continue; } y;}); ++y) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}} + } +} + +void pr32648_3(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; for (; y; y++) { break; } y;}); ++y) {} // no warning + } +} + +void pr32648_4(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; for (({ break; }); y; y++) { } y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}} + } +} + +void pr32648_5(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; while (({ break; y; })) {} y;}); ++y) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}} + } +} + +void pr32648_6(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; do {} while (({ break; y; })); y;}); ++y) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}} + } +} + +void pr32648_7(int x, int y) { + switch(x) { + case 1: + for ( ; ({ ++y; do { break; } while (y); y;}); ++y) {} // no warning + } +} diff --git a/test/Sema/warn-cast-qual.c b/test/Sema/warn-cast-qual.c index dc11f5717ebe5..a682cad75ed6a 100644 --- a/test/Sema/warn-cast-qual.c +++ b/test/Sema/warn-cast-qual.c @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -Wcast-qual -verify %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -fsyntax-only -Wcast-qual -verify %s #include <stdint.h> @@ -26,4 +27,34 @@ void foo() { const char **charptrptrc; char **charptrptr = (char **)charptrptrc; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} + + const char *constcharptr; + char *charptr = (char *)constcharptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} + const char *constcharptr2 = (char *)constcharptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}} + const char *charptr2 = (char *)charptr; // no warning +} + +void bar_0() { + struct C { + const int a; + int b; + }; + + const struct C S = {0, 0}; + + *(int *)(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} + *(int *)(&S.b) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} +} + +void bar_1() { + struct C { + const int a; + int b; + }; + + struct C S = {0, 0}; + S.b = 0; // no warning + + *(int *)(&S.a) = 0; // expected-warning {{cast from 'const int *' to 'int *' drops const qualifier}} + *(int *)(&S.b) = 0; // no warning } diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 0c92b2aa029fe..ccf374ccd0609 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -1186,7 +1186,7 @@ class Predicate /// @brief A C++ wrapper class for providing threaded access to a value /// of type T. /// -/// A template specilization class. +/// A template specialization class. //---------------------------------------------------------------------- template<> class Predicate<int, char> { |