[LLVMbugs] [Bug 24250] New: diagnose assignment at top level in constant-expression better
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 24 11:23:49 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24250
Bug ID: 24250
Summary: diagnose assignment at top level in
constant-expression better
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Top-level assignment in a constant-expression is forbidden by the grammar (and
thus rejected in Clang's parser). This results in some confusing diagnostics:
struct N { constexpr int operator=(int n) { return n; } } n;
int a[n = 0];
template<int> struct X {};
X<n = 0> x;
enum E { e = n = 0 };
struct Q { int k : n = 0; };
Gives:
<stdin>:2:9: error: expected ']'
int a[n = 0];
^
<stdin>:2:6: note: to match this '['
int a[n = 0];
^
<stdin>:2:7: error: size of array has non-integer type 'struct N'
int a[n = 0];
^
<stdin>:4:5: error: expected '>'
X<n = 0> x;
^
<stdin>:4:5: error: expected unqualified-id
<stdin>:5:14: error: integral constant expression must have integral or
unscoped enumeration type, not 'struct N'
enum E { e = n = 0 };
^
<stdin>:5:16: error: expected '}' or ','
enum E { e = n = 0 };
^
<stdin>:6:22: error: bitfield member cannot have an in-class initializer
struct Q { int k : n = 0; };
^
<stdin>:6:20: error: integral constant expression must have integral or
unscoped enumeration type, not 'struct N'
struct Q { int k : n = 0; };
^
It would be nice to diagnose these cases better (except for the last case,
where the current diagnostic seems appropriate).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150724/70879b46/attachment.html>
More information about the llvm-bugs
mailing list