[LLVMbugs] [Bug 10326] New: Unfortunate error message for incorrect operator precedence between 'new' and '->'
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jul 10 16:09:59 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10326
Summary: Unfortunate error message for incorrect operator
precedence between 'new' and '->'
Product: clang
Version: unspecified
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: chandlerc at gmail.com
CC: llvmbugs at cs.uiuc.edu
The following program is clearly invalid, but I think we could do better
diagnosing it:
% cat x.cc
struct S {
S* foo(int) { return this; }
};
S* test() {
return new S()->foo(42);
}
% ./bin/clang -fsyntax-only x.cc
x.cc:6:17: error: expected ';' after return statement
return new S()->foo(42);
^
;
1 error generated.
It seems like it would be better to say in the error that the new operator has
lower precedence than '->', and thus the new expression must be explicitly
grouped. Then we could recover and continue parsing the rest of the expression
as if that grouping had been performed. This seems reasonable to do for most of
the postfix expressions which form a suffix but could not reasonable be part of
a new-type-id: '->', '--', '++', and even '(...)' when the parentheses are not
parsed as part of the new-initializer.
--
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