This revision was automatically updated to reflect the committed changes.
Closed by commit rL242029: Support alternate attribute spelling __enable_if__
(authored by uweigand).
Changed prior to commit:
http://reviews.llvm.org/D11142?vs=29561&id=29565#toc
Repository:
rL LLVM
http://reviews.llvm.org/D11142
Files:
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Sema/enable_if.c
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -365,7 +365,8 @@
// These may refer to the function arguments, but need to be parsed early to
// participate in determining whether it's a redeclaration.
std::unique_ptr<ParseScope> PrototypeScope;
- if (AttrName->isStr("enable_if") && D && D->isFunctionDeclarator()) {
+ if (normalizeAttrName(AttrName->getName()) == "enable_if" &&
+ D && D->isFunctionDeclarator()) {
DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo();
PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope |
Scope::FunctionDeclarationScope |
Index: cfe/trunk/test/Sema/enable_if.c
===================================================================
--- cfe/trunk/test/Sema/enable_if.c
+++ cfe/trunk/test/Sema/enable_if.c
@@ -77,6 +77,21 @@
#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'}}
Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -365,7 +365,8 @@
// These may refer to the function arguments, but need to be parsed early to
// participate in determining whether it's a redeclaration.
std::unique_ptr<ParseScope> PrototypeScope;
- if (AttrName->isStr("enable_if") && D && D->isFunctionDeclarator()) {
+ if (normalizeAttrName(AttrName->getName()) == "enable_if" &&
+ D && D->isFunctionDeclarator()) {
DeclaratorChunk::FunctionTypeInfo FTI = D->getFunctionTypeInfo();
PrototypeScope.reset(new ParseScope(this, Scope::FunctionPrototypeScope |
Scope::FunctionDeclarationScope |
Index: cfe/trunk/test/Sema/enable_if.c
===================================================================
--- cfe/trunk/test/Sema/enable_if.c
+++ cfe/trunk/test/Sema/enable_if.c
@@ -77,6 +77,21 @@
#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'}}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits