[PATCH] Better macro error messages involving initializer lists
Richard Trieu
rtrieu at google.com
Fri Jun 14 19:27:49 PDT 2013
When an initializer list is used within a marco argument, each comma is the list is treated as a macro argument separator. When this happens, the only error message is "too many macro arguments provided". This patch changes the handling of function-like macros to give additional notes detailing the problems.
For a macro FOO(vector<int>{1,2,3}, 3), it will suggest parenthesis to preserve the initializer list with the corrected code as FOO((vector<int>{1,2,3}), 3).
For a macro such as FOO( {1,2,3} ), it will provide a different note saying that initializer lists cannot be used as macro arguments. This is because adding parentheses around the braces would make it no longer an initializer list.
http://llvm-reviews.chandlerc.com/D986
Files:
lib/Lex/PPMacroExpansion.cpp
test/Preprocessor/macro_with_initializer_list.cpp
include/clang/Basic/DiagnosticLexKinds.td
include/clang/Lex/Preprocessor.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D986.1.patch
Type: text/x-patch
Size: 20653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130614/82b1180f/attachment.bin>
More information about the cfe-commits
mailing list