[LLVMbugs] [Bug 9049] New: type-dependent attribute evaluated during template definition
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 25 02:01:34 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=9049
Summary: type-dependent attribute evaluated during template
definition
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: devlists at shadowlab.org
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
Created an attachment (id=6045)
--> (http://llvm.org/bugs/attachment.cgi?id=6045)
Simple test case
When using type dependent 'attribute' on a template function, clang checks the
type while parsing the template, and not at instantiation, and so may emit
invalid diagnostics.
For example, in the following case, we are using the 'cf_returns_retained'
attribute, which require a pointer return type. As the type is undefined in
template definition, the check fails, and clang emits a warning.
----------- attr.cpp
extern const void *CFRetain(const void *ref);
template<typename T> __attribute__((cf_returns_retained))
inline T WBCFRetain(T aValue) { return aValue ? (T)CFRetain(aValue) : (T)0; }
------------
> clang++ -fsyntax-only attr.cpp
attr.cpp:5:10: warning: 'cf_returns_retained' attribute only applies to
functions that return a pointer
inline T WBCFRetain(T aValue) { return aValue ? (T)CFRetain(aValue) : (T)0; }
^
1 warning generated.
Note that this problem also occurs if you use attributes on a type-dependent
arguments.
----------- attr.cpp
extern void CFRelease(const void *ref);
template<typename T>
inline void WBCFRelease(__attribute__((cf_consumed)) T aValue) { if(aValue)
CFRelease(aValue); }
-----------
> clang++ -fsyntax-only attr.cpp
attr.cpp:5:54: warning: 'cf_consumed' attribute only applies to pointer
parameters
inline void WBCFRelease(__attribute__((cf_consumed)) T aValue) { if(aValue)
CFRelease(aValue); }
~~~~~~~~~~~ ^
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list