summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2015-07-13 14:13:01 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2015-07-13 14:13:01 +0000
commitef5aa29e12d0203a8196ed715d262357deddc218 (patch)
treed3f0adf3a3827a10f145611695e31f1e67356002 /clang/test/Sema
parent6d8f78507310f2a2a37a6cd24bfc2f99e4e2dc1a (diff)
downloadbcm5719-llvm-ef5aa29e12d0203a8196ed715d262357deddc218.tar.gz
bcm5719-llvm-ef5aa29e12d0203a8196ed715d262357deddc218.zip
Support alternate attribute spelling __enable_if__
Attribute names usually support an alternate spelling that uses double underscores before and after the attribute name, like e.g. attribute ((__aligned__)) for attribute ((aligned)). This is necessary to allow use of attributes in system headers without polluting the name space. However, for attribute ((enable_if)) that alternate spelling does not work correctly. This is because of code in Parser::ParseGNUAttributeArgs (ParseDecl.cpp) that specifically checks for the "enable_if" spelling without allowing the alternate spelling. Similar code in ParseDecl.cpp uses the normalizeAttrName helper to allow both spellings. This patch adds use of that helper for the "enable_if" check as well, which fixes attribute ((__enable_if__)). Differential Revision: http://reviews.llvm.org/D11142 llvm-svn: 242029
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/enable_if.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Sema/enable_if.c b/clang/test/Sema/enable_if.c
index 4644858593d..7faae43b577 100644
--- a/clang/test/Sema/enable_if.c
+++ b/clang/test/Sema/enable_if.c
@@ -77,6 +77,21 @@ void test3(int c) {
#endif
}
+// Verify that the alternate spelling __enable_if__ works as well.
+int isdigit2(int c) __attribute__((overloadable)); // expected-note{{candidate function}}
+int isdigit2(int c) __attribute__((overloadable)) // expected-note{{candidate function has been explicitly made unavailable}}
+ __attribute__((__enable_if__(c <= -1 || c > 255, "'c' must have the value of an unsigned char or EOF")))
+ __attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
+
+void test4(int c) {
+ isdigit2(c);
+ isdigit2(10);
+#ifndef CODEGEN
+ isdigit2(-10); // expected-error{{call to unavailable function 'isdigit2': 'c' must have the value of an unsigned char or EOF}}
+#endif
+}
+
+
#ifndef CODEGEN
__attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) void f1(int n); // expected-error{{use of undeclared identifier 'n'}}
OpenPOWER on IntegriCloud