summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-08-13 18:04:58 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-08-13 18:04:58 +0000
commit794ae1ea7766a7ec18d91ecc54b08f84e3a8216a (patch)
tree0fe1dfa5c6933f228d8f4b973c5a73c02bea93f4
parent3c7e44191ded8f678fc7769f7b6053d74425876e (diff)
downloadbcm5719-llvm-794ae1ea7766a7ec18d91ecc54b08f84e3a8216a.tar.gz
bcm5719-llvm-794ae1ea7766a7ec18d91ecc54b08f84e3a8216a.zip
c: make __has_attribute(const) work for const
function attribute. // rdar://10253857 llvm-svn: 161767
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp7
-rw-r--r--clang/test/Sema/inline.c2
-rw-r--r--clang/test/Sema/unused-expr.c4
3 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 3a7f02cafbf..7aef2f1a0e4 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1062,6 +1062,13 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
if (Tok.is(tok::r_paren))
IsValid = true;
}
+ else if (Tok.is(tok::kw_const)) {
+ FeatureII = getIdentifierInfo("const");
+ // Read the ')'.
+ Lex(Tok);
+ if (Tok.is(tok::r_paren))
+ IsValid = true;
+ }
}
bool Value = false;
diff --git a/clang/test/Sema/inline.c b/clang/test/Sema/inline.c
index c27c00efaad..6377d40b8f3 100644
--- a/clang/test/Sema/inline.c
+++ b/clang/test/Sema/inline.c
@@ -34,7 +34,9 @@ extern inline int useStaticInlineFromExtern () {
return useStaticFromStatic(); // no-warning
}
+#if __has_attribute(const)
static int constFunction() __attribute__((const));
+#endif
inline int useConst () {
return constFunction(); // no-warning
diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c
index d8d8795278a..6081ce651f0 100644
--- a/clang/test/Sema/unused-expr.c
+++ b/clang/test/Sema/unused-expr.c
@@ -82,7 +82,9 @@ void t5() {
int fn1() __attribute__ ((warn_unused_result));
int fn2() __attribute__ ((pure));
-int fn3() __attribute__ ((const));
+#if __has_attribute(__const)
+int fn3() __attribute__ ((__const));
+#endif
// rdar://6587766
int t6() {
if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings
OpenPOWER on IntegriCloud