[cfe-commits] r140658 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/attr-sentinel.c
Eli Friedman
eli.friedman at gmail.com
Tue Sep 27 16:46:37 PDT 2011
Author: efriedma
Date: Tue Sep 27 18:46:37 2011
New Revision: 140658
URL: http://llvm.org/viewvc/llvm-project?rev=140658&view=rev
Log:
PR11002: Make sure we emit sentinel warnings with a valid source location. (Ideally, we want to use the location returned by getLocForEndOfToken, but that is not always successful.)
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-sentinel.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140658&r1=140657&r2=140658&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Sep 27 18:46:37 2011
@@ -252,10 +252,13 @@
NullValue = "NULL";
else
NullValue = "(void*) 0";
-
- Diag(MissingNilLoc, diag::warn_missing_sentinel)
- << calleeType
- << FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue);
+
+ if (MissingNilLoc.isInvalid())
+ Diag(Loc, diag::warn_missing_sentinel) << calleeType;
+ else
+ Diag(MissingNilLoc, diag::warn_missing_sentinel)
+ << calleeType
+ << FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue);
Diag(D->getLocation(), diag::note_sentinel_here) << calleeType;
}
Modified: cfe/trunk/test/Sema/attr-sentinel.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-sentinel.c?rev=140658&r1=140657&r2=140658&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-sentinel.c (original)
+++ cfe/trunk/test/Sema/attr-sentinel.c Tue Sep 27 18:46:37 2011
@@ -4,13 +4,15 @@
#define ATTR __attribute__ ((__sentinel__))
-void foo1 (int x, ...) ATTR; // expected-note 2 {{function has been explicitly marked sentinel here}}
+void foo1 (int x, ...) ATTR; // expected-note 3 {{function has been explicitly marked sentinel here}}
void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
+#define FOOMACRO(...) foo1(__VA_ARGS__)
+
void test1() {
foo1(1, NULL); // OK
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
@@ -30,6 +32,9 @@
struct A a, b, c;
foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}}
foo1(3, &a, &b, &c, (struct A*) 0);
+
+ // PR11002
+ FOOMACRO(1, 2); // expected-warning {{missing sentinel in function call}}
}
More information about the cfe-commits
mailing list